# srio_osal.h File Reference

This is the sample OS Adaptation layer which is used by the SRIO driver. The OSAL layer can be ported in either of the following manners to a native OS: More...

`#include <ti/drv/srio/srio_drv.h>`
`#include <string.h>`

## 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.

## Detailed Description

This is the sample OS Adaptation layer which is used by the SRIO driver. The OSAL layer can be ported in either of the following manners to a native OS:

Approach 1:
Use Prebuilt Libraries

- Ensure that the provide an implementation of all Osal_XXX API for their native OS.
- Link the prebuilt libraries with their application.
- Refer to the "example" directory for an example of this
  Pros:
- Customers can reuse prebuilt TI provided libraries
  Cons:
- Level of indirection in the API to get to the actual OS call

Approach 2:
Rebuilt Library

- Create a copy of this file and modify it to directly inline the native OS calls
- Rebuild the SRIO Driver library; ensure that the Include path points to the directory where the copy of this file has been provided.
- Please refer to the "test" directory for an example of this
  Pros:
- Optimizations can be done to remove the level of indirection
  Cons:
- SRIO Libraries need to be rebuilt by the customer.

  NOTE: (C) Copyright 2009-2012 Texas Instruments, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of Texas Instruments Incorporated nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Copyright 2012, Texas Instruments Incorporated