Global¶
- group Global_buffer
buffer globals
lorem
Macros¶
- group Macros_buffer_h
Variables¶
- group Variables_buffer_h
API’s¶
- group Apis_buffer_h
Getters¶
- group Getters_buffer_h
Functions
-
unsigned char *buffer_getBuffer(CosmOS_BufferConfigurationType *bufferCfg)¶
Get buffer pointer.
- Parameters
bufferCfg – [in] configuration pointer
- Returns
unsigned char *
-
BitWidthType buffer_getBufferId(CosmOS_BufferConfigurationType *bufferCfg)¶
Get buffer id.
- Parameters
bufferCfg – [in] configuration pointer
- Returns
BitWidthType
-
BitWidthType buffer_getBufferSize(CosmOS_BufferConfigurationType *bufferCfg)¶
Get buffer size.
- Parameters
bufferCfg – [in] configuration pointer
- Returns
BitWidthType
-
CosmOS_BooleanType buffer_isBufferInterCore(CosmOS_BufferConfigurationType *bufferCfg)¶
Is buffer inter core.
- Parameters
bufferCfg – [in] configuration pointer
- Returns
CosmOS_BooleanType
-
BitWidthType buffer_getBufferSpinlockId(CosmOS_BufferConfigurationType *bufferCfg)¶
Get buffer spinlockId.
- Parameters
bufferCfg – [in] configuration pointer
- Returns
BitWidthType
-
CosmOS_PermissionsConfigurationType *buffer_getBufferReadPermission(CosmOS_BufferConfigurationType *bufferCfg)¶
Get buffer readPermission.
- Parameters
bufferCfg – [in] configuration pointer
- Returns
-
CosmOS_PermissionsConfigurationType *buffer_getBufferWritePermission(CosmOS_BufferConfigurationType *bufferCfg)¶
Get buffer writePermission.
- Parameters
bufferCfg – [in] configuration pointer
- Returns
-
BitWidthType buffer_getBufferHead(CosmOS_BufferConfigurationType *bufferCfg)¶
Get buffer head.
- Parameters
bufferCfg – [in] configuration pointer
- Returns
BitWidthType
-
BitWidthType buffer_getBufferTail(CosmOS_BufferConfigurationType *bufferCfg)¶
Get buffer tail.
- Parameters
bufferCfg – [in] configuration pointer
- Returns
BitWidthType
-
BitWidthType buffer_getFullCellsNum(CosmOS_BufferConfigurationType *bufferCfg)¶
-
BitWidthType buffer_getEmptyCellsNum(CosmOS_BufferConfigurationType *bufferCfg)¶
Get empty bufferCfg cells DEMO CODE.
- Parameters
bufferCfg – [in] configuration pointer
- Returns
CosmOS_BufferStateType
-
unsigned char *buffer_getBuffer(CosmOS_BufferConfigurationType *bufferCfg)¶
Setters¶
- group Setters_buffer_h
Functions
-
void buffer_setBufferHead(CosmOS_BufferConfigurationType *bufferCfg, BitWidthType headParam)¶
Set buffer head. This function cannot be called from the unprivileged context directly.
- Parameters
bufferCfg – [out] configuration pointer
headParam – [in] head of the buffer
- Returns
none
-
void buffer_setBufferTail(CosmOS_BufferConfigurationType *bufferCfg, BitWidthType tailParam)¶
Set buffer tail. This function cannot be called from the unprivileged context directly.
- Parameters
bufferCfg – [out] configuration pointer
tailParam – [in] tail of the buffer
- Returns
none
-
void buffer_setBufferfullCells(CosmOS_BufferConfigurationType *bufferCfg, BitWidthType fullCellsParam)¶
Set buffer fullCells. This function cannot be called from the unprivileged context directly.
- Parameters
bufferCfg – [out] configuration pointer
fullCellsParam – [in] full cells
- Returns
none
-
void buffer_setBufferHead(CosmOS_BufferConfigurationType *bufferCfg, BitWidthType headParam)¶
General¶
- group General_buffer_h
Functions
-
CosmOS_BufferStateType buffer_readArrayInternal(BitWidthType id, void *buffer, CosmOS_BufferConfigurationType *systemBufferCfg, BitWidthType size)¶
Reading array from the buffer. This function cannot be called from the unprivileged context directly. DEMO.
The implementation contains while loop, that calls function buffer_pull and increments the userBufferIndex till its equal the required number of data is read from the buffer and then the bufferState is returned with the last value returned from the buffer_pull function.
- Parameters
id – [in] buffer identifier
buffer – [in] pointer to the user buffer array
systemBufferCfg – [out] configuration pointer
size – [in] of the bytes to read
- Returns
CosmOS_BufferStateType
-
CosmOS_BufferStateType buffer_writeArrayInternal(BitWidthType id, void *buffer, CosmOS_BufferConfigurationType *systemBufferCfg, BitWidthType size)¶
Writing array from the buffer. This function cannot be called from the unprivileged context directly. DEMO.
The implementation contains while loop, that calls function buffer_push and increments the userBufferIndex till its equal the required number of data is written to the buffer and then the bufferState is returned with the last value returned from the buffer_push function.
- Parameters
id – [in] buffer identifier
buffer – [in] pointer to the user buffer array
systemBufferCfg – [out] configuration pointer
size – [in] of the bytes to write
- Returns
CosmOS_BufferStateType
-
CosmOS_BufferStateType buffer_readArray(BitWidthType bufferId, void *buffer, BitWidthType size)¶
Reading array from the buffer. DEMO.
The implementation contains obtaining of the operating system generated variable structure by os_getOsCfg function that stores all system buffers in it. Then the operating system configuration in function os_getOsNumberOfBuffers to get number of buffers. The input element id argument is then checked againts the number of buffers, if it is greater than number of buffers BUFFER_STATE_ENUM__ERROR_INVALID_ID is returned. Then the generated core configuration structure is obtained by the function CILcore_getCoreCfg and used in the memoryProtection_isMemoryRegionProtected function call to check if the memory where the data from the buffer will be written is protected. If yes the bufferState is returned with the value BUFFER_STATE_ENUM__ERROR_INPUT_ARRAY_IS_PROTECTED. If not bufferCfg is obtained by the function os_getOsBufferCfg based on the id argument which is mapped with the routes to the proper entity, in this case one of the system buffers. From the buffer variable are then extracted read permissions by the function call buffer_getBufferReadPermission and passed to the function permission_tryAccess that checks if the current schedulable has read access to this system buffer and if not bufferState is returned with the value BUFFER_STATE_ENUM__ERROR_ACCESS_DENIED. If yes spinlock id is obtained by the function buffer_getBufferSpinlockId and then the spinlock is tried by the non-blocking function spinlock_trySpinlock. If the spinlock cannot be obtained the bufferState is returned with the value BUFFER_STATE_ENUM__ERROR_BUFFER_OCCUPIED. If the spinlock was obtained the function buffer_getFullCellsNum is called to get full cells number and check if the user required more bytes to read than available. If yes then the bufferState is returned with the value BUFFER_STATE_ENUM__ERROR_SIZE_BIGGER_THAN_FULL_CELLS_NUM. If there is enough bytes to read we check the core mode. If the core is in the privileged mode the while loop is implemented, that calls function buffer_pull and increments the userBufferIndex till its equal the required number of data is read from the buffer and then the bufferState is returned with the last value returned from the buffer_pull function. If the core is not in the privileged mode the while loop is implemented that reads bytes till the size is non-zero value. Inside this while loop is the if condition implemented to check if the size to read is bigger than SYCALL_BYTES_CHUNK, if yes only number of bytes defined by SYCALL_BYTES_CHUNK is read from the buffer to not block system by long too long system call that is called by function as macro cosmosApiInternal_buffer_readArrayInternal, the size to read is always decremented by SYCALL_BYTES_CHUNK till its not smaller than SYCALL_BYTES_CHUNK and then is the size set to zero and last bytes are read from the buffer. The bufferState is returned with the last value returned from the cosmosApiInternal_buffer_readArrayInternal function as macro.
- Parameters
bufferId – [in] buffer identifier
buffer – [out] pointer to the user buffer array
size – [in] of the bytes to read
- Returns
CosmOS_BufferStateType
-
CosmOS_BufferStateType buffer_writeArray(BitWidthType bufferId, void *buffer, BitWidthType size)¶
Writing array into the buffer. DEMO.
The implementation contains obtaining of the operating system generated variable structure by os_getOsCfg function that stores all system buffers in it. Then the generated core configuration structure is obtained by the function CILcore_getCoreCfg and used in the memoryProtection_isMemoryRegionProtected function call to check if the memory where the data from the buffer will be read from is protected. If yes the bufferState is returned with the value BUFFER_STATE_ENUM__ERROR_INPUT_ARRAY_IS_PROTECTED. If not bufferCfg is obtained by the function os_getOsBufferCfg based on the id argument which is mapped with the routes to the proper entity, in this case one of the system buffers. From the buffer variable are then extracted write permissions by the function call buffer_getBufferReadPermission and passed to the function permission_tryAccess that checks if the current schedulable has write access to this system buffer and if not bufferState is returned with the value BUFFER_STATE_ENUM__ERROR_ACCESS_DENIED. If yes spinlock id is obtained by the function buffer_getBufferSpinlockId and then the spinlock is tried by the non-blocking function spinlock_trySpinlock. If the spinlock cannot be obtained the bufferState is returned with the value BUFFER_STATE_ENUM__ERROR_BUFFER_OCCUPIED. If the spinlock was obtained the function buffer_getEmptyCellsNum is called to get empty cells number and check if the user required more bytes to write than empty cells available in the buffer. If yes then the bufferState is returned with the value BUFFER_STATE_ENUM__ERROR_SIZE_BIGGER_THAN_FULL_CELLS_NUM. If there is enough bytes to write we check the core mode. If the core is in the privileged mode the while loop is implemented, that calls buffer_push function and increments the userBufferIndex till its equal the required number of data is written to the buffer and then the bufferState is returned with the last value returned from the buffer_push function. If the core is not in the privileged mode the while loop is implemented that writes bytes till the size is non-zero value. Inside this while loop is the if condition implemented to check if the size to write is bigger than SYCALL_BYTES_CHUNK, if yes only number of bytes defined by SYCALL_BYTES_CHUNK is write from the buffer to not block system by long too long system call that is called by function as macro cosmosApiInternal_buffer_writeArrayInternal, the size to write is always decremented by SYCALL_BYTES_CHUNK till its not smaller than SYCALL_BYTES_CHUNK and then is the size set to zero and last bytes are write from the buffer. The bufferState is returned with the last value returned from the cosmosApiInternal_buffer_writeArrayInternal function as macro.
- Parameters
bufferId – [in] buffer identifier
buffer – [in] pointer to the user buffer array
size – [in] of the bytes to write
- Returns
CosmOS_BufferStateType
-
CosmOS_BufferStateType buffer_isEmpty(CosmOS_BufferConfigurationType *bufferCfg)¶
Returning if the buffer is empty or ok.
- Parameters
bufferCfg – [in] configuration pointer
- Returns
CosmOS_BufferStateType
-
CosmOS_BufferStateType buffer_isFull(CosmOS_BufferConfigurationType *bufferCfg)¶
Returning if the buffer is full or ok.
- Parameters
bufferCfg – [in] configuration pointer
- Returns
CosmOS_BufferStateType
-
CosmOS_BufferStateType buffer_readArrayInternal(BitWidthType id, void *buffer, CosmOS_BufferConfigurationType *systemBufferCfg, BitWidthType size)¶