F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
Os Namespace Reference

Namespaces

namespace  FileSystem
 
namespace  SystemResources
 
namespace  ValidateFile
 

Classes

class  BareQueueHandle
 
class  BareTaskHandle
 
class  BufferQueue
 A generic buffer queue data structure. More...
 
class  Directory
 
class  Event
 
struct  FIFOQueue
 
class  File
 
class  InterruptLock
 
class  IntervalTimer
 
class  IPCQueue
 
class  LocklessQueue
 
class  Log
 
class  MaxHeap
 A stable max heap data structure. More...
 
class  Mem
 
class  Mutex
 
struct  PriorityQueue
 
class  Queue
 
class  QueueHandle
 
class  QueueRegistry
 
class  QueueString
 
class  Task
 forward declaration More...
 
class  TaskId
 
class  TaskLock
 
class  TaskRegistry
 
class  TaskRunner
 
class  TaskString
 
class  ValidatedFile
 A validated file. More...
 
class  WatchdogTimer
 

Typedefs

typedef bool(* OpenInterceptor) (Os::File::Status &status, const char *fileName, Os::File::Mode mode, void *ptr)
 
typedef bool(* ReadInterceptor) (Os::File::Status &status, void *buffer, NATIVE_INT_TYPE &size, bool waitForFull, void *ptr)
 
typedef bool(* WriteInterceptor) (Os::File::Status &status, const void *buffer, NATIVE_INT_TYPE &size, bool waitForDone, void *ptr)
 
typedef bool(* SeekInterceptor) (Os::File::Status &status, NATIVE_INT_TYPE offset, bool absolute, void *ptr)
 

Enumerations

enum  StatusFileType { FileType , HashFileType }
 

Functions

Queue::QueueStatus bareSendNonBlock (BareQueueHandle &handle, const U8 *buffer, NATIVE_INT_TYPE size, NATIVE_INT_TYPE priority)
 
Queue::QueueStatus bareSendBlock (BareQueueHandle &handle, const U8 *buffer, NATIVE_INT_TYPE size, NATIVE_INT_TYPE priority)
 
Queue::QueueStatus bareReceiveNonBlock (BareQueueHandle &handle, U8 *buffer, NATIVE_INT_TYPE capacity, NATIVE_INT_TYPE &actualSize, NATIVE_INT_TYPE &priority)
 
Queue::QueueStatus bareReceiveBlock (BareQueueHandle &handle, U8 *buffer, NATIVE_INT_TYPE capacity, NATIVE_INT_TYPE &actualSize, NATIVE_INT_TYPE &priority)
 
U64 getCpuUsed (U32 cpu_data[4])
 
U64 getCpuTotal (U32 cpu_data[4])
 
SystemResources::SystemResourcesStatus openProcStatFile (FILE *&fp)
 
SystemResources::SystemResourcesStatus readProcStatLine (FILE *fp, char proc_stat_line[LINE_SIZE])
 
SystemResources::SystemResourcesStatus getCpuDataLine (FILE *fp, U32 cpu_index, char proc_stat_line[LINE_SIZE])
 
SystemResources::SystemResourcesStatus parseCpuData (char proc_stat_line[LINE_SIZE], U32 cpu_data[4])
 
SystemResources::SystemResourcesStatus getCpuData (U32 cpu_index, U32 cpu_data[4])
 
U64 getMemoryTotal (FwSizeType total_ram, FwSizeType memory_unit)
 
U64 getMemoryUsed (FwSizeType total_ram, FwSizeType free_ram, FwSizeType memory_unit)
 
bool checkCastingAndTypeErrors (FwSizeType total_ram, FwSizeType free_ram, FwSizeType memory_unit, const struct sysinfo &memory_info)
 
bool checkInvalidMemoryCalculation (FwSizeType total_ram, FwSizeType free_ram)
 
bool checkMultiplicationOverflow (FwSizeType total_ram, FwSizeType memory_unit)
 
Queue::QueueStatus sendNonBlockIPCStub (QueueHandle *queueHandle, const U8 *buffer, NATIVE_INT_TYPE size, NATIVE_INT_TYPE priority)
 
