From 35d92b4dc06a6da27db320797c86079d8a9f5954 Mon Sep 17 00:00:00 2001 From: Josiitaa RL Date: Thu, 30 May 2024 12:35:41 +0530 Subject: [PATCH 3/3] TOG Integration with PDK BootApp --- packages/ti/boot/sbl/build/boot_app.mk | 12 + .../boot/sbl/example/boot_app/boot_app_main.c | 73 ++- .../ti/boot/sbl/example/boot_app/tog/tog.c | 452 ++++++++++++++++++ .../ti/boot/sbl/example/boot_app/tog/tog.h | 60 +++ .../example/boot_app/tog/tog_test_utils.asm | 60 +++ .../sbl/example/boot_app/tog/tog_test_utils.h | 58 +++ 6 files changed, 713 insertions(+), 2 deletions(-) create mode 100644 packages/ti/boot/sbl/example/boot_app/tog/tog.c create mode 100644 packages/ti/boot/sbl/example/boot_app/tog/tog.h create mode 100644 packages/ti/boot/sbl/example/boot_app/tog/tog_test_utils.asm create mode 100644 packages/ti/boot/sbl/example/boot_app/tog/tog_test_utils.h diff --git a/packages/ti/boot/sbl/build/boot_app.mk b/packages/ti/boot/sbl/build/boot_app.mk index 69856ae2..56aff76f 100644 --- a/packages/ti/boot/sbl/build/boot_app.mk +++ b/packages/ti/boot/sbl/build/boot_app.mk @@ -53,6 +53,7 @@ ifeq ($(BOOTMODE), mmcsd) CFLAGS_LOCAL_COMMON += -DBIST_TASK_ENABLED CFLAGS_LOCAL_COMMON += -DVTM_TASK_ENABLED CFLAGS_LOCAL_COMMON += -DPOK_TASK_ENABLED + CFLAGS_LOCAL_COMMON += -DTOG_TASK_ENABLED #CFLAGS_LOCAL_COMMON += INCDIR += $(PDK_SBL_COMP_PATH)/example/boot_app/bist INCDIR += $(PDK_SBL_COMP_PATH)/example/boot_app/bist/soc/$(SOC) @@ -60,6 +61,8 @@ ifeq ($(BOOTMODE), mmcsd) INCDIR += $(PDK_SBL_COMP_PATH)/example/boot_app/vtm INCDIR += $(PDK_SBL_COMP_PATH)/example/boot_app/pok + + INCDIR += $(PDK_SBL_COMP_PATH)/example/boot_app/tog # SDL Include Files SDL_INSTALL_PATH=$(PDK_INSTALL_PATH)/../../sdl INCDIR += $(SDL_INSTALL_PATH)/ @@ -67,15 +70,20 @@ ifeq ($(BOOTMODE), mmcsd) INCDIR += $(SDL_INSTALL_PATH)/src/ip INCDIR += $(SDL_INSTALL_PATH)/include INCDIR += $(SDL_INSTALL_PATH)/include/soc/$(SOC) + INCDIR += $(SDL_INSTALL_PATH)/test/osal + INCDIR += $(SDL_INSTALL_PATH)/src/ip/r5 # SDL Source File Paths SRCDIR += $(SDL_INSTALL_PATH)/test/osal/src SRCDIR += $(PDK_SBL_COMP_PATH)/example/boot_app/bist SRCDIR += $(PDK_SBL_COMP_PATH)/example/boot_app/bist/soc/$(SOC) + SRCDIR += $(SDL_INSTALL_PATH)/test/unity/src SRCDIR += $(PDK_SBL_COMP_PATH)/example/boot_app/vtm SRCDIR += $(PDK_SBL_COMP_PATH)/example/boot_app/pok + + SRCDIR += $(PDK_SBL_COMP_PATH)/example/boot_app/tog # SDL Integration EXT_LIB_LIST_COMMON += $(SDL_INSTALL_PATH)/binary/osal/lib/$(SOC)/r5f/$(BUILD_PROFILE)/sdl_osal.$(LIBEXT) EXT_LIB_LIST_COMMON += $(SDL_INSTALL_PATH)/binary/src/ip/lib/$(SOC)/r5f/$(BUILD_PROFILE)/sdl_ip.$(LIBEXT) @@ -91,6 +99,10 @@ ifeq ($(BOOTMODE), mmcsd) SRCS_COMMON += vtm.c vtm_example.c SRCS_COMMON += pok.c pok_example.c + + SRCS_COMMON += tog.c + SRCS_COMMON += unity.c + SRCS_ASM_COMMON += tog_test_utils.asm endif endif ifeq ($(BOOTMODE), ospi) diff --git a/packages/ti/boot/sbl/example/boot_app/boot_app_main.c b/packages/ti/boot/sbl/example/boot_app/boot_app_main.c index d8311308..748c8c58 100644 --- a/packages/ti/boot/sbl/example/boot_app/boot_app_main.c +++ b/packages/ti/boot/sbl/example/boot_app/boot_app_main.c @@ -91,6 +91,9 @@ #if defined(POK_TASK_ENABLED) #include "pok.h" #endif +#if defined(TOG_TASK_ENABLED) +#include "tog.h" +#endif /* ========================================================================== */ /* Macros & Typedefs */ /* ========================================================================== */ @@ -101,12 +104,12 @@ #define BOOT_TASK_PRIORITY (2) #if defined(BIST_TASK_ENABLED) -#define BIST_TASK_PRIORITY (5) +#define BIST_TASK_PRIORITY (6) #define BIST_TASK_STACKSIZE (16U * 1024U) #endif #if defined(VTM_TASK_ENABLED) -#define VTM_TASK_PRIORITY (4) +#define VTM_TASK_PRIORITY (5) #define VTM_TASK_STACKSIZE (10U * 1024U) #endif @@ -114,6 +117,11 @@ #define POK_TASK_PRIORITY (3) #define POK_TASK_STACKSIZE (10U * 1024U) #endif + +#if defined(TOG_TASK_ENABLED) +#define TOG_TASK_PRIORITY (4) +#define TOG_TASK_STACKSIZE (10U * 1024U) +#endif /* uncomment the following for debug logs */ // #define UART_PRINT_DEBUG @@ -136,6 +144,9 @@ static void VtmApp_TaskFxn(void* a0, void* a1); #if defined(POK_TASK_ENABLED) static void PokApp_TaskFxn(void* a0, void* a1); #endif +#if defined(TOG_TASK_ENABLED) +static void TogApp_TaskFxn(void* a0, void* a1); +#endif static uint32_t Boot_App(); static void BootApp_AppSetup(); static int32_t BootApp_RequestStageCores(uint8_t stageNum); @@ -181,6 +192,13 @@ static uint64_t gtimePokAppStart, gtimePokAppFinish; static SemaphoreP_Handle gPokTaskCompletedSem = NULL; #endif +#if defined(TOG_TASK_ENABLED) +static uint8_t gTog_TaskStack[TOG_TASK_STACKSIZE] __attribute__((aligned(32))); +TaskP_Handle gTogTask; +static uint64_t gtimeTogAppStart, gtimeTogAppFinish; +/* Semaphore to indicate TOG Task completion */ +static SemaphoreP_Handle gTogTaskCompletedSem = NULL; +#endif int32_t main(void) { Board_initCfg boardCfg; @@ -288,6 +306,31 @@ int32_t main(void) OS_stop(); } #endif + +#if defined(TOG_TASK_ENABLED) + /* initializing the semaphores*/ + SemaphoreP_Params TogsemParams; + SemaphoreP_Params_init(&TogsemParams); + gTogTaskCompletedSem = SemaphoreP_create(0, &TogsemParams); + if(NULL == gTogTaskCompletedSem) + { + UART_printf("\n Semaphore create failed\r\n"); + } + + /* Initialize the task params */ + TaskP_Params TogTaskParams; + TaskP_Params_init(&TogTaskParams); + TogTaskParams.priority = TOG_TASK_PRIORITY; + TogTaskParams.stack = gTog_TaskStack; + TogTaskParams.stacksize = sizeof (gTog_TaskStack); + + gTogTask = TaskP_create(&TogApp_TaskFxn, &TogTaskParams); + if (NULL == gTogTask) + { + UART_printf("\nTOG Task creation failed\r\n"); + OS_stop(); + } +#endif OS_start(); /* does not return */ return(0); @@ -306,6 +349,10 @@ static void BootApp_TaskFxn(void* a0, void* a1) #if defined(POK_TASK_ENABLED) /* Wait for the POK task completion */ SemaphoreP_pend(gPokTaskCompletedSem, SemaphoreP_WAIT_FOREVER); +#endif +#if defined(TOG_TASK_ENABLED) + /* Wait for the TOG task completion */ + SemaphoreP_pend(gTogTaskCompletedSem, SemaphoreP_WAIT_FOREVER); #endif gtimeBootAppStart = BootApp_GetTimeInMicroSec(CSL_armR5PmuReadCntr(CSL_ARM_R5_PMU_CYCLE_COUNTER_NUM)); @@ -380,6 +427,28 @@ static void PokApp_TaskFxn(void* a0, void* a1) return; } #endif + +#if defined(TOG_TASK_ENABLED) +static void TogApp_TaskFxn(void* a0, void* a1) +{ + /* Initialize the SDL osal */ + SDL_TEST_osalInit(); + + gtimeTogAppStart = BootApp_GetTimeInMicroSec(CSL_armR5PmuReadCntr(CSL_ARM_R5_PMU_CYCLE_COUNTER_NUM)); + + tog_example_app(); + + gtimeTogAppFinish = BootApp_GetTimeInMicroSec(CSL_armR5PmuReadCntr(CSL_ARM_R5_PMU_CYCLE_COUNTER_NUM)); + + UART_printf("\nTOG Task started at %d usecs and finished at %d usecs\r\n", (uint32_t)gtimeTogAppStart, (uint32_t)gtimeTogAppFinish); + + /* Post semaphore after TOG task completion so other tasks could start execution */ + SemaphoreP_post(gTogTaskCompletedSem); + + return; +} +#endif + uint32_t Boot_App() { uint32_t retVal; diff --git a/packages/ti/boot/sbl/example/boot_app/tog/tog.c b/packages/ti/boot/sbl/example/boot_app/tog/tog.c new file mode 100644 index 00000000..a189861d --- /dev/null +++ b/packages/ti/boot/sbl/example/boot_app/tog/tog.c @@ -0,0 +1,452 @@ +/* + * TOG Usecases + * + * Timeout Gasket (TOG) Example Application + * + * Copyright (c) 2024 Texas Instruments Incorporated + * + * 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. + */ +/** + * \file tog_usecase.c + * + * \brief This file triggers input for the Timeout Gasket (TOG) example + */ + +#include "tog.h" +#include +#include +#include +#include +/* ========================================================================== */ +/* Function Declarations */ +/* ========================================================================== */ +void TOG_datAbortExceptionHandler(void *param); +extern int32_t tog_minTimeout(uint32_t instanceIndex); +/* ========================================================================== */ +/* Global Variables */ +/* ========================================================================== */ +const SDL_R5ExptnHandlers TOG_R5ExptnHandlers = +{ + .udefExptnHandler = NULL, + .swiExptnHandler = NULL, + .pabtExptnHandler = NULL, + .dabtExptnHandler = &TOG_datAbortExceptionHandler, + .irqExptnHandler = NULL, + .fiqExptnHandler = NULL, + .udefExptnHandlerArgs = ((void *)0u), + .swiExptnHandlerArgs = ((void *)0u), + .pabtExptnHandlerArgs = ((void *)0u), + .dabtExptnHandlerArgs = ((void *)0u), + .irqExptnHandlerArgs = ((void *)0u), +}; +/* ========================================================================== */ +/* Macros */ +/* ========================================================================== */ +#if defined (SOC_J721E) + #include +#endif +#if defined (SOC_J7200) + #include +#endif +#if defined (SOC_J721S2) + #include +#endif +#if defined (SOC_J784S4) + #include +#endif +#define ESM_CFG_BASE (SDL_ESM0_CFG_BASE) +#define TOG_INSTANCE_MCU_INFRA0_CFG 0 + +__attribute((section(".text:TOG_test"))) int32_t tog_minTimeout(uint32_t instanceIndex); +__attribute((section(".text:TOG_test"))) void TOG_injectMCUINFRATimeoutError(uint32_t instanceIndex); +__attribute((section(".text:TOG_test"))) void TOG_injectESMError(uint32_t instanceIndex); + +__attribute((section(".text:ESMApp_Handlers"))) int32_t SDL_TOG_ESM_applicationCallbackFunction(SDL_ESM_Inst esmInst, + SDL_ESM_IntType esmIntrType, uint32_t grpChannel, + uint32_t index, uint32_t intSrc, void *arg); + +__attribute((section(".text:TOG_test"))) void TOG_eventHandler(uint32_t instanceIndex); + + +#define TOG_TEST_TIMEOUTVAL 0x10000U +static uint32_t arg; + +volatile bool handlerFlag __attribute__((section(".data:TOG_test"))) = false; + +SDL_ESM_config TOG_Test_esmInitConfig_MCU = +{ + .esmErrorConfig = {0u, 3u}, /* Self test error config */ + .enableBitmap = {0xffffffffu, 0xff0fffffu, 0x7fffffffu, 0x00000007u, + }, + /**< All events enable: except timer and self test events, and Main ESM output */ + /* Temporarily disabling vim compare error as well*/ + .priorityBitmap = {0xffffffffu, 0xff0fffffu, 0x7fffffffu, 0x00000007u, + }, + /**< All events high priority: except timer, selftest error events, and Main ESM output */ + .errorpinBitmap = {0xffffffffu, 0xff0fffffu, 0x7fffffffu, 0x00000007u, + }, + /**< All events high priority: except timer, selftest error events, and Main ESM output */ +}; + +int32_t SDL_TOG_ESM_applicationCallbackFunction(SDL_ESM_Inst esmInst, + SDL_ESM_IntType esmIntrType, + uint32_t grpChannel, + uint32_t index, + uint32_t intSrc, + void *arg) +{ + int32_t retVal = SDL_PASS; + +#if defined (SOC_J721E) || defined (SOC_J7200) + TOG_eventHandler(0); +#elif defined (SOC_J721S2) + TOG_eventHandler(16); +#elif defined (SOC_J784S4) + TOG_eventHandler(16); +#endif + UART_printf("\n ESM Call back function called : instType 0x%x, intType 0x%x, " \ + "grpChannel 0x%x, index 0x%x, intSrc 0x%x \n", + esmInst, esmIntrType, grpChannel, index, intSrc); + UART_printf(" Take action \n"); + + /* Any additional customer specific actions can be added here */ + + return retVal; +} + +void TOG_eventHandler( uint32_t instanceIndex ) +{ + int32_t status = SDL_PASS; + uint32_t pendInts; + uint32_t intCount; + SDL_TOG_errInfo errInfo; + SDL_TOG_config cfg; + SDL_TOG_Inst instance; + SDL_TOG_IntrSrc intSrc; + intSrc = (SDL_TOG_INTRSRC_UNEXPECTED_RESPONSE | + SDL_TOG_INTRSRC_TRANSACTION_TIMEOUT); + + instance = instanceIndex; + cfg.cfgCtrl = SDL_TOG_CFG_TIMEOUT; + + UART_printf(" \n TOG_eventHandler \n"); + if (intSrc != 0U) + { + /* Read error info */ + status = SDL_TOG_getErrInfo(instance, &errInfo); + TEST_ASSERT_EQUAL_INT32(SDL_PASS, status); + } + + if (intSrc & SDL_TOG_INTRSRC_TRANSACTION_TIMEOUT) + { + /* Get Transaction timeout interrupt count */ + if (status == SDL_PASS) + { + status = SDL_TOG_getIntrCount(instance, SDL_TOG_INTRSRC_TRANSACTION_TIMEOUT, &intCount); + TEST_ASSERT_EQUAL_INT32(SDL_PASS, status); + } + + /* Clear Transaction timeout interrupt events */ + if ((status == SDL_PASS) && (intCount != 0)) + { + status = SDL_TOG_ackIntr(instance, SDL_TOG_INTRSRC_TRANSACTION_TIMEOUT, intCount); + TEST_ASSERT_EQUAL_INT32(SDL_PASS, status); + } + } + + if (intSrc & SDL_TOG_INTRSRC_UNEXPECTED_RESPONSE) + { + /* Get Unexpected Response interrupt count */ + if (status == SDL_PASS) + { + status = SDL_TOG_getIntrCount(instance, SDL_TOG_INTRSRC_UNEXPECTED_RESPONSE, &intCount); + + TEST_ASSERT_EQUAL_INT32(SDL_PASS, status); + } + + /* Clear Unexpected response interrupt events */ + if ((status == SDL_PASS) && (intCount != 0)) + { + status = SDL_TOG_ackIntr(instance, SDL_TOG_INTRSRC_UNEXPECTED_RESPONSE, intCount); + TEST_ASSERT_EQUAL_INT32(SDL_PASS, status); + } + } + + /* Get Pending interrupt count */ + if (status == SDL_PASS) + { + status = SDL_TOG_getIntrPending(instance, &pendInts ); + TEST_ASSERT_EQUAL_INT32(SDL_PASS, status); + } + + /* Clear Pending interrupt */ + if (status == SDL_PASS) + { + status = SDL_TOG_clrIntrPending(instance, SDL_TOG_INTRSRC_TRANSACTION_TIMEOUT); + TEST_ASSERT_EQUAL_INT32(SDL_PASS, status); + } + + if (status == SDL_PASS) + { + status = SDL_TOG_clrIntrPending(instance, SDL_TOG_INTRSRC_UNEXPECTED_RESPONSE); + TEST_ASSERT_EQUAL_INT32(SDL_PASS, status); + } + + if (status == SDL_PASS) + { + handlerFlag = true; + /* Call SDL API to configure back Timeout Gasket */ + cfg.timeoutVal = TOG_TEST_TIMEOUTVAL; + status = SDL_TOG_init(instance, &cfg); + TEST_ASSERT_EQUAL_INT32(SDL_PASS, status); + + /* Stop the Timeout Gasket */ + SDL_TOG_stop( instance ); + + /* Reset the Timeout gasket */ + SDL_TOG_reset( instance ); + } + return; +} + +#if defined (SOC_J721E) || defined (SOC_J7200) + +void TOG_injectMCUINFRATimeoutError(uint32_t instanceIndex) +{ + SDL_TOG_Inst instance; + SDL_TOG_config cfg; + instance = instanceIndex; + cfg.cfgCtrl = SDL_TOG_CFG_TIMEOUT; + int32_t status; + volatile esmRevisionId_t esmRevisionId; + + /* Injecting error can result in a Data abort, so disable temporarily */ + disableABORT(); + + /* Call SDL API to set smaller timeout to trigger error */ + cfg.timeoutVal = 1u; + status = SDL_TOG_init(instance, &cfg); + if (status != SDL_PASS) + { + UART_printf(" Inject SDL_TOG_init TimeoutVal Failed \n"); + /* Assert */ + } + + /* Access Main ESM to trigger transaction through the Gasket */ + (void)SDL_ESM_getRevisionId(ESM_CFG_BASE, (esmRevisionId_t *)&esmRevisionId); + + /* Call SDL API to set configure back to original timeout value */ + cfg.timeoutVal = TOG_TEST_TIMEOUTVAL; + status = SDL_TOG_init(instance, &cfg); + if (status != SDL_PASS) + { + UART_printf("\n Configure back SDL_TOG_init TimeoutVal Failed \n"); + /* Assert */ + } + + /* Enable back Abort */ + enableABORT(); +} +#endif + +#if defined (SOC_J721S2) || defined (SOC_J784S4) + +#define END_POINT_ACCESS 0x00A90000U + +void TOG_injectESMError(uint32_t instanceIndex) +{ + SDL_TOG_Inst instance; + SDL_TOG_config cfg; + instance = instanceIndex; + cfg.cfgCtrl = SDL_TOG_CFG_TIMEOUT; + int32_t status; + /* Injecting error can result in a Data abort, so disable temporarily */ + disableABORT(); + + /* Call SDL API to set smaller timeout to trigger error */ + cfg.timeoutVal = 1u; + status = SDL_TOG_init(instance, &cfg); + if (status != SDL_PASS) + { + UART_printf(" Inject SDL_TOG_init TimeoutVal Failed \n"); + /* Assert */ + } + + SDL_REG32_RD(END_POINT_ACCESS); + + /* Call SDL API to set configure back to original timeout value */ + cfg.timeoutVal = TOG_TEST_TIMEOUTVAL; + status = SDL_TOG_init(instance, &cfg); + if (status != SDL_PASS) + { + UART_printf(" Configure back SDL_TOG_init TimeoutVal Failed \n"); + /* Assert */ + } + + /* Enable back Abort */ + enableABORT(); +} + +#endif + +int32_t tog_minTimeout(uint32_t instanceIndex) +{ + SDL_TOG_Inst instance; + SDL_TOG_config cfg; + void *ptr = (void *)&arg; + int32_t status = SDL_PASS; + int32_t result = 0; + volatile uint32_t timeoutCount = 0; + instance = instanceIndex; + cfg.cfgCtrl = SDL_TOG_CFG_TIMEOUT; + + /* Initialize done flag */ + handlerFlag = false; + + UART_printf("\n Demo for minimum value timeout \n"); + + /* Initialize MCU ESM module */ + status = SDL_ESM_init(SDL_ESM_INST_MCU_ESM0, &TOG_Test_esmInitConfig_MCU, SDL_TOG_ESM_applicationCallbackFunction, ptr); + if (status != SDL_PASS) { + /* print error and quit */ + UART_printf("TOG_App_init: Error initializing MCU ESM: result = %d\n", result); + + result = -1; + } else { + UART_printf("\nECC_Test_init: Init MCU ESM complete \n"); + } + + if (result == 0) + { + /* Enable interrupts */ + status = SDL_TOG_setIntrEnable(instance, SDL_TOG_INTRSRC_ALL, true); + if (status != SDL_PASS) + { + UART_printf(" SDL_TOG_setIntrEnable Failed \n"); + result = -1; + } else { + UART_printf("\nSDL_TOG_setIntrEnable complete \n"); + } + + } + + /** Step 2: Configure and enable Timeout Gasket */ + if (result == 0) + { + /* Call SDL API to configure Timeout Gasket */ + cfg.timeoutVal = TOG_TEST_TIMEOUTVAL; + status = SDL_TOG_init(instance, &cfg); + if (status != SDL_PASS) + { + UART_printf(" SDL_TOG_init timeout Failed \n"); + result = -1; + } else { + UART_printf("\nSDL_TOG_init.timeout complete \n"); + } + } + + if (result == 0) + { + /* Call SDL API to enable Timeout Gasket */ + status = SDL_TOG_start(instance); + if (status != SDL_PASS) + { + UART_printf(" SDL_TOG_start Failed \n"); + result = -1; + } else { + UART_printf("\nSDL_TOG_start complete \n"); + } + } + + /* Step 3: Inject timeout error */ + if (result == 0) + { +#if defined (SOC_J721E) || defined (SOC_J7200) + TOG_injectMCUINFRATimeoutError(instance); +#elif defined (SOC_J721S2) || defined (SOC_J784S4) + TOG_injectESMError(instance); +#endif + } + + /**--- Step 3: Wait for TOG Interrupt ---*/ + if (result == 0) + { + /* Timeout if exceeds time */ + while ((!handlerFlag) + && (timeoutCount < TOG_MAX_TEST_TIMEOUT_VALUE)) + { + timeoutCount++; + } + + if (!(handlerFlag)) + { + SDL_TOG_stop( instance ); + UART_printf(" TOG test timed out \n"); + result = -1; + } else { + UART_printf("\nSDL_TOG_stop complete \n"); + } + /* reset Done flag so we can run again */ + handlerFlag = false; + } + + return (result); +} + +void TOG_datAbortExceptionHandler(void *param) +{ + /* This is a fake exception so return */ +} + +void tog_example_app(void) +{ + int32_t result = 0; + + UART_printf("\nTOG Sample Example \r\n"); + /* Register exception handler */ + /* This is needed to handle data abort that can happen in the process of injecting the error */ + Intc_RegisterExptnHandlers(&TOG_R5ExptnHandlers); + if (result == 0) + { +#if defined (SOC_J721E) || defined (SOC_J7200) + result = tog_minTimeout(0); +#elif defined (SOC_J721S2) + result = tog_minTimeout(16); +#elif defined (SOC_J784S4) + result = tog_minTimeout(16); +#endif + if (result != 0) + { + UART_printf(" \n TOG example failed \n"); + } +} + + return; +} \ No newline at end of file diff --git a/packages/ti/boot/sbl/example/boot_app/tog/tog.h b/packages/ti/boot/sbl/example/boot_app/tog/tog.h new file mode 100644 index 00000000..885477ec --- /dev/null +++ b/packages/ti/boot/sbl/example/boot_app/tog/tog.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) Texas Instruments Incorporated 2024 + * + * 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. + * + */ + + /** + * \file tog.h + * + * \brief TOG Example functions + * + * \details This file contains C prototype + * + **/ + +#include +#include +#include +#include "tog_test_utils.h" +#include + +#ifdef UNITY_INCLUDE_CONFIG_H +#include +#include +#endif + +#define TOG_MAX_USECASE 2 +#define TOG_MAX_TEST_TIMEOUT_VALUE (10000000u) +#define MCU_ESM_BASE (SDL_MCU_ESM0_CFG_BASE) + +typedef void (*TOG_injectFunction)(uint32_t instanceIndex); + +/* Nothing past this point */ \ No newline at end of file diff --git a/packages/ti/boot/sbl/example/boot_app/tog/tog_test_utils.asm b/packages/ti/boot/sbl/example/boot_app/tog/tog_test_utils.asm new file mode 100644 index 00000000..fc83245b --- /dev/null +++ b/packages/ti/boot/sbl/example/boot_app/tog/tog_test_utils.asm @@ -0,0 +1,60 @@ +;****************************************************************************** +; @file tog_test_utils.asm +; +; @brief +; Implementation file for the TOG utils assembly functions +; +; \par +; ============================================================================ +; @n (C) Copyright 2024, 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. +;****************************************************************************** + + .text + .global enableABORT + .global disableABORT + +enableABORT: + PUSH {r0} + MRS r0, CPSR + BIC r0, r0, #(1<<5) + MSR CPSR_cxsf, r0 + POP {r0} + BX LR + +disableABORT: + PUSH {r0} + MRS r0, CPSR + ORR r0, r0, #(1<<5) + MSR CPSR_cxsf, r0 + POP {r0} + BX LR + + .end \ No newline at end of file diff --git a/packages/ti/boot/sbl/example/boot_app/tog/tog_test_utils.h b/packages/ti/boot/sbl/example/boot_app/tog/tog_test_utils.h new file mode 100644 index 00000000..988ad065 --- /dev/null +++ b/packages/ti/boot/sbl/example/boot_app/tog/tog_test_utils.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) Texas Instruments Incorporated 2024 + * + * 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. + * + */ + + /** + * \file tog_test_utils.h + * + * \brief Utility functions for TOG test + * + * \details This file contains C prototype of Assembly functions + **/ +#ifndef TOG_TEST_UTILS_H +#define TOG_TEST_UTILS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +void disableABORT(void); +void enableABORT(void); + +#ifdef __cplusplus +} +#endif + +#endif /* TOG_TEST_UTILS_H */ + +/* Nothing past this point */ \ No newline at end of file -- 2.34.1