/* BEGIN_FILE_HDR ******************************************************************************** * NOTICE * This software is the property of HiRain Technologies. Any information * contained in this doc should not be reproduced, or used, or disclosed * without the written authorization from HiRain Technologies. ******************************************************************************** * File Name: Os_Cpu.c ******************************************************************************** * Project/Product: AUTOSAR OS PROJECT * Title: Os_Cpu.c * Author: Hirain ******************************************************************************** * Description: Cpu Module of OS * ******************************************************************************** * Limitations : None * ******************************************************************************** * ******************************************************************************** * Revision History: * * Version Date Initials CR# Descriptions * --------- ---------- ------------ ---------- --------------- * 0.0.0.1 24/03/2021 Ning.Chen N/A Init version * 0.0.0.2 18/04/2021 Feixiang.Dong N/A EAS422_OS_20210418_01 * 1.0.0.0 20/05/2021 Feixiang.Dong N/A EAS422_OS_20210520_01 * 1.1.1.0 08/12/2022 Yanan.zhao1 N/A EAS422_OS_20210918_01 ******************************************************************************** * END_FILE_HDR*/ #include "Os_Internal.h" /***************************************************************************** * General QAC Suppression ******************************************************************************/ /*PRQA S 303,305,306 EOF*/ /* * MISRA-C:2004 11.3(303):Cast between a pointer to volatile object and an integral type. * MISRA-C:2004 11.3(305):Cast a pointer to an integral type. * MISRA-C:2004 11.3(306):Cast between a pointer to function and an integral type. * To address a flash must cast an integral type to a pointer. * To address a System Register must cast an integral type to a pointer and volatile is a type specifier to make sure the instruction can not be omitted due to compiler optimizations. */ /*PRQA S 3383 EOF*/ /* The comparative operation or arithmetic expression of non-negative variables does not cause overflow. */ /*PRQA S 3442 EOF*/ /* They are essential operators to access registers. */ /*PRQA S 4570 EOF*/ /* They have the same variable definition of CoreIdType. */ /*PRQA S 4397 EOF*/ /* The result of a ~ or << operation and is of unsigned essential type narrower than int can not make mistakes. */ /*PRQA S 3344 EOF*/ /* Controlling expressions appear in while constructs can not make mistakes. */ /*PRQA S 2740 EOF*/ /* The loop construct can be terminated with a 'break' statement. */ #define OS_START_SEC_VAR_NOINIT_UNSPECIFIED #include "Os_MemMap.h" /* OsCpu_FirstTaskCSA is Data switching center */ VAR(Os_AddrType, OS_VAR) OsCpu_FirstTaskCSA[OS_USED_CORE_NUMBER]; VAR(Os_boolean, OS_VAR) OsCpu_TpFlag; VAR(Os_boolean, OS_VAR) OsCpu_MPUFlag; #define OS_STOP_SEC_VAR_NOINIT_UNSPECIFIED #include "Os_MemMap.h" typedef volatile struct { Os_uint32 PCKMD : 2; /* [1:0] r/w */ Os_uint32 RSVD_3_2 : 2; /* [3:2] r */ Os_uint32 CLKMUX : 3; /* [6:4] r/w */ Os_uint32 RSVD_7 : 1; /* [7] r */ Os_uint32 CLKDIV : 4; /* [11:8] r/w */ Os_uint32 RSVD_15_12 : 4; /* [15:12] r */ Os_uint32 PWLK : 1; /* [16] r/w */ Os_uint32 RSVD_19_17 : 3; /* [19:17] r */ Os_uint32 PSUPVACEN : 1; /* [20] r/w */ Os_uint32 PRSTB : 1; /* [21] r/w */ Os_uint32 RSVD_23_22 : 2; /* [23:22] r */ Os_uint32 PPR : 1; /* [24] r/w */ Os_uint32 PCLKMUXPR : 1; /* [25] r/w */ Os_uint32 PCLKDIVPR : 1; /* [26] r/w */ Os_uint32 PSUPVACPR : 1; /* [27] r/w */ Os_uint32 RSVD_30_28 : 3; /* [30:28] r */ Os_uint32 LOCK : 1; /* [31] r/w */ } Os_ModuleCfgBf_t; /***************************************************************************** * MACRO ******************************************************************************/ /***************************************************************************** * static const define ******************************************************************************/ #define OS_START_SEC_CODE #include "Os_MemMap.h" /***************************************************************************** * OS private code ******************************************************************************/ STATIC FUNC(void, OS_CODE) OsCpu_TaskUnterminateProcess(void); STATIC FUNC(void, OS_CODE) OsCpu_InitStack ( Os_AddrType *taskStkTop, /*PRQA S 3672 ++*/ /* *Using non-const pointer to function for init stack. */ Os_TaskFuncType pxCode /*PRQA S 3672 --*/ ); /***************************************************************************** * OS internal code ******************************************************************************/ /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_TaskUnterminateProcess * * Description: Call in OsCpu_TaskSwitch, when user task return * * Inputs: None * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ /*PRQA S 3219 ++*/ /* This function be called by assembly instructions which PRQA can not parse. */ STATIC FUNC(void, OS_CODE) OsCpu_TaskUnterminateProcess /*PRQA S 3219 --*/ ( void ) { CoreIdType CoreID; TaskType tempTaskID; CoreID = OsCpu_GetCoreID(); /*switch to kernel mpu set*/ /*PRQA S 3200 ++*/ /* Inline function "OsMpu_SetKernel" do not have return value. */ OsMpu_SetKernel(CoreID); /*PRQA S 3200 --*/ /* no need to switch stack pointer here*/ /* report error */ /* SWS_Os_00069 */ OsHook_ReportErrorDisInt(CoreID, E_OS_MISSINGEND, OSServiceId_OsCpu_TaskSwitch, OS_IE_NOMORE_INFO, (Os_uint32)Os_CurrentTaskId[CoreID], OS_IE_NO_ERRPAR, OS_IE_NO_ERRPAR); OsIntc_DisableGlobalInterrupt(CoreID); tempTaskID = Os_CurrentTaskId[CoreID]; OsTask_InternalTerminateTask(CoreID); /* as current task id has been cleared in OsTask_InternalTerminateTask, tempTaskID is needed*/ OsCpu_TaskTerminateSchedule(CoreID, tempTaskID); /* never reach here*/ OsHook_FataErrReport(CoreID, E_OS_SYSFATA_UNREACHABLE, OSServiceId_TerminateTask, OS_IE_NOMORE_INFO, OS_IE_NO_ERRPAR, OS_IE_NO_ERRPAR, OS_IE_NO_ERRPAR); } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_Init * * Description: OsCpu_Init * * Inputs: CoreID * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(void , OS_CODE) OsCpu_Init ( CoreIdType CoreID ) { (void)CoreID; /* Lazy save close. */ *(OS_PL_FPU_FPCCR) &= (Os_uint32)~OS_PL_FPU_LSPEN_BITS; /* DIV_0_TRAP enable*/ OS_SCB->CCR |= ((Os_uint32)OS_SCB_DIV_O_TRP_MSK << (Os_uint32)OS_SCB_DIV_O_TRP_SHIFT); } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_FirstSchedule * * Description: Call in Start OS, it should do following jobs: * 1.since this is the 1st time os start scheduing, so clear all pre context * 2.return to TaskSwitch to start schedule * * Inputs: CoreID * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(void , OS_CODE) OsCpu_FirstSchedule ( CoreIdType CoreID ) { OsIntc_SuspendOsInterrupts(CoreID); /* Start the first task. This also clears the bit that indicates the FPU is * in use in case the FPU was used before the scheduler was started - which * would otherwise result in the unnecessary leaving of space in the SVC stack * for lazy saving of FPU registers. */ OS_ASM_KEYWORD ( " ldr r0, =0xE000ED08 \n"/* Use the NVIC offset register to locate the stack. */ " ldr r0, [r0] \n" " ldr r0, [r0] \n" " msr msp, r0 \n"/* Set the msp back to the start of the stack. */ " mov r0, #0 \n"/* Clear the bit that indicates the FPU is in use, see comment above. */ " msr control, r0 \n" " cpsie i \n"/* Globally enable interrupts. */ " cpsie f \n" " dsb \n" " isb \n" " svc 255 \n"/* System call to start first task. */ " nop \n" " \n" ); } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_SVC_Schedule * * Description: SVC Schedule in CPU * * Inputs: None * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_SVC_Schedule(void) { OS_ASM_KEYWORD ( "cpsid i \n" "ldr r1, =OsCpu_TaskSwitch \n" "blx r1 \n" "isb \n" "LDR r3, = OsCpu_FirstTaskCSA \n" "ldr r0,[r3] \n" /*Load psp from OsCpu_FirstTaskCSA[0] */ /*control*/ "ldr r1,[r0],#4 \n" "msr control,r1 \n" "ldmia r0!, {r4-r11, r14} \n" /* Pop the registers that are not automatically saved on exception entry and the critical nesting count. */ " \n" "tst r14, #0x10 \n" /* Is the task using the FPU context? If so, pop the high vfp registers too. */ "it eq \n" "vldmiaeq r0!, {s16-s31} \n" " \n" "msr psp, r0 \n" /* Restore the task stack pointer. */ "cpsie i \n" "bx r14 \n" " \n" ); } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_TaskTerminateSchedule * * Description: Called at the end of TerminateTask and ChainTask * release all user task ctx and start schedule * * Inputs: CoreID * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(void , OS_CODE)OsCpu_TaskTerminateSchedule ( CoreIdType CoreID, TaskType TaskID ) { (void)CoreID; (void)TaskID; #if((OS_ON == OS_TIMING_PROTECTION_SUPPORT) || (OS_ON == OS_MEM_PROTECTION_SUPPORT)) if(OsCpu_TpFlag == OS_TRUE) { OsCpu_TpFlag = OS_FALSE; OsCpu_SVC_Schedule(); } else if(OsCpu_MPUFlag == OS_TRUE) { OsCpu_MPUFlag = OS_FALSE; OsCpu_SVC_Schedule(); } else #endif { OsIntc_SuspendOsInterrupts(CoreID); /*PRQA S 3109 ++*/ /* *scheduling entry task will not return. */ OsCpu_SetSVC(OS_SYSCALL_TIN); /*PRQA S 3109 --*/ } } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_InternalTaskPreempt * * Description: Jump from system call trap, this function can only be jump, can not be called, * to avoid CDC++, which cause RFE fail * * * Inputs: None * * Outputs: None * * Limitations: 1.only can be trigger from task; InIsrC2 dont affect by this function *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_InternalTaskPreempt ( void ) { CoreIdType CoreID; TaskType TaskID; Os_uint32 val = (Os_uint32)0; /* Step1, save context */ /* upper ctx has been saved during syscall trap*/ CoreID = OsCpu_GetCoreID(); TaskID = Os_CurrentTaskId[CoreID]; val = (Os_uint32)OsCpu_FirstTaskCSA[CoreID]; /* Before trigger pendsv, save PSP, because OsCpu_SetPendSV save Upper Context auto, * so - OS_PL_REG_WIDTH_BYTES * OS_PL_UPPER_CONTEXT_NUM */ Os_TaskCBTable[TaskID].OsTaskCtxPtr = (Os_AddrType)val; #if(OS_CRC_SUPPORT == OS_ON) Os_TaskCBTable[TaskID].crcResult = OsCrc_Calculate(val); #endif if(Os_IntNestDepth[CoreID] != OS_INVALID_ISR) { /*Pendsv Must is last ISR*/ OsHook_FataErrReport(CoreID, E_OS_SYSFATA_ISR_NEST_LIMIT_ERROR, OSServiceId_OsIsr_InISR2, OS_IE_NOMORE_INFO, (Os_uint32)Os_IntNestDepth[CoreID], OS_IE_NO_ERRPAR, OS_IE_NO_ERRPAR); } OsCpu_TaskSwitch(); } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_InitStack * * Description: OsCpu_InitStack * * * Inputs: taskStkTop, pxCode * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ STATIC FUNC(void, OS_CODE) OsCpu_InitStack ( Os_AddrType *taskStkTop, /*PRQA S 3672 ++*/ /* *Using non-const pointer to function for init stack. */ Os_TaskFuncType pxCode /*PRQA S 3672 ++*/ ) { #if(OS_ON == OS_MEM_PROTECTION_SUPPORT) ApplicationType ApplID; TaskType TaskID; CoreIdType CoreID = OsCpu_GetCoreID(); TaskID = Os_CurrentTaskId[CoreID]; ApplID = Os_TaskCfg[TaskID].ApplID; #endif /* Simulate the stack frame as it would be created by a context switch * interrupt. */ /* Offset added to account for the way the MCU uses the stack on entry/exit * of interrupts, and to ensure alignment. */ /* Check register val */ /*PRQA S 1338,0489,0488 ++*/ /* *Operation of the task stack pointer for task scheduling. */ taskStkTop--; *taskStkTop = (Os_AddrType)OS_INIT_XPSR; /* xPSR */ taskStkTop--; *taskStkTop = (Os_AddrType) pxCode & (Os_AddrType)OS_START_ADDRESS_MASK; /* PC */ taskStkTop--; *taskStkTop = (Os_AddrType)&OsCpu_TaskUnterminateProcess; /* Save code space by skipping register initialisation. */ taskStkTop -= 5; /* R12, R3, R2 ,R1 and R0. */ /* A save method is being used that requires each task to maintain its * own exec return value. */ taskStkTop--; *taskStkTop = OS_INIT_EXC_RETURN; taskStkTop -= 8; /* R11, R10, R9, R8, R7, R6, R5 and R4. */ /* Control */ taskStkTop--; #if(OS_ON == OS_MEM_PROTECTION_SUPPORT) /* if trusted application or idle task, just set to kernel set*/ if((OS_TRUE == Os_AppCfg[ApplID].isTrusted) || (TaskID == Os_CoreCfg[CoreID].idleTaskId)) { *taskStkTop = OsCpu_GetControl() & ~((Os_uint32)OS_PL_UNPRIVILEGED_MASK);/* nPRIV=1: unprivileged */ } else if(OS_TRUE != Os_AppCfg[ApplID].isTrusted) { *taskStkTop = OsCpu_GetControl() | OS_PL_UNPRIVILEGED_MASK;/* nPRIV=1: unprivileged */ } else #endif { /*used for no sc3 mode*/ *taskStkTop = OsCpu_GetControl() & ~((Os_uint32)OS_PL_UNPRIVILEGED_MASK);/* nPRIV=1: unprivileged */ } /*PRQA S 1338,0489,0488 --*/ } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsKernel_TaskSwitch * * Description: Task Switch function * * * Inputs: None * * Outputs: None * * Limitations: 1.trigger from task or outISRC2 2.use old stack, before switch to next task, no system stack switch 3.must done all the process of old task or ISR, before call this fucntion, this function only do the new task switch job *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_TaskSwitch(void) { CoreIdType CoreID = OsCpu_GetCoreID(); TaskStateType taskState; Os_AddrType tempCtxPtr; OsKernel_CheckTaskSwitch(CoreID); /* save the state as state will set to running in Enter Task before PreTaskHook*/ taskState = Os_TaskCBTable[Os_CurrentTaskId[CoreID]].OsTaskState; if(taskState == OS_TASK_NEW)/* Start new Task */ { OsKernel_EnterTask(CoreID, OS_FALSE);/* prepare for new task*/ /* set interrupt priority to lowest so that any interrupt can generate when task running */ OsIntc_ReplaceIntPriority(CoreID, (Os_PrioType)OS_PL_LOWEST_ISR_PRI); /*save the next CSA, wich will be first used in next task, * so that, when task end, os will release CSA to this OsCpu_FirstTaskCSA * */ /*switch to task mpu set*/ OsMpu_ClearRegion(); OsMpu_SetTask(CoreID, Os_CurrentTaskId[CoreID]); /* switch to new task's stack OS_PL_SET_REG(sp, Os_TaskCfg[Os_CurrentTaskId[CoreID]].OsTaskStkBottom);*/ tempCtxPtr = (Os_AddrType)Os_TaskCfg[Os_CurrentTaskId[CoreID]].OsTaskStkBottom; OsCpu_SetPSP(tempCtxPtr); /*OS_PL_EnableInterrupts();*/ OsCpu_InitStack((Os_AddrType *)tempCtxPtr, Os_TaskCfg[Os_CurrentTaskId[CoreID]].OsTaskAddr); /*Os_TaskCfg[Os_CurrentTaskId[CoreID]].OsTaskAddr(); if user task return SWS_OS_00069*/ OsCpu_FirstTaskCSA[CoreID] = tempCtxPtr - ((OS_PL_UPPER_CONTEXT_NUM + OS_PL_LOWER_CONTEXT_NUM) * OS_PL_REG_WIDTH_BYTES) - (OS_PL_CONTROL_CONTEXT_NUM * OS_PL_REG_WIDTH_BYTES); /* Must after control interrupt, to change usermode */ /* task not terminate detected. */ } else if((taskState == OS_TASK_READY) || (taskState == OS_TASK_WAITING_TO_READY))/* waiting task will set to ready when event set*/ { OsKernel_EnterTask(CoreID, OS_TRUE);/* prepare for restore task*/ /*switch to task mpu set as mpu not saved in CSA*/ OsMpu_ClearRegion(); OsMpu_SetTask(CoreID, Os_CurrentTaskId[CoreID]); /* restore old task*/ tempCtxPtr = Os_TaskCBTable[Os_CurrentTaskId[CoreID]].OsTaskCtxPtr; OsCpu_FirstTaskCSA[CoreID] = tempCtxPtr; OS_PL_DSYNC(); OsIntc_ResumeOsInterrupts(CoreID); /* Must after control interrupt, to change usermode */ } else { OsHook_FataErrReport(CoreID, E_OS_SYSFATA_UNREACHABLE, OSServiceId_OsCpu_TaskSwitch, OS_IE_NOMORE_INFO, OS_IE_NO_ERRPAR, OS_IE_NO_ERRPAR, OS_IE_NO_ERRPAR); } } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_TaskPreemptSchedule * * Description: Implement as macro in this platform, to trigger syscall trap * * Inputs: None * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_EnterCritical * * Description: Disable global interrupt to enter Critical area * * Inputs: CoreID, gIntState * * Outputs: gIntState * * Limitations: 1.input CoreID is logical id, If needed , CoreID need to change to phy core id * 2.can not use isr priority to enter and leave Critical area, as in resouce API, need to change celling priority * 3.This function must be inline code. as Call and RET cmd may change the global interrupt state *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_EnterCritical ( CoreIdType CoreID, P2VAR(Os_boolean, AUTOMATIC, AUTOMATIC) gIntState ) { Os_boolean state = OS_FALSE; Os_uint32 val; (void)CoreID; val = (Os_uint32)OsCpu_GetPRIMASK(); if((Os_uint32)0 == (Os_uint32)(val & OS_PL_ICR_IE_MASK)) { state = OS_TRUE; } *gIntState = state; OS_PL_DisableInterrupts(); } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_SYSCTRL_EnableModule * * Description: Enable module * * Inputs: mod * * Outputs: None * * Limitations: The module is enabled in normal/wait/stop modes *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_SYSCTRL_EnableModule(OS_SYSCTRL_Module_t mod) { Os_ModuleCfgBf_t *mod_bf_p = (Os_ModuleCfgBf_t *)(OS_PARCC_BASE_ADDR + (Os_uint32)mod); Os_uint32 *mod_p = (Os_uint32 *)(OS_PARCC_BASE_ADDR + (Os_uint32)mod); if(mod_bf_p->LOCK != 0U) { /* unlock this register */ *mod_p = 0x5B000000UL; } mod_bf_p->PCKMD = 1U; mod_bf_p->PRSTB = 1U; mod_bf_p->LOCK = 1U; } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_SYSCTRL_ResetModule * * Description: Reset module * * Inputs: mod * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_SYSCTRL_ResetModule(OS_SYSCTRL_Module_t mod) { Os_ModuleCfgBf_t *mod_bf_p = (Os_ModuleCfgBf_t *)(OS_PARCC_BASE_ADDR + (Os_uint32)mod); Os_uint32 *mod_p = (Os_uint32 *)(OS_PARCC_BASE_ADDR + (Os_uint32)mod); if(mod_bf_p->LOCK != 0U) { /* unlock this register */ *mod_p = 0x5B000000UL; } mod_bf_p->PRSTB = 0U; mod_bf_p->PRSTB = 1U; mod_bf_p->LOCK = 1U; } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_GetCoreID * * Description: Get current logical core Id * * Inputs: None * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_GetPhyCoreId * * Description: Get current physical core Id, used when non autosar core read coreid * * Inputs: None * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_SetMode * * Description: Start or stop core running * * Inputs: CoreID(must be physical core id), mode * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ #if(OS_CRC_SUPPORT == OS_ON) /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_ConvertAddr * * Description: Convert Addr from PCX to real phy addr * * Inputs: pcxAddr * * Outputs: Os_AddrType * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(Os_AddrType, OS_CODE) OsCpu_ConvertAddr ( Os_AddrType pcxAddr ) { Os_AddrType addr; addr = pcxAddr; return addr; } #endif /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_FreeTaskCSA * * Description: free Task CSA, only used in terminate App * * Inputs: CoreID, TaskID * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_FreeTaskCSA ( Os_uint8 CoreID, TaskType TaskID ) { (void)CoreID; (void)TaskID; /* release all task CSA */ } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_MemoryInit * * Description: None * * Inputs: CoreID * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_MemoryInit ( CoreIdType CoreID ) { (void)CoreID; /* release all task CSA */ } /* BEGIN_FUNCTION_HDR *********************************************************************************************** * Function Name: OsCpu_VariablesInit * * Description: None * * Inputs: CoreID * * Outputs: None * * Limitations: None *********************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_VariablesInit ( CoreIdType CoreID ) { (void)CoreID; /* release all task CSA */ } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: OsCpu_ReadIo8 * * Description: Return 8-bit value from memory base on address. * * Inputs: Address * * Outputs: Os_uint8 * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(Os_uint8, OS_CODE) OsCpu_ReadIo8 ( P2CONST(Os_uint8, AUTOMATIC, OS_APPL_CONST) Address ) { return *Address; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: OsCpu_ReadIo16 * * Description: Return 16-bit value from memory base on address. * * Inputs: Address * * Outputs: Os_uint16 * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(Os_uint16, OS_CODE) OsCpu_ReadIo16 ( P2CONST(Os_uint16, AUTOMATIC, OS_APPL_CONST) Address ) { return *Address; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: OsCpu_ReadIo32 * * Description: Return 32-bit value from memory base on address. * * Inputs: Address * * Outputs: Os_uint32 * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(Os_uint32, OS_CODE) OsCpu_ReadIo32 ( P2CONST(Os_uint32, AUTOMATIC, OS_APPL_CONST) Address ) { return *Address; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: OsCpu_WriteIo8 * * Description: Write 8-bit value into memeory base on address. * * Inputs: Address, WriteValue * * Outputs: None * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_WriteIo8 ( P2VAR(Os_uint8, AUTOMATIC, OS_APPL_DATA) Address, Os_uint8 WriteValue ) { *Address = WriteValue; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: OsCpu_WriteIo16 * * Description: Write 16-bit value into memeory base on address. * * Inputs: Address, WriteValue * * Outputs: None * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_WriteIo16 ( P2VAR(Os_uint16, AUTOMATIC, OS_APPL_DATA) Address, Os_uint16 WriteValue ) { *Address = WriteValue; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: OsCpu_WriteIo32 * * Description: Write 32-bit value into memeory base on address. * * Inputs: Address, WriteValue * * Outputs: None * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_WriteIo32 ( P2VAR(Os_uint32, AUTOMATIC, OS_APPL_DATA) Address, Os_uint32 WriteValue ) { *Address = WriteValue; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: OsCpu_RmwIo8 * * Description: Read-modify-write 8-bit value from and into memory base on address. * Modify: Clear some bits and set others. * * Inputs: Address, ClearMask, SetMask * * Outputs: None * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_RmwIo8 ( P2VAR(Os_uint8, AUTOMATIC, OS_APPL_DATA) Address, Os_uint8 ClearMask, Os_uint8 SetMask ) { Os_uint8 tempVal; tempVal = *Address; tempVal = (tempVal & ClearMask) | SetMask; *Address = tempVal; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: OsCpu_RmwIo16 * * Description: Read-modify-write 16-bit value from and into memory base on address. * Modify: Clear some bits and set others. * * Inputs: Address, ClearMask, SetMask * * Outputs: None * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_RmwIo16 ( P2VAR(Os_uint16, AUTOMATIC, OS_APPL_DATA) Address, Os_uint16 ClearMask, Os_uint16 SetMask ) { Os_uint16 tempVal; tempVal = *Address; tempVal = (tempVal & ClearMask) | SetMask; *Address = tempVal; } /* BEGIN_FUNCTION_HDR **************************************************************************************************** * Function Name: OsCpu_RmwIo32 * * Description: Read-modify-write 32-bit value from and into memory base on address. * Modify: Clear some bits and set others. * * Inputs: Address, ClearMask, SetMask * * Outputs: None * * Limitations: None **************************************************************************************************** END_FUNCTION_HDR*/ FUNC(void, OS_CODE) OsCpu_RmwIo32 ( P2VAR(Os_uint32, AUTOMATIC, OS_APPL_DATA) Address, Os_uint32 ClearMask, Os_uint32 SetMask ) { Os_uint32 tempVal; tempVal = *Address; tempVal = (tempVal & ClearMask) | SetMask; *Address = tempVal; } #define OS_STOP_SEC_CODE #include "Os_MemMap.h"