Queue::QueueStatus sendBlockIPCStub (QueueHandle *queueHandle, const U8 *buffer, NATIVE_INT_TYPE size, NATIVE_INT_TYPE priority)
 
Queue::QueueStatus receiveNonBlockIPCStub (QueueHandle *queueHandle, U8 *buffer, NATIVE_INT_TYPE capacity, NATIVE_INT_TYPE &actualSize, NATIVE_INT_TYPE &priority)
 
Queue::QueueStatus receiveBlockIPCStub (QueueHandle *queueHandle, U8 *buffer, NATIVE_INT_TYPE capacity, NATIVE_INT_TYPE &actualSize, NATIVE_INT_TYPE &priority)
 
kern_return_t vm_stat_helper (FwSizeType &used, FwSizeType &total)
 reads macOS virtual memory statistics for memory calculation
 
kern_return_t cpu_data_helper (processor_cpu_load_info_t &cpu_load_info, U32 &cpu_count)
 helper around raw CPU capture API
 
kern_return_t cpu_by_index (U32 cpu_index, FwSizeType &used, FwSizeType &total)
 Query for a single CPU's ticks information.
 
void validate_arguments (NATIVE_UINT_TYPE &priority, NATIVE_UINT_TYPE &stack, NATIVE_UINT_TYPE &affinity, bool expect_perm)
 
Task::TaskStatus set_stack_size (pthread_attr_t &att, NATIVE_UINT_TYPE stack)
 
Task::TaskStatus set_priority_params (pthread_attr_t &att, NATIVE_UINT_TYPE priority)
 
Task::TaskStatus set_cpu_affinity (pthread_attr_t &att, NATIVE_UINT_TYPE cpuAffinity)
 
Task::TaskStatus create_pthread (NATIVE_UINT_TYPE priority, NATIVE_UINT_TYPE stackSize, NATIVE_UINT_TYPE cpuAffinity, pthread_t *&tid, void *arg, bool expect_perm)
 
NATIVE_UINT_TYPE checkoutIndex (PriorityQueue *pQueue, NATIVE_UINT_TYPE depth)
 
void returnIndex (PriorityQueue *pQueue, NATIVE_UINT_TYPE depth, NATIVE_UINT_TYPE index)
 
Queue::QueueStatus sendNonBlock (QueueHandle *queueHandle, const U8 *buffer, NATIVE_INT_TYPE size, NATIVE_INT_TYPE priority)
 
Queue::QueueStatus sendBlock (QueueHandle *queueHandle, const U8 *buffer, NATIVE_INT_TYPE size, NATIVE_INT_TYPE priority)
 
Queue::QueueStatus receiveNonBlock (QueueHandle *queueHandle, U8 *buffer, NATIVE_INT_TYPE capacity, NATIVE_INT_TYPE &actualSize, NATIVE_INT_TYPE &priority)
 
Queue::QueueStatus receiveBlock (QueueHandle *queueHandle, U8 *buffer, NATIVE_INT_TYPE capacity, NATIVE_INT_TYPE &actualSize, NATIVE_INT_TYPE &priority)
 
void registerReadInterceptor (ReadInterceptor funcPtr, void *ptr)
 
void clearReadInterceptor ()
 
void registerWriteInterceptor (WriteInterceptor funcPtr, void *ptr)
 
void clearWriteInterceptor ()
 
void registerOpenInterceptor (OpenInterceptor funcPtr, void *ptr)
 
void clearOpenInterceptor ()
 
void registerSeekInterceptor (SeekInterceptor funcPtr, void *ptr)
 
void clearSeekInterceptor ()
 
void setLastError (NATIVE_INT_TYPE error)
 
File::Status computeHash (const char *fileName, Utils::HashBuffer &hashBuffer)
 
File::Status readHash (const char *hashFileName, Utils::HashBuffer &hashBuffer)
 
File::Status writeHash (const char *hashFileName, Utils::HashBuffer hashBuffer)
 
ValidateFile::Status translateStatus (File::Status status, StatusFileType type)
 

Variables

static ReadInterceptor readInterceptor = nullptr
 
static void * readInterceptorPtr = nullptr
 
static WriteInterceptor writeInterceptor = nullptr
 
static void * writeInterceptorPtr = nullptr
 
