4.4. OSAL

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

    • FreeRTOS

    • SafeRTOS

    • Non-OS (Baremetal)

  • Supported SOCs

    • Please refer to component release notes

4.4.2. User Interface

For details about individual fields of this library structure, see the PDK doxygen documentation / OSAL API Guide

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

The following table shows which all OSAL modules are supported for FreeRTOS and Non-OS. Using OSAL APIs that are not supported for an OS will result in linking errors.

OSAL Module

FreeRTOS

SafeRTOS

Non-OS(Baremetal)

Tasks (TaskP)

YES

YES

NO

Semaphores (SempahoreP)

YES

YES

YES

HW Interrupts (HwiP)

YES

YES

YES

HW Timers (TimerP)

YES

YES

YES

Cache Ops (CahceP)

YES

YES

YES

Cycle profiler (CycleProfilerP)

YES

YES

YES

SW Timer (ClockP)

YES

YES

YES

Events (EventP)

YES

YES

YES

SW Mailbox (MailboxP)

YES

YES

YES

Mutex (MutexP)

YES

YES

YES

Queue (QueueP)

YES

NO

YES

Arbitrary Heap (HeapP)

YES

NO

YES

Task/CPU Load (LoadP)

YES

NO

YES

SW Interrupts (SwiP)

NO

NO

YES

In case of FreeRTOS/Non-OS, static memory allocation is done inside the osal library for all the modules.

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.4.2.2. Application Integration Details

  1. Baremetal or Non-OS Use case

    • Reference library path to be included in application build environment:

    <ti/osal/lib/nonos/[soc]/[[cpu]/>
    
  2. FreeRTOS based application

    • Reference library path to be included in application build environment:

    <ti/osal/lib/freertos/[soc]/[[cpu]/>
    
  3. SafeRTOS based application

    • Reference library path to be included in application build environment:

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

4.4.2.3. RTOS Tick-Timer Allocation

For FreeRTOS and SafeRTOS, the below table summarizes the various timers, that are used as tick timers on various cores. Applications must ensure to not use these timers. if used, this may lead to unexpected behavior, due to clash of timers.

mcu1_0

mcu1_1

mcu2_0

mcu2_1

mcu3_0

mcu3_1

c7x_1

c66xdsp_1

c66xdsp_2

FreeRTOS

MCU DMT1

MCU DMT2

DMT12

DMT13

DMT14

DMT15

DMT2

DMT0

DMT1

SafeRTOS

MCU DMT1

MCU DMT2

DMT12

DMT13

DMT14

DMT15

DMT2

DMT0

DMT1

4.4.3. Application

4.4.3.1. Examples

OSAL Unit Test

Application Name

Example

FreeRTOS

SafeRTOS

Non-OS(Baremetal)

Unit Test

OSAL_TestApp_freertos

OSAL_TestApp_safertos

OSAL_Baremetal_TestApp

Description

The unit testapp tests all the supported OSAL modules for an OS and prints output on UART console.

Expected Results

The output for each of the tests (Hwi, Timer, Delay, Semaphores etc) can be seen on the UART console like

<Module> tests have passed.

After a successful run following will also be displayed on the UART console.

All tests have passed.