# SRIO OSAL Functions
[SRIO LLD]

## Defines

#define | Srio_osalCreateSem() Osal_srioCreateSem()
| The macro is used by the SRIO driver to create a semaphore for each SRIO socket opened in blocking mode. Semaphores created should *initially* be created with a count of 0 i.e. unavailable.
#define | Srio_osalDeleteSem(X) Osal_srioDeleteSem(X)
| The macro is used by the SRIO driver to delete a previously created semaphore. This is called when a SRIO socket opened in blocking mode is being closed.
#define | Srio_osalPendSem(X) Osal_srioPendSem(X)
| The macro is used by the SRIO driver to pend on a semaphore This is called when an application tries to receive data on a blocking socket when there is no data available. Since all semaphores are initially created to be unavailable; this will cause the application to block.
#define | Srio_osalPostSem(X) Osal_srioPostSem(X)
| The macro is used by the SRIO driver to post the semaphore The driver posts the semaphore once data is received on a specific socket.
#define | Srio_osalMalloc(X) Osal_srioMalloc(X)
| The macro is used by the SRIO driver to allocate memory The SRIO driver uses this macro to allocate memory for its internal driver structures. This is invoked during the driver initialization and startup process.
#define | Srio_osalFree(X, Y) Osal_srioFree(X, Y)
| The macro is used by the SRIO driver to free a previously allocated block of memory.
#define | Srio_osalDataBufferMalloc(X) Osal_srioDataBufferMalloc(X)
| The macro is used by the SRIO driver to allocate memory for the data buffers in Driver Managed Configuration. All data buffers should allocated should be in the global address space. This macro is invoked during the data path.
#define | Srio_osalDataBufferFree(X, Y) Osal_srioDataBufferFree(X, Y)
| The macro is used by the SRIO driver to free a previously allocated block data buffer. This macro is used to clean up previously allocated data buffers and is invoked during the data path.
#define | Srio_osalLog Osal_srioLog
| The macro is used by the SRIO driver to log various messages.
#define | Srio_osalEnterMultipleCoreCriticalSection Osal_srioEnterMultipleCoreCriticalSection
| The macro is used by the SRIO Driver to protect its shared resources access from MULTIPLE CORES. This is required if the SRIO Driver API's are being invoked from multiple cores. If this is not the case then these macros can be defined to be NOP.
#define | Srio_osalExitMultipleCoreCriticalSection Osal_srioExitMultipleCoreCriticalSection
| The macro is used by the SRIO driver to end the protection of its internal shared "resources" from MULTIPLE CORE access.
#define | Srio_osalEnterSingleCoreCriticalSection Osal_srioEnterSingleCoreCriticalSection
| The macro is used by the SRIO driver to protect its internal shared resources from SINGLE CORE MULTIPLE CONTEXT (thread or ISR) access. If all the SRIO Driver APIs are being called from threads then this API could use semaphores. However if the SRIO driver API's are being called from both ISR & Thread context then the critical section here would need to disable/enable interrupts.
#define | Srio_osalExitSingleCoreCriticalSection Osal_srioExitSingleCoreCriticalSection
| The macro is used to denote the end of the protection of the internal shared resource from SINGLE CORE MULTIPLE CONTEXT access.
#define | Srio_osalBeginMemAccess Osal_srioBeginMemAccess
| The macro is used by the SRIO driver to indicate that a block of memory is about to be accessed. If the memory block is cached then this indicates that the application would need to ensure that the cache is updated with the data from the actual memory.
#define | Srio_osalEndMemAccess Osal_srioEndMemAccess
| The macro is used by the SRIO driver to indicate that the block of memory has finished being accessed. If the memory block is cached then the application would need to ensure that the contents of the cache are updated immediately to the actual memory.
#define | Srio_osalBeginDescriptorAccess Osal_srioBeginDescriptorAccess
| The macro is used by the SRIO driver to indicate that the driver is about to start accessing a descriptor.
#define | Srio_osalEndDescriptorAccess Osal_srioEndDescriptorAccess
| The macro is used by the SRIO driver to indicate that the driver is finished populating the descriptor.

## Define Documentation

#define Srio_osalBeginDescriptorAccess Osal_srioBeginDescriptorAccess