static OpenInterceptor openInterceptor = nullptr
 
static void * openInterceptorPtr = nullptr
 
static SeekInterceptor seekInterceptor = nullptr
 
static void * seekInterceptorPtr = nullptr
 
static NATIVE_INT_TYPE lastError = 0
 

Detailed Description

IntervalTimer.hpp:

 Interval timer provides timing over a set interval to the caller. It is one of the core Os  package supplied items.

IntervalTimerCommon.cpp:

Contains the common functions for interval timer. This set of functions makes no assumption on the format of the RawTime objects and thus it operates through functions that abstract that implementation away, or it is working on the raw values, as raw values.

Note: If the RawTime object is using U32 upper to store seconds and U32 lower to store nano seconds, then X86/IntervalTimer.cpp can be used, and the implementer need only fill in the getRawTime function for the specific OS.

File: Os/Log.hpp Description: this file provides an implementation of the Fw::Logger class that is backed by the Os abstraction layer.

File: Os/LogPrintf.cpp Description: an implementation on the Os::Log abstraction that routes log messages into standard printf calls.

Posix/IntervalTimer.cpp:

The Posix implementation of the interval timer shares the same raw setup as other X86 implementations. That is: the lower U32 of the RawTime is nano-seconds, and the upper U32 of RawTime object is seconds. Thus only the "getRawTime" function differs from the base X86 version of this file.

Queue.hpp:

Queues are used internally to F prime in order to support the messaging between components. The Queue class is used to abstract away from the standard OS-based queue, allowing F prime support multiple OSes in a consistent way.

Like most items in the OS package, the implementation is done in two parts. One part is the file QueueCommon.cpp. It contains the shared code for queues regardless of the OS. The other is a .cpp file containing the OS specific backends for defined functions. (i.e. Posix/Queue.cpp).

X86/IntervalTimer.cpp:

This file supports the core functions of the IntervalTimer for X86 implementations that support the following specification for the "RawTime" object:

RawTime.lower = nanoseconds of time RawTime.upper = seconds of time.

Any implementation that fills "RawTime" via this specification can use these basic implementations.

Note: this file is cloned from the original Linux implementation.

Typedef Documentation

◆ OpenInterceptor

typedef bool(* Os::OpenInterceptor) (Os::File::Status &status, const char *fileName, Os::File::Mode mode, void *ptr)

Definition at line 24 of file FileStubs.hpp.

◆ ReadInterceptor

typedef bool(* Os::ReadInterceptor) (Os::File::Status &status, void *buffer, NATIVE_INT_TYPE &size, bool waitForFull, void *ptr)

Definition at line 25 of file FileStubs.hpp.

◆ SeekInterceptor

typedef bool(* Os::SeekInterceptor) (Os::File::Status &status, NATIVE_INT_TYPE offset, bool absolute, void *ptr)

Definition at line 27 of file FileStubs.hpp.

◆ WriteInterceptor

typedef bool(* Os::WriteInterceptor) (Os::File::Status &status, const void *buffer, NATIVE_INT_TYPE &size, bool waitForDone, void *ptr)

Definition at line 26 of file FileStubs.hpp.

Enumeration Type Documentation

◆ StatusFileType

Enumerator
FileType 
HashFileType 

Definition at line 118 of file ValidateFileCommon.cpp.

Function Documentation

◆ bareReceiveBlock()

Queue::QueueStatus Os::bareReceiveBlock ( BareQueueHandle handle,
U8 buffer,
NATIVE_INT_TYPE  capacity,
NATIVE_INT_TYPE actualSize,
NATIVE_INT_TYPE priority 
)

Definition at line 159 of file Queue.cpp.

◆ bareReceiveNonBlock()

Queue::QueueStatus Os::bareReceiveNonBlock ( BareQueueHandle handle,
U8 buffer,
NATIVE_INT_TYPE  capacity,
NATIVE_INT_TYPE actualSize,
NATIVE_INT_TYPE priority 
)

Definition at line 128 of file Queue.cpp.

◆ bareSendBlock()

Queue::QueueStatus Os::bareSendBlock ( BareQueueHandle handle,
const U8 buffer,
NATIVE_INT_TYPE  size,
NATIVE_INT_TYPE  priority 
)

