4.3. OSAL

4.3.1. Introduction

The OSAL library provides operating system abstraction layer API sample implementations that are required for processor SDK drivers. Scope of APIs supported in the module is limited to support OS services required for RTOS or bare metal drivers

  • Supported Operating Systems
    • TIRTOS
    • NONOS (baremetal)
  • Supported SOCs
    • Please refer to component release notes

4.3.2. User Interface

For details about individual fields of this library structure, see the PDK doxygen documentation

4.3.2.1. APIs

Porting of OSAL component will enable extending PDK components to additional OS environment. Reference top level API header file includes:

#include <ti/osal/osal.h>

OSAL APIs have support for Semaphore, Interrupt Registration, Timers, Cache APIs for both TI-RTOS and NONOS cases. For TI-RTOS OS, Task APIs are also supported. On Baremetal, any TaskP APIs from OSAL will result in linking errors. For Timer (TimerP), Semaphore(SemaphoreP) and Interrupts (HwiP), static memory allocation is done inside the osal library.

The static memory allocation for SemaphoreP and HwiP are scalable if needed by the application users, especially when the create APIs fail to create the SemaphoreP and HwiP handles. (Indicated by NULL handle values).

The application can provide a continuous segment of external memory for SemaphoreP as below.

  1. Get the current OSAL attributes
...
osal_ret = Osal_getHwAttrs(&hwAttrs);
  1. Set the continuous external memory block address and size
...
hwAttrs.extSemaphorePBlock.base = (uintptr_t) &semPMemBlock[0];
...
hwAttrs.extSemaphorePBlock.size = SEMP_BLOCK_SIZE;
...
ctrlBitMap                      = OSAL_HWATTR_SET_SEMP_EXT_BASE;
...
osal_ret = Osal_setHwAttrs(ctrlBitMap, &hwAttrs);

The application can provide a continuous segment of external memory for HwiP as below.

  1. Get the current OSAL attributes
...
osal_ret = Osal_getHwAttrs(&hwAttrs);
  1. Set the continuous external memory block address and size
...
hwAttrs.extSemaphorePBlock.base = (uintptr_t) &hwiPMemBlock[0];
...
hwAttrs.extSemaphorePBlock.size = HWIP_BLOCK_SIZE;
...
ctrlBitMap                      = OSAL_HWATTR_SET_HWIP_EXT_BASE;
...
osal_ret = Osal_setHwAttrs(ctrlBitMap, &hwAttrs);

4.3.2.2. Application Integration Details

Baremetal or No-OS Use case

Reference library path to be included in application build environment:

<ti/osal/lib/nonos/[soc]/[[cpu]/>

SysBIOS based application

Any RTSC application that needs to use osal library, should have below RTSC configuration lines before any other processor sdk components (e.g., board, gpio, uart etc).

/* set the operating system type,
 * supported types are "tirtos" and "nonos"
 */
var osType           = "tirtos";

/* set the soc type
 * (applicable only when osTYpe
 *  is "nonos" only)
*/
var socType           = "am572x";

/* Setup the OSAL Library */
var Osal = xdc.loadPackage('ti.osal');
Osal.Settings.osType  = osType;
Osal.Settings.socType = socType;

4.3.3. Application

4.3.3.1. Examples

Sysbios Example

This sysbios example OSAL_BasicExample_<board>_<coretype>TestProject tests Hwi, Timer, Delay, Semaphores etc and prints output on UART console.

Introduction

This sysbios based example tests Hwi, Timer, Semaphores etc.

Supported platforms

evmAM335x
evmAM437x
idkAM571x
idkAM574x
evmAM572x
evmK2G
evmK2H
evmOMAPL137
lcdkOMAPL138
am65xx_evm
am65xx_idk
j721e_evm
j7200_evm
am64x_evm

Build instructions

  • Run pdkProjectCreate to create the OSAL_BasicExample_<evm>_<device>TestProject
  • Load the project on to CCS and build the same.
  • Build the example
  • Load the OSAL_BasicExample_<evm>_<device>TestProject
  • Run the example

Testing the example

The output for each of the tests (Hwi, Timer, Delay, Semaphores etc) can be seen on the UART console. After a successful run, “All tests have PASSED” will be displayed on the screen.

Baremetal Example

Introduction

This baremetal example ‘osal_baremetal_test’ tests Hwi, Timer, Semaphores etc and prints output on UART console.

Supported platforms

evmAM572x
evmAM335x
evmAM437x
evmDRA72x
evmDRA75x
evmDRA78x
iceK2G
idkAM574x
idkAM572x
idkAM571x
idkAM437x
am65xx_evm
am65xx_idk
j721e_evm
j7200_evm
am64x_evm

Build instructions

Testing the example

The output for each of the tests (Hwi, Timer, Delay, Semaphores, etc) can be seen on the UART console. After a successful run, “All tests have passed” will be displayed on the screen.

Output

The output of osal example looks like below. The below sample output is from idkAM571x on the UART console.

HWI tests have passed.
TimerTestLog: got 100 ticks from timer id = 1
TimerTestLog: got 100 ticks from timer id = 2
Timer tests have passed.
Running Osal_Delay test:..........
Osal_Delay tests have passed.
Clock tests have passed.
Semaphore tests have passed.
Semaphore Statistics:
PeakSemObjs = 5,
numMaxSemObjs = 100,
numFreeSemObjs = 97
Hwi Statistics:
PeakHwiObjs = 3,
numMaxHwiObjs = 100,
numFreeHwiObjs = 98
Timer Statistics:
PeakTimerObjs = 2,
numMaxTimerObjs = 100,
numFreeTimerObjs = 99
All tests have passed.