The macro is used by the SRIO driver to indicate that the driver is about to start accessing a descriptor.

Prototype: The following is the C prototype for the expected OSAL API.

           void  Osal_srioBeginDescriptorAccess (Srio_DrvHandle drvHandle,void* ptr, uint32_t descSize)

Parameter
drvHandle - Driver Handle for which the descriptor is being accessed.
ptr - Address of the descriptor which is being accessed.
size - Size of the descriptor
(Only Applicable for Driver Managed is 0 for App Managed)

Return Value
None

#define Srio_osalBeginMemAccess Osal_srioBeginMemAccess

The macro is used by the SRIO driver to indicate that a block of memory is about to be accessed. If the memory block is cached then this indicates that the application would need to ensure that the cache is updated with the data from the actual memory.

Prototype: The following is the C prototype for the expected OSAL API.

           void  Osal_srioBeginMemAccess(void* ptr, uint32_t size)

Parameter
ptr - Pointer to the memory
size - Size of the memory being accessed.

Return Value
None

#define Srio_osalCreateSem | ( |  | ) | Osal_srioCreateSem()

The macro is used by the SRIO driver to create a semaphore for each SRIO socket opened in blocking mode. Semaphores created should *initially* be created with a count of 0 i.e. unavailable.

Prototype: The following is the C prototype for the expected OSAL API.

           void* Osal_srioCreateSem(void);

Parameter
Not Applicable

Return Value
Semaphore Handle

#define Srio_osalDataBufferFree | ( | X,
|  | Y |  | ) | Osal_srioDataBufferFree(X, Y)

The macro is used by the SRIO driver to free a previously allocated block data buffer. This macro is used to clean up previously allocated data buffers and is invoked during the data path.

Prototype: The following is the C prototype for the expected OSAL API.

           void Osal_srioDataBufferFree(void* ptr, uint32_t numBytes)

Parameter
Pointer to the block of memory to be cleaned up.
Size of the allocated memory which is being freed.

Return Value
Not applicable.

#define Srio_osalDataBufferMalloc | ( | X |  | ) | Osal_srioDataBufferMalloc(X)

The macro is used by the SRIO driver to allocate memory for the data buffers in Driver Managed Configuration. All data buffers should allocated should be in the global address space. This macro is invoked during the data path.

Prototype: The following is the C prototype for the expected OSAL API.

           void* Osal_srioDataBufferMalloc(uint32_t numBytes)

Parameter
Number of bytes to be allocated

Return Value
Pointer to the allocated block size

#define Srio_osalDeleteSem | ( | X |  | ) | Osal_srioDeleteSem(X)

The macro is used by the SRIO driver to delete a previously created semaphore. This is called when a SRIO socket opened in blocking mode is being closed.

Prototype: The following is the C prototype for the expected OSAL API.

           void Osal_srioDeleteSem(void* semHandle)

Parameter
Semaphore Handle returned by the create semaphore

Return Value
Not Applicable

#define Srio_osalEndDescriptorAccess Osal_srioEndDescriptorAccess

The macro is used by the SRIO driver to indicate that the driver is finished populating the descriptor.

Prototype: The following is the C prototype for the expected OSAL API.

           void  Osal_srioEndDescriptorAccess (Srio_DrvHandle drvHandle,void* ptr, uint32_t descSize)

Parameter
drvHandle - Driver Handle for which the descriptor is being accessed.
ptr - Address of the descriptor which is being accessed.
size - Size of the descriptor
(Only Applicable for Driver Managed is 0 for App Managed)

Return Value
None

#define Srio_osalEndMemAccess Osal_srioEndMemAccess

The macro is used by the SRIO driver to indicate that the block of memory has finished being accessed. If the memory block is cached then the application would need to ensure that the contents of the cache are updated immediately to the actual memory.

Prototype: The following is the C prototype for the expected OSAL API.

           void  Osal_srioEndMemAccess(void* ptr, uint32_t size)

Parameter
ptr - Pointer to the memory
size - Size of the memory

Return Value
None

#define Srio_osalEnterMultipleCoreCriticalSection Osal_srioEnterMultipleCoreCriticalSection