Definition at line 86 of file Queue.cpp.

◆ bareSendNonBlock()

Queue::QueueStatus Os::bareSendNonBlock ( BareQueueHandle handle,
const U8 buffer,
NATIVE_INT_TYPE  size,
NATIVE_INT_TYPE  priority 
)

Definition at line 74 of file Queue.cpp.

◆ checkCastingAndTypeErrors()

bool Os::checkCastingAndTypeErrors ( FwSizeType  total_ram,
FwSizeType  free_ram,
FwSizeType  memory_unit,
const struct sysinfo &  memory_info 
)

Definition at line 123 of file SystemResources.cpp.

◆ checkInvalidMemoryCalculation()

bool Os::checkInvalidMemoryCalculation ( FwSizeType  total_ram,
FwSizeType  free_ram 
)

Definition at line 133 of file SystemResources.cpp.

◆ checkMultiplicationOverflow()

bool Os::checkMultiplicationOverflow ( FwSizeType  total_ram,
FwSizeType  memory_unit 
)

Definition at line 137 of file SystemResources.cpp.

◆ checkoutIndex()

NATIVE_UINT_TYPE Os::checkoutIndex ( PriorityQueue pQueue,
NATIVE_UINT_TYPE  depth 
)

Definition at line 44 of file PriorityBufferQueue.cpp.

◆ clearOpenInterceptor()

void Os::clearOpenInterceptor ( )

Definition at line 54 of file FileStub.cpp.

◆ clearReadInterceptor()

void Os::clearReadInterceptor ( )

Definition at line 36 of file FileStub.cpp.

◆ clearSeekInterceptor()

void Os::clearSeekInterceptor ( )

Definition at line 63 of file FileStub.cpp.

◆ clearWriteInterceptor()

void Os::clearWriteInterceptor ( )

Definition at line 45 of file FileStub.cpp.

◆ computeHash()

File::Status Os::computeHash ( const char *  fileName,
Utils::HashBuffer hashBuffer 
)

< gets the size of the file (in bytes) at location path

Definition at line 8 of file ValidateFileCommon.cpp.

◆ cpu_by_index()

kern_return_t Os::cpu_by_index ( U32  cpu_index,
FwSizeType used,
FwSizeType total 
)

Query for a single CPU's ticks information.

Queries all CPU information but only deals with a single CPU's output. This is done because the load average is tracked sample to sample and the call pattern is cpu0, cpu1, ..., cpu last, wait for sample window, cpu0, ... and thus each call should update one CPU's sample or only the last cpu will have the benefit of the sampling window.

Parameters
cpu_indexindex of current CPU being queried
usedfilled with CPU's used ticks count
totalfilled with CPU's total ticks
Returns
success/failure using kern_return_t

Definition at line 82 of file SystemResources.cpp.

◆ cpu_data_helper()

kern_return_t Os::cpu_data_helper ( processor_cpu_load_info_t &  cpu_load_info,
U32 &  cpu_count 
)

helper around raw CPU capture API

Calls for the CPU information from the machine, improving readability in cpu_by_index

Parameters
cpu_load_infofilled with CPU data
cpu_countfilled with CPU count
Returns
success/failure using kern_return_t

Definition at line 63 of file SystemResources.cpp.

◆ create_pthread()

Task::TaskStatus Os::create_pthread ( NATIVE_UINT_TYPE  priority,
NATIVE_UINT_TYPE  stackSize,
NATIVE_UINT_TYPE  cpuAffinity,
pthread_t *&  tid,
void *  arg,
bool  expect_perm 
)

Definition at line 126 of file Task.cpp.

◆ getCpuData()

SystemResources::SystemResourcesStatus Os::getCpuData ( U32  cpu_index,
U32  cpu_data[4] 
)

Definition at line 78 of file SystemResources.cpp.

◆ getCpuDataLine()

SystemResources::SystemResourcesStatus Os::getCpuDataLine ( FILE *  fp,
U32  cpu_index,
char  proc_stat_line[LINE_SIZE] 
)

Definition at line 51 of file SystemResources.cpp.

◆ getCpuTotal()

U64 Os::getCpuTotal ( U32  cpu_data[4])

