summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 71528de)
raw | patch | inline | side by side (parent: 71528de)
author | Prasad Konnur <prasadkonnur@ti.com> | |
Tue, 23 Feb 2021 14:20:11 +0000 (19:50 +0530) | ||
committer | Ankur <ankurbaranwal@ti.com> | |
Fri, 5 Mar 2021 10:02:31 +0000 (04:02 -0600) |
- added osal lib
- added semephore osal implementation
- other components of osal use the nonos implementation
- added taskp in freertos
- added memoryP in freertos
- added memoryP test in osal testapp
- added delay implementation using TaskP_sleep
Signed-off-by: Prasad Konnur <prasadkonnur@ti.com>
- added semephore osal implementation
- other components of osal use the nonos implementation
- added taskp in freertos
- added memoryP in freertos
- added memoryP test in osal testapp
- added delay implementation using TaskP_sleep
Signed-off-by: Prasad Konnur <prasadkonnur@ti.com>
22 files changed:
index b0697d03d846347c2a37fd5c73d700bac76bbddd..4fd771404fa13e648d9b513820635d611b60ffd5 100644 (file)
SDK_INSTALL_PATH ?= $(abspath ../../../../)
TOOLS_INSTALL_PATH ?= $(SDK_INSTALL_PATH)
-#Default BUILD_OS_TYPE (tirtos/baremetal/qnx)
+#Default BUILD_OS_TYPE (tirtos/baremetal/qnx/freertos)
export BUILD_OS_TYPE ?= tirtos
include $(PDK_INSTALL_PATH)/ti/build/procsdk_defs.mk
index f3ccec6fc0b5d7a0294a2aa1321bbd9bfe6ec5e9..3eda0698f017a76a4839e0bada9db443158a4f68 100644 (file)
endif
endif
+PDK_COMMON_FREERTOS_COMP = $(PDK_COMMON_COMP) osal_freertos
+ifeq ($(SOC),$(filter $(SOC), tpr12))
+ PDK_COMMON_FREERTOS_COMP += freertos
+endif
+ifeq ($(ARCH),c66x)
+ PDK_COMMON_FREERTOS_COMP += csl_intc
+else
+ ifneq ($(ARCH),c71)
+ PDK_COMMON_FREERTOS_COMP += csl_init
+ endif
+endif
+
export PDK_COMMON_TIRTOS_COMP
export PDK_COMMON_BAREMETAL_COMP
+export PDK_COMMON_FREERTOS_COMP
pdk_component_make_include := 1
endif
index dc2b245828835a780f50c77067f2e4a972619817..a19b1e44cc2a9bf0deed4f2884453162da4c1fa3 100644 (file)
CHMOD = $(UTILSPATH)chmod
endif
-ifeq ($(BUILD_OS_TYPE),baremetal)
+ifeq ($(BUILD_OS_TYPE),$(filter $(BUILD_OS_TYPE), baremetal freertos))
ifeq ($(SOC),$(filter $(SOC), am65xx j721e am77x j7200 am64x))
ifeq ($(CONFIG_BLD_XDC_r5f),)
CONFIG_BLD_LNK_r5f = $(pdk_PATH)/ti/build/$(SOC)/linker_r5.lds
endif
ifeq ($(SOC),$(filter $(SOC), tpr12 awr294x))
ifeq ($(CONFIG_BLD_XDC_r5f),)
+ ifeq ($(BUILD_OS_TYPE),freertos)
+ CONFIG_BLD_LNK_r5f = $(pdk_PATH)/ti/build/$(SOC)/linker_r5_freertos.lds
+ else
CONFIG_BLD_LNK_r5f = $(pdk_PATH)/ti/build/$(SOC)/linker_r5.lds
+ endif
endif
ifeq ($(CONFIG_BLD_XDC_c66),)
+ ifeq ($(BUILD_OS_TYPE),freertos)
+ CONFIG_BLD_LNK_c66 = $(pdk_PATH)/ti/build/$(SOC)/linker_c66_freertos.cmd
+ else
CONFIG_BLD_LNK_c66 = $(pdk_PATH)/ti/build/$(SOC)/linker_c66_baremetal.cmd
+ endif
endif
endif
endif
diff --git a/packages/ti/kernel/freertos/portable/TI_CGT/c66/portmacro.h b/packages/ti/kernel/freertos/portable/TI_CGT/c66/portmacro.h
index 64d52c2f24e3204e7ca90ec836045ad2e4304995..11f8ab8bd007d520a5a5cab62fb01ace1860c84f 100644 (file)
#define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority()
#endif /* configASSERT */
-
+ extern BaseType_t xPortInIsrContext(void);
+
#ifdef __cplusplus
} /* extern C */
#endif
diff --git a/packages/ti/kernel/freertos/portable/TI_CGT/r5f/port.c b/packages/ti/kernel/freertos/portable/TI_CGT/r5f/port.c
index 150e05f284e98d176591c79b8b39fa06b370343b..8765ca91dd3958b2bb4ce6093a590017c537411b 100644 (file)
*/
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}
+
+/*
+ * Returns true if the current core is in ISR context; low prio ISR, med prio ISR or timer tick ISR. High prio ISRs
+ * aren't detected here, but they normally cannot call C code, so that should not be an issue anyway.
+ */
+BaseType_t xPortInIsrContext()
+{
+ BaseType_t inISR = false;
+ if (ulPortInterruptNesting != 0)
+ {
+ inISR = true;
+ }
+ return inISR;
+}
diff --git a/packages/ti/kernel/freertos/portable/TI_CGT/r5f/portmacro.h b/packages/ti/kernel/freertos/portable/TI_CGT/r5f/portmacro.h
index e246d4109e8aeb046a1b42b081dca8618364b512..04440b88ec39ec260c2629eaf46f84199757c755 100644 (file)
#define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority()
#endif /* configASSERT */
+ extern BaseType_t xPortInIsrContext(void);
#ifdef __cplusplus
} /* extern C */
diff --git a/packages/ti/kernel/test/freertos/task_switch/main.c b/packages/ti/kernel/test/freertos/task_switch/main.c
index 8f0318c0be3f441d32cca0f0a1524d42e0b60841..eb4c92d30ede78026096014d25dc28407aaba8dc 100644 (file)
#include <stdlib.h>
#include <ti/osal/osal.h>
#include <ti/osal/DebugP.h>
+#include <ti/osal/TaskP.h>
#include <ti/board/board.h>
#include "FreeRTOS.h"
#include "task.h"
#define MAIN_TASK_PRI (configMAX_PRIORITIES-1)
-#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE))
+#define MAIN_TASK_SIZE (4096u)
StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32)));
-StaticTask_t gMainTaskObj;
-TaskHandle_t gMainTask;
+TaskP_Handle gMainTask;
void task_switch_main(void *args);
-void frertos_main(void *args)
-{
- task_switch_main(NULL);
-
- vTaskDelete(NULL);
-}
-
-
int main()
{
Board_initCfg boardCfg;
Board_STATUS status;
+ TaskP_Params taskParams;
boardCfg = BOARD_INIT_PINMUX_CONFIG |
BOARD_INIT_UNLOCK_MMR;
status = Board_init(boardCfg);
DebugP_assert(status == BOARD_SOK);
+
+ TaskP_Params_init(&taskParams);
+ taskParams.name = "freertos_main";
+ taskParams.stacksize = MAIN_TASK_SIZE;
+ taskParams.stack = gMainTaskStack;
+ taskParams.priority = MAIN_TASK_PRI;
+ taskParams.arg0 = NULL;
+ taskParams.arg1 = NULL;
+
/* This task is created at highest priority, it should create more tasks and then delete itself */
- gMainTask = xTaskCreateStatic( frertos_main, /* Pointer to the function that implements the task. */
- "freertos_main", /* Text name for the task. This is to facilitate debugging only. */
- MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
- NULL, /* We are not using the task parameter. */
- MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
- gMainTaskStack, /* pointer to stack base */
- &gMainTaskObj ); /* pointer to statically allocated task object memory */
+ gMainTask = TaskP_create(task_switch_main, &taskParams);
configASSERT(gMainTask != NULL);
/* Start the scheduler to start the tasks executing. */
diff --git a/packages/ti/kernel/test/freertos/task_switch/makefile b/packages/ti/kernel/test/freertos/task_switch/makefile
index 3637351df31219d03274bd416438029ab15da002..d12adfc34a73724891d1ecc9a8a95a551757b683 100644 (file)
APP_NAME = freertos_test_task_switch
-BUILD_OS_TYPE=baremetal
+BUILD_OS_TYPE=freertos
CFLAGS_TEST_DEFINES =
#
# List all the external components/interfaces, whose interface header files
# need to be included for this component
INCLUDE_EXTERNAL_INTERFACES = pdk
-ifeq ($(BUILD_OS_TYPE), baremetal)
-COMP_LIST_COMMON = $(PDK_COMMON_BAREMETAL_COMP)
+ifeq ($(BUILD_OS_TYPE), freertos)
+COMP_LIST_COMMON = $(PDK_COMMON_FREERTOS_COMP)
else
# List all the components required by the application
endif
-COMP_LIST_COMMON += freertos
-
ifeq ($(CORE),$(filter $(CORE), c66xdsp_1))
EXTERNAL_LNKCMD_FILE_LOCAL = $(PDK_INSTALL_PATH)/ti/build/$(SOC)/linker_c66_freertos.cmd
endif
diff --git a/packages/ti/kernel/test/freertos/task_switch/task_switch.c b/packages/ti/kernel/test/freertos/task_switch/task_switch.c
index dbc1befe743bcffb54fb71503e988793eb1a898c..b4a24bcc86045d813c6ca7bb2f7fa6e98f1d1b0a 100644 (file)
#include <ti/osal/osal.h>
#include <ti/osal/DebugP.h>
#include <ti/osal/HwiP.h>
+#include <ti/osal/SemaphoreP.h>
+#include <ti/osal/TaskP.h>
#include <FreeRTOS.h>
#include <task.h>
-#include <semphr.h>
#include <ti/csl/soc.h>
+TaskHandle_t TaskP_getFreertosHandle(TaskP_Handle handle);
+
/*
* IMPORTANT NOTES:
*
#define PONG_TASK_SIZE (4096u)
StackType_t gPongTaskStack[PONG_TASK_SIZE] __attribute__((aligned(32)));
-StaticTask_t gPingTaskObj;
-TaskHandle_t gPingTask;
-StaticSemaphore_t gPingSemObj;
-SemaphoreHandle_t gPingSem;
+TaskP_Handle gPingTask;
+SemaphoreP_Handle gPingSem;
-StaticTask_t gPongTaskObj;
-TaskHandle_t gPongTask;
-StaticSemaphore_t gPongSemObj;
-SemaphoreHandle_t gPongSem;
+TaskP_Handle gPongTask;
+SemaphoreP_Handle gPongSem;
static void ping_isr(uintptr_t arg)
{
- BaseType_t doTaskSwitch = 0;
-
- xSemaphoreGiveFromISR( gPongSem, &doTaskSwitch); /* wake up pong task */
- portYIELD_FROM_ISR( doTaskSwitch );
+ SemaphoreP_post(gPongSem);
}
static void pong_isr(uintptr_t arg)
{
- BaseType_t doTaskSwitch = 0;
-
- xSemaphoreGiveFromISR( gPingSem, &doTaskSwitch); /* wake up ping task */
- portYIELD_FROM_ISR( doTaskSwitch );
+ SemaphoreP_post(gPingSem);
}
void ping_main(void *args)
curTime = uiPortGetRunTimeCounterValue();
while(count--)
{
- xSemaphoreGive( gPongSem); /* wake up pong task */
- xSemaphoreTake( gPingSem, portMAX_DELAY); /* wait for pong to signal */
+ SemaphoreP_post(gPongSem);
+ SemaphoreP_pend(gPingSem, SemaphoreP_WAIT_FOREVER);
}
curTime = uiPortGetRunTimeCounterValue() - curTime;
curTime = uiPortGetRunTimeCounterValue();
while(count--)
{
- xTaskNotifyGive( gPongTask); /* wake up pong task */
+ xTaskNotifyGive( TaskP_getFreertosHandle(gPongTask)); /* wake up pong task */
ulTaskNotifyTake( pdTRUE, portMAX_DELAY); /* wait for pong to signal */
}
curTime = uiPortGetRunTimeCounterValue() - curTime;
while(count--)
{
HwiP_post(PING_INT_NUM);
- xSemaphoreTake( gPingSem, portMAX_DELAY); /* wait for ISR to signal */
+ SemaphoreP_pend(gPingSem, SemaphoreP_WAIT_FOREVER);
}
curTime = uiPortGetRunTimeCounterValue() - curTime;
DebugP_log0("[FreeRTOS] ping task ... done !!!\r\n");
DebugP_log0("\r\n");
DebugP_log0("All tests have passed!!\r\n");
-
- /* One MUST not return out of a FreeRTOS task instead one MUST call vTaskDelete */
- vTaskDelete(NULL);
+ printf("All tests have passed!!\r\n");
}
void pong_main(void *args)
count = NUM_TASK_SWITCHES;
while(count--)
{
- xSemaphoreTake( gPongSem, portMAX_DELAY); /* wait for ping to signal */
- xSemaphoreGive( gPingSem); /* wakeup ping task */
+ SemaphoreP_pend(gPongSem, SemaphoreP_WAIT_FOREVER);
+ SemaphoreP_post(gPingSem);
}
count = NUM_TASK_SWITCHES;
while(count--)
{
ulTaskNotifyTake( pdTRUE, portMAX_DELAY); /* wait for ping to signal */
- xTaskNotifyGive( gPingTask); /* wake up ping task */
+ xTaskNotifyGive( TaskP_getFreertosHandle(gPingTask)); /* wake up ping task */
}
{
HwiP_Params hwiParams;
count = NUM_TASK_SWITCHES;
while(count--)
{
- xSemaphoreTake( gPongSem, portMAX_DELAY); /* wait for ISR to signal */
+ SemaphoreP_pend(gPongSem, SemaphoreP_WAIT_FOREVER);
HwiP_post(PONG_INT_NUM);
}
hwiStatus = HwiP_delete(hHwi);
DebugP_assert(hwiStatus == HwiP_OK);
}
- /* One MUST not return out of a FreeRTOS task instead one MUST call vTaskDelete */
- vTaskDelete(NULL);
}
void task_switch_main(void *args)
{
+ SemaphoreP_Params semParams;
+ TaskP_Params taskParams;
+
/* Open drivers to open the UART driver for console */
//Drivers_open();
+ SemaphoreP_Params_init(&semParams);
+ semParams.mode = SemaphoreP_Mode_BINARY;
+
/* first create the semaphores */
- gPingSem = xSemaphoreCreateBinaryStatic(&gPingSemObj);
+ gPingSem = SemaphoreP_create(0, &semParams);
configASSERT(gPingSem != NULL);
- gPongSem = xSemaphoreCreateBinaryStatic(&gPongSemObj);
+ gPongSem = SemaphoreP_create(0, &semParams);
configASSERT(gPongSem != NULL);
- /* then create the tasks, order of task creation does not matter for this example */
- gPongTask = xTaskCreateStatic( pong_main, /* Pointer to the function that implements the task. */
- "pong", /* Text name for the task. This is to facilitate debugging only. */
- PONG_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
- NULL, /* We are not using the task parameter. */
- PONG_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
- gPongTaskStack, /* pointer to stack base */
- &gPongTaskObj ); /* pointer to statically allocated task object memory */
+ TaskP_Params_init(&taskParams);
+ taskParams.name = "pong";
+ taskParams.stacksize = PONG_TASK_SIZE;
+ taskParams.stack = gPongTaskStack;
+ taskParams.priority = PONG_TASK_PRI;
+ taskParams.arg0 = NULL;
+
+ gPongTask = TaskP_create(pong_main, &taskParams);
configASSERT(gPongTask != NULL);
- gPingTask = xTaskCreateStatic( ping_main, /* Pointer to the function that implements the task. */
- "ping", /* Text name for the task. This is to facilitate debugging only. */
- PING_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
- NULL, /* We are not using the task parameter. */
- PING_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
- gPingTaskStack, /* pointer to stack base */
- &gPingTaskObj ); /* pointer to statically allocated task object memory */
+ TaskP_Params_init(&taskParams);
+ taskParams.name = "ping";
+ taskParams.stacksize = PING_TASK_SIZE;
+ taskParams.stack = gPingTaskStack;
+ taskParams.priority = PING_TASK_PRI;
+ taskParams.arg0 = NULL;
+ gPingTask = TaskP_create(ping_main, &taskParams);
configASSERT(gPingTask != NULL);
/* Dont close drivers to keep the UART driver open for console */
/* Drivers_close(); */
}
+
diff --git a/packages/ti/osal/build/makefile_freertos.mk b/packages/ti/osal/build/makefile_freertos.mk
--- /dev/null
@@ -0,0 +1,74 @@
+#
+# Copyright (c) 2016, Texas Instruments Incorporated
+# All rights reserved.
+#
+# 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.
+#
+
+include $(PDK_INSTALL_PATH)/ti/build/Rules.make
+include $(PDK_OSAL_COMP_PATH)/src/src_common_freertos.mk
+
+MODULE_NAME = osal_freertos
+
+MUXINTCP = src/nonos/muxintcp
+TIMER = src/nonos/timer
+
+ifeq ($(SOC),$(filter $(SOC), tpr12 awr294x))
+ SRCDIR += $(MUXINTCP)/v2 $(TIMER)/v2
+ INCDIR += $(MUXINTCP)/v2 $(TIMER)/v2
+ PACKAGE_SRCS_COMMON += $(MUXINTCP)/v2 $(TIMER)/v2
+ SRCS_COMMON += MuxIntcP_nonos.c
+endif
+
+ifeq ($(SOC),$(filter $(SOC), am65xx j721e j7200 am64x tpr12 awr294x))
+SRCS_COMMON += TimerP_nonos.c
+endif
+
+
+# List all the external components/interfaces, whose interface header files
+# need to be included for this component
+INCLUDE_EXTERNAL_INTERFACES = pdk
+
+INCDIR = ${FREERTOS_KERNEL_INSTALL_PATH}/FreeRTOS-Kernel/include
+INCDIR += $(PDK_FREERTOS_COMP_PATH)/freertos/portable/TI_CGT/$(ISA)
+INCDIR += $(PDK_FREERTOS_COMP_PATH)/freertos/config/$(SOC)/$(ISA)
+
+CFLAGS_LOCAL_COMMON += $(PDK_CFLAGS)
+
+# Include common make files
+ifeq ($(MAKERULEDIR), )
+#Makerule path not defined, define this and assume relative path from ROOTDIR
+ MAKERULEDIR := $(ROOTDIR)/ti/build/makerules
+ export MAKERULEDIR
+endif
+include $(MAKERULEDIR)/common.mk
+
+# OBJs and libraries are built by using rule defined in rules_<target>.mk
+# and need not be explicitly specified here
+
+# Nothing beyond this point
index eb10a268a62ad0b47f91fc430ebd707b2cfe283a..f10910bd949f9880e2cb5068e814d83a87e8a183 100644 (file)
--- a/packages/ti/osal/osal.h
+++ b/packages/ti/osal/osal.h
*********************************************************************/
#define OSAL_TIRTOS_HWIP_SIZE_BYTES (96U)
+/*********************************************************************
+ * @def OSAL_FREERTOS_SEMAPHOREP_SIZE_BYTES
+ * Semaphorep handle size for non-os use case
+ * Application can use this size to provide a secondary extended
+ * memory block for semaphore creation when all the memory (internal to osal)
+ * are utilized
+ *
+ *********************************************************************/
+#define OSAL_FREERTOS_SEMAPHOREP_SIZE_BYTES ((uint32_t) 96U)
+
+/*********************************************************************
+ * @def OSAL_FREERTOS_TASKP_SIZE_BYTES
+ * TaskP handle size for non-os use case
+ * Application can use this size to provide a secondary extended
+ * memory block for semaphore creation when all the memory (internal to osal)
+ * are utilized
+ *
+ *********************************************************************/
+#define OSAL_FREERTOS_TASKP_SIZE_BYTES ((uint32_t) 128U)
+
/**
* \brief This structure holds static memory status parameters of OSAL
* library
index 033a71605c7dea3a412685e54b9ab14ff9f7b232..bc44b85b5cc38ecf4e3c41d46f381bf1fd8c4706 100644 (file)
libosal_BOARDLIST = evmAM572x evmAM335x evmAM437x iceK2G idkAM574x idkAM572x idkAM571x idkAM437x am65xx_evm am65xx_idk evmOMAPL137 lcdkOMAPL138 evmK2E evmK2H evmK2K evmK2L j721e_evm j7200_evm am64x_evm tpr12_evm tpr12_qt awr294x_evm
libosal_SOCLIST = tda2xx tda2px tda2ex tda3xx dra78x dra72x dra75x am574x am572x am571x k2h k2k k2l k2e k2g c6678 c6657 am437x am335x omapl137 omapl138 am65xx j721e j7200 am64x tpr12 awr294x
+libosal_freertos_BOARDLIST = tpr12_evm
+libosal_freertos_SOCLIST = tpr12
libosal_tda2xx_CORELIST = a15_0 ipu1_0
libosal_tda2px_CORELIST = a15_0 ipu1_0
libosal_tda2ex_CORELIST = a15_0 ipu1_0
ifeq ($(BUILD_OS_TYPE),tirtos)
osal_LIB_LIST += osal_tirtos osal_tirtos_indp
endif
+osal_LIB_LIST += osal_freertos
libosal_LIB_LIST = $(osal_LIB_LIST)
############################
osal_tirtos_indp_$(SOC)_CORELIST = $(libosal_$(SOC)_CORELIST)
export osal_tirtos_indp_$(SOC)_CORELIST
+# OSAL FREE RTOS LIB
+osal_freertos_COMP_LIST = osal_freertos
+osal_freertos_RELPATH = ti/osal
+osal_freertos_PATH = $(PDK_OSAL_COMP_PATH)
+osal_freertos_LIBNAME = ti.osal
+export osal_freertos_LIBNAME
+osal_freertos_LIBPATH = $(osal_freertos_PATH)/lib/freertos
+export osal_freertos_LIBPATH
+osal_freertos_OBJPATH = $(osal_freertos_RELPATH)/osal_freertos
+export osal_freertos_OBJPATH
+osal_freertos_MAKEFILE = -f build/makefile_freertos.mk
+export osal_freertos_MAKEFILE
+osal_freertos_PLATFORM_DEPENDENCY = no
+osal_freertos_CORE_DEPENDENCY = no
+osal_freertos_SOC_DEPENDENCY = yes
+export osal_freertos_COMP_LIST
+export osal_freertos_PLATFORM_DEPENDENCY
+export osal_freertos_CORE_DEPENDENCY
+export osal_freertos_SOC_DEPENDENCY
+osal_freertos_PKG_LIST = osal_freertos
+export osal_freertos_PKG_LIST
+osal_freertos_INCLUDE = $(osal_freertos_PATH)
+osal_freertos_SOCLIST = $(libosal_freertos_SOCLIST)
+export osal_freertos_SOCLIST
+osal_freertos_$(SOC)_CORELIST = $(libosal_$(SOC)_CORELIST)
+export osal_freertos_$(SOC)_CORELIST
+
#
# OSAL Examples
#
endif
export OSAL_Baremetal_TestApp_SBL_APPIMAGEGEN
+OSAL_freertos_TestApp_COMP_LIST = OSAL_freertos_TestApp
+OSAL_freertos_TestApp_RELPATH = ti/osal/test/freertos
+OSAL_freertos_TestApp_PATH = $(PDK_OSAL_COMP_PATH)/test/freertos
+OSAL_freertos_TestApp_BOARD_DEPENDENCY = yes
+OSAL_freertos_TestApp_CORE_DEPENDENCY = no
+export OSAL_freertos_TestApp_COMP_LIST
+export OSAL_freertos_TestApp_BOARD_DEPENDENCY
+export OSAL_freertos_TestApp_CORE_DEPENDENCY
+OSAL_freertos_TestApp_PKG_LIST = OSAL_freertos_TestApp
+OSAL_freertos_TestApp_INCLUDE = $(OSAL_freertos_TestApp_PATH)
+OSAL_freertos_TestApp_BOARDLIST = $(libosal_freertos_BOARDLIST)
+export OSAL_freertos_TestApp_BOARDLIST
+OSAL_freertos_TestApp_SBL_APPIMAGEGEN = yes
+export OSAL_freertos_TestApp_SBL_APPIMAGEGEN
+
# OSAL sysbios unit test app
OSAL_TestApp_COMP_LIST = OSAL_TestApp
OSAL_TestApp_RELPATH = ti/osal/test/sysbios_unit_test
ifeq ($(SOC),$(filter $(SOC), tpr12))
OSAL_TestApp_$(SOC)_CORELIST = mcu1_0 c66xdsp_1
OSAL_Baremetal_TestApp_$(SOC)_CORELIST = mcu1_0 c66xdsp_1
+ OSAL_freertos_TestApp_$(SOC)_CORELIST = mcu1_0 c66xdsp_1
endif
ifeq ($(SOC),$(filter $(SOC), awr294x))
export OSAL_TestApp_$(SOC)_CORELIST
osal_EXAMPLE_LIST += OSAL_Baremetal_TestApp
+osal_EXAMPLE_LIST += OSAL_freertos_TestApp
# do not support RTOS example for AM64x yet
osal_EXAMPLE_LIST += OSAL_TestApp
index 7b52b1e761657abf4831651ceb56d621d5e9deaf..4ecd1948ebf2f2de55b3b47a966301bcdf3e03fe 100644 (file)
#define OSAL_TIRTOS_CONFIGNUM_SEMAPHORE (OSAL_TIRTOS_MAX_SEMAPHOREP_PER_SOC)
#endif /* OSAL_TIRTOS_CONFIGNUM_SEMAPHORE */
+/*********************************************************************
+ * @def OSAL_FREERTOS_CONFIGNUM_SEMAPHORE
+ * To satisfy AMIC110 out of box needs, defaults are reduced to 20 as below
+ * If the need is more than the defaults, application would need to
+ * suppliment the additional memory for OSAL using @ref Osal_setHwAttrs
+ * API calls by setting the extended memory block for semaphores
+ *********************************************************************/
+
+/* Set the number of SemaphoreP_Handles for FREERTOS */
+#ifndef OSAL_FREERTOS_CONFIGNUM_SEMAPHORE
+#define OSAL_FREERTOS_CONFIGNUM_SEMAPHORE (OSAL_FREERTOS_MAX_SEMAPHOREP_PER_SOC)
+#endif /* OSAL_FREERTOS_CONFIGNUM_SEMAPHORE */
+
+/*********************************************************************
+ * @def OSAL_FREERTOS_CONFIGNUM_TASK
+ * To satisfy AMIC110 out of box needs, defaults are reduced to 20 as below
+ * If the need is more than the defaults, application would need to
+ * suppliment the additional memory for OSAL using @ref Osal_setHwAttrs
+ * API calls by setting the extended memory block for semaphores
+ *********************************************************************/
+
+/* Set the number of SemaphoreP_Handles for FREERTOS */
+#ifndef OSAL_FREERTOS_CONFIGNUM_TASK
+#define OSAL_FREERTOS_CONFIGNUM_TASK (OSAL_FREERTOS_MAX_TASKP_PER_SOC)
+#endif /* OSAL_FREERTOS_CONFIGNUM_TASK */
+
/*********************************************************************
* @def OSAL_NONOS_CONFIGNUM_HWI
* To satisfy AMIC110 out of box needs, defaults are reduced to 10 as below
index 081a5799aff9633ad2f81158ddbeb891da07931b..46d72c7cb47f5bab21ff03b37e57cf176b94783c 100644 (file)
#define OSAL_TIRTOS_MAX_HWIP_PER_SOC ((uint32_t) 40U)
#define OSAL_TIRTOS_MAX_TIMERP_PER_SOC (TimerP_numTimerDevices)
+#define OSAL_FREERTOS_MAX_SEMAPHOREP_PER_SOC ((uint32_t) 150U)
+#define OSAL_FREERTOS_MAX_HWIP_PER_SOC ((uint32_t) 40U)
+#define OSAL_FREERTOS_MAX_TIMERP_PER_SOC (TimerP_numTimerDevices)
+#define OSAL_FREERTOS_MAX_TASKP_PER_SOC ((uint32_t) 20U)
+
#define OSAL_ARCH_TIMER_INST_FOR_TS (TimerP_ANY)
/* external references */
extern Osal_HwAttrs gOsal_HwAttrs;
diff --git a/packages/ti/osal/src/freertos/MemoryP_freertos.c b/packages/ti/osal/src/freertos/MemoryP_freertos.c
--- /dev/null
@@ -0,0 +1,149 @@
+/*\r
+ * Copyright (c) 2015-2020, Texas Instruments Incorporated\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ * * Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * * Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ *\r
+ * * Neither the name of Texas Instruments Incorporated nor the names of\r
+ * its contributors may be used to endorse or promote products derived\r
+ * from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+/*\r
+ * ======== MemoryP_tirtos.c ========\r
+ */\r
+#include <ti/osal/MemoryP.h>\r
+\r
+#include <stdint.h>\r
+#include <stdbool.h>\r
+#include <stdlib.h>\r
+\r
+#include <FreeRTOS.h>\r
+#include <portable.h>\r
+\r
+typedef struct MemoryTrack_s\r
+{\r
+ uint32_t allocKey;\r
+ void *origAllocAddress;\r
+ uint32_t origAllocSize;\r
+} MemoryTrack_t __attribute__ ((aligned(portBYTE_ALIGNMENT)));\r
+\r
+/*\r
+ * ======== MemoryP_ctrlAlloc ========\r
+ */\r
+void* MemoryP_ctrlAlloc(uint32_t size, uint8_t alignment)\r
+{\r
+ /* Allocate memory from the default heap for the control memory:\r
+ * One possible use case is to use seperate heaps for the data\r
+ * and control operations. */\r
+\r
+ void *allocAddress;\r
+ void *origAllocAddress;\r
+ MemoryTrack_t *memoryTrackAddress;\r
+ uintptr_t offset;\r
+ if (alignment < portBYTE_ALIGNMENT)\r
+ {\r
+ /* If alignment not requested by application set to minimum alignment. */\r
+ alignment = portBYTE_ALIGNMENT;\r
+ }\r
+ /* Assert that requested align is a power of 2 */\r
+ DebugP_assert(((alignment & (alignment - 1)) == 0));\r
+\r
+ /* Assert that requested block size is non-zero */\r
+ DebugP_assert((size != 0));\r
+\r
+ origAllocAddress = pvPortMalloc(size + alignment + sizeof(MemoryTrack_t));\r
+ offset = (uintptr_t)origAllocAddress & (alignment - 1);\r
+ allocAddress = (void *)((uintptr_t)origAllocAddress - offset + alignment);\r
+ if (((uintptr_t)allocAddress - (uintptr_t)origAllocAddress) < sizeof(MemoryTrack_t))\r
+ {\r
+ /* We cant add the mem track address before the alloc Address.\r
+ * Move the alloc address by alignment value.\r
+ * This happens when the original alloc address is already aligned.\r
+ */\r
+ allocAddress = (void *)((uintptr_t)allocAddress + alignment);\r
+ if ((alignment < sizeof(MemoryTrack_t)) &&\r
+ (((uintptr_t)allocAddress - (uintptr_t)origAllocAddress) < sizeof(MemoryTrack_t)))\r
+ {\r
+ /* if alignment value is less than MemoryTrack_t,\r
+ * the alloc address might need to be updated again.\r
+ * to accomodate the MemoryTrack_t before the address passed to app.\r
+ */\r
+ allocAddress = (void *)((uintptr_t)allocAddress + alignment);\r
+ }\r
+ }\r
+ memoryTrackAddress = (MemoryTrack_t *)((uintptr_t)allocAddress - sizeof(MemoryTrack_t));\r
+ DebugP_assert(memoryTrackAddress >= origAllocAddress);\r
+ memoryTrackAddress->allocKey = 0xDEADBEEF;\r
+ memoryTrackAddress->origAllocAddress = origAllocAddress;\r
+ memoryTrackAddress->origAllocSize = size + alignment + sizeof(MemoryTrack_t);\r
+ DebugP_assert(((uintptr_t)allocAddress & (alignment - 1)) == 0);\r
+ DebugP_assert(((uintptr_t)allocAddress + size) <= ((uintptr_t)memoryTrackAddress->origAllocAddress + memoryTrackAddress->origAllocSize));\r
+ return allocAddress;\r
+}\r
+\r
+/*\r
+ * ======== MemoryP_ctrlFree ========\r
+ */\r
+void MemoryP_ctrlFree(void* ptr, uint32_t size)\r
+{\r
+ void *origAllocAddress;\r
+ MemoryTrack_t *memoryTrackAddress;\r
+\r
+ memoryTrackAddress = (MemoryTrack_t *)((uintptr_t)ptr - sizeof(MemoryTrack_t));\r
+ DebugP_assert(memoryTrackAddress->allocKey == 0xDEADBEEF);\r
+ \r
+ origAllocAddress = memoryTrackAddress->origAllocAddress;\r
+ vPortFree(origAllocAddress);\r
+}\r
+\r
+/*\r
+ * ======== MemoryP_dataAlloc ========\r
+ */\r
+void* MemoryP_dataAlloc(uint32_t size, uint8_t alignment)\r
+{\r
+ /* FREE RTOS uses the same memory for ctrl and data heaps. */\r
+ return MemoryP_ctrlAlloc (size, alignment);\r
+}\r
+\r
+/*\r
+ * ======== MemoryP_dataFree ========\r
+ */\r
+void MemoryP_dataFree(void* ptr, uint32_t size)\r
+{\r
+ /* Free the memory to the appropriate heap: */\r
+ MemoryP_ctrlFree(ptr, size);\r
+}\r
+\r
+/*\r
+ * ======== MemoryP_getStats ========\r
+ */\r
+void MemoryP_getStats(MemoryP_Stats *stats)\r
+{
+ HeapStats_t memStats;
+\r
+ vPortGetHeapStats(&memStats);
+ // stats->totalSize = (uint32_t)memStats.totalSize;
+ stats->totalFreeSize = (uint32_t)memStats.xAvailableHeapSpaceInBytes;\r
+}\r
+\r
diff --git a/packages/ti/osal/src/freertos/SemaphoreP_freertos.c b/packages/ti/osal/src/freertos/SemaphoreP_freertos.c
--- /dev/null
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 2015-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * 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.
+ */
+/*
+ * ======== SemaphoreP_freertos.c ========
+ */
+#include <ti/osal/SemaphoreP.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ti/csl/csl_types.h>
+#include <ti/osal/osal.h>
+#include <ti/osal/soc/osal_soc.h>
+
+#include <FreeRTOS.h>
+#include <semphr.h>
+
+extern uint32_t gOsalSemAllocCnt, gOsalSemPeak;
+
+/*!
+ * @brief Semaphore structure
+ */
+typedef struct SemaphoreP_freertos_s {
+ bool used;
+ StaticSemaphore_t semObj;
+ SemaphoreHandle_t semHndl;
+} SemaphoreP_freertos;
+
+/* global pool of statically allocated semaphore pools */
+static SemaphoreP_freertos gOsalSemPfreertosPool[OSAL_FREERTOS_CONFIGNUM_SEMAPHORE];
+
+int32_t SemaphoreP_constructBinary(SemaphoreP_freertos *handle, uint32_t initCount);
+int32_t SemaphoreP_constructCounting(SemaphoreP_freertos *handle, uint32_t initCount, uint32_t maxCount);
+
+/*
+ * Dummy function to check size during compile time
+ * ======== SemaphoreP_compileTime_SizeChk ========
+ */
+
+void SemaphoreP_compileTime_SizeChk(void)
+{
+#if defined(__GNUC__) && !defined(__ti__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#else
+/* TI compiler */
+#pragma diag_suppress 179
+#endif
+ OSAL_COMPILE_TIME_SIZE_CHECK ((uint32_t)sizeof(SemaphoreP_freertos),OSAL_FREERTOS_SEMAPHOREP_SIZE_BYTES);
+#if defined(__GNUC__) && !defined(__ti__)
+#pragma GCC diagnostic pop
+#endif
+}
+
+/*
+ * ======== SemaphoreP_create ========
+ */
+SemaphoreP_Handle SemaphoreP_create(uint32_t count,
+ const SemaphoreP_Params *params)
+{
+ SemaphoreP_Handle ret_handle;
+ SemaphoreP_freertos *handle = (SemaphoreP_freertos *) NULL_PTR;
+ uint32_t i;
+ uintptr_t key;
+ uintptr_t temp;
+ SemaphoreP_freertos *semPool;
+ uint32_t maxSemaphores;
+ int32_t retVal;
+
+ /* Check if user has specified any memory block to be used, which gets
+ * the precedence over the internal static memory block
+ */
+ if (gOsal_HwAttrs.extSemaphorePBlock.base != (uintptr_t)0U)
+ {
+ /* pick up the external memory block configured */
+ semPool = (SemaphoreP_freertos *) gOsal_HwAttrs.extSemaphorePBlock.base;
+ temp = (uintptr_t) gOsal_HwAttrs.extSemaphorePBlock.size;
+ maxSemaphores = (uint32_t)(temp/(sizeof(SemaphoreP_freertos)));
+ }
+ else
+ {
+ /* Pick up the internal static memory block */
+ semPool = (SemaphoreP_freertos *) &gOsalSemPfreertosPool[0];
+ maxSemaphores = OSAL_FREERTOS_CONFIGNUM_SEMAPHORE;
+
+ if(gOsalSemAllocCnt==0U)
+ {
+ (void)memset( (void *)gOsalSemPfreertosPool,0,sizeof(gOsalSemPfreertosPool));
+ }
+ }
+
+ key = HwiP_disable();
+
+ for (i = 0; i < maxSemaphores; i++)
+ {
+ if (semPool[i].used == FALSE)
+ {
+ semPool[i].used = TRUE;
+ /* Update statistics */
+ gOsalSemAllocCnt++;
+ if (gOsalSemAllocCnt > gOsalSemPeak)
+ {
+ gOsalSemPeak = gOsalSemAllocCnt;
+ }
+ break;
+ }
+ }
+ HwiP_restore(key);
+
+ if (i < maxSemaphores)
+ {
+ /* Grab the memory */
+ handle = (SemaphoreP_freertos *) &semPool[i];
+ }
+
+ if (handle == NULL_PTR) {
+ ret_handle = NULL_PTR;
+ }
+ else
+ {
+ if (params == NULL_PTR)
+ {
+ SemaphoreP_Params semParam;
+ SemaphoreP_Params_init(&semParam);
+ retVal = SemaphoreP_constructCounting(handle, count, semParam.maxCount);
+ }
+ else
+ {
+ if (params->mode == SemaphoreP_Mode_BINARY)
+ {
+ retVal = SemaphoreP_constructBinary(handle, count);
+ }
+ else
+ {
+ retVal = SemaphoreP_constructCounting(handle, count, params->maxCount);
+ }
+ }
+
+ /* If there was an error reset the sem object and return NULL. */
+ if (retVal != SemaphoreP_OK)
+ {
+ key = HwiP_disable();
+ handle->used = FALSE;
+ /* Found the osal semaphore object to delete */
+ if (gOsalSemAllocCnt > 0U)
+ {
+ gOsalSemAllocCnt--;
+ }
+ HwiP_restore(key);
+ ret_handle = NULL_PTR;
+ }
+ else
+ {
+ ret_handle = ((SemaphoreP_Handle)handle);
+ }
+ }
+ return ret_handle;
+}
+
+int32_t SemaphoreP_constructBinary(SemaphoreP_freertos *handle, uint32_t initCount)
+{
+ int32_t status;
+
+ handle->semHndl = xSemaphoreCreateBinaryStatic(&handle->semObj);
+ if( handle->semHndl == NULL )
+ {
+ status = SemaphoreP_FAILURE;
+ }
+ else
+ {
+ if(initCount == 1)
+ {
+ /* post a semaphore to increment initial count to 1 */
+ xSemaphoreGive(handle->semHndl);
+ }
+ status = SemaphoreP_OK;
+ }
+
+ return status;
+}
+
+int32_t SemaphoreP_constructCounting(SemaphoreP_freertos *handle, uint32_t initCount, uint32_t maxCount)
+{
+ int32_t status;
+
+ handle->semHndl = xSemaphoreCreateCountingStatic(
+ maxCount,
+ initCount,
+ &handle->semObj);
+ if( handle->semHndl == NULL )
+ {
+ status = SemaphoreP_FAILURE;
+ }
+ else
+ {
+ status = SemaphoreP_OK;
+ }
+
+ return status;
+}
+
+/*
+ * ======== SemaphoreP_delete ========
+ */
+SemaphoreP_Status SemaphoreP_delete(SemaphoreP_Handle handle)
+{
+ DebugP_assert((handle != NULL_PTR));
+
+ uintptr_t key;
+ SemaphoreP_Status ret = SemaphoreP_OK;
+ SemaphoreP_freertos *semaphore = (SemaphoreP_freertos *)handle;
+
+ if((semaphore != NULL_PTR) && (semaphore->used==TRUE))
+ {
+ vSemaphoreDelete(semaphore->semHndl);
+
+ key = HwiP_disable();
+ semaphore->used = FALSE;
+ /* Found the osal semaphore object to delete */
+ if (gOsalSemAllocCnt > 0U)
+ {
+ gOsalSemAllocCnt--;
+ }
+ HwiP_restore(key);
+ ret = SemaphoreP_OK;
+ }
+ else
+ {
+ ret = SemaphoreP_FAILURE;
+ }
+ return (ret);
+}
+
+/*
+ * ======== SemaphoreP_Params_init ========
+ */
+void SemaphoreP_Params_init(SemaphoreP_Params *params)
+{
+ DebugP_assert((params != NULL_PTR));
+
+ if(params != NULL_PTR)
+ {
+ params->mode = SemaphoreP_Mode_COUNTING;
+ params->name = (char *) NULL_PTR;
+ params->maxCount = 0xFFU;
+ }
+}
+
+/*
+ * ======== SemaphoreP_pend ========
+ */
+SemaphoreP_Status SemaphoreP_pend(SemaphoreP_Handle handle, uint32_t timeout)
+{
+ uint32_t isSemTaken;
+ SemaphoreP_Status ret_val;
+ SemaphoreP_freertos *pSemaphore = (SemaphoreP_freertos *)handle;
+
+ DebugP_assert((handle != NULL_PTR));
+
+ if( xPortInIsrContext() )
+ {
+ BaseType_t xHigherPriorityTaskWoken = 0;
+
+ /* timeout is ignored when in ISR mode */
+ isSemTaken = xSemaphoreTakeFromISR(pSemaphore->semHndl, &xHigherPriorityTaskWoken);
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
+ }
+ else
+ {
+ if (timeout == SemaphoreP_WAIT_FOREVER)
+ {
+ timeout = portMAX_DELAY;
+ }
+ isSemTaken = xSemaphoreTake(pSemaphore->semHndl, timeout);
+ }
+
+ if(isSemTaken)
+ {
+ ret_val = SemaphoreP_OK;
+ }
+ else
+ {
+ ret_val = SemaphoreP_TIMEOUT;
+ }
+
+ return ret_val;
+}
+
+/*
+ * ======== SemaphoreP_post ========
+ */
+SemaphoreP_Status SemaphoreP_post(SemaphoreP_Handle handle)
+{
+ DebugP_assert((handle != NULL_PTR));
+ SemaphoreP_freertos *pSemaphore = (SemaphoreP_freertos *)handle;
+
+ if( xPortInIsrContext() )
+ {
+ BaseType_t xHigherPriorityTaskWoken = 0;
+
+ xSemaphoreGiveFromISR(pSemaphore->semHndl, &xHigherPriorityTaskWoken);
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
+ }
+ else
+ {
+ xSemaphoreGive(pSemaphore->semHndl);
+ }
+
+ return (SemaphoreP_OK);
+}
+
+/*
+ * ======== SemaphoreP_postFromClock ========
+ */
+SemaphoreP_Status SemaphoreP_postFromClock(SemaphoreP_Handle handle)
+{
+ return (SemaphoreP_post(handle));
+}
+
+/*
+ * ======== SemaphoreP_postFromISR ========
+ */
+SemaphoreP_Status SemaphoreP_postFromISR(SemaphoreP_Handle handle)
+{
+ return (SemaphoreP_post(handle));
+}
+/*
+ * ======== SemaphoreP_getCount ========
+ */
+int32_t SemaphoreP_getCount(SemaphoreP_Handle handle)
+{
+ DebugP_assert((handle != NULL_PTR));
+
+ SemaphoreP_freertos *pSemaphore = (SemaphoreP_freertos *)handle;
+
+ return (uxSemaphoreGetCount(pSemaphore->semHndl));
+}
+
+SemaphoreP_Status SemaphoreP_reset(SemaphoreP_Handle handle)
+{
+ uint32_t isSemTaken = 0;
+ SemaphoreP_Status ret_val = SemaphoreP_OK;
+ SemaphoreP_freertos *pSemaphore = (SemaphoreP_freertos *)handle;
+
+ DebugP_assert((handle != NULL_PTR));
+
+ vTaskSuspendAll();
+ do {
+ isSemTaken = xSemaphoreTake(pSemaphore->semHndl, 0);
+ } while(isSemTaken != 0);
+ xTaskResumeAll();
+
+ return (ret_val);
+}
+/* Nothing past this point */
diff --git a/packages/ti/osal/src/freertos/TaskP_freertos.c b/packages/ti/osal/src/freertos/TaskP_freertos.c
--- /dev/null
@@ -0,0 +1,328 @@
+/*
+ * Copyright (c) 2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * 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.
+ */
+/*
+ * ======== TaskP_tirtos.c ========
+ */
+#include <ti/osal/TaskP.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ti/csl/csl_types.h>
+#include <ti/osal/osal.h>
+#include <ti/osal/DebugP.h>
+#include <ti/osal/soc/osal_soc.h>
+
+#include <FreeRTOS.h>
+#include <task.h>
+
+TaskHandle_t TaskP_getFreertosHandle(TaskP_Handle handle);
+
+/**
+ * \brief Value to be used for lowest priority task
+ */
+#define TaskP_PRIORITY_LOWEST (0u)
+
+/**
+ * \brief Value to be used for highest priority task
+ */
+#define TaskP_PRIORITY_HIGHEST (configMAX_PRIORITIES - 1)
+
+/*
+ * Defines the prototype of the task main functions.
+ */
+typedef void (* TaskP_mainFunction_t)( void *arg0, void *arg1);
+
+/*!
+ * @brief Task structure
+ */
+typedef struct TaskP_freertos_s {
+ bool used;
+ StaticTask_t *taskObj;
+ TaskHandle_t taskHndl;
+ TaskP_mainFunction_t taskfxn;
+ void *arg0;
+ void *arg1;
+} TaskP_freertos;
+
+/* task obj is too large to keep in structure. So keep it in global array. */
+static StaticTask_t gOsalFreertosTaskObjPool[OSAL_FREERTOS_CONFIGNUM_TASK];
+/* global pool of statically allocated task pools */
+static TaskP_freertos gOsalTaskPfreertosPool[OSAL_FREERTOS_CONFIGNUM_TASK];
+
+uint32_t gOsalTaskAllocCnt, gOsalTaskPeak;
+
+void TaskP_compileTime_SizeChk(void)
+{
+#if defined(__GNUC__) && !defined(__ti__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#else
+/* TI compiler */
+#pragma diag_suppress 179
+#endif
+ OSAL_COMPILE_TIME_SIZE_CHECK ((uint32_t)sizeof(TaskP_freertos),OSAL_FREERTOS_TASKP_SIZE_BYTES);
+#if defined(__GNUC__) && !defined(__ti__)
+#pragma GCC diagnostic pop
+#endif
+}
+
+void TaskP_Function (void *arg)
+{
+ TaskP_freertos *handle = (TaskP_freertos *)(arg);
+
+ /* Call the application function. */
+ (*handle->taskfxn)(handle->arg0, handle->arg0);
+
+ /* One MUST not return out of a FreeRTOS task instead one MUST call vTaskDelete */
+ TaskP_delete((TaskP_Handle) handle);
+}
+
+/*
+ * ======== TaskP_create ========
+ */
+TaskP_Handle TaskP_create(void *taskfxn, const TaskP_Params *params)
+{
+ TaskP_Handle ret_handle;
+ TaskP_freertos *handle = (TaskP_freertos *) NULL_PTR;
+ TaskP_freertos *taskPool;
+ uint32_t i;
+ uintptr_t key;
+ uint32_t maxTasks;
+ uint32_t taskPriority;
+
+ DebugP_assert((taskfxn != NULL_PTR));
+ DebugP_assert((params != NULL_PTR));
+ DebugP_assert((params->stack != NULL_PTR));
+
+ /* Pick up the internal static memory block */
+ taskPool = (TaskP_freertos *) &gOsalTaskPfreertosPool[0];
+ maxTasks = OSAL_FREERTOS_CONFIGNUM_TASK;
+
+ if(gOsalTaskAllocCnt==0U)
+ {
+ (void)memset( (void *)gOsalTaskPfreertosPool,0,sizeof(gOsalTaskPfreertosPool));
+ }
+
+ key = HwiP_disable();
+
+ for (i = 0; i < maxTasks; i++)
+ {
+ if (taskPool[i].used == FALSE)
+ {
+ taskPool[i].used = TRUE;
+ taskPool[i].taskObj = &gOsalFreertosTaskObjPool[i];
+ /* Update statistics */
+ gOsalTaskAllocCnt++;
+ if (gOsalTaskAllocCnt > gOsalTaskPeak)
+ {
+ gOsalTaskPeak = gOsalTaskAllocCnt;
+ }
+ break;
+ }
+ }
+ HwiP_restore(key);
+
+ if (i < maxTasks)
+ {
+ /* Grab the memory */
+ handle = (TaskP_freertos *) &taskPool[i];
+ }
+
+ if (handle == NULL_PTR) {
+ ret_handle = NULL_PTR;
+ }
+ else
+ {
+ taskPriority = params->priority;
+ /* if prority is out of range, adjust to bring it in range */
+ if(taskPriority > TaskP_PRIORITY_HIGHEST)
+ {
+ taskPriority = TaskP_PRIORITY_HIGHEST;
+ }
+ if(taskPriority <= TaskP_PRIORITY_LOWEST)
+ {
+ taskPriority = TaskP_PRIORITY_LOWEST;
+ }
+ /* Store the task function and args in taskP object. */
+ handle->taskfxn = (TaskP_mainFunction_t)(taskfxn);
+ handle->arg0 = params->arg0;
+ handle->arg1 = params->arg1;
+
+ handle->taskHndl = xTaskCreateStatic((TaskFunction_t)TaskP_Function, /* Pointer to the function that implements the task. */
+ (char *)params->name, /* Text name for the task. This is to facilitate debugging only. */
+ params->stacksize/(sizeof(UBaseType_t)), /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
+ handle, /* task specific args */
+ taskPriority, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
+ (StackType_t*)params->stack, /* pointer to stack base */
+ handle->taskObj); /* pointer to statically allocated task object memory */
+ if(handle->taskHndl == NULL)
+ {
+ /* If there was an error reset the task object and return NULL. */
+ key = HwiP_disable();
+ handle->used = FALSE;
+ /* Found the osal task object to delete */
+ if (gOsalTaskAllocCnt > 0U)
+ {
+ gOsalTaskAllocCnt--;
+ }
+ HwiP_restore(key);
+ ret_handle = NULL_PTR;
+ }
+ else
+ {
+ ret_handle = ((TaskP_Handle)handle);
+ }
+ }
+
+ return (ret_handle);
+}
+
+/*
+ * ======== TaskP_delete ========
+ */
+TaskP_Status TaskP_delete(TaskP_Handle *handle)
+{
+ uintptr_t key;
+ TaskP_Status ret = TaskP_OK;
+ TaskP_freertos *task = (TaskP_freertos *)handle;
+ TaskHandle_t taskHndl;
+
+ if((task != NULL_PTR) && (task->used==TRUE))
+ {
+ key = HwiP_disable();
+ taskHndl = task->taskHndl;
+ task->used = FALSE;
+ task->taskObj = NULL;
+ task->taskHndl = NULL;
+ task->taskfxn = NULL;
+ task->arg0 = NULL;
+ task->arg1 = NULL;
+
+ /* Found the osal task object to delete */
+ if (gOsalTaskAllocCnt > 0U)
+ {
+ gOsalTaskAllocCnt--;
+ }
+ HwiP_restore(key);
+
+ vTaskDelete(taskHndl);
+ ret = TaskP_OK;
+ }
+ else
+ {
+ ret = TaskP_FAILURE;
+ }
+ return (ret);
+}
+
+/*
+ * ======== TaskP_Params_init ========
+ */
+void TaskP_Params_init(TaskP_Params *params)
+{
+ params->name = "FREERTOS_TASK";
+ params->stacksize = 0;
+ params->stack = NULL;
+ params->priority = (TaskP_PRIORITY_HIGHEST - TaskP_PRIORITY_LOWEST) / 2;
+ params->arg0 = NULL;
+ params->arg1 = NULL;
+}
+
+void TaskP_sleep(uint32_t timeout)
+{
+ vTaskDelay(timeout);
+}
+
+void TaskP_sleepInMsecs(uint32_t timeoutInMsecs)
+{
+ uint32_t ticks;
+
+ /* portTICK_PERIOD_MS is in units of usecs */
+ ticks = (uint32_t)((uint64_t)timeoutInMsecs * 1000U) / portTICK_PERIOD_MS;
+
+ vTaskDelay(ticks);
+}
+
+void TaskP_setPrio(TaskP_Handle handle, uint32_t priority)
+{
+ TaskP_freertos *taskHandle = handle;
+
+ DebugP_assert((handle != NULL_PTR));
+ vTaskPrioritySet(taskHandle->taskHndl, priority);
+}
+
+TaskP_Handle TaskP_self(void)
+{
+ // return ((TaskP_Handle)Task_self());
+ return NULL_PTR;
+}
+
+TaskP_Handle TaskP_selfmacro(void)
+{
+ // return ((TaskP_Handle)Task_selfMacro());
+ return NULL_PTR;
+}
+
+void TaskP_yield(void) {
+ taskYIELD();
+}
+
+uint32_t TaskP_isTerminated(TaskP_Handle handle)
+{
+ uint32_t isTaskTerminated = 0;
+ TaskP_freertos *taskHandle = handle;
+
+ DebugP_assert((handle != NULL_PTR));
+ if(eTaskGetState(taskHandle->taskHndl) != eDeleted)
+ {
+ isTaskTerminated = 0;
+ }
+ else
+ {
+ isTaskTerminated = 1;
+ }
+ return isTaskTerminated;
+}
+
+TaskHandle_t TaskP_getFreertosHandle(TaskP_Handle handle)
+{
+ DebugP_assert((handle != NULL_PTR));
+
+ TaskP_freertos *taskHandle = handle;
+ DebugP_assert((taskHandle->used != FALSE));
+
+ return (taskHandle->taskHndl);
+}
+
+/* Nothing past this point */
diff --git a/packages/ti/osal/src/freertos/Utils_freertos.c b/packages/ti/osal/src/freertos/Utils_freertos.c
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * Copyright (c) 2015-2018, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * 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.
+ */
+/*
+ * ======== HwiP_tirtos.c ========
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ti/osal/src/nonos/Nonos_config.h>
+#include <ti/osal/TaskP.h>
+
+#include <FreeRTOS.h>
+
+/* External Clock should be defined under osal_soc.h
+ * if SOC is not supporting it, set to -1
+ */
+#ifndef EXTERNAL_CLOCK_KHZ_DEFAULT
+#define EXTERNAL_CLOCK_KHZ_DEFAULT (-1)
+#endif
+
+#ifndef OSAL_DELAY_TIMER_ADDR_DEFAULT
+#define OSAL_DELAY_TIMER_ADDR_DEFAULT ((uintptr_t)(0U))
+#endif
+
+#ifndef OSAL_TARGET_PROC_MASK_DEFAULT
+#define OSAL_TARGET_PROC_MASK_DEFAULT (0xFFFFU)
+#endif
+
+/* Global Osal static memory status variables */
+uint32_t gOsalSemAllocCnt = 0U, gOsalSemPeak = 0U;
+uint32_t gOsalTimerAllocCnt = 0U, gOsalTimerPeak = 0U;
+uint32_t gOsalHwiAllocCnt = 0U, gOsalHwiPeak = 0U;
+#ifndef OSAL_CPU_FREQ_KHZ_DEFAULT
+#define OSAL_CPU_FREQ_KHZ_DEFAULT (400000)
+#endif
+
+volatile bool Osal_DebugP_Assert_Val=(bool)true;
+
+/* Global Osal_HwAttr structure */
+Osal_HwAttrs gOsal_HwAttrs = {
+ OSAL_CPU_FREQ_KHZ_DEFAULT,
+ EXTERNAL_CLOCK_KHZ_DEFAULT,
+#if defined(gnu_targets_arm_A15F)
+ OSAL_TARGET_PROC_MASK_DEFAULT,
+#endif
+#ifdef _TMS320C6X
+ /* ECM_intNum[]: Event combiner interrupts */
+ { OSAL_ECM_GROUP0_INT, /* Interrupt[4-15] to use for Event Combiner Group 0 */
+ OSAL_ECM_GROUP1_INT, /* Interrupt[4-15] to use for Event Combiner Group 1 */
+ OSAL_ECM_GROUP2_INT, /* Interrupt[4-15] to use for Event Combiner Group 2 */
+ OSAL_ECM_GROUP3_INT /* Interrupt[4-15] to use for Event Combiner Group 3 */
+ },
+#endif
+ OSAL_HWACCESS_UNRESTRICTED, /* Unrestricted access to hardware resources */
+ /* Below timer base configuration is applicable for only AM335x/AM437x SoCs
+ * It is not applicable and should not be set for other SoCs
+ * Osal setHwAttrs API would return failure (osal_FAILURE) if attempted to
+ * be set for SoCs other than AM335x and AM437x.
+ */
+ (uintptr_t) OSAL_DELAY_TIMER_ADDR_DEFAULT, /* Timer Base address for osal delay implementation for AM3/AM4 parts */
+ /* Default external Semaphore Memory Block */
+ {
+ (uintptr_t) 0U,
+ 0U
+ },
+ /* Default external HwiP Memory Block */
+ {
+ (uintptr_t) 0U,
+ 0U
+ }
+};
+
+/*
+ * ======== Osal_DebugP_assert ========
+ */
+void Osal_DebugP_assert(int32_t expression, const char *file, int32_t line)
+{
+ (void)file;
+ (void)line;
+
+ if (expression != 0) {
+ while (Osal_DebugP_Assert_Val == (bool)true) {}
+ }
+}
+
+Osal_ThreadType Osal_getThreadType(void)
+{
+ Osal_ThreadType osalThreadType;
+ if( xPortInIsrContext())
+ {
+ osalThreadType = Osal_ThreadType_Hwi;
+ }
+ else
+ {
+ osalThreadType = Osal_ThreadType_Task;
+ }
+ return (osalThreadType);
+}
+
+/* Osal delay */
+int32_t Osal_delay(uint32_t nTicks)
+{
+ Osal_ThreadType type;
+ int32_t ret;
+
+ type = Osal_getThreadType();
+ if (type == Osal_ThreadType_Task) {
+ TaskP_sleep(nTicks);
+ ret = osal_OK;
+ }
+ else {
+ ret = osal_FAILURE;
+ }
+ return(ret);
+}
+
+/*
+ * set Osal_HwAttrs structure
+ */
+int32_t Osal_setHwAttrs(uint32_t ctrlBitMap, const Osal_HwAttrs *hwAttrs)
+{
+ int32_t ret = osal_FAILURE;
+ if (hwAttrs != NULL_PTR) {
+ if ((ctrlBitMap & OSAL_HWATTR_SET_EXT_CLK) !=0U) {
+ gOsal_HwAttrs.extClkKHz= hwAttrs->extClkKHz;
+ ret = osal_OK;
+ }
+#ifdef _TMS320C6X
+ /* Set the Event Combiner Interrupts */
+ if ((ctrlBitMap & OSAL_HWATTR_SET_ECM_INT) !=0U) {
+ (void)memcpy(gOsal_HwAttrs.ECM_intNum,hwAttrs->ECM_intNum,4U*sizeof(gOsal_HwAttrs.ECM_intNum[0]));
+ ret = osal_OK;
+ }
+#endif
+ /* Set the Hw Access type */
+ if ((ctrlBitMap & OSAL_HWATTR_SET_HWACCESS_TYPE) != 0U) {
+ gOsal_HwAttrs.hwAccessType = hwAttrs->hwAccessType;
+ ret = osal_OK;
+ }
+
+ /* Set the Hw Access type */
+ if ((ctrlBitMap & OSAL_HWATTR_SET_OSALDELAY_TIMER_BASE) !=0U) {
+#if defined(SOC_AM437x)|| defined (SOC_AM335x)
+ gOsal_HwAttrs.osalDelayTimerBaseAddr = hwAttrs->osalDelayTimerBaseAddr;
+ ret = osal_OK;
+#else
+ ret = osal_UNSUPPORTED;
+#endif
+ }
+
+ /* Set the extended memmory block for semaphore operations */
+ if ((ctrlBitMap & OSAL_HWATTR_SET_SEMP_EXT_BASE) !=0U)
+ {
+ gOsal_HwAttrs.extSemaphorePBlock = hwAttrs->extSemaphorePBlock;
+ /* Zero out the given memory block */
+ (void)memset((void*)gOsal_HwAttrs.extSemaphorePBlock.base, 0, gOsal_HwAttrs.extSemaphorePBlock.size);
+ ret = osal_OK;
+ }
+
+ /* Set the extended memmory block for semaphore operations */
+ if ((ctrlBitMap & OSAL_HWATTR_SET_HWIP_EXT_BASE)!=0U)
+ {
+ gOsal_HwAttrs.extHwiPBlock = hwAttrs->extHwiPBlock;
+ /* Zero out the given memory block */
+ (void)memset((void*)gOsal_HwAttrs.extHwiPBlock.base, 0, gOsal_HwAttrs.extHwiPBlock.size);
+ ret = osal_OK;
+ }
+ /* Set the CPU frequency */
+ if ((ctrlBitMap & OSAL_HWATTR_SET_CPU_FREQ)!=0U)
+ {
+ gOsal_HwAttrs.cpuFreqKHz = hwAttrs->cpuFreqKHz;
+ ret = osal_OK;
+ }
+ }
+ return(ret);
+}
+
+/*
+ * set Osal_HwAttrs structure
+ */
+int32_t Osal_getHwAttrs( Osal_HwAttrs *hwAttrs)
+{
+ int32_t ret = osal_FAILURE;
+ if (hwAttrs != NULL_PTR) {
+ (void)memcpy(hwAttrs, &gOsal_HwAttrs, sizeof(Osal_HwAttrs));
+ ret = osal_OK;
+ }
+ return(ret);
+}
+
+int32_t Osal_getStaticMemStatus(Osal_StaticMemStatus *pMemStat)
+{
+ int32_t retVal = osal_OK;
+ uintptr_t cookie;
+
+ if (NULL_PTR != pMemStat)
+ {
+ cookie = HwiP_disable();
+
+ pMemStat->peakSemObjs = gOsalSemPeak;
+ pMemStat->numMaxSemObjs = OSAL_TIRTOS_CONFIGNUM_SEMAPHORE;
+ pMemStat->numFreeSemObjs =
+ pMemStat->numMaxSemObjs - gOsalSemAllocCnt;
+
+ pMemStat->peakTimerObjs = gOsalTimerPeak;
+ pMemStat->numMaxTimerObjs = OSAL_TIRTOS_CONFIGNUM_TIMER;
+ pMemStat->numFreeTimerObjs =
+ pMemStat->numMaxTimerObjs - gOsalTimerAllocCnt;
+
+ pMemStat->peakHwiObjs = gOsalHwiPeak;
+ pMemStat->numMaxHwiObjs = OSAL_TIRTOS_CONFIGNUM_HWI;
+ pMemStat->numFreeHwiObjs =
+ pMemStat->numMaxHwiObjs - gOsalHwiAllocCnt;
+
+ HwiP_restore(cookie);
+ }
+ else
+ {
+ retVal = osal_FAILURE;
+ }
+
+ return (retVal);
+}
+
+/* Nothing past this point */
diff --git a/packages/ti/osal/src/src_common_freertos.mk b/packages/ti/osal/src/src_common_freertos.mk
--- /dev/null
@@ -0,0 +1,35 @@
+
+SRCDIR = . src/freertos src/nonos arch/core
+INCDIR = . src/freertos src/nonos arch/core
+
+SRCS_COMMON += HwiP_nonos.c SwiP_nonos.c DebugP_nonos.c RegisterIntr_nonos.c Core_utils.c
+SRCS_COMMON += SemaphoreP_freertos.c TaskP_freertos.c MemoryP_freertos.c Utils_freertos.c
+
+PACKAGE_SRCS_COMMON = makefile HwiP.h SwiP.h MuxIntcP.h osal.h osal_component.mk SemaphoreP.h \
+ TimerP.h RegisterIntr.h EventCombinerP.h CycleprofilerP.h CacheP.h DebugP.h soc/osal_soc.h soc/$(SOC) \
+ src/nonos/Nonos_config.h src/nonos/HwiP_nonos.c src/nonos/SwiP_nonos.c src/nonos/CycleprofilerP_nonos.c \
+ src/nonos/RegisterIntr_nonos.c src/freertos/SemaphoreP_freertos.c src/freertos/TaskP_freertos.c src/nonos/Utils_nonos.c src/nonos/DebugP_nonos.c \
+ src/src_common_nonos.mk src/Module.xs \
+ arch/core/Core_utils.c docs/OSAL_SoftwareManifest.html docs/ReleaseNotes_OSAL.pdf \
+ build \
+ config_mk.bld osalver.h osalver.h.xdt package.bld package.xdc package.xs Settings.xdc.xdt
+
+
+ifeq ($(SOC),$(filter $(SOC), tpr12 awr294x))
+ SRCDIR += soc/$(SOC)
+ SRCS_COMMON += TimerP_default.c CycleprofilerP_nonos.c
+endif
+
+ifeq ($(CORE),$(filter $(CORE), mcu1_0 mcu2_0 mcu2_1 mcu1_1))
+ SRCDIR += arch/core/r5
+ SRCS_COMMON += CacheP_nonos.c Arch_util.c
+ SRCS_ASM_COMMON += TimestampProvider_asm.asm
+ PACKAGE_SRCS_COMMON += arch/core/r5
+endif
+
+ifeq ($(CORE),$(filter $(CORE), c66x c66xdsp_1 c66xdsp_2 c674x))
+ SRCDIR += arch/core/c6x
+ SRCS_COMMON += CacheP_nonos.c Arch_util.c EventCombinerP_nonos.c
+ PACKAGE_SRCS_COMMON += arch/core/c6x src/nonos/EventCombinerP_nonos.c
+endif
+
diff --git a/packages/ti/osal/test/freertos/makefile b/packages/ti/osal/test/freertos/makefile
--- /dev/null
@@ -0,0 +1,60 @@
+#
+# This file is the makefile for building CSL timer app.
+#
+ifeq ($(RULES_MAKE), )
+include $(PDK_INSTALL_PATH)/ti/build/Rules.make
+else
+include $(RULES_MAKE)
+endif
+
+#Name of the directory created under packages/ti/binary/
+APP_NAME = OSAL_freertos_TestApp
+# Name of the binary if different from the default (APP_NAME)_$(BOARD_$(CORE)_<build_profile>
+LOCAL_APP_NAME = OSAL_freertos_$(BOARD)_$(CORE)TestApp
+BUILD_OS_TYPE = freertos
+
+SRCDIR = ../src
+INCDIR = ../src
+INCDIR += ${FREERTOS_KERNEL_INSTALL_PATH}/FreeRTOS-Kernel/include
+INCDIR += $(PDK_FREERTOS_COMP_PATH)/freertos/portable/TI_CGT/$(ISA)
+INCDIR += $(PDK_FREERTOS_COMP_PATH)/freertos/config/$(SOC)/$(ISA)
+INCDIR += $(PDK_FREERTOS_COMP_PATH)/freertos/dpl/common
+
+# List all the external components/interfaces, whose interface header files
+# need to be included for this component
+INCLUDE_EXTERNAL_INTERFACES = pdk
+
+# List all the components required by the application
+COMP_LIST_COMMON = $(PDK_COMMON_FREERTOS_COMP)
+
+# Common source files and CFLAGS across all platforms and cores
+PACKAGE_SRCS_COMMON = . ../src
+CFLAGS_LOCAL_COMMON = $(PDK_CFLAGS) -DFREERTOS
+
+ifeq ($(MANUAL_CACHE_TEST),YES)
+ CFLAGS_LOCAL_COMMON += -DMANUAL_CACHE_TEST
+endif
+
+ifeq ($(SOC),$(filter $(SOC), am65xx j721e j7200 am64x tpr12 awr294x))
+ CFLAGS_LOCAL_COMMON += -DENABLE_TIMER_TEST
+endif
+
+SRCS_COMMON += main_osal_test.c
+
+# Core/SoC/platform specific source files and CFLAGS
+# Example:
+# SRCS_<core/SoC/platform-name> =
+# CFLAGS_LOCAL_<core/SoC/platform-name> =
+
+# Include common make files
+ifeq ($(MAKERULEDIR), )
+#Makerule path not defined, define this and assume relative path from ROOTDIR
+ MAKERULEDIR := $(ROOTDIR)/ti/build/makerules
+ export MAKERULEDIR
+endif
+include $(MAKERULEDIR)/common.mk
+
+# OBJs and libraries are built by using rule defined in rules_<target>.mk
+# and need not be explicitly specified here
+
+# Nothing beyond this point
index f5be37797b7d64f94ba54158e860065bb1d90b42..30b284600e039fcf4a9bbcf8becbeeec54c17326 100644 (file)
}
#define OSAL_log dummy_printf
#else
- #if defined(BARE_METAL)
+ #if defined(BARE_METAL) || defined(FREERTOS)
#define OSAL_log printf
#else
#define OSAL_log System_printf
diff --git a/packages/ti/osal/test/src/main_osal_test.c b/packages/ti/osal/test/src/main_osal_test.c
index 3e8ec7f503190bc309d0c24ba1bbe03e734f81ba..878caf895f07d9d4365c85952b1e5aad9dd2bd15 100644 (file)
*
*/
-#ifndef BARE_METAL
+#if !(defined(BARE_METAL) || defined(FREERTOS))
/* XDCtools Header files */
#include <xdc/std.h>
#if defined (SOC_J721E) || defined(SOC_J7200)
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
-#include <ti/osal/TaskP.h>
#include <ti/osal/SwiP.h>
#endif
+#if !defined(BARE_METAL)
+/* include for both tirtos and freertos. */
+#include <ti/osal/TaskP.h>
+#endif
+
+#if defined (FREERTOS)
+#include "FreeRTOS.h"
+#include "task.h"
+#include <ti/osal/MemoryP.h>
+#endif
+
#include <stdio.h>
#include <string.h>
#include <ti/csl/arch/csl_arch.h>
#endif
#include <ti/csl/tistdtypes.h>
-#ifdef BARE_METAL
+#if defined (BARE_METAL)
#if !defined(SOC_TPR12) && !defined (SOC_AWR294X)
#include <ti/csl/csl_timer.h>
#endif
#undef TWO_TIMER_INTERRUPT_TEST
#define TWO_TIMER_INTERRUPT_TEST 1
#endif
+#elif defined (FREERTOS)
#else
void ErrorHandler(Error_Block *eb)
TimerP_Status timerStatus;
Osal_HwAttrs hwAttrs;
-#ifdef BARE_METAL
+#if defined(BARE_METAL) || defined(FREERTOS)
int32_t id = OSAL_TEST_TIMER_ID;
#else
int32_t id = TimerP_ANY;
#if !defined(SOC_J721E) || !defined(SOC_J7200)
#if defined(_TMS320C6X)
+#if defined(SOC_TPR12)
+ timerParams.intNum = 16;
+#else
timerParams.intNum = 15;
+#endif
OSAL_log("\n set intNum=%d, id=%d, \n", timerParams.intNum, id);
#endif
#endif
return true;
}
-#ifndef BARE_METAL
+#if !(defined(BARE_METAL) || defined(FREERTOS))
/*
* ======== Queue test function ========
#endif
#ifndef BARE_METAL
+#if defined(FREERTOS)
+
+#else
#include <ti/sysbios/knl/Clock.h>
+#endif
#ifndef SIM_BUILD
#define OSAL_TASKP_TEST_ITERATION (10U)
+#if defined(FREERTOS)
+#define OSAL_TASKP_TEST_1MS (1U)
+#else
#define OSAL_TASKP_TEST_1MS (1000U)
+#endif
#define OSAL_TASKP_TEST_TICKS (1000U)
#else
#define OSAL_TASKP_TEST_ITERATION (2U)
#define OSAL_TASKP_TEST_1MS (10U)
#define OSAL_TASKP_TEST_TICKS (10U)
#endif
+
+uint64_t OSAL_get_ticks()
+{
+ uint64_t ticks;
+#if defined(FREERTOS)
+ ticks = (uint64_t)uiPortGetRunTimeCounterValue();
+#else
+ ticks = (uint64_t)Clock_getTicks();
+#endif
+ return ticks;
+}
+
bool OSAL_task_sleep_test(void)
{
int32_t i;
- uint32_t start_time_nticks, end_time_nticks;
+ uint64_t start_time_nticks, end_time_nticks;
uint32_t diff_nticks, diff_tout;
/* nTicks in OSAL is 1000 ticks per milli seconds
* hence the task sleep = 1000 milliseconds should
* provide the same sleep time as in TaskP_sleep(nTicks = 1000)
*/
- start_time_nticks = Clock_getTicks();
+ start_time_nticks = OSAL_get_ticks();
for (i=0; i < OSAL_TASKP_TEST_ITERATION; i++)
{
TaskP_sleep(OSAL_TASKP_TEST_TICKS);
}
- end_time_nticks = Clock_getTicks();
- diff_nticks = end_time_nticks - start_time_nticks;
+ end_time_nticks = OSAL_get_ticks();
+ diff_nticks = (uint32_t)(end_time_nticks - start_time_nticks);
- start_time_nticks = Clock_getTicks();
+ start_time_nticks = OSAL_get_ticks();
for (i=0; i < OSAL_TASKP_TEST_ITERATION; i++)
{
TaskP_sleepInMsecs(OSAL_TASKP_TEST_1MS);
}
- end_time_nticks = Clock_getTicks();
- diff_tout = end_time_nticks - start_time_nticks;
+ end_time_nticks = OSAL_get_ticks();
+ diff_tout = (uint32_t)(end_time_nticks - start_time_nticks);
OSAL_log(" \n \
diff_nticks = %d \n \
- diff_tout = %d \n \
- Clock_tickPeriod = %d \n \
- Clock_tickSource = %d ", diff_nticks, diff_tout, \
- Clock_tickPeriod, Clock_tickSource);
+ diff_tout = %d \n ", diff_nticks, diff_tout);
+#if !defined(FREERTOS)
+ OSAL_log(" Clock_tickPeriod = %d \n \
+ Clock_tickSource = %d ", Clock_tickPeriod, Clock_tickSource);
+#endif
return (true);
}
#endif
+#if defined(FREERTOS)
+bool OSAL_mempry_test()
+{
+ void *memPtr1, *memPtr2, *memPtr[5];
+ uint32_t align;
+ bool retVal = true;
+ uint32_t i;
+
+ /* Test1: Allocate 16 bytes aligned memory. */
+ align = 16;
+ memPtr1 = MemoryP_ctrlAlloc(100, align);
+ if (memPtr1 != NULL)
+ {
+ /* Check if teh allocated mempry is 16 bytes aligned. */
+ if ((uintptr_t)memPtr1 & (align - 1)!= 0)
+ {
+ retVal = false;
+ }
+ }
+ else
+ {
+ retVal = false;
+ }
+
+ /* Test2: Allocate 64 bytes aligned memory. */
+ align = 64;
+ memPtr2 = MemoryP_ctrlAlloc(200, align);
+ if (memPtr2 != NULL)
+ {
+ /* Check if teh allocated mempry is 16 bytes aligned. */
+ if ((uintptr_t)memPtr2 & (align - 1)!= 0)
+ {
+ retVal = false;
+ }
+ }
+ else
+ {
+ retVal = false;
+ }
+
+ if (memPtr1 != NULL)
+ {
+ MemoryP_ctrlFree(memPtr1, 100);
+ }
+ if (memPtr2 != NULL)
+ {
+ MemoryP_ctrlFree(memPtr2, 200);
+ }
+
+ /* Test2: check memory leak
+ * multiple iteration of alloc and free to give same mem pointer.
+ */
+ for (i=0; i<5; i++)
+ {
+ align = 64;
+ memPtr[i] = MemoryP_ctrlAlloc(200, align);
+ MemoryP_ctrlFree(memPtr[i], 200);
+ }
+ for (i=1; i<5; i++)
+ {
+ if (memPtr[i] != memPtr[i-1])
+ {
+ retVal = false;
+ break;
+ }
+ }
+ return retVal;
+}
+#endif
+
/*
* ======== main test function ========
*/
-#ifdef BARE_METAL
+#if defined(BARE_METAL)
void osal_test()
+#elif defined(FREERTOS)
+void osal_test(void *arg0, void *arg1)
#else
void osal_test(UArg arg0, UArg arg1)
#endif
OSAL_log("\n Memory Statistics query failed \n");
}
-#ifndef BARE_METAL
+#if !(defined(BARE_METAL) || defined(FREERTOS))
if(OSAL_swi_test() == true)
{
OSAL_log("\n SWI tests have passed. \n");
}
#endif
+#if defined(FREERTOS)
+ if(OSAL_mempry_test() == true)
+ {
+ OSAL_log("\n MemoryP Log tests have passed. \n");
+ }
+ else
+ {
+ OSAL_log("\n MemoryP Log tests have failed. \n");
+ testFail = true;
+ }
+#endif
+
if(testFail == true)
{
OSAL_log("\n Some tests have failed. \n");
*/
#if defined (SOC_AM65XX) || defined (SOC_J721E) || defined(SOC_J7200) || defined(SOC_TPR12) || defined (SOC_AWR294X)|| defined(SOC_AM64X)
TaskP_Params taskParams;
+#if !defined(FREERTOS)
Error_Block eb;
+#endif
TaskP_Params_init(&taskParams);
taskParams.priority =2;
taskParams.stack = gAppTskStackMain;
taskParams.stacksize = sizeof (gAppTskStackMain);
+#if !defined(FREERTOS)
taskParams.pErrBlk = &eb;
+#endif
TaskP_create(osal_test, &taskParams);
#endif
+#if defined (FREERTOS)
+ /* Start the scheduler to start the tasks executing. */
+ vTaskStartScheduler();
+#else
/* Start BIOS */
BIOS_start();
+#endif
#endif
return (0);
}