The macro is used by the SRIO Driver to protect its shared resources access from MULTIPLE CORES. This is required if the SRIO Driver API's are being invoked from multiple cores. If this is not the case then these macros can be defined to be NOP.

Prototype: The following is the C prototype for the expected OSAL API.

           void* Osal_srioEnterMultipleCoreCriticalSection(void)

Parameter
None

Return Value
Opaque Handle used for holding critical section locking information

#define Srio_osalEnterSingleCoreCriticalSection Osal_srioEnterSingleCoreCriticalSection

The macro is used by the SRIO driver to protect its internal shared resources from SINGLE CORE MULTIPLE CONTEXT (thread or ISR) access. If all the SRIO Driver APIs are being called from threads then this API could use semaphores. However if the SRIO driver API's are being called from both ISR & Thread context then the critical section here would need to disable/enable interrupts.

Prototype: The following is the C prototype for the expected OSAL API.

           void* Osal_srioEnterSingleCoreCriticalSection(Srio_DrvHandle drvHandle)

Parameter
drvHandle - Driver Handle for which the critical section is being entered.

Return Value
Opaque Handle used for holding critical section locking information

#define Srio_osalExitMultipleCoreCriticalSection Osal_srioExitMultipleCoreCriticalSection

The macro is used by the SRIO driver to end the protection of its internal shared "resources" from MULTIPLE CORE access.

Prototype: The following is the C prototype for the expected OSAL API.

           void  Osal_srioExitMultipleCoreCriticalSection(void* critSectHandle)

Parameter
Opaque Handle used for holding critical section locking information

Return Value
None

#define Srio_osalExitSingleCoreCriticalSection Osal_srioExitSingleCoreCriticalSection

The macro is used to denote the end of the protection of the internal shared resource from SINGLE CORE MULTIPLE CONTEXT access.

Prototype: The following is the C prototype for the expected OSAL API.

           void  Osal_srioExitSingleCoreCriticalSection(Srio_DrvHandle drvHandle, void* critSectHandle)

Parameter
drvHandle - Driver Handle for which the critical section is being exited.
critSectHandle - Opaque Handle used for holding critical section locking information

Return Value
None

#define Srio_osalFree | ( | X,
|  | Y |  | ) | Osal_srioFree(X, Y)

The macro is used by the SRIO driver to free a previously allocated block of memory.

Prototype: The following is the C prototype for the expected OSAL API.

           void Osal_srioFree(void* ptr, uint32_t numBytes)

Parameter
Pointer to the block of memory to be cleaned up.
Size of the allocated memory which is being freed.

Return Value
Not applicable.

#define Srio_osalLog Osal_srioLog

The macro is used by the SRIO driver to log various messages.

Prototype: The following is the C prototype for the expected OSAL API.

           void Osal_srioLog( char* fmt, ... )

Parameter
printf-style format string

Return Value
Not applicable.

#define Srio_osalMalloc | ( | X |  | ) | Osal_srioMalloc(X)

The macro is used by the SRIO driver to allocate memory The SRIO driver uses this macro to allocate memory for its internal driver structures. This is invoked during the driver initialization and startup process.

Prototype: The following is the C prototype for the expected OSAL API.

           void* Osal_srioMalloc(uint32_t numBytes)

Parameter
Number of bytes to be allocated

Return Value
Pointer to the allocated block size

See also:
  Srio_osalDataBufferMalloc

#define Srio_osalPendSem | ( | X |  | ) | Osal_srioPendSem(X)

The macro is used by the SRIO driver to pend on a semaphore This is called when an application tries to receive data on a blocking socket when there is no data available. Since all semaphores are initially created to be unavailable; this will cause the application to block.

Prototype: The following is the C prototype for the expected OSAL API.

           void Osal_srioPendSem(void* semHandle)

Parameter
Semaphore Handle

Return Value
Not Applicable

#define Srio_osalPostSem | ( | X |  | ) | Osal_srioPostSem(X)

The macro is used by the SRIO driver to post the semaphore The driver posts the semaphore once data is received on a specific socket.

Prototype: The following is the C prototype for the expected OSAL API.

           void Osal_srioPostSem(void* semHandle)

Parameter
Semaphore Handle

Return Value
Not Applicable

Copyright 2012, Texas Instruments Incorporated