Definition at line 33 of file SystemResources.cpp.

◆ getCpuUsed()

U64 Os::getCpuUsed ( U32  cpu_data[4])

Definition at line 30 of file SystemResources.cpp.

◆ getMemoryTotal()

U64 Os::getMemoryTotal ( FwSizeType  total_ram,
FwSizeType  memory_unit 
)

Definition at line 116 of file SystemResources.cpp.

◆ getMemoryUsed()

U64 Os::getMemoryUsed ( FwSizeType  total_ram,
FwSizeType  free_ram,
FwSizeType  memory_unit 
)

Definition at line 119 of file SystemResources.cpp.

◆ openProcStatFile()

SystemResources::SystemResourcesStatus Os::openProcStatFile ( FILE *&  fp)

Definition at line 37 of file SystemResources.cpp.

◆ parseCpuData()

SystemResources::SystemResourcesStatus Os::parseCpuData ( char  proc_stat_line[LINE_SIZE],
U32  cpu_data[4] 
)

Definition at line 69 of file SystemResources.cpp.

◆ readHash()

File::Status Os::readHash ( const char *  hashFileName,
Utils::HashBuffer hashBuffer 
)

Definition at line 64 of file ValidateFileCommon.cpp.

◆ readProcStatLine()

SystemResources::SystemResourcesStatus Os::readProcStatLine ( FILE *  fp,
char  proc_stat_line[LINE_SIZE] 
)

Definition at line 44 of file SystemResources.cpp.

◆ receiveBlock()

Queue::QueueStatus Os::receiveBlock ( QueueHandle queueHandle,
U8 buffer,
NATIVE_INT_TYPE  capacity,
NATIVE_INT_TYPE actualSize,
NATIVE_INT_TYPE priority 
)

Definition at line 258 of file Queue.cpp.

◆ receiveBlockIPCStub()

Queue::QueueStatus Os::receiveBlockIPCStub ( QueueHandle queueHandle,
U8 buffer,
NATIVE_INT_TYPE  capacity,
NATIVE_INT_TYPE actualSize,
NATIVE_INT_TYPE priority 
)

Definition at line 257 of file IPCQueueStub.cpp.

◆ receiveNonBlock()

Queue::QueueStatus Os::receiveNonBlock ( QueueHandle queueHandle,
U8 buffer,
NATIVE_INT_TYPE  capacity,
NATIVE_INT_TYPE actualSize,
NATIVE_INT_TYPE priority 
)

Definition at line 202 of file Queue.cpp.

◆ receiveNonBlockIPCStub()

Queue::QueueStatus Os::receiveNonBlockIPCStub ( QueueHandle queueHandle,
U8 buffer,
NATIVE_INT_TYPE  capacity,
NATIVE_INT_TYPE actualSize,
NATIVE_INT_TYPE priority 
)

Definition at line 201 of file IPCQueueStub.cpp.

◆ registerOpenInterceptor()

void Os::registerOpenInterceptor ( OpenInterceptor  funcPtr,
void *  ptr 
)

Definition at line 49 of file FileStub.cpp.

◆ registerReadInterceptor()

void Os::registerReadInterceptor ( ReadInterceptor  funcPtr,
void *  ptr 
)

Definition at line 31 of file FileStub.cpp.

◆ registerSeekInterceptor()

void Os::registerSeekInterceptor ( SeekInterceptor  funcPtr,
void *  ptr 
)

Definition at line 58 of file FileStub.cpp.

◆ registerWriteInterceptor()

void Os::registerWriteInterceptor ( WriteInterceptor  funcPtr,
void *  ptr 
)

Definition at line 40 of file FileStub.cpp.

◆ returnIndex()

void Os::returnIndex ( PriorityQueue pQueue,
NATIVE_UINT_TYPE  depth,
NATIVE_UINT_TYPE  index 
)

Definition at line 55 of file PriorityBufferQueue.cpp.

◆ sendBlock()

Queue::QueueStatus Os::sendBlock ( QueueHandle queueHandle,
const U8 buffer,
NATIVE_INT_TYPE  size,
NATIVE_INT_TYPE  priority 
)

Definition at line 133 of file Queue.cpp.

◆ sendBlockIPCStub()

Queue::QueueStatus Os::sendBlockIPCStub ( QueueHandle queueHandle,
const U8 buffer,
NATIVE_INT_TYPE  size,
NATIVE_INT_TYPE  priority 
)

Definition at line 132 of file IPCQueueStub.cpp.

◆ sendNonBlock()

Queue::QueueStatus Os::sendNonBlock ( QueueHandle queueHandle,
const U8 buffer,
NATIVE_INT_TYPE  size,
NATIVE_INT_TYPE  priority 
)

Definition at line 95 of file Queue.cpp.

◆ sendNonBlockIPCStub()

Queue::QueueStatus Os::sendNonBlockIPCStub ( QueueHandle queueHandle,
const U8 buffer,
NATIVE_INT_TYPE  size,
NATIVE_INT_TYPE  priority 
)

Definition at line 94 of file IPCQueueStub.cpp.

◆ set_cpu_affinity()

Task::TaskStatus Os::set_cpu_affinity ( pthread_attr_t &  att,
NATIVE_UINT_TYPE  cpuAffinity 
)

Definition at line 104 of file Task.cpp.

◆ set_priority_params()

Task::TaskStatus Os::set_priority_params ( pthread_attr_t &  att,
NATIVE_UINT_TYPE  priority 
)

Definition at line 77 of file Task.cpp.

◆ set_stack_size()

Task::TaskStatus Os::set_stack_size ( pthread_attr_t &  att,
NATIVE_UINT_TYPE  stack 
)

Definition at line 65 of file Task.cpp.

◆ setLastError()

void Os::setLastError ( NATIVE_INT_TYPE  error)

Definition at line 67 of file FileStub.cpp.

◆ translateStatus()

ValidateFile::Status Os::translateStatus ( File::Status  status,
StatusFileType  type 
)

Definition at line 123 of file ValidateFileCommon.cpp.

◆ validate_arguments()

void Os::validate_arguments ( NATIVE_UINT_TYPE priority,
NATIVE_UINT_TYPE stack,
NATIVE_UINT_TYPE affinity,
bool  expect_perm 
)

Definition at line 32 of file Task.cpp.

◆ vm_stat_helper()

kern_return_t Os::vm_stat_helper ( FwSizeType used,
FwSizeType total 
)

reads macOS virtual memory statistics for memory calculation

Queries the macOS kernel for virtual memory information. These items are returned in units of page-size and are then converted back into bytes.

Thanks to: https://stackoverflow.com/questions/8782228/retrieve-ram-info-on-a-mac

Parameters
usedused memory in bytes
totaltotal memory in bytes
Returns
: kern_return_t with success/failure straight from the kernel

Definition at line 33 of file SystemResources.cpp.

◆ writeHash()

File::Status Os::writeHash ( const char *  hashFileName,
Utils::HashBuffer  hashBuffer 
)

Definition at line 94 of file ValidateFileCommon.cpp.

Variable Documentation

◆ lastError

NATIVE_INT_TYPE Os::lastError = 0
static

Definition at line 29 of file FileStub.cpp.

◆ openInterceptor

OpenInterceptor Os::openInterceptor = nullptr
static

Definition at line 23 of file FileStub.cpp.

◆ openInterceptorPtr

void* Os::openInterceptorPtr = nullptr
static

Definition at line 24 of file FileStub.cpp.

◆ readInterceptor

ReadInterceptor Os::readInterceptor = nullptr
static

Definition at line 17 of file FileStub.cpp.

◆ readInterceptorPtr

void* Os::readInterceptorPtr = nullptr
static

Definition at line 18 of file FileStub.cpp.

◆ seekInterceptor

SeekInterceptor Os::seekInterceptor = nullptr
static

Definition at line 26 of file FileStub.cpp.

◆ seekInterceptorPtr

void* Os::seekInterceptorPtr = nullptr
static

Definition at line 27 of file FileStub.cpp.

◆ writeInterceptor

WriteInterceptor Os::writeInterceptor = nullptr
static

Definition at line 20 of file FileStub.cpp.

◆ writeInterceptorPtr

void* Os::writeInterceptorPtr = nullptr
static

Definition at line 21 of file FileStub.cpp.