#include "Det.h"\r
#if defined(USE_KERNEL)\r
#include "Os.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#endif\r
\r
\r
#include <stdlib.h>\r
#include <string.h>\r
#include "Os.h"
-#include "irq.h"\r
+#include "isr.h"\r
#include "arc.h"
\r
#include <string.h>\r
#if defined(USE_KERNEL)\r
#include "Os.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#include "arc.h"\r
#endif\r
#include "stm32f10x.h"\r
#include "Det.h"\r
#if defined(USE_KERNEL)\r
#include "Os.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#endif\r
\r
// Implementation specific\r
/* STM32 helper arrays\r
- *
+ *\r
*/\r
TIM_TypeDef * const TimAddr[] =\r
{\r
{\r
// TODO: make switch here... for now just call func.\r
Irq_Enable();\r
- os_sys.curr_pcb->entry();\r
+ Os_Sys.currTaskPtr->entry();\r
}\r
\r
void *Os_ArchGetStackPtr( void ) {\r
return SC_SIZE;\r
}\r
\r
-void Os_ArchSetTaskEntry(OsPcbType *pcbPtr ) {\r
+void Os_ArchSetTaskEntry(OsTaskVarType *pcbPtr ) {\r
// TODO: Add lots of things here, see ppc55xx\r
uint32_t *context = (uint32_t *)pcbPtr->stack.curr;\r
\r
\r
}\r
\r
-void Os_ArchSetupContext( OsPcbType *pcb ) {\r
+void Os_ArchSetupContext( OsTaskVarType *pcb ) {\r
// TODO: Add lots of things here, see ppc55xx\r
// uint32_t *context = (uint32_t *)pcb->stack.curr;\r
\r
#include "arch_offset.h"\r
#include "stack.h"\r
\r
-.extern os_sys\r
+.extern Os_Sys\r
.extern TailChaining\r
\r
.syntax unified\r
mov r0,sp // stack as first arg\r
\r
// When at interrupt nest count = 0, load interrupt stack \r
- ldr r4,=os_sys\r
+ ldr r4,=Os_Sys\r
ldr r5,[r4,#SYS_INT_NEST_CNT]\r
cmp r5, #0\r
bgt arggg \r
\r
// TODO: Fix this for all arch's..call pre,post hooks. Done here or after?\r
// Set new current pcb\r
- ldr r5,= os_sys\r
+ ldr r5,= Os_Sys\r
str r1,[r5,#SYS_CURR_PCB_P]\r
\r
// Restore C context\r
#include "task_i.h"
#include "hooks.h"
#include "stm32f10x.h"
-#include "irq.h"
+#include "isr.h"
extern void *Irq_VectorTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];
* @param vector
*/
void Irq_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) {
- OsPcbType *pcb;
+ OsTaskVarType *pcb;
- pcb = os_find_task(tid);
+ pcb = Os_TaskGet(tid);
Irq_VectorTable[vector+16] = (void *)pcb;
NVIC_InitVector(vector, osPrioToCpuPio(pcb->prio));
#include "Os.h"\r
#include "internal.h"\r
#include "stm32f10x.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#include "arc.h"\r
\r
\r
#include "Det.h"\r
#include "CanIf_Cbk.h"\r
#include "Os.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#include "Mcu.h"\r
#include "arc.h"\r
\r
{\r
// TODO: make switch here... for now just call func.\r
Irq_Enable();\r
- os_sys.curr_pcb->entry();\r
+ Os_Sys.currTaskPtr->entry();\r
}\r
\r
void *Os_ArchGetStackPtr( void ) {\r
return SC_SIZE;\r
}\r
\r
-void Os_ArchSetTaskEntry(OsPcbType *pcbPtr ) {\r
+void Os_ArchSetTaskEntry(OsTaskVarType *pcbPtr ) {\r
// TODO: Add lots of things here, see ppc55xx\r
uint32_t *context = (uint32_t *)pcbPtr->stack.curr;\r
\r
\r
}\r
\r
-void Os_ArchSetupContext( OsPcbType *pcb ) {\r
+void Os_ArchSetupContext( OsTaskVarType *pcb ) {\r
// TODO: Add lots of things here, see ppc55xx\r
// uint32_t *context = (uint32_t *)pcb->stack.curr;\r
\r
#include "kernel_offset.h"\r
#include "stack.h"\r
\r
-.extern os_sys\r
+.extern Os_Sys\r
\r
.syntax unified\r
.cpu cortex-r4\r
mov r0,sp \r
\r
// When at interrupt nest count = 0, load interrupt stack \r
- ldr r4,=os_sys\r
+ ldr r4,=Os_Sys\r
ldr r5,[r4,#SYS_INT_NEST_CNT]\r
cmp r5, #0\r
bgt arggg\r
mov.w sp,r2\r
\r
// Set new current pcb\r
- ldr r5,= os_sys\r
+ ldr r5,= Os_Sys\r
str r1,[r5,#SYS_CURR_PCB_P]\r
\r
// Restore C context\r
#include "internal.h"
#include "task_i.h"
#include "hooks.h"
-#include "irq.h"
+#include "isr.h"
#include "core_cr4.h"
extern TaskType Os_Arc_CreateIsr( void (*entry)(void ), uint8_t prio, const char *name );
}
stack = (uint32_t *)stack_p;
- struct OsPcb * pcb = (struct OsPcb *)Irq_VectorTable[virtualChannel];
+ struct OsTaskVar * pcb = (struct OsTaskVar *)Irq_VectorTable[virtualChannel];
// Save the hardware channel in the PCB, so that Os_Isr knows which interrupt channel to deactivate.
pcb->vector = channel;
stack = Os_Isr(stack, (void *)pcb);
* @param vector
*/
void Irq_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) {
- OsPcbType *pcb;
+ OsTaskVarType *pcb;
- pcb = os_find_task(tid);
+ pcb = Os_TaskGet(tid);
Irq_VectorTable[vector] = (void *)pcb;
IrqActivateChannel(vector);
#include "Os.h"\r
#include "internal.h"\r
#include "core_cr4.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#include "arc.h"\r
\r
#define RTICLK_PRESCALER 10\r
#include "Adc.h"\r
#include "Det.h"\r
#include "Os.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#include "regs.h"\r
#include "arc.h"\r
\r
#include <stdlib.h>\r
#include <string.h>\r
#include "Os.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#include "arc.h"\r
\r
// bits in CANxCTL0:\r
#include "Det.h"\r
#include "Os.h"\r
#include "arc.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
\r
#define FIRST_OC_REG 0x50\r
\r
{\r
// TODO: make switch here... for now just call func.\r
Irq_Enable();\r
- os_sys.curr_pcb->entry();\r
+ Os_Sys.currTaskPtr->entry();\r
}\r
\r
void *Os_ArchGetStackPtr( void ) {\r
}\r
\r
\r
-void Os_ArchSetupContext( OsPcbType *pcb ) {\r
+void Os_ArchSetupContext( OsTaskVarType *pcb ) {\r
// Nothing to be done here\r
}\r
\r
* @param pcbPtr\r
*/\r
\r
-void Os_ArchSetTaskEntry(OsPcbType *pcbPtr ) {\r
+void Os_ArchSetTaskEntry(OsTaskVarType *pcbPtr ) {\r
uint8_t *context_bytes = (uint8_t *)pcbPtr->stack.curr;\r
uint16_t temp;\r
\r
#include "context.h"\r
#include "irq_defines.h"\r
\r
-.extern os_sys\r
+.extern Os_Sys\r
\r
\r
/* \r
#include "asm_hc1x.sx"\r
#include "context.sx"\r
\r
-.extern os_sys\r
+.extern Os_Sys\r
.extern os_proc_start_extended\r
\r
#define IRQ_ENABLE() cpsie i\r
\r
Os_ArchSwapContextTo_do:\r
// Set current process\r
- sty os_sys // new (Y) --> os_sys.curr_pcb\r
+ sty Os_Sys // new (Y) --> Os_Sys.curr_pcb\r
// Restore context\r
lds PCB_STACK_CURR_P, y // new->stack.curr --> SP\r
\r
* -------------------------------- Arctic Core ------------------------------*/\r
\r
#include "internal.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#include "irq_types.h"\r
#include "regs.h"\r
\r
* @param vector\r
*/\r
void Irq_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) {\r
- OsPcbType *pcb;\r
+ OsTaskVarType *pcb;\r
\r
- pcb = os_find_task(tid);\r
+ pcb = Os_TaskGet(tid);\r
Irq_VectorTable[vector] = (void *)pcb;\r
Irq_IsrTypeTable[vector] = PROC_ISR2;\r
\r
\r
#include "Os.h"\r
#include "internal.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#include "arc.h"\r
#include "regs.h"\r
#include "Mcu.h"\r
#include "Det.h"\r
#if defined(USE_KERNEL)\r
#include "Os.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#include "arc.h"\r
#endif\r
\r
* -------------------------------- Arctic Core ------------------------------*/\r
\r
\r
-\r
-\r
-\r
-\r
-\r
-\r
#include "Can.h"\r
\r
#ifndef USE_CAN_STUB\r
#include <string.h>\r
#if defined(USE_KERNEL)\r
#include "Os.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#include "arc.h"\r
#endif\r
\r
\r
#define GET_CONTROLLER_CNT() (CAN_CONTROLLER_CNT)\r
\r
+\r
+#define _INSTALL_HANDLER(_can_entry, _unique, _vector,_priority,_core) \\r
+ do { \\r
+ const OsIsrConstType _can_entry ## _unique = { \\r
+ .vector = _vector, \\r
+ .type = ISR_TYPE_2, \\r
+ .priority = _priority, \\r
+ .entry = _can_entry, \\r
+ .core = _core, \\r
+ .name = "Can", \\r
+ .resourceMask = 0, \\r
+ .appOwner = 0, \\r
+ }; \\r
+ Os_IsrAdd( & _can_entry ## _unique); \\r
+ } while(0);\r
+\r
+\r
+\r
+#define INSTALL_HANDLER(_can_entry, _vector,_priority,_core) \\r
+ _INSTALL_HANDLER(_can_entry, __LINE__, _vector,_priority,_core) \\r
+\r
+#define INSTALL_HANDLER4(_can_entry, _vector,_priority,_core)\\r
+ INSTALL_HANDLER(_can_entry, _vector+0,_priority,_core) \\r
+ INSTALL_HANDLER(_can_entry, _vector+1,_priority,_core) \\r
+ INSTALL_HANDLER(_can_entry, _vector+2,_priority,_core) \\r
+ INSTALL_HANDLER(_can_entry, _vector+3,_priority,_core)\r
+\r
+#define INSTALL_HANDLER16(_can_entry, _vector,_priority,_core)\\r
+ INSTALL_HANDLER4(_can_entry, _vector+0,_priority,_core) \\r
+ INSTALL_HANDLER4(_can_entry, _vector+4,_priority,_core) \\r
+ INSTALL_HANDLER4(_can_entry, _vector+8,_priority,_core) \\r
+ INSTALL_HANDLER4(_can_entry, _vector+12,_priority,_core)\r
+\r
+\r
//-------------------------------------------------------------------\r
\r
#if ( CAN_DEV_ERROR_DETECT == STD_ON )\r
\r
} Can_UnitType;\r
\r
-#if defined(CFG_MPC5567)\r
-Can_UnitType CanUnit[CAN_CONTROLLER_CNT] =\r
-{\r
- {\r
- .state = CANIF_CS_UNINIT,\r
- },{\r
- .state = CANIF_CS_UNINIT,\r
- },{\r
- .state = CANIF_CS_UNINIT,\r
- },{\r
- .state = CANIF_CS_UNINIT,\r
- },{\r
- .state = CANIF_CS_UNINIT,\r
- },\r
-};\r
-#else\r
Can_UnitType CanUnit[CAN_CONTROLLER_CNT] =\r
{\r
{\r
.state = CANIF_CS_UNINIT,\r
},{\r
.state = CANIF_CS_UNINIT,\r
- },{\r
+ }\r
+#if defined(CFG_MPC5516) || defined(CFG_MPC5517)\r
+ ,{\r
.state = CANIF_CS_UNINIT,\r
}\r
-};\r
#endif\r
+};\r
\r
//-------------------------------------------------------------------\r
\r
void Can_C_Isr( void ) { Can_Isr(CAN_CTRL_C); }\r
void Can_D_Isr( void ) { Can_Isr(CAN_CTRL_D); }\r
void Can_E_Isr( void ) { Can_Isr(CAN_CTRL_E); }\r
-#if defined(CFG_MPC5567)\r
-#else\r
+#if defined(CFG_MPC5516) || defined(CFG_MPC5517)\r
void Can_F_Isr( void ) { Can_Isr(CAN_CTRL_F); }\r
#endif\r
\r
void Can_C_Err( void ) { Can_Err(CAN_CTRL_C); }\r
void Can_D_Err( void ) { Can_Err(CAN_CTRL_D); }\r
void Can_E_Err( void ) { Can_Err(CAN_CTRL_E); }\r
-#if defined(CFG_MPC5567)\r
-#else\r
+#if defined(CFG_MPC5516) || defined(CFG_MPC5517)\r
void Can_F_Err( void ) { Can_Err(CAN_CTRL_F); }\r
#endif\r
\r
void Can_C_BusOff( void ) { Can_BusOff(CAN_CTRL_C); }\r
void Can_D_BusOff( void ) { Can_BusOff(CAN_CTRL_D); }\r
void Can_E_BusOff( void ) { Can_BusOff(CAN_CTRL_E); }\r
-#if defined(CFG_MPC5567)\r
-#else\r
+#if defined(CFG_MPC5516) || defined(CFG_MPC5517)\r
void Can_F_BusOff( void ) { Can_BusOff(CAN_CTRL_F); }\r
#endif\r
//-------------------------------------------------------------------\r
}\r
}\r
\r
+\r
//-------------------------------------------------------------------\r
\r
-#if defined(USE_KERNEL)\r
-#define INSTALL_HANDLERS( _can_name,_boff,_err,_start,_stop) \\r
- do { \\r
- TaskType tid; \\r
- tid = Os_Arc_CreateIsr(_can_name ## _BusOff,2/*prio*/,"Can"); \\r
- Irq_AttachIsr2(tid,NULL,_boff); \\r
- tid = Os_Arc_CreateIsr(_can_name ## _Err,2/*prio*/,"Can"); \\r
- Irq_AttachIsr2(tid,NULL,_err); \\r
- for(i=_start;i<=_stop;i++) { \\r
- tid = Os_Arc_CreateIsr(_can_name ## _Isr,2/*prio*/,"Can"); \\r
- Irq_AttachIsr2(tid,NULL,i); \\r
- } \\r
- } while(0);\r
-#else\r
-#define INSTALL_HANDLERS( _can_name,_boff,_err,_start,_stop) \\r
- Irq_InstallVector(_can_name ## _BusOff, _boff, 1, CPU_Z1); \\r
- Irq_InstallVector(_can_name ## _Err, _err, 1, CPU_Z1); \\r
- for(i=_start;i<=_stop;i++) { \\r
- Irq_InstallVector(_can_name ## _Isr, i, 1, CPU_Z1); \\r
- }\r
-#endif\r
\r
// This initiates ALL can controllers\r
void Can_Init( const Can_ConfigType *config ) {\r
}\r
} while (!hoh->Can_Arc_EOL);\r
\r
+\r
+\r
// Note!\r
// Could install handlers depending on HW objects to trap more errors\r
// in configuration\r
-#if defined(CFG_MPC5567)\r
- switch( canHwConfig->CanControllerId ) {\r
- case CAN_CTRL_A:\r
- INSTALL_HANDLERS(Can_A, FLEXCAN_A_ESR_BOFF_INT, FLEXCAN_A_ESR_ERR_INT, FLEXCAN_A_IFLAG1_BUF0I, FLEXCAN_A_IFLAG1_BUF31_16I); break;\r
- case CAN_CTRL_B:\r
- INSTALL_HANDLERS(Can_B, FLEXCAN_B_ESR_BOFF_INT, FLEXCAN_B_ESR_ERR_INT, FLEXCAN_B_IFLAG1_BUF0I, FLEXCAN_B_IFLAG1_BUF31_16I); break;\r
- case CAN_CTRL_C:\r
- INSTALL_HANDLERS(Can_C, FLEXCAN_C_ESR_BOFF_INT, FLEXCAN_C_ESR_ERR_INT, FLEXCAN_C_IFLAG1_BUF0I, FLEXCAN_C_IFLAG1_BUF31_16I); break;\r
- case CAN_CTRL_D:\r
- INSTALL_HANDLERS(Can_D, FLEXCAN_D_ESR_BOFF_INT, FLEXCAN_D_ESR_ERR_INT, FLEXCAN_D_IFLAG1_BUF0I, FLEXCAN_D_IFLAG1_BUF31_16I); break;\r
- case CAN_CTRL_E:\r
- INSTALL_HANDLERS(Can_E, FLEXCAN_E_ESR_BOFF_INT, FLEXCAN_E_ESR_ERR_INT, FLEXCAN_E_IFLAG1_BUF0I, FLEXCAN_E_IFLAG1_BUF31_16I); break;\r
- default:\r
- assert(0);\r
- }\r
-#else\r
switch( canHwConfig->CanControllerId ) {\r
case CAN_CTRL_A:\r
- INSTALL_HANDLERS(Can_A, FLEXCAN_A_ESR_BOFF_INT, FLEXCAN_A_ESR_ERR_INT, FLEXCAN_A_IFLAG1_BUF0I, FLEXCAN_A_IFLAG1_BUF31_16I); break;\r
+ INSTALL_HANDLER( Can_A_BusOff, FLEXCAN_A_ESR_BOFF_INT, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER( Can_A_Err, FLEXCAN_A_ESR_ERR_INT, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER16( Can_A_Isr, FLEXCAN_A_IFLAG1_BUF0I, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER( Can_A_Isr, FLEXCAN_A_IFLAG1_BUF31_16I, 2, CPU_CORE0 );\r
+ break;\r
case CAN_CTRL_B:\r
- INSTALL_HANDLERS(Can_B, FLEXCAN_B_ESR_BOFF_INT, FLEXCAN_B_ESR_ERR_INT, FLEXCAN_B_IFLAG1_BUF0I, FLEXCAN_B_IFLAG1_BUF31_16I); break;\r
+ INSTALL_HANDLER( Can_B_BusOff, FLEXCAN_B_ESR_BOFF_INT, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER( Can_B_Err, FLEXCAN_B_ESR_ERR_INT, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER16( Can_B_Isr, FLEXCAN_B_IFLAG1_BUF0I, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER( Can_B_Isr, FLEXCAN_B_IFLAG1_BUF31_16I, 2, CPU_CORE0 );\r
+ break;\r
case CAN_CTRL_C:\r
- INSTALL_HANDLERS(Can_C, FLEXCAN_C_ESR_BOFF_INT, FLEXCAN_C_ESR_ERR_INT, FLEXCAN_C_IFLAG1_BUF0I, FLEXCAN_C_IFLAG1_BUF31_16I); break;\r
+ INSTALL_HANDLER( Can_C_BusOff, FLEXCAN_C_ESR_BOFF_INT, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER( Can_C_Err, FLEXCAN_C_ESR_ERR_INT, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER16( Can_C_Isr, FLEXCAN_C_IFLAG1_BUF0I, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER( Can_C_Isr, FLEXCAN_C_IFLAG1_BUF31_16I, 2, CPU_CORE0 );\r
+ break;\r
case CAN_CTRL_D:\r
- INSTALL_HANDLERS(Can_D, FLEXCAN_D_ESR_BOFF_INT, FLEXCAN_D_ESR_ERR_INT, FLEXCAN_D_IFLAG1_BUF0I, FLEXCAN_D_IFLAG1_BUF31_16I); break;\r
+ INSTALL_HANDLER( Can_D_BusOff, FLEXCAN_D_ESR_BOFF_INT, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER( Can_D_Err, FLEXCAN_D_ESR_ERR_INT, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER16( Can_D_Isr, FLEXCAN_D_IFLAG1_BUF0I, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER( Can_D_Isr, FLEXCAN_D_IFLAG1_BUF31_16I, 2, CPU_CORE0 );\r
+ break;\r
case CAN_CTRL_E:\r
- INSTALL_HANDLERS(Can_E, FLEXCAN_E_ESR_BOFF_INT, FLEXCAN_E_ESR_ERR_INT, FLEXCAN_E_IFLAG1_BUF0I, FLEXCAN_E_IFLAG1_BUF31_16I); break;\r
+ INSTALL_HANDLER( Can_E_BusOff, FLEXCAN_E_ESR_BOFF_INT, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER( Can_E_Err, FLEXCAN_E_ESR_ERR_INT, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER16( Can_E_Isr, FLEXCAN_E_IFLAG1_BUF0I, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER( Can_E_Isr, FLEXCAN_E_IFLAG1_BUF31_16I, 2, CPU_CORE0 );\r
+ break;\r
+#if defined(CFG_MPC5516) || defined(CFG_MPC5517)\r
case CAN_CTRL_F:\r
- INSTALL_HANDLERS(Can_F, FLEXCAN_F_ESR_BOFF_INT, FLEXCAN_F_ESR_ERR_INT, FLEXCAN_F_IFLAG1_BUF0I, FLEXCAN_F_IFLAG1_BUF31_16I); break;\r
+ INSTALL_HANDLER( Can_F_BusOff, FLEXCAN_F_ESR_BOFF_INT, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER( Can_F_Err, FLEXCAN_F_ESR_ERR_INT, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER16( Can_F_Isr, FLEXCAN_F_IFLAG1_BUF0I, 2, CPU_CORE0 );\r
+ INSTALL_HANDLER( Can_F_Isr, FLEXCAN_F_IFLAG1_BUF31_16I, 2, CPU_CORE0 );\r
+ break;\r
+#endif\r
default:\r
assert(0);\r
}\r
-#endif\r
}\r
return;\r
}\r
#include "Det.h"\r
#if defined(USE_KERNEL)\r
#include "Os.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#endif\r
\r
// Implementation specific\r
#include "LinIf_Cbk.h"\r
#if defined(USE_KERNEL)\r
#include "Os.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#endif\r
\r
#define ESCI(exp) (volatile struct ESCI_tag *)(0xFFFA0000 + (0x4000 * exp))\r
* -------------------------------- Arctic Core ------------------------------*/\r
\r
\r
-\r
-\r
-\r
-\r
-\r
-\r
+/* ----------------------------[includes]------------------------------------*/\r
#include <assert.h>\r
#include <string.h>\r
#include "Std_Types.h"\r
#include "Cpu.h"\r
#include "Ramlog.h"\r
#include "Os.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
\r
+/* ----------------------------[private define]------------------------------*/\r
//#define USE_LDEBUG_PRINTF 1\r
#include "debug.h"\r
\r
#define SYSCLOCK_SELECT_PLL 0x2\r
\r
+/* ----------------------------[private macro]-------------------------------*/\r
+\r
#if defined(CFG_MPC5567)\r
#define CALC_SYSTEM_CLOCK(_extal,_emfd,_eprediv,_erfd) \\r
( (_extal) * ((_emfd)+4) / (((_eprediv)+1)*(1<<(_erfd))) )\r
( (_extal) * ((_emfd)+16) / (((_eprediv)+1)*((_erfd)+1)) )\r
#endif\r
\r
-typedef void (*vfunc_t)();\r
+/* Development error macros. */\r
+#if ( MCU_DEV_ERROR_DETECT == STD_ON )\r
+#define VALIDATE(_exp,_api,_err ) \\r
+ if( !(_exp) ) { \\r
+ Det_ReportError(MODULE_ID_MCU,0,_api,_err); \\r
+ return; \\r
+ }\r
+\r
+#define VALIDATE_W_RV(_exp,_api,_err,_rv ) \\r
+ if( !(_exp) ) { \\r
+ Det_ReportError(MODULE_ID_MCU,0,_api,_err); \\r
+ return (_rv); \\r
+ }\r
+#else\r
+#define VALIDATE(_exp,_api,_err )\r
+#define VALIDATE_W_RV(_exp,_api,_err,_rv )\r
+#endif\r
\r
-/* Function declarations. */\r
-static void Mcu_ConfigureFlash(void);\r
\r
+/* ----------------------------[private typedef]-----------------------------*/\r
+typedef void (*vfunc_t)();\r
\r
typedef struct {\r
uint32 lossOfLockCnt;\r
\r
} Mcu_GlobalType;\r
\r
-/* Development error macros. */\r
-#if ( MCU_DEV_ERROR_DETECT == STD_ON )\r
-#define VALIDATE(_exp,_api,_err ) \\r
- if( !(_exp) ) { \\r
- Det_ReportError(MODULE_ID_MCU,0,_api,_err); \\r
- return; \\r
- }\r
\r
-#define VALIDATE_W_RV(_exp,_api,_err,_rv ) \\r
- if( !(_exp) ) { \\r
- Det_ReportError(MODULE_ID_MCU,0,_api,_err); \\r
- return (_rv); \\r
- }\r
-#else\r
-#define VALIDATE(_exp,_api,_err )\r
-#define VALIDATE_W_RV(_exp,_api,_err,_rv )\r
-#endif\r
+/* ----------------------------[private function prototypes]-----------------*/\r
+static void Mcu_ConfigureFlash(void);\r
+/* ----------------------------[private variables]---------------------------*/\r
\r
// Global config\r
Mcu_GlobalType Mcu_Global =\r
.config = &McuConfigData[0],\r
};\r
\r
-//-------------------------------------------------------------------\r
+/* ----------------------------[private functions]---------------------------*/\r
+/* ----------------------------[public functions]----------------------------*/\r
\r
-static void Mcu_LossOfLock( void ) {\r
+\r
+/**\r
+ * ISR wh\r
+ */\r
+void Mcu_LossOfLock( void ) {\r
#if defined(USE_DEM)\r
Dem_ReportErrorStatus(MCU_E_CLOCK_FAILURE, DEM_EVENT_STATUS_FAILED);\r
#endif\r
\r
}\r
\r
-//-------------------------------------------------------------------\r
-static void Mcu_LossOfCLock( void ) {\r
+/**\r
+ *\r
+ */\r
+void Mcu_LossOfClock( void ) {\r
\r
/* Should report MCU_E_CLOCK_FAILURE with DEM here */\r
\r
}\r
\r
\r
+\r
//-------------------------------------------------------------------\r
\r
-void Mcu_Init(const Mcu_ConfigType *configPtr)\r
-{\r
- VALIDATE( ( NULL != configPtr ), MCU_INIT_SERVICE_ID, MCU_E_PARAM_CONFIG );\r
+void Mcu_Init(const Mcu_ConfigType *configPtr) {\r
+#if 0\r
+ IRQ_DECL_ISR1( "LossOfLock", PLL_SYNSR_LOLF, CPU_CORE0, 10, Mcu_LossOfLock );\r
+ IRQ_DECL_ISR1( "LossOfClock", PLL_SYNSR_LOCF, CPU_CORE0, 10, Mcu_LossOfClock );\r
+#endif\r
\r
- if( !SIMULATOR() ) {\r
- Mcu_CheckCpu();\r
- }\r
+ VALIDATE( ( NULL != configPtr ), MCU_INIT_SERVICE_ID, MCU_E_PARAM_CONFIG );\r
\r
- memset(&Mcu_Global.stats,0,sizeof(Mcu_Global.stats));\r
+ if (!SIMULATOR()) {\r
+ Mcu_CheckCpu();\r
+ }\r
\r
+ memset(&Mcu_Global.stats, 0, sizeof(Mcu_Global.stats));\r
\r
- //\r
- // Setup memories\r
- //\r
- Mcu_ConfigureFlash();\r
+ //\r
+ // Setup memories\r
+ //\r
+ Mcu_ConfigureFlash();\r
\r
- Mcu_Global.config = configPtr;\r
- Mcu_Global.initRun = 1;\r
+ Mcu_Global.config = configPtr;\r
+ Mcu_Global.initRun = 1;\r
\r
- if( Mcu_Global.config->McuClockSrcFailureNotification == TRUE ){\r
- // Enable loss of lock interrupt\r
+ if (Mcu_Global.config->McuClockSrcFailureNotification == TRUE) {\r
+ // Enable loss of lock interrupt\r
\r
- Irq_AttachIsr1(Mcu_LossOfLock, NULL, PLL_SYNSR_LOLF,10 );\r
+// IRQ_ATTACH( PLL_SYNSR_LOLF );\r
+ //Irq_Attach( &IRQ_NAME(PLL_SYNSR_LOLF) );\r
+// Irq_AttachIsr1(Mcu_LossOfLock, NULL, PLL_SYNSR_LOLF, 10);\r
#if defined(CFG_MPC5516)\r
-// FMPLL.SYNCR.B.LOCIRQ = 1; TODO: Kolla denna bortkommentering med MÃ¥rten.\r
- FMPLL.ESYNCR2.B.LOLIRQ = 1;\r
+ FMPLL.ESYNCR2.B.LOLIRQ = 1;\r
#elif defined(CFG_MPC5554) || defined(CFG_MPC5567)\r
- FMPLL.SYNCR.B.LOLIRQ = 1;\r
+ FMPLL.SYNCR.B.LOLIRQ = 1;\r
#endif\r
- Irq_AttachIsr1(Mcu_LossOfCLock, NULL, PLL_SYNSR_LOCF,10 );\r
+\r
+// IRQ_ATTACH( PLL_SYNSR_LOLF );\r
+// Irq_Attach( &IRQ_NAME(PLL_SYNSR_LOLF));\r
+// Irq_AttachIsr1(Mcu_LossOfClock, NULL, PLL_SYNSR_LOCF, 10);\r
#if defined(CFG_MPC5516)\r
-// FMPLL.SYNCR.B.LOCIRQ = 1; TODO: Kolla denna bortkommentering med MÃ¥rten.\r
- FMPLL.ESYNCR2.B.LOCIRQ = 1;\r
+ FMPLL.ESYNCR2.B.LOCIRQ = 1;\r
#elif defined(CFG_MPC5554) || defined(CFG_MPC5567)\r
- FMPLL.SYNCR.B.LOCIRQ = 1;\r
+ FMPLL.SYNCR.B.LOCIRQ = 1;\r
#endif\r
- }\r
+ }\r
}\r
//-------------------------------------------------------------------\r
\r
\r
/**\r
* Get the peripheral clock in Hz for a specific device\r
+ *\r
+ * @param type\r
+ * @return\r
*/\r
-\r
uint32_t McuE_GetPeripheralClock(McuE_PeriperalClock_t type)\r
{\r
#if defined(CFG_MPC5567)\r
\r
#include "Os.h"\r
#include "internal.h"\r
-#include "irq.h"\r
+#include "isr.h"\r
#include "arc.h"\r
\r
/**\r
* Init of free running timer.\r
*/\r
void Os_SysTickInit( void ) {\r
- TaskType tid;\r
+// TaskType tid;\r
+\r
+// Irq_Attach(INTC_SSCIR0_CLR7);\r
+// Irq_Attach2( INTC_SSCIR0_CLR7 );\r
+\r
+#if 0\r
+ IRQ_DECL_ISR2("MyIsr", 7 , CPU_CORE0, 6 , OsTick, 0 , NULL );\r
+ IRQ_ATTACH(7);\r
+\r
+// else\r
tid = Os_Arc_CreateIsr(OsTick,6/*prio*/,"OsTick");\r
Irq_AttachIsr2(tid,NULL,7);\r
+#endif\r
}\r
\r
/**\r
\r
/**\r
* NOT complete yet.....\r
- *
- * @param err The error code.
+ *\r
+ * @param err The error code.\r
* @param errFramePtr Pointer to extra information about the error, if any.\r
- * @param excFramePtr Pointer to the exception frame, that cause the error.
+ * @param excFramePtr Pointer to the exception frame, that cause the error.\r
*/\r
void Os_ArchPanic( uint32_t err, void *errFramePtr , Os_ExceptionFrameType *excFramePtr) {\r
switch(err) {\r
\r
/**\r
* Setup a context for a task.\r
- *
- * @param pcb Pointer to the pcb to setup
+ *\r
+ * @param pcb Pointer to the pcb to setup\r
*/\r
void Os_ArchSetupContext( OsPcbType *pcbPtr ) {\r
Os_FuncFrameType *cPtr = (Os_FuncFrameType *)pcbPtr->stack.curr;\r
+\r
/* -------------------------------- Arctic Core ------------------------------\r
* Arctic Core - the open source AUTOSAR platform http://arccore.com\r
*\r
/* ----------------------------[public functions]----------------------------*/\r
\r
\r
+/* ----------------------------[includes]------------------------------------*/\r
+\r
#include "internal.h"\r
+#include "asm_book_e.h"\r
#include "irq_types.h"\r
#include "mpc55xx.h"\r
-\r
-\r
#include "pcb.h"\r
#include "sys.h"\r
#include "internal.h"\r
#include "task_i.h"\r
#include "hooks.h"\r
+#include "debug.h"\r
+#include "isr.h"\r
+#include "irq_config.h"\r
+#include <stdint.h>\r
\r
+/* ----------------------------[private define]------------------------------*/\r
+/* ----------------------------[private macro]-------------------------------*/\r
+/* ----------------------------[private typedef]-----------------------------*/\r
+typedef void (*f_t)( uint32_t *);\r
\r
-#include "debug.h"\r
+/* ----------------------------[private function prototypes]-----------------*/\r
+//extern uintptr_t Irq_VectorTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];\r
+//extern uint8 Irq_IsrTypeTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];\r
+//extern const OsIsrConstType *Irq_Map[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];\r
\r
-#include "irq.h"\r
+static void dumpExceptionRegs( uint32_t *regs );\r
\r
-typedef void (*f_t)( uint32_t *);\r
+/* ----------------------------[private variables]---------------------------*/\r
extern void exception_tbl(void);\r
\r
-\r
-extern void * Irq_VectorTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];\r
-//extern uint8 Irq_IsrTypeTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];\r
+/* ----------------------------[private functions]---------------------------*/\r
+/* ----------------------------[public functions]----------------------------*/\r
\r
// write 0 to pop INTC stack\r
void Irq_Init( void ) {\r
INTC.MCR.B.VTES = 0; // 4 byte offset between entries\r
#endif\r
\r
-\r
-\r
-#if 1\r
- // Check alignment requirements for the INTC table\r
- assert( (((uint32_t)&Irq_VectorTable[0]) & 0x7ff) == 0 );\r
- #if defined(CFG_MPC5516)\r
- INTC.IACKR_PRC0.R = (uint32_t) & Irq_VectorTable[0]; // Set INTC ISR vector table\r
- #elif defined(CFG_MPC5554) || defined(CFG_MPC5567)\r
- INTC.IACKR.R = (uint32_t) & Irq_VectorTable[0]; // Set INTC ISR vector table\r
- #endif\r
-#endif\r
// Pop the FIFO queue\r
for (int i = 0; i < 15; i++)\r
{\r
#elif defined(CFG_MPC5554) || defined(CFG_MPC5567)\r
INTC.CPR.B.PRI = 0;\r
#endif\r
-\r
}\r
\r
void Irq_EOI( void ) {\r
#if defined(CFG_MPC5516)\r
- volatile struct INTC_tag *intc = &INTC;\r
+ struct INTC_tag *intc = &INTC;\r
intc->EOIR_PRC0.R = 0;\r
#elif defined(CFG_MPC5554)||defined(CFG_MPC5567)\r
volatile struct INTC_tag *intc = &INTC;\r
#endif\r
}\r
\r
-#if 0\r
+\r
/**\r
*\r
* @param stack_p Ptr to the current stack.\r
void *Irq_Entry( void *stack_p )\r
{\r
uint32_t vector;\r
- volatile struct INTC_tag *intc = &INTC;\r
+ uint32_t *stack = (uint32_t *)stack_p;\r
+ uint32_t exc_vector = (EXC_OFF_FROM_BOTTOM+EXC_VECTOR_OFF) / sizeof(uint32_t);\r
+ const OsIsrConstType *isr;\r
\r
+ // Check for exception\r
+ if( stack[exc_vector]>=CRITICAL_INPUT_EXCEPTION )\r
+ {\r
+ vector = stack[exc_vector];\r
+ }\r
+ else\r
+ {\r
#if defined(CFG_MPC5516)\r
- vector = (intc->IACKR_PRC0.B.INTVEC_PRC0);\r
+ struct INTC_tag *intc = &INTC;\r
+ vector = (intc->IACKR_PRC0.B.INTVEC_PRC0);\r
#elif defined(CFG_MPC5554)||defined(CFG_MPC5567)\r
- vector = (intc->IACKR.B.INTVEC);\r
+ volatile struct INTC_tag *intc = &INTC;\r
+ vector = (intc->IACKR.B.INTVEC);\r
#endif\r
- // Clear software int if that was it.\r
- if(vector<=INTC_SSCIR0_CLR7)\r
- {\r
- intc->SSCIR[vector].B.CLR = 1;\r
- asm("mbar 0");\r
+ // save the vector for later\r
+ stack[exc_vector] = vector;\r
+\r
+ // Check for software interrupt\r
+ if((uint32_t)vector<=INTC_SSCIR0_CLR7)\r
+ {\r
+ // Clear soft int\r
+ intc->SSCIR[vector].B.CLR = 1;\r
+ asm("mbar 0");\r
+ }\r
}\r
\r
- if( Irq_GetIsrType(vector) == ISR_TYPE_1 ) {\r
- // It's a function, just call it.\r
- ((func_t)Irq_VectorTable[vector])();\r
- return stack_p;\r
+ isr = Os_IsrGet(exc_vector);\r
+ if( isr->type == ISR_TYPE_1 ) {\r
+ isr->entry();\r
+ return stack;\r
} else {\r
- // It's a PCB\r
- // Let the kernel handle the rest,\r
- return Os_Isr(stack_p, (void *)Irq_VectorTable[vector]);\r
+ return Os_Isr(stack, vector);\r
}\r
}\r
\r
-#endif\r
-\r
-\r
-\r
-\r
static inline int osPrioToCpuPio( uint8_t prio ) {\r
assert(prio<32);\r
return prio>>1; // Os have 32 -> 16\r
\r
\r
\r
+#if 0\r
/**\r
* Attach an ISR type 1 to the interrupt controller.\r
*\r
}\r
\r
}\r
+#endif\r
+\r
+\r
+void Irq_EnableVector( int16_t vector, int priority, int core ) {\r
+\r
+ if (vector < INTC_NUMBER_OF_INTERRUPTS) {\r
+ Irq_SetPriority(core,vector + IRQ_INTERRUPT_OFFSET, osPrioToCpuPio(priority));\r
+ } else if ((vector >= CRITICAL_INPUT_EXCEPTION)\r
+ && (vector<= DEBUG_EXCEPTION)) {\r
+ } else {\r
+ /* Invalid vector! */\r
+ assert(0);\r
+ }\r
+}\r
+\r
+\r
+\r
+#if 0\r
\r
+/**\r
+ *\r
+ * @param isrPtr\r
+ * @param type\r
+ * @param int_ctrl\r
+ */\r
+ISRType Irq_Attach( int vector ) {\r
+// Os_Sys.isrCnt\r
+// uint32_t vector = isrPtr->vector;\r
+\r
+ //Irq_VectorTable[vector] = (uintptr_t)isrPtr;\r
+// Irq_IsrTypeTable[vector] = type;\r
+// Irq_VectorTable[vector] = isrPtr;\r
+\r
+\r
+ if (vector < INTC_NUMBER_OF_INTERRUPTS) {\r
+ Irq_SetPriority(Irq_Map[vector]->core ,vector + IRQ_INTERRUPT_OFFSET, osPrioToCpuPio(Irq_Map[vector]->priority));\r
+ } else if ((vector >= CRITICAL_INPUT_EXCEPTION)\r
+ && (vector<= DEBUG_EXCEPTION)) {\r
+ } else {\r
+ /* Invalid vector! */\r
+ assert(0);\r
+ }\r
+\r
+\r
+ return;\r
+}\r
+#endif\r
+\r
+#if 0\r
/**\r
* Attach a ISR type 2 to the interrupt controller.\r
*\r
* @param vector\r
*/\r
void Irq_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) {\r
- OsPcbType *pcb;\r
+ OsTaskVarType *pcb;\r
\r
- pcb = os_find_task(tid);\r
- Irq_VectorTable[vector] = pcb;\r
+ pcb = Os_TaskGet(tid);\r
+ Irq_VectorTable[vector] = (void *)pcb;\r
Irq_IsrTypeTable[vector] = PROC_ISR2;\r
\r
if (vector < INTC_NUMBER_OF_INTERRUPTS) {\r
assert(0);\r
}\r
}\r
+#endif\r
\r
\r
/**\r
}\r
\r
\r
+\r
+void dummy (void);\r
+\r
+// Critical Input Interrupt\r
+void IVOR0Exception (uint32_t *regs)\r
+{\r
+// srr0 = get_spr(SPR_SRR0);\r
+// srr1 = get_spr(SPR_SRR0);\r
+// ExceptionSave(srr0,srr1,esr,mcsr,dear;)\r
+ // CSRR0, CSSR1\r
+ // Nothing more\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+\r
+// Machine check\r
+void IVOR1Exception (uint32_t *regs)\r
+{\r
+ // CSRR0, CSSR1\r
+ // MCSR - Source of machine check\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+// Data Storage Interrupt\r
+void IVOR2Exception (uint32_t *regs)\r
+{\r
+ // SRR0, SRR1\r
+ // ESR - lots of stuff\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+\r
+// Instruction Storage Interrupt\r
+void IVOR3Exception (uint32_t *regs)\r
+{\r
+ // SRR0, SRR1\r
+ // ESR - lots of stuff\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+\r
+// Alignment Interrupt\r
+void IVOR5Exception (uint32_t *regs)\r
+{\r
+ // SRR0, SRR1\r
+ // ESR - lots of stuff\r
+ // DEAR - Address of load store that caused the exception\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+\r
+// Program Interrupt\r
+void IVOR6Exception (uint32_t *regs)\r
+{\r
+ // SRR0, SRR1\r
+ // ESR - lots of stuff\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+\r
+// Floating point unavailable\r
+void IVOR7Exception (uint32_t *regs)\r
+{\r
+ // SRR0, SRR1\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+\r
+// System call\r
+void IVOR8Exception (uint32_t *regs)\r
+{\r
+ // SRR0, SRR1\r
+ // ESR\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+\r
+// Aux processor Unavailable\r
+void IVOR9Exception (uint32_t *regs)\r
+{\r
+ // Does not happen on e200\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+#if 0\r
+// Decrementer\r
+void IVOR10Exception (uint32_t *regs)\r
+{\r
+ // SRR0, SRR1\r
+ while (1);\r
+}\r
+#endif\r
+\r
+// FIT\r
+void IVOR11Exception (uint32_t *regs)\r
+{\r
+ // SRR0, SRR1\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+\r
+// Watchdog Timer\r
+void IVOR12Exception (uint32_t *regs)\r
+{\r
+ // SRR0, SRR1\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+\r
+// Data TLB Error Interrupt\r
+void IVOR13Exception (uint32_t *regs)\r
+{\r
+\r
+ // SRR0, SRR1\r
+ // ESR - lots\r
+ // DEAR -\r
+ while (1);\r
+}\r
+\r
+// Instruction TLB Error Interupt\r
+void IVOR14Exception (uint32_t *regs)\r
+{\r
+ // SRR0, SRR1\r
+ // ESR - MIF set, All others cleared\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+\r
+void IVOR15Exception (uint32_t *regs)\r
+{\r
+ // Debug\r
+ dumpExceptionRegs(regs);\r
+ while (1);\r
+}\r
+\r
+#if defined(CFG_CONSOLE_T32) || defined(CFG_CONSOLE_WINIDEA)\r
+\r
+typedef struct {\r
+ uint32_t sp;\r
+ uint32_t bc; // backchain\r
+ uint32_t pad;\r
+ uint32_t srr0;\r
+ uint32_t srr1;\r
+ uint32_t lr;\r
+ uint32_t ctr;\r
+ uint32_t xer;\r
+ uint32_t cr;\r
+ uint32_t esr;\r
+ uint32_t mcsr;\r
+ uint32_t dear;\r
+ uint32_t vector;\r
+ uint32_t r3;\r
+ uint32_t r4;\r
+} exc_stack_t;\r
+\r
+\r
+\r
+static void dumpExceptionRegs( uint32_t *regs ) {\r
+ exc_stack_t *r = (exc_stack_t *)regs;\r
+\r
+ LDEBUG_PRINTF("sp %08x srr0 %08x srr1 %08x\n",r->sp,r->srr0,r->srr1);\r
+ LDEBUG_PRINTF("lr %08x ctr %08x xer %08x\n",r->lr,r->ctr,r->xer);\r
+ LDEBUG_PRINTF("cr %08x esr %08x mcsr %08x\n",r->cr,r->esr,r->mcsr);\r
+ LDEBUG_PRINTF("dear %08x vec %08x r3 %08x\n",r->dear,r->vector,r->r3);\r
+ LDEBUG_PRINTF("r4 %08x\n",r->r4);\r
+}\r
+\r
+#else\r
+static void dumpExceptionRegs( uint32_t *regs ) {\r
+}\r
+#endif\r
+\r
OUTPUT_ARCH(powerpc)\r
ENTRY(_start)\r
\r
-\r
+/*\r
+ * _idata - Start of .data in flash \r
+ * _data - start address of .data in RAM\r
+ * _edata - end address of .data in RAM\r
+ * _bss - start address of .bss\r
+ * _ebss - end address of .bss\r
+ * _etext - end of .text\r
+ * _end - End of something.... \r
+ * \r
+ * More stuff:\r
+ * \r
+ * _arc_heap_start\r
+ * _arc_heap_end\r
+ * _arc_stack\r
+ *\r
+ * Dwarf stuff: (same as Dwarf3 .debug_frame? )\r
+ * eh_frame_hdr (C++ only? unwind info for C++ exceptions?)\r
+ * eh_frame (C++ only?)\r
+ *\r
+ * Exception table:\r
+ * _exc_frame_start\r
+ * _exc_frame_end\r
+ *\r
+ * PowerPC EABI special:\r
+ * _SDA2_BASE_\r
+ * _SDA_BASE\r
+ */\r
\r
MEMORY\r
{\r
\r
.data : {\r
. = . + ALIGN(4);\r
- __DATA_RAM = .; *(.data .data.* .gnu.linkonce.d.* .gnu.linkonce.r.* .eh_frame)\r
+ __DATA_RAM = .; \r
+ *(.data .data.* .gnu.linkonce.d.* .gnu.linkonce.r.* .eh_frame)\r
} > ram AT> flash\r
\r
.sdata : {\r
__SBSS_START__ = .;\r
*(.sbss .sbss.* .scommon .gnu.linkonce.sb.* .t32_outport);\r
__SBSS_END__ = .;\r
+ _end = .;\r
} > ram\r
\r
- .got2 ALIGN(0x10): {. = . + ALIGN(16);*(.got2); . = . + ALIGN(8); } > ram\r
- .fixup : { . = . + ALIGN(16);*(.fixup); . = . + ALIGN(8); } > ram\r
- .t32_outport ALIGN(0x10): { *(.t32_outport); } > ram\r
- .got : AT(ALIGN(LOADADDR(.sdata)+SIZEOF(.sdata),4)) { *(.got.plt) *(.got) } > ram\r
- /* .bss : { *(.bss .bss.* COMMON .gnu.linkonce.b.*);__BSS_END = .; } > ram */\r
- .bss : AT(ADDR(.bss)) { *(.bss .bss.* COMMON .gnu.linkonce.b.*);__BSS_END = .; } > ram\r
- .init_stack ALIGN(16) (NOLOAD) : { __SP_END = .;. = . + 1000; __SP_INIT = .; } > ram\r
+ .got2 ALIGN(0x10): \r
+ {\r
+ . = . + ALIGN(16);\r
+ *(.got2); \r
+ . = . + ALIGN(8); \r
+ } > ram\r
+ .fixup : \r
+ { \r
+ . = . + ALIGN(16);\r
+ *(.fixup);\r
+ . = . + ALIGN(8); \r
+ } > ram\r
+ .t32_outport ALIGN(0x10): \r
+ { \r
+ *(.t32_outport); \r
+ } > ram\r
+ \r
+ .got : AT(ALIGN(LOADADDR(.sdata)+SIZEOF(.sdata),4)) \r
+ { \r
+ *(.got.plt) *(.got) \r
+ } > ram\r
+ \r
+ .bss : AT(ADDR(.bss)) \r
+ { \r
+ *(.bss .bss.* COMMON .gnu.linkonce.b.*);\r
+ __BSS_END = .; \r
+ } > ram\r
+ .init_stack ALIGN(16) (NOLOAD) : \r
+ { \r
+ __SP_END = .;\r
+ . = . + 1000; \r
+ __SP_INIT = .; \r
+ } > ram\r
+ \r
/* Fls RAM section */\r
.fls_ram ALIGN(16) (NOLOAD) : {\r
__FLS_ERASE_RAM__ = .;\r
. = . + SIZEOF(.fls_rom);\r
} > ram\r
+ \r
+ /* Always place last in RAM */\r
+ .heap ALIGN(0x4): {\r
+ PROVIDE(_heap_start = .);\r
+ } > ram\r
+ \r
\r
.ctors :\r
{\r
.debug_varnames 0 : { *(.debug_varnames) }\r
}\r
\r
+_heap_end = ORIGIN(ram) + LENGTH(ram);\r
+\r
__TEXT_START = ADDR(.text);\r
__RAM_START = ADDR(.sdata);\r
\r
\r
+_BOARD_COMMON_MK:=y # Include guard for backwards compatability\r
+\r
obj-$(CFG_PPC) += crt0.o\r
obj-$(CFG_HC1X) += crt0.o\r
\r
\r
# libs needed by us\r
#build-lib-y += $(ROOTDIR)/libs/libboard_$(BOARDDIR).a\r
+\r
\r
/* If we use malloc and it runs out of memory it calls sbrk()\r
*/\r
-#if 1\r
\r
+#if defined(PPC)\r
+\r
+/* linker symbols */\r
+extern char _heap_start;\r
+extern char _heap_end; // same as _end?\r
+\r
+void * sbrk( ptrdiff_t incr )\r
+{\r
+ char *prevEnd;\r
+ static char *nextAvailMemPtr = (char *)&_heap_start;\r
+\r
+ if( nextAvailMemPtr + incr > (char*)&_heap_end) {\r
+ write( 2, "Heap overflow!\n", 15 );\r
+ abort();\r
+ }\r
+ prevEnd = nextAvailMemPtr;\r
+ nextAvailMemPtr += incr;\r
+ return prevEnd;\r
+}\r
+#else\r
extern char _end[];\r
\r
//static char *curbrk = _end;\r
\r
return (caddr_t) prev_heap_end;\r
}\r
-#else\r
-void *sbrk(int inc )\r
-{\r
- /* We use our own malloc */\r
- return (void *)(-1);\r
-}\r
#endif\r
\r
int stat( const char *file, struct stat *st ) {\r
\r
\r
uint16_t handle_SysMonCommand(TCF_Command* command, char* buf) {\r
- OsPcbType *iterPcbPtr;\r
+ OsTaskVarType *iterPcbPtr;\r
\r
/* Start building return message */\r
start_tcf_field(buf, (char *)TCF_S_R); /* Start */\r
\r
/* Add data field */\r
mystrcat(buf, JSON_ListStart);\r
- TAILQ_FOREACH(iterPcbPtr,& os_sys.pcb_head,pcb_list) {\r
+ TAILQ_FOREACH(iterPcbPtr,& Os_Sys.pcb_head,pcb_list) {\r
if(iterPcbPtr->proc_type < 4)\r
{\r
if(first){\r
\r
/* Add data field */\r
char *arg = command->arguments + 1; /* add 1 for " */\r
- TAILQ_FOREACH(iterPcbPtr,& os_sys.pcb_head,pcb_list) {\r
+ TAILQ_FOREACH(iterPcbPtr,& Os_Sys.pcb_head,pcb_list) {\r
if(strncmp(arg, iterPcbPtr->name, strlen(command->arguments)-2) == 0)\r
{\r
break;\r
#define OS_OSIDLE_STACK_SIZE 512\r
\r
#define OS_ALARM_CNT 3 \r
-#define OS_TASK_CNT 5\r
+#define OS_TASK_CNT 6\r
#define OS_SCHTBL_CNT 0\r
#define OS_COUNTER_CNT 1\r
#define OS_EVENTS_CNT 0\r
\r
/* FIXME: OSMEMORY_IS__ , see 8.2*/\r
\r
+#define OSMEMORY_IS_READABLE(_access)\r
+#define OSMEMORY_IS_WRITEABLE(_access)\r
+#define OSMEMORY_IS_EXECUTABLE(_access)\r
+#define OSMEMORY_IS_STACKSPACE(_access)\r
+\r
#define OSDEFAULTAPPMODE 1\r
\r
#define INVALID_OSAPPLICATION (-1)\r
\r
/* TODO, I have no idea what this should be*/\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
typedef sint32 ApplicationType;\r
\r
+typedef enum {\r
+ APPLICATION_ACCESSIBLE,\r
+ APPLICATION_RESTARTING,\r
+ APPLICATION_TERMINATED\r
+} ApplicationStateType;\r
+\r
+typedef ApplicationStateType *ApplicationStateRefType;\r
+#endif\r
+\r
/* See oil config for defines */\r
typedef sint32 AppModeType;\r
\r
#define INVALID_ISR ((sint16)(-1))\r
typedef sint16 ISRType;\r
\r
+#define APP_NO_OWNER (-1UL)\r
+\r
typedef void * MemoryStartAddressType;\r
typedef uint32 MemorySizeType;\r
\r
\r
\r
\r
-ApplicationType GetApplicationID( void );\r
ISRType GetISRID( void );\r
StatusType GetActiveApplicationMode( AppModeType* mode);\r
\r
/*\r
* Class 2,3 and 4 API\r
*/\r
+\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+\r
ApplicationType GetApplicationID( void );\r
AccessType CheckISRMemoryAccess( ISRType ISRID,\r
MemoryStartAddressType Address,\r
MemoryStartAddressType Address,\r
MemorySizeType Size );\r
\r
+ObjectAccessType CheckObjectAccess( ApplicationType ApplId,\r
+ ObjectTypeType ObjectType,\r
+ uint32_t objectId );\r
+ApplicationType CheckObjectOwnership( ObjectTypeType ObjectType,\r
+ uint32_t objectId );\r
+StatusType TerminateApplication( ApplicationType Application, RestartType RestartOption );\r
+StatusType AllowAccess( void );\r
+StatusType GetApplicationState( ApplicationType Application, ApplicationStateRefType Value );\r
StatusType CallTrustedFunction( TrustedFunctionIndexType FunctionIndex,\r
TrustedFunctionParameterRefType FunctionParams );\r
+#endif\r
\r
StatusType GetTaskID( TaskRefType TaskID );\r
StatusType GetTaskState( TaskType task_id, TaskStateRefType state);\r
#ifndef BIT_H_\r
#define BIT_H_\r
\r
+#include <stdint.h>\r
/**\r
* @param aPtr Ptr to an array of unsigned chars.\r
* @param num The bit number to get.\r
#ifndef IRQ_H_\r
#define IRQ_H_\r
\r
+#include <stdint.h>\r
+#include "os.h"\r
#include "irq_types.h"\r
#include "bit.h"\r
\r
typedef void ( * func_t)(void);\r
\r
-extern uint8_t Irq_PriorityTable[];\r
-extern uint8_t Irq_IsrTypeTable[];\r
\r
-#define ISR_TYPE_1 0\r
-#define ISR_TYPE_2 1\r
\r
-typedef _Bool IsrType;\r
+#if (OS_SC2==STD_ON) || (OS_SC4==STD_ON)\r
+#define HAVE_SC2_SC4(_value) _value\r
+#else\r
+#define HAVE_SC2_SC4(_value)\r
+#endif\r
+\r
+#define IRQ_NAME(_vector) IrqVector_ ## _vector\r
+\r
+#define IRQ_DECL_ISR2_TIMING_PROT( \\r
+ _name, \\r
+ _max_all_interrupt_lock_time, \\r
+ _exeution_budget, \\r
+ _os_interrupt_lock_budget, \\r
+ _time_frame, \\r
+ _resource_lock_list )\r
+\r
+\r
+#define IRQ_DECL_ISR1(_name, _vector, _core, _prio, _entry ) \\r
+ const OsIsrConstType Irq_VectorConst_ ## _vector = { \\r
+ .name = _name, \\r
+ .vector = (_vector), \\r
+ .core = (_core), \\r
+ .prio = (_prio), \\r
+ .entry = (_entry), \\r
+ .type = ISR_TYPE_1, \\r
+ }\r
+\r
+\r
+#define IRQ_DECL_ISR2(_name,_vector, _core, _prio, _entry, _resource_mask, _timing_prot) \\r
+ const OsIsrConstType Irq_VectorConst_ ## _vector = { \\r
+ .name = _name, \\r
+ .vector = (_vector), \\r
+ .core = (_core), \\r
+ .prio = (_prio), \\r
+ .entry = (_entry), \\r
+ .type = ISR_TYPE_2, \\r
+ .resourceMask = (_resource_mask), \\r
+ .timingProtPtr = (_timing_prot) \\r
+ }\r
+\r
+\r
+#define IRQ_ATTACH(_vector) Irq_Attach(&Irq_VectorConst_ ## _vector)\r
+\r
+/* Example:\r
+ * IRQ_DECL_ISR2_RESOURCE(res2, RES_ID_2, 500000U ); // Max 50us\r
+ * IRQ_DECL_ISR2_TIMING_PROT(timing,0,0,0,0,res2);\r
+ * IRQ_DECL_ISR2("MyIsr",10,10,MyIsr,HAVE_SC2_SC4(RES_ID_1),HAVE_SC2_SC4(timing));\r
+ *
+ */\r
+\r
+// typedef _Bool IsrType;\r
\r
/**\r
* Init the interrupt controller\r
void Irq_Init( void );\r
\r
\r
-\r
-\r
#if defined(CFG_HC1X)\r
/**\r
*\r
*/\r
void *Irq_Entry( void *stack_p );\r
#endif\r
+\r
+//ISRType Irq_Attach( const OsIsrConstType *isrPtr );\r
+ISRType Irq_Attach( int vector );\r
+ISRType Irq_Attach2( const OsIsrConstType * );\r
+\r
/**\r
* Attach an ISR type 1 to the interrupt controller.\r
*\r
*/\r
uint8_t Irq_GetCurrentPriority( Cpu_t cpu);\r
\r
-\r
/**\r
* Set the priority in the interrupt controller for vector\r
*/\r
void Irq_SetPriority( Cpu_t cpu, IrqType vector, uint8_t prio );\r
\r
+void Irq_EnableVector( int16_t vector, int priority, int core );\r
+\r
/**\r
*\r
* @param vector\r
* @param type\r
*/\r
-static inline void Irq_SetIsrType( IrqType vector, IsrType type ) {\r
+#if 0\r
+static inline void Irq_SetIsrType( IrqType vector, int8_t type ) {\r
Irq_IsrTypeTable[vector] = type;\r
}\r
\r
* @return 0 - Isr1\r
* 1 - Isr2\r
*/\r
-static inline IsrType Irq_GetIsrType( IrqType vector ) {\r
+static inline int8_t Irq_GetIsrType( IrqType vector ) {\r
return Irq_IsrTypeTable[vector];\r
}\r
+#endif\r
\r
\r
#if 0\r
--- /dev/null
+/* -------------------------------- Arctic Core ------------------------------\r
+ * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
+ *\r
+ * Copyright (C) 2009 ArcCore AB <contact@arccore.com>\r
+ *\r
+ * This source code is free software; you can redistribute it and/or modify it\r
+ * under the terms of the GNU General Public License version 2 as published by the\r
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
+ *\r
+ * This program is distributed in the hope that it will be useful, but\r
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\r
+ * for more details.\r
+ * -------------------------------- Arctic Core ------------------------------*/\r
+\r
+#ifndef ISR_H_\r
+#define ISR_H_\r
+\r
+/*\r
+ * INCLUDE "RULES"\r
+ * Since this types and methods defined here are used by the drivers, they should\r
+ * include it. E.g. #include "isr.h"\r
+ *\r
+ * This file is also used internally by the kernel\r
+ *\r
+ *\r
+ * irq_types.h ( Vector enums )\r
+ * irq.h ( Interface )\r
+ *\r
+ * Problem:\r
+ * Os_Cfg.h needs types from isr.h\r
+ *\r
+ */\r
+\r
+/* ----------------------------[includes]------------------------------------*/\r
+/* ----------------------------[define]--------------------------------------*/\r
+\r
+#define ISR_TYPE_1 0\r
+#define ISR_TYPE_2 1\r
+\r
+/* ----------------------------[macro]---------------------------------------*/\r
+/* ----------------------------[typedef]-------------------------------------*/\r
+\r
+\r
+typedef struct {\r
+ void *curr; /* Current stack ptr( at swap time ) */\r
+ void *top; /* Top of the stack( low address ) */\r
+ uint32 size; /* The size of the stack */\r
+} OsIsrStackType;\r
+\r
+\r
+/*\r
+ * This type should map against the AUTOSAR OsISR type\r
+ */\r
+typedef struct {\r
+ const char *name;\r
+ uint8_t core;\r
+ int16_t vector;\r
+ int16_t type;\r
+ int16_t priority;\r
+ void (*entry)();\r
+ uint32_t appOwner;\r
+ /* Mapped against OsIsrResourceRef */\r
+ uint32_t resourceMask;\r
+#if ( OS_USE_ISR_TIMING_PROT == STD_ON )\r
+ /* Mapped against OsIsrTimingProtection[C] */\r
+ OsIsrTimingProtectionType *timingProtPtr;\r
+#else\r
+ void *timingProtPtr;\r
+#endif\r
+} OsIsrConstType;\r
+\r
+/*\r
+ *\r
+ */\r
+typedef struct {\r
+ OsIsrStackType stack;\r
+ int state;\r
+ const OsIsrConstType *constPtr;\r
+} OsIsrVarType;\r
+\r
+\r
+/* ----------------------------[functions]-----------------------------------*/\r
+\r
+void Os_IsrInit( void );\r
+ISRType Os_IsrAdd( const OsIsrConstType * restrict isrPtr );\r
+const OsIsrConstType * Os_IsrGet( int16_t vector);\r
+\r
+#endif /*ISR_H_*/\r
assert(#_a #_b); \\r
}\r
\r
-\r
-\r
-\r
void Os_CfgValidate(void ) {\r
OS_VALIDATE(OS_COUNTER_CNT,ARRAY_SIZE(counter_list));\r
#if (RESOURCE_CNT!=0)\r
OS_VALIDATE(OS_RESOURCE_CNT,ARRAY_SIZE(resource_list));\r
#endif\r
- OS_VALIDATE(OS_TASK_CNT ,ARRAY_SIZE(rom_pcb_list));\r
+ OS_VALIDATE(OS_TASK_CNT ,ARRAY_SIZE( Os_TaskConstList));\r
#if (RESOURCE_CNT!=0)\r
OS_VALIDATE(OS_ALARM_CNT,ARRAY_SIZE(alarm_list));\r
#endif\r
#endif\r
\r
/*-----------------------------------------------------------------*/\r
-#if ( OS_SC3 == STD_ON) || ( OS_SC4==STD_ON)\r
-int Os_CfgGetApplCnt(void) {\r
- return APPLICATION_CNT;\r
-}\r
+#if 0\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
\r
-OsRomApplicationType *Os_CfgGetApplObj( ApplicationType application_id ) {\r
+OsRomApplicationType *Os_CfgGetApplObj( ApplicationType appId ) {\r
return &rom_app_list[application_id];\r
}\r
#endif\r
+#endif\r
\r
/*-----------------------------------------------------------------*/\r
\r
\r
/*-----------------------------------------------------------------*/\r
\r
-#if ( OS_SC3 == STD_ON) || ( OS_SC4 == STD_ON)\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
uint32 Os_CfgGetServiceCnt( void ) {\r
- return SERVICE_CNT;\r
+ return OS_SERVICE_CNT;\r
}\r
#endif\r
\r
#define ARRAY_SIZE(_x) (sizeof(_x)/sizeof((_x)[0]))\r
#endif\r
\r
-#if defined(CFG_PPC)\r
-#define VECTOR_TBL_ALIGNMENT __attribute__ ((aligned (0x800)))\r
-#else\r
-#define VECTOR_TBL_ALIGNMENT\r
-#endif\r
-\r
-\r
\r
// +1 here.. easy to have a reference..\r
-#define GEN_TRUSTEDFUNCTIONS_LIST trusted_func_t os_cfg_trusted_list[SERVICE_CNT];\r
+#define GEN_TRUSTEDFUNCTIONS_LIST trusted_func_t os_cfg_trusted_list[OS_SERVICE_CNT];\r
\r
-#define GEN_APPLICATION_HEAD const OsRomApplicationType rom_app_list[] =\r
+#define GEN_APPLICATION_HEAD const OsAppConstType Os_AppConst[OS_APPLICATION_CNT] =\r
\r
-#define GEN_APPLICATON( _id,_name,_trusted,_startuphook,_shutdownhook, \\r
- _errorhook,_isr_mask,_scheduletable_mask, _alarm_mask, \\r
- _counter_mask,_resource_mask,_message_mask ) \\r
+#define GEN_APPLICATION( _id,_name,_trusted,_startuphook,_shutdownhook, _errorhook, \\r
+ _restart_task ) \\r
{ \\r
- .application_id = _id, \\r
+ .appId = _id, \\r
.name = _name, \\r
.trusted = _trusted, \\r
.StartupHook = _startuphook, \\r
.ShutdownHook = _shutdownhook, \\r
.ErrorHook = _errorhook, \\r
- .isr_mask = _isr_mask, \\r
- .scheduletable_mask = _scheduletable_mask, \\r
- .alarm_mask = _alarm_mask, \\r
- .counter_mask = _counter_mask, \\r
- .resource_mask = _resource_mask, \\r
- .message_mask = _message_mask, \\r
+ .restartTaskId = _restart_task \\r
}\r
\r
-\r
-#define GEN_TASK_HEAD const OsRomPcbType rom_pcb_list[] =\r
+#define GEN_TASK_HEAD const OsTaskConstType Os_TaskConstList[OS_TASK_CNT] =\r
\r
\r
\r
* become (1<<2)|(1<<4) = 0x14 (limits resources to 32).\r
* Currently used for calculating the ceiling priority.\r
*/\r
-#define GEN_ETASK( _id, _priority, _scheduling, _autostart, _resource_int_p, _resource_mask ) \\r
+#define GEN_ETASK( _id, _name, _priority, _scheduling, \\r
+ _autostart, _resource_int_p, _resource_mask, \\r
+ _appl_owner, _accessing_appl_mask ) \\r
{ \\r
- .pid = TASK_ID_##_id, \\r
- .name = #_id, \\r
+ .pid = TASK_ID_ ## _id, \\r
+ .name = _name, \\r
.entry = _id, \\r
.prio = _priority, \\r
.proc_type = PROC_EXTENDED, \\r
.stack.size = sizeof stack_##_id, \\r
.stack.top = stack_##_id, \\r
.autostart = _autostart, \\r
- .resource_int_p = _resource_int_p, \\r
+ .resourceIntPtr = _resource_int_p, \\r
.scheduling = _scheduling, \\r
.resourceAccess = _resource_mask, \\r
.activationLimit = 1, \\r
+ .applOwnerId = _appl_owner, \\r
+ .accessingApplMask = _accessing_appl_mask, \\r
}\r
\r
-#define GEN_BTASK( _id, _priority, _scheduling, _autostart, _resource_int_p, _resource_mask, _activation_limit ) \\r
+#define GEN_BTASK( _id, _name, _priority, _scheduling, \\r
+ _autostart, _resource_int_p, _resource_mask, \\r
+ _activation_limit, _appl_owner, _accessing_appl_mask ) \\r
{ \\r
- .pid = TASK_ID_##_id, \\r
- .name = #_id, \\r
+ .pid = TASK_ID_ ## _id, \\r
+ .name = _name, \\r
.entry = _id, \\r
.prio = _priority, \\r
.proc_type = PROC_BASIC, \\r
.stack.size = sizeof stack_##_id, \\r
.stack.top = stack_##_id, \\r
.autostart = _autostart, \\r
- .resource_int_p = _resource_int_p, \\r
+ .resourceIntPtr = _resource_int_p, \\r
.scheduling = _scheduling, \\r
.resourceAccess = _resource_mask, \\r
.activationLimit = _activation_limit, \\r
+ .applOwnerId = _appl_owner, \\r
+ .accessingApplMask = _accessing_appl_mask, \\r
}\r
\r
#define GEN_ISR_2( _id, _name, _entry, _priority, _vector ) \\r
.vector = _vector, \\r
}\r
\r
-//#define GEN_PCB_LIST() uint8_t pcb_list[PCB_T_SIZE*ARRAY_SIZE(rom_pcb_list)];\r
-#define GEN_PCB_LIST() OsPcbType pcb_list[ARRAY_SIZE(rom_pcb_list)];\r
+//#define GEN_PCB_LIST() uint8_t Os_TaskVarList[PCB_T_SIZE*ARRAY_SIZE( Os_TaskConstList)];\r
+#define GEN_PCB_LIST() OsTaskVarType Os_TaskVarList[ARRAY_SIZE( Os_TaskConstList)];\r
\r
-#define GEN_RESOURCE_HEAD OsResourceType resource_list[] =\r
+#define GEN_RESOURCE_HEAD OsResourceType resource_list[OS_RESOURCE_CNT] =\r
\r
\r
/**\r
* NOT USED. Set to 0\r
*/\r
\r
-#define GEN_COUNTER_HEAD OsCounterType counter_list[] =\r
+#define GEN_COUNTER_HEAD OsCounterType counter_list[OS_COUNTER_CNT] =\r
#define GEN_COUNTER( _id, _name, _type, _unit, \\r
_maxallowedvalue, \\r
_ticksperbase, \\r
_mincycle, \\r
- _gpt_ch ) \\r
+ _gpt_ch, \\r
+ _appl_owner, \\r
+ _accessing_appl_mask ) \\r
{ \\r
.type = _type, \\r
.unit = _unit, \\r
.alarm_base.maxallowedvalue = _maxallowedvalue, \\r
.alarm_base.tickperbase = _ticksperbase, \\r
.alarm_base.mincycle = _mincycle, \\r
+ .applOwnerId = _appl_owner, \\r
+ .accessingApplMask = _accessing_appl_mask, \\r
}\r
-#if 0\r
- // For now...\r
- .driver.OsGptChannelRef = _gpt_ch\r
-#endif\r
-\r
\r
#define GEN_ALARM_AUTOSTART_NAME(_id) &(Os_AlarmAutoStart_ ## _id)\r
\r
.appModeRef = _app_mode \\r
}\r
\r
-#define GEN_ALARM_HEAD OsAlarmType alarm_list[] =\r
+#define GEN_ALARM_HEAD OsAlarmType alarm_list[OS_ALARM_CNT] =\r
\r
/**\r
* _id\r
* _X_counter_id - The counter ID if type is ALARM_ACTION_INCREMENTCOUNTER\r
*\r
*/\r
-#define GEN_ALARM( _id, _name, _counter_id, \\r
- _autostart_ref, \\r
- _action_type, \\r
- _action_task_id, \\r
- _action_event_id, \\r
- _action_counter_id ) \\r
+#define GEN_ALARM( _id, _name, _counter_id, \\r
+ _autostart_ref, \\r
+ _action_type, \\r
+ _action_task_id, \\r
+ _action_event_id, \\r
+ _action_counter_id, \\r
+ _appl_owner, \\r
+ _accessing_appl_mask ) \\r
{ \\r
.name = _name, \\r
.counter = &counter_list[_counter_id], \\r
.counter_id = _counter_id, \\r
- .autostartPtr = _autostart_ref, \\r
+ .autostartPtr = _autostart_ref, \\r
.action = { \\r
.type = _action_type, \\r
.task_id = _action_task_id, \\r
.event_id = _action_event_id, \\r
.counter_id = _action_counter_id \\r
}, \\r
+ .applOwnerId = _appl_owner, \\r
+ .accessingApplMask = _accessing_appl_mask, \\r
}\r
\r
/*\r
}\r
\r
\r
-#if ( OS_SC3 == STD_ON) || ( OS_SC4 == STD_ON)\r
-#error OLD or NOT implemented\r
#define GEN_HOOKS( _startup, _protection, _shutdown, _error, _pretask, _posttask ) \\r
struct OsHooks os_conf_global_hooks = { \\r
.StartupHook = _startup, \\r
.PreTaskHook = _pretask, \\r
.PostTaskHook = _posttask \\r
}\r
-#else\r
-#define GEN_HOOKS( _startup, _protection, _shutdown, _error, _pretask, _posttask ) \\r
-struct OsHooks os_conf_global_hooks = { \\r
- .StartupHook = _startup, \\r
- .ShutdownHook = _shutdown, \\r
- .ErrorHook = _error, \\r
- .PreTaskHook = _pretask, \\r
- .PostTaskHook = _posttask \\r
-}\r
-\r
-#endif\r
-\r
-\r
-#define GEN_IRQ_VECTOR_TABLE_HEAD \\r
- void * Irq_VectorTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] VECTOR_TBL_ALIGNMENT =\r
-\r
-#define GEN_IRQ_ISR_TYPE_TABLE_HEAD \\r
- uint8_t Irq_IsrTypeTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] =\r
-\r
-#define GEN_IRQ_PRIORITY_TABLE_HEAD \\r
- uint8_t Irq_PriorityTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] =\r
\r
#define ALIGN_16(x) (((x)>>4)<<4)\r
\r
# BOARDDIR=<board dir> \r
# Select what board to build for \r
# BDIR=<dir>[,<dir>] \r
-# Select what directories to build. The kernel if always built.\r
+# Select what directories to build. The kernel is always built.\r
# CROSS_COMPILE\r
# Specify the compiler to use. \r
# Q=[(@)/empty] \r
\r
.PHONY: help\r
help:\r
- @echo "Make kernel and a simple example"\r
+ @echo "Build a simple example"\r
@echo " > make BOARDDIR=mpc551xsim CROSS_COMPILE=/opt/powerpc-eabi/bin/powerpc-eabi- BDIR=examples/simple all"\r
@echo ""\r
- @echo "Save the config (CROSS_COMPILE and BDIR)"\r
- @echo " > make BOARDDIR=mpc551xsim CROSS_COMPILE=/opt/powerpc-eabi/bin/powerpc-eabi- BDIR=examples/simple save"\r
- @echo ""\r
@echo "Clean"\r
@echo " > make clean"\r
@echo ""\r
@echo "Present config:"\r
- @echo " ARCH=$(ARCH)"\r
- @echo " ARCH_FAM=$(ARCH_FAM)"\r
- @echo " BOARDDIR =$(BOARDDIR)"\r
- @echo " CROSS_COMPILE =$(CROSS_COMPILE)"\r
+ @echo " BDIR = ${BDIR}"\r
+ @echo " BOARDDIR = $(BOARDDIR)"\r
+ @echo " CROSS_COMPILE = $(CROSS_COMPILE)"\r
+ @echo " CWD = ${CWD}"\r
@echo ""\r
\r
export CFG_MCU \r
@echo $(all_boards)\r
\r
show_build:\r
- @echo "BUILD INFO"\r
+ @echo ""\r
+ @echo "==========[ BUILD INFO ]==========="\r
@echo "BOARDDIR: $(BOARDDIR) [$(origin BOARDDIR)]"\r
@echo "BDIR: $(BDIR) [$(origin BDIR)]"\r
@echo "CROSS_COMPILE: $(CROSS_COMPILE) [$(origin CROSS_COMPILE)]"\r
- @echo "cmd_cmd_goals: $(cmd_cmd_goals)"\r
+ @echo "CWD: ${CWD}"\r
\r
\r
$(dir_cmd_goals) :: show_build FORCE \r
- @echo ==========[ $@ ]===========\r
+ @echo ""\r
+ @echo ==========[ ${abspath $@} ]===========\r
@if [ ! -d $@ ]; then echo "No such directory: \"$@\" quitting"; exit 1; fi\r
+@[ -d $@/$(objdir) ] || mkdir -p $@/$(objdir)\r
@chmod 777 $@/$(objdir)\r
\r
\r
+# Arch specific settings\r
+ifneq ($(ARCH),)\r
+ include $(ROOTDIR)/$(ARCH_PATH-y)/scripts/gcc.mk\r
+endif\r
+\r
+\r
HOST := $(shell uname)\r
export prefix\r
\r
--- /dev/null
+\r
+BEGIN {\r
+ kilobyte = 1024\r
+ \r
+ print " >> Image size: (decimal)"\r
+}\r
+\r
+/^\.text/ {\r
+ text += $3; \r
+ rom+=$3 \r
+};\r
+\r
+/^\.data/ {\r
+ data += $3;\r
+ rom+=$3; \r
+ ram+=$3\r
+};\r
+\r
+/^\.bss/ {\r
+ bss += $3; \r
+ ram+=$3\r
+};\r
+\r
+END { \r
+\r
+ printf "%-10s %10s %10.1f %s\n", " text:", text " B", text/kilobyte, "kB";\r
+ printf "%-10s %10s %10.1f %s\n", " data:", data " B", data/kilobyte, "kB";\r
+ printf "%-10s %10s %10.1f %s\n", " bss:", bss " B", bss/kilobyte, "kB"; \r
+ printf "%-10s %10s %10.1f %s\n", " ROM:", rom " B", rom/kilobyte, "kB";\r
+ printf "%-10s %10s %10.1f %s\n", " RAM:", ram " B", ram/kilobyte, "kB";\r
+ \r
+}
\ No newline at end of file
\r
-CFG_ARCH_$(ARCH):=y\r
-\r
-RELDIR := $(subst $(TOPDIR)/,,$(CURDIR))\r
\r
-# Create the target name... \r
-target := $(subst /,_,$(SUBDIR))\r
-\r
-#goal=$(subst /cygdrive/c/,c:/,$(abspath $@))\r
-#goal=$(abspath $@)\r
-goal=$@\r
+###############################################################################\r
+# BUILD SETTINGS #\r
+###############################################################################\r
\r
-#===== MODULE CONFIGURATION =====\r
+# Board settings\r
include $(ROOTDIR)/boards/$(BOARDDIR)/build_config.mk\r
+\r
+# Project settings\r
-include ../build_config.mk\r
\r
+# Perform build system version check\r
+include $(ROOTDIR)/scripts/version_check.mk\r
+\r
+\r
+\r
+###############################################################################\r
+# MODULE CONFIGURATION #\r
+###############################################################################\r
+\r
+# Some useful vars\r
+CFG_ARCH_$(ARCH):=y\r
+RELDIR := $(subst $(TOPDIR)/,,$(CURDIR))\r
+target := $(subst /,_,$(SUBDIR))\r
+goal=$@\r
+\r
define MOD_AVAIL_template\r
MOD_$(1)=y\r
endef\r
$(error Trying to build a module that is not available: $(not_avail))\r
endif\r
\r
-#===== COMPILER CONFIG =====\r
+\r
+\r
+###############################################################################\r
+# TOOLS CONFIGURATION #\r
+###############################################################################\r
\r
# set debug optimization level as default\r
ifeq ($(SELECT_OPT),)\r
\r
ARCH_PATH-y = arch/$(ARCH_FAM)/$(ARCH)\r
\r
-# Include compiler generic and arch specific\r
+# Include compiler settings\r
COMPILER?=gcc\r
-ifeq ($(COMPILER),gcc)\r
- ifneq ($(ARCH),)\r
- include $(ROOTDIR)/$(ARCH_PATH-y)/scripts/gcc.mk\r
- endif\r
-endif\r
include $(ROOTDIR)/scripts/cc_$(COMPILER).mk\r
\r
# Include pclint or splint settings\r
\r
\r
\r
-# Get object files\r
+###############################################################################\r
+# PROJECT MAKEFILE #\r
+###############################################################################\r
+\r
+# Include project makefile\r
include ../makefile\r
\r
-# Perform build system version check\r
-include $(ROOTDIR)/scripts/version_check.mk\r
+# All module object files (guarded for backwards compatability)\r
+ifndef _BOARD_COMMON_MK\r
+include $(ROOTDIR)/boards/board_common.mk\r
+endif\r
+\r
+\r
+##### For backwards compatability with older project makefiles:\r
\r
-##### For backwards compatability with older project makefiles\r
# Remove dependency on libkernel\r
deprecated-libs += $(ROOTDIR)/libs/libkernel_$(ARCH_MCU).a\r
deprecated-libs-included = $(filter $(deprecated-libs),$(libitem-y))\r
\r
#####\r
\r
+inc-y += ../include\r
inc-y += $(ROOTDIR)/include\r
inc-y += $(ROOTDIR)/include/$(ARCH_FAM)\r
inc-y += $(ROOTDIR)/include/$(ARCH_FAM)/$(ARCH)\r
-\r
-\r
-.PHONY clean: \r
-clean: FORCE\r
- @-rm -f *.o *.d *.h *.elf *.a *.ldp\r
-\r
-.PHONY config: \r
-config: FORCE\r
- @echo "board modules:" $(MOD_AVAIL)\r
- @echo "example modules:" $(MOD_USE)\r
- @echo $(MOD) ${def-y}\r
-\r
-FORCE:\r
-\r
-$(ROOTDIR)/binaries:\r
- @mkdir -p $@\r
-\r
-# build- targets are "end" target that the included makefile want's to build\r
-.PHONY all:\r
-all: $(build-exe-y) $(build-hex-y) $(build-lib-y) $(build-bin-y) $(ROOTDIR)/binaries\r
- @cp -v $(build-lib-y) $(build-exe-y) $(build-hex-y) $(build-bin-y) $(ROOTDIR)/binaries\r
-\r
-\r
-# Determine what kind of filetype to build from \r
+ \r
VPATH += $(ROOTDIR)/$(SUBDIR)/src\r
VPATH += $(ROOTDIR)/$(SUBDIR)\r
\r
-inc-y += ../include\r
\r
-.SUFFIXES:\r
\r
-# Simple depencendy stuff\r
--include $(subst .o,.d,$(obj-y))\r
-# Some dependency for xxx_offset.c/h also\r
--include $(subst .h,.d,$(dep-y))\r
+###############################################################################\r
+# LINT #\r
+###############################################################################\r
\r
-#LINT:\r
LINT_EXCLUDE_PATHS := $(abspath $(LINT_EXCLUDE_PATHS))\r
$(info $(LINT_EXCLUDE_PATHS))\r
\r
endif\r
\r
\r
+\r
+###############################################################################\r
+# TOP-LEVEL TARGETS #\r
+###############################################################################\r
+\r
+.PHONY clean: \r
+clean: FORCE\r
+ @-rm -f *.o *.d *.h *.elf *.a *.ldp\r
+\r
+.PHONY config: \r
+config: FORCE\r
+ @echo "board modules:" $(MOD_AVAIL)\r
+ @echo "example modules:" $(MOD_USE)\r
+ @echo $(MOD) ${def-y}\r
+\r
+FORCE:\r
+\r
+$(ROOTDIR)/binaries:\r
+ @mkdir -p $@\r
+\r
+.PHONY all:\r
+all: $(build-exe-y) $(build-hex-y) $(build-lib-y) $(build-bin-y) $(ROOTDIR)/binaries\r
+ @cp -v $(build-lib-y) $(build-exe-y) $(build-hex-y) $(build-bin-y) $(ROOTDIR)/binaries\r
+\r
+\r
+.SUFFIXES:\r
+\r
+\r
+\r
+###############################################################################\r
+# TARGETS #\r
+###############################################################################\r
+ \r
+# Simple depencendy stuff\r
+-include $(subst .o,.d,$(obj-y))\r
+# Some dependency for xxx_offset.c/h also\r
+-include $(subst .h,.d,$(dep-y))\r
+\r
# Compile\r
%.o: %.c\r
@echo " >> CC $(notdir $<)"\r
-# compile\r
$(Q)$(CC) -c $(CFLAGS) -o $(goal) $(addprefix -I,$(inc-y)) $(addprefix -D,$(def-y)) $(abspath $<)\r
# run lint if enabled\r
$(run_pclint)\r
$(run_splint)\r
\r
# Assembler\r
-\r
%.o: %.s\r
@echo " >> AS $(notdir $<) $(ASFLAGS)"\r
$(Q)$(AS) $(ASFLAGS) -o $(goal) $<\r
inc-y += $(ROOTDIR)/boards/$(BOARDDIR)\r
\r
# Preprocess linker files..\r
-%.lcf: %.ldf\r
+%.ldp %.lcf: %.ldf\r
@echo " >> CPP $<"\r
$(Q)$(CPP) -E -P $(CPP_ASM_FLAGS) -o $@ $(addprefix -I,$(inc-y)) $(addprefix -D,$(def-y)) $<\r
\r
-# @cat $@ \r
- \r
.PHONY $(ROOTDIR)/libs:\r
$(ROOTDIR)/libs:\r
$(Q)mkdir -p $@\r
\r
dep-y += $(ROOTDIR)/libs\r
\r
-# lib \r
+# lib output\r
$(build-lib-y): $(dep-y) $(obj-y)\r
@echo " >> AR $@" \r
$(Q)$(AR) -r -o $@ $(obj-y) 2> /dev/null\r
\r
+# hex output\r
$(build-hex-y): $(build-exe-y)\r
@echo " >> OBJCOPY $@" \r
$(Q)$(CROSS_COMPILE)objcopy -O ihex $< $@\r
\r
+# bin output\r
$(build-bin-y): $(build-exe-y)\r
@echo " >> OBJCOPY $@" \r
$(Q)$(CROSS_COMPILE)objcopy -O binary $< $@ \r
\r
# Linker\r
-# Could use readelf -S instead of parsing the *.map file.\r
$(build-exe-y): $(dep-y) $(obj-y) $(sim-y) $(libitem-y) $(ldcmdfile-y)\r
@echo " >> LD $@"\r
ifeq ($(CROSS_COMPILE),)\r
$(Q)$(CC) $(LDFLAGS) -o $@ $(libpath-y) $(obj-y) $(lib-y) $(libitem-y) \r
else\r
$(Q)$(LD) $(LDFLAGS) $(LD_FILE) $(ldcmdfile-y) -o $@ $(libpath-y) $(LD_START_GRP) $(obj-y) $(lib-y) $(libitem-y) $(LD_END_GRP) $(LDMAPFILE)\r
-endif\r
-ifdef CFG_MC912DG128A\r
+ ifdef CFG_MC912DG128A\r
+ # Print memory layout\r
@$(CROSS_COMPILE)objdump -h $@ | gawk -f $(ROOTDIR)/scripts/hc1x_memory.awk\r
-else \r
-ifeq ($(COMPILER),gcc) \r
- @echo "Image size: (decimal)"\r
- @gawk --non-decimal-data '/^\.text/ { print " text:" $$3+0 " bytes"; rom+=$$3 };\\r
- /^\.data/ { print " data:" $$3+0 " bytes"; rom+=$$3; ram+=$$3}; \\r
- /^\.bss/ { print " bss :" $$3+0 " bytes"; ram+=$$3}; \\r
- END { print " ROM: ~" rom " bytes"; print " RAM: ~" ram " bytes"}' $(subst .elf,.map,$@)\r
-endif # ($(COMPILER),gcc) \r
-ifeq ($(BUILD_LOAD_MODULE),y)\r
+ else\r
+ ifeq ($(COMPILER),gcc) \r
+ # Print memory layout\r
+ @echo ""\r
+ @gawk --non-decimal-data -f $(ROOTDIR)/scripts/gcc_map_memory.awk $(subst .elf,.map,$@)\r
+ endif # ($(COMPILER),gcc)\r
+ \r
+ ifeq ($(BUILD_LOAD_MODULE),y)\r
@$(CROSS_COMPILE)objcopy -O srec $@ $@.raw.s19\r
srec_cat $@.raw.s19 --crop 0x8008000 0x803fffc --fill 0x00 0x8008000 0x803fffc --l-e-crc32 0x803fffc -o $@.lm.s19\r
-endif\r
-endif\r
+ endif #($(BUILD_LOAD_MODULE),y)\r
+ \r
+ endif #CFG_MC912DG128A\r
+\r
+endif #($(CROSS_COMPILE),)\r
@echo\r
@echo " >>>>>>> DONE <<<<<<<<<"\r
@echo\r
\r
- \r
-$(size-exe-y): $(build-exe-y)\r
- $(Q)$(OBJDUMP) -h $<\r
- @echo TODO: Parse the file....\r
-\r
CORE_BUILD_SYSTEM_VERSION_MINOR = 0\r
CORE_BUILD_SYSTEM_VERSION_PATCH = 0\r
\r
-ifneq ($(REQUIRED_BUILD_SYSTEM_VERSION),) # Only check if specified\r
+# Only check if specified \r
+# (remove when we want to start checking always)\r
+ifneq ($(REQUIRED_BUILD_SYSTEM_VERSION),)\r
\r
REQUIRED_BUILD_SYSTEM_VERSION:=$(subst ., ,$(REQUIRED_BUILD_SYSTEM_VERSION))\r
REQUIRED_BUILD_SYSTEM_VERSION_MAJOR=$(word 1,$(REQUIRED_BUILD_SYSTEM_VERSION))\r
#include "EcuM_Cbk.h"\r
#include "Mcu.h"\r
#include "Det.h"\r
-#include "irq.h"\r
+//#include "isr.h"\r
#if defined(USE_NVM)\r
#include "Nvm.h"\r
#endif\r
InitOS();\r
\r
// Enable interrupts\r
- Irq_Init();\r
+ Isr_Init();\r
\r
// Determine PostBuild configuration\r
internal_data.config = EcuM_DeterminePbConfiguration();\r
if (alarmPtr->autostartPtr != NULL) {\r
const OsAlarmAutostartType *autoPtr = alarmPtr->autostartPtr;\r
\r
- if (os_sys.appMode & autoPtr->appModeRef) {\r
+ if (Os_Sys.appMode & autoPtr->appModeRef) {\r
if (autoPtr->autostartType == ALARM_AUTOSTART_ABSOLUTE) {\r
SetAbsAlarm(j, autoPtr->alarmTime, autoPtr->cycleTime);\r
} else {\r
* for more details.\r
* -------------------------------- Arctic Core ------------------------------*/\r
\r
+/* ----------------------------[includes]------------------------------------*/\r
+\r
#include <stdlib.h>\r
+#include <stdint.h>\r
#include "Os.h"\r
\r
#include "internal.h"\r
#include "arc.h"\r
#include "arch.h"\r
\r
+/* ----------------------------[private define]------------------------------*/\r
+/* ----------------------------[private macro]-------------------------------*/\r
+#define APPL_ID_TO_MASK(_x) (1<<(_x))\r
+\r
+/* ----------------------------[private typedef]-----------------------------*/\r
+/* ----------------------------[private function prototypes]-----------------*/\r
+/* ----------------------------[private variables]---------------------------*/\r
+#if OS_APPLICATION_CNT!=0\r
+OsAppVarType Os_AppVar[OS_APPLICATION_CNT];\r
+#endif\r
+\r
+/* ----------------------------[private functions]---------------------------*/\r
+/* ----------------------------[public functions]----------------------------*/\r
+\r
+\r
+/* @req OS547\r
+ * Availability of AllowAccess(): Available in Scalability Classes 3 and 4.\r
+ * @req OS536\r
+ * Availability of TerminateApplication(): Available in Scalability Classes 3 and 4.\r
+ * @req OS520\r
+ * Availability of CheckObjectOwnership():Available in Scalability Classes 3 and 4.\r
+ *\r
+ */\r
+\r
+\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+\r
+/**\r
+ * This service determines the currently running OS-Application (a unique\r
+ * identifier has to be allocated to each application).\r
+ *
+ * @return <identifier of running OS-Application> or INVALID_OSAPPLICATION
+ */\r
+\r
+ApplicationType GetApplicationID( void ) {\r
+ return Os_Sys.currApplId;\r
+}\r
+\r
+\r
+/**\r
+ * A (trusted or non-trusted) OS-Application uses this service to call a trusted\r
+ * function\r
+ *
+ * @param FunctionIndex Index of the function to be called.
+ * @param FunctionParams Pointer to the parameters for the function -\r
+ * specified by the FunctionIndex - to be called.\r
+ * If no parameters are provided, a NULL pointer has\r
+ * to be passed.
+ * @return
+ */\r
+StatusType CallTrustedFunction( TrustedFunctionIndexType FunctionIndex,\r
+ TrustedFunctionParameterRefType FunctionParams ) {\r
+\r
+\r
+ return E_OK;\r
+}\r
+\r
+\r
+\r
+/**\r
+ * This service checks if a memory region is write/read/execute accessible\r
+ * and also returns information if the memory region is part of the stack\r
+ * space.\r
+ *
+ * @param ISRID ISR reference
+ * @param Address Start of memory area
+ * @param Size Size of memory area
+ * @return
+ */\r
+AccessType CheckISRMemoryAccess( ISRType isrId,\r
+ MemoryStartAddressType address,\r
+ MemorySizeType size )\r
+{\r
+ ptrdiff_t addr = (ptrdiff_t)address;\r
+ (void)addr;\r
+ (void)size;\r
+\r
+ if( isrId > OS_TASK_CNT ) {\r
+ return 0;\r
+ }\r
+ return 0;\r
+}\r
+/**\r
+ * This service checks if a memory region is write/read/execute accessible\r
+ * and also returns information if the memory region is part of the stack\r
+ * space.\r
+ *\r
+ * Check returned accesstype with:\r
+ * OSMEMORY_IS_READABLE(<AccessType>)\r
+ * OSMEMORY_IS_WRITEABLE(<AccessType>)\r
+ * OSMEMORY_IS_EXECUTABLE(<AccessType>)\r
+ * OSMEMORY_IS_STACKSPACE(<AccessType>)\r
+ *\r
+ * TODO: Not really sure what this function is actually good for? Add a use-case!\r
+ *
+ * @param TaskID Task reference
+ * @param Address Start of memory area
+ * @param Size Size of memory area
+ * @return
+ */\r
+AccessType CheckTaskMemoryAccess( TaskType taskId,\r
+ MemoryStartAddressType address,\r
+ MemorySizeType size )\r
+{\r
+ ptrdiff_t addr = (ptrdiff_t)address;\r
+ (void)addr;\r
+ (void)size;\r
+\r
+ /* @req OS270:\r
+ * if the Task reference <TaskID> in a call of CheckTaskMemoryAccess() is\r
+ * not valid, CheckTaskMemoryAccess() shall yield no access rights.\r
+ */\r
+ if( taskId > OS_TASK_CNT ) {\r
+ return 0;\r
+ }\r
+\r
+ /* TODO: Add body :) */\r
+ return 0;\r
+}\r
+\r
+\r
+/**\r
+ * This service determines if the OS-Applications, given by ApplID,\r
+ * is allowed to use the IDs of a Task, ISR, Resource, Counter,\r
+ * Alarm or Schedule Table in API calls.\r
+ *\r
+ * @param ApplID OS-Application identifier
+ * @param ObjectType Type of the following parameter
+ * @param object The object to be examined
+ * @return ACCESS if the ApplID has access to the object\r
+ * NO_ACCESS otherwise
+ */\r
+ObjectAccessType CheckObjectAccess( ApplicationType ApplId,\r
+ ObjectTypeType ObjectType,\r
+ uint32_t objectId )\r
+{\r
+ uint32 appMask = APPL_ID_TO_MASK(ApplId);\r
+ ObjectAccessType orv;\r
+ _Bool rv = 0;\r
+\r
+\r
+ /* @req OS423\r
+ * If in a call of CheckObjectAccess() the object to be examined\r
+ * is not avalid object OR <ApplID> is invalid OR <ObjectType> is\r
+ * invalid THEN CheckObjectAccess() shall return NO_ACCESS.\r
+ */\r
+ if( ApplId > OS_APPLICATION_CNT ) {\r
+ return NO_ACCESS;\r
+ }\r
+\r
+ /* @req OS272\r
+ * If the OS-Application <ApplID> in a call of CheckObjectAccess() has no\r
+ * access to the queried object, CheckObjectAccess() shall return NO_ACCESS.\r
+ *\r
+ * TODO: Could be that OS450 comes into play here....and then this is wrong.\r
+ */\r
+ if( Os_AppVar[ApplId].state != APPLICATION_ACCESSIBLE ) {\r
+ return NO_ACCESS;\r
+ }\r
\r
+ /* TODO: check id */\r
+ switch( ObjectType ) {\r
+ case OBJECT_ALARM:\r
+ rv = ((OsAlarmType *)objectId)->accessingApplMask & (appMask);\r
+ break;\r
+ case OBJECT_COUNTER:\r
+ rv = ((OsCounterType *)objectId)->accessingApplMask & (appMask);\r
+ break;\r
+ case OBJECT_ISR:\r
+ /* TODO: Add more things here for missing objects */\r
+ break;\r
+ case OBJECT_MESSAGE:\r
+ case OBJECT_RESOURCE:\r
+ case OBJECT_SCHEDULETABLE:\r
+ break;\r
+ case OBJECT_TASK:\r
+ rv = ((OsCounterType *)objectId)->accessingApplMask & (appMask);\r
+ break;\r
+ default:\r
+ /* @req OS423 */\r
+ rv = NO_ACCESS;\r
+ break;\r
+ }\r
+\r
+ orv = rv ? ACCESS : NO_ACCESS;\r
+\r
+ return orv;\r
+}\r
+\r
+/**\r
+ * This service determines to which OS-Application a given Task, ISR, Resource,\r
+ * Counter, Alarm or Schedule Table belongs\r
+ *
+ * @param ObjectType Type of the following parameter
+ * @param object The object to be examined\r
+ * @return The OS-Application to which the object ObjectType belongs or\r
+ * INVALID_OSAPPLICATION if the object does not exists
+ */\r
+ApplicationType CheckObjectOwnership( ObjectTypeType ObjectType,\r
+ uint32_t objectId )\r
+{\r
+ ApplicationType rv = INVALID_OSAPPLICATION;\r
+\r
+ switch( ObjectType ) {\r
+ case OBJECT_ALARM:\r
+ break;\r
+ case OBJECT_COUNTER:\r
+ break;\r
+ case OBJECT_ISR:\r
+ break;\r
+ case OBJECT_MESSAGE:\r
+ break;\r
+ case OBJECT_RESOURCE:\r
+ break;\r
+ case OBJECT_SCHEDULETABLE:\r
+ break;\r
+ case OBJECT_TASK:\r
+#if 0\r
+ if( objectId < OS_TASK_CNT ) {\r
+ rv = Os_TaskGet(objectId)\r
+ }\r
+\r
+\r
+ OsTaskVarTypeapplOwnerId\r
+ if( objectId > OS_MAX )\r
+#endif\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return rv;\r
+}\r
+\r
+\r
+/**\r
+ * This service terminates the OS-Application to which the calling Task/Category 2\r
+ * ISR/application specific error hook belongs.\r
+ *
+ * @param Application - The identifier of the OS-Application to be terminated.\r
+ * If the caller belongs to <Application> the call results in a\r
+ * self termination.\r
+ *\r
+ * @param RestartOption - Either RESTART for doing a restart of the\r
+ * OS-Application or NO_RESTART if OS-Application shall not be restarted.\r
+ *
+ * @return E_OK: No errors\r
+ * E_OS_ID: <Application> was not valid\r
+ * E_OS_VALUE: <RestartOption> was neither RESTART nor NO_RESTART\r
+ * E_OS_ACCESS: The caller does not have the right to terminate <Application>\r
+ * E_OS_STATE: The state of <Application> does not allow terminating <Application>
+ */\r
+StatusType TerminateApplication( ApplicationType applId, RestartType restartOption ) {\r
+ (void)applId;\r
+ (void)restartOption;\r
+ return E_OK;\r
+}\r
+\r
+\r
+/**\r
+ * This service sets the own state of an OS-Application from\r
+ * APPLICATION_RESTARTING to APPLICATION_ACCESSIBLE.\r
+ *
+ * @return E_OK : No errors\r
+ * E_OS_STATE : The OS-Application of the caller is in the wrong\r
+state
+ */\r
+StatusType AllowAccess( void ) {\r
+ ApplicationType applId = Os_Sys.currApplId;\r
+\r
+ /* @req OS497 */\r
+ if( Os_AppVar[applId].state != APPLICATION_RESTARTING ) {\r
+ return E_OS_STATE;\r
+ }\r
+\r
+ /* @req OS498 */\r
+ Os_AppVar[applId].state = APPLICATION_ACCESSIBLE;\r
+ return E_OK;\r
+}\r
+\r
+/**\r
+ * This service returns the current state of an OS-Application.\r
+ * SC: SC3 and SC4\r
+ *
+ * @param ApplId The OS-Application from which the state is requested
+ * @param Value The current state of the application
+ * @return E_OK: No errors, E_OS_ID: <Application> is not valid
+ */\r
+StatusType GetApplicationState( ApplicationType applId, ApplicationStateRefType value ) {\r
+\r
+ if(applId > OS_APPLICATION_CNT ) {\r
+ return E_OS_ID;\r
+ }\r
+\r
+ *value = Os_AppVar[applId].state;\r
+\r
+ return E_OK;\r
+}\r
+\r
+\r
+/**\r
+ * TODO: Move somewhere else
+ * @param mode
+ * @return
+ */\r
StatusType GetActiveApplicationMode( AppModeType* mode) {\r
- *mode = os_sys.appMode;\r
+ *mode = Os_Sys.appMode;\r
return E_OK;\r
}\r
+\r
+/**\r
+ *
+ */\r
+void Os_ApplStart( void ) {\r
+ uint16_t i;\r
+\r
+ /* Call startuphooks for all applications */\r
+ for(i=0;i<OS_APPLICATION_CNT;i++) {\r
+\r
+ Os_AppVar[i].state = APPLICATION_ACCESSIBLE;\r
+\r
+ if( Os_AppConst[i].StartupHook != NULL ) {\r
+ Os_AppConst[i].StartupHook();\r
+ }\r
+ }\r
+}\r
+\r
+#endif\r
__declspec(section ".apa") char _var[100+ (_offset)]\r
#pragma section ".apa" ".apa"\r
#endif\r
-\r
- DECLARE(PCB_STACK_CURR_P, offsetof(OsPcbType, stack));\r
- DECLARE(PCB_ENTRY_P, offsetof(OsPcbType, entry));\r
- DECLARE(SYS_CURR_PCB_P, offsetof(sys_t, curr_pcb));\r
- DECLARE(SYS_INT_NEST_CNT, offsetof(sys_t, int_nest_cnt));\r
- DECLARE(SYS_INT_STACK, offsetof(sys_t, int_stack));\r
+DECLARE(PCB_STACK_CURR_P, offsetof(OsTaskVarType, stack));\r
+ DECLARE(PCB_CONST_P, offsetof(OsTaskVarType, constPtr));\r
+// DECLARE(PCB_ENTRY_P, offsetof(OsTaskVarType, entry));\r
+ DECLARE(SYS_CURR_PCB_P, offsetof(Os_SysType, currTaskPtr));\r
+ DECLARE(SYS_INT_NEST_CNT, offsetof(Os_SysType, intNestCnt));\r
+ DECLARE(SYS_INT_STACK, offsetof(Os_SysType, intStack));\r
#if defined(__GNUC__)\r
}\r
#endif\r
*\r
*/\r
\r
+#include "Os.h"\r
+\r
void apa(void *);\r
\r
void interrupt(void) __attribute__((__interrupt__));\r
\r
void func1( int a ) {\r
\r
+\r
}\r
\r
int func3( int a ) {\r
if( cPtr->type == COUNTER_TYPE_HARD ) {\r
if( cPtr->driver == NULL ) {\r
/* It's OSINTERNAL */\r
- *tick_ref = os_sys.tick;\r
+ *tick_ref = Os_Sys.tick;\r
} else {\r
#if 0\r
/* We support only GPT for now */\r
\r
OsCounterType *cPtr = Os_CfgGetCounter(Os_Arc_OsTickCounter);\r
\r
- os_sys.tick++;\r
+ Os_Sys.tick++;\r
\r
cPtr->val = Os_CounterAdd( cPtr->val, Os_CounterGetMaxValue(cPtr), 1 );\r
\r
- // os_sys.tick = cPtr->val;\r
+ // Os_Sys.tick = cPtr->val;\r
#if OS_ALARM_CNT!=0\r
Os_AlarmCheck(cPtr);\r
#endif\r
}\r
\r
TickType GetOsTick( void ) {\r
- return get_os_tick();\r
+ return Os_Sys.tick;\r
}\r
\r
\r
\r
StatusType WaitEvent( EventMaskType Mask ) {\r
\r
- OsPcbType *curr_pcb = get_curr_pcb();\r
+ OsTaskVarType *curr_pcb = get_curr_pcb();\r
StatusType rv = E_OK;\r
\r
OS_DEBUG(D_EVENT,"# WaitEvent %s\n",Os_TaskGetCurrent()->name);\r
\r
- if( os_sys.int_nest_cnt != 0 ) {\r
+ if( Os_Sys.intNestCnt != 0 ) {\r
rv = E_OS_CALLEVEL;\r
goto err;\r
}\r
\r
- if (curr_pcb->proc_type != PROC_EXTENDED) {\r
+ if (curr_pcb->constPtr->proc_type != PROC_EXTENDED) {\r
rv = E_OS_ACCESS;\r
goto err;\r
}\r
curr_pcb->ev_wait = Mask;\r
\r
if ( Os_SchedulerResourceIsFree() ) {\r
- // Os_TaskMakeWaiting(curr_pcb);\r
+ // Os_TaskMakeWaiting(currTaskPtr);\r
Os_Dispatch(OP_WAIT_EVENT);\r
assert( curr_pcb->state & ST_RUNNING );\r
} else {\r
\r
StatusType SetEvent( TaskType TaskID, EventMaskType Mask ) {\r
StatusType rv = E_OK;\r
- OsPcbType *dest_pcb;\r
- OsPcbType *currPcbPtr;\r
+ OsTaskVarType *destPcbPtr;\r
+ OsTaskVarType *currPcbPtr;\r
uint32_t flags;\r
\r
OS_DEBUG(D_EVENT,"# SetEvent %s\n",Os_TaskGetCurrent()->name);\r
goto err;\r
}\r
\r
- dest_pcb = os_get_pcb(TaskID);\r
+ destPcbPtr = Os_TaskGet(TaskID);\r
+\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+ if( destPcbPtr->constPtr->applOwnerId != Os_Sys.currApplId ) {\r
+ /* We are activating a task in another application */\r
+ if( Os_AppVar[Os_Sys.currApplId].state != APPLICATION_ACCESSIBLE ) {\r
+ rv=E_OS_ACCESS;\r
+ goto err;\r
+ }\r
+ }\r
+#endif\r
\r
#if (OS_STATUS_EXTENDED == STD_ON )\r
- if( dest_pcb->proc_type != PROC_EXTENDED ) {\r
+ if( destPcbPtr->constPtr->proc_type != PROC_EXTENDED ) {\r
rv = E_OS_ACCESS;\r
goto err;\r
}\r
\r
- if( (dest_pcb->state & ST_SUSPENDED ) ) {\r
+ if( (destPcbPtr->state & ST_SUSPENDED ) ) {\r
rv = E_OS_STATE;\r
goto err;\r
}\r
* defined, see chapter 9.2)\r
* ... */\r
\r
- dest_pcb->ev_set |= Mask;\r
+ destPcbPtr->ev_set |= Mask;\r
\r
- if( (Mask & dest_pcb->ev_wait) ) {\r
+ if( (Mask & destPcbPtr->ev_wait) ) {\r
/* We have an event match */\r
- if( dest_pcb->state & ST_WAITING) {\r
- Os_TaskMakeReady(dest_pcb);\r
+ if( destPcbPtr->state & ST_WAITING) {\r
+ Os_TaskMakeReady(destPcbPtr);\r
\r
currPcbPtr = Os_TaskGetCurrent();\r
/* Checking "4.6.2 Non preemptive scheduling" it does not dispatch if NON */\r
- if( (os_sys.int_nest_cnt == 0) &&\r
- (currPcbPtr->scheduling == FULL) &&\r
- (dest_pcb->prio > currPcbPtr->prio) &&\r
+ if( (Os_Sys.intNestCnt == 0) &&\r
+ (currPcbPtr->constPtr->scheduling == FULL) &&\r
+ (destPcbPtr->activePriority > currPcbPtr->activePriority) &&\r
(Os_SchedulerResourceIsFree()) )\r
{\r
Os_Dispatch(OP_SET_EVENT);\r
}\r
\r
- } else if(dest_pcb->state & (ST_READY|ST_RUNNING) ) {\r
+ } else if(destPcbPtr->state & (ST_READY|ST_RUNNING) ) {\r
/* Hmm, we do nothing */\r
} else {\r
assert( 0 );\r
*/\r
StatusType GetEvent( TaskType TaskId, EventMaskRefType Mask) {\r
\r
- OsPcbType *dest_pcb;\r
+ OsTaskVarType *destPcbPtr;\r
StatusType rv = E_OK;\r
\r
if( TaskId >= OS_TASK_CNT ) {\r
goto err;\r
}\r
\r
- dest_pcb = os_get_pcb(TaskId);\r
+ destPcbPtr = Os_TaskGet(TaskId);\r
\r
- VALIDATE_W_RV(dest_pcb->proc_type != PROC_EXTENDED,E_OS_ACCESS);\r
- VALIDATE_W_RV(dest_pcb->state & ST_SUSPENDED,E_OS_STATE);\r
+ VALIDATE_W_RV(destPcbPtr->constPtr->proc_type != PROC_EXTENDED,E_OS_ACCESS);\r
+ VALIDATE_W_RV(destPcbPtr->state & ST_SUSPENDED,E_OS_STATE);\r
\r
- *Mask = dest_pcb->ev_set;\r
+ *Mask = destPcbPtr->ev_set;\r
\r
if (0) goto err;\r
\r
*/\r
StatusType ClearEvent( EventMaskType Mask) {\r
StatusType rv = E_OK;\r
- OsPcbType *pcb;\r
+ OsTaskVarType *pcb;\r
\r
- if( os_sys.int_nest_cnt != 0 ) {\r
+ if( Os_Sys.intNestCnt != 0 ) {\r
rv = E_OS_CALLEVEL;\r
goto err;\r
}\r
\r
pcb = get_curr_pcb();\r
\r
- if (pcb->proc_type != PROC_EXTENDED) {\r
+ if (pcb->constPtr->proc_type != PROC_EXTENDED) {\r
rv = E_OS_ACCESS;\r
goto err;\r
}\r
} OsAlarmAutostartType;\r
\r
/* STD container : OsAlarm\r
- * OsAlarmAccessionApplication: 0..* Ref to OS application\r
+ * OsAlarmAccessingApplication: 0..* Ref to OS application\r
* OsAlamCounterRef: 1 Ref to counter\r
* OsAlarmAction[C] 1 Action when alarm expires\r
* OsAlarmAutostart[C] 0..1 Autostart\r
/* Reference to counter */\r
struct OsCounter *counter;\r
\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+ ApplicationType applOwnerId;\r
+ uint32 accessingApplMask;\r
+#endif\r
+\r
CounterType counter_id;\r
/* cycle, 0 = no cycle */\r
uint32 alarmtime;\r
#ifndef APPLICATION_H_\r
#define APPLICATION_H_\r
\r
-#if ( OS_SC3 == STD_ON) || ( OS_SC4 == STD_ON )\r
+/*\r
+ * IMPLEMENTATION NOTES:\r
+ *\r
+ * OS448: The Operating System module shall prevent access of\r
+ * OS-Applications, trusted or non-trusted, to objects not belonging\r
+ * to this OS-Application, except access rights for such objects are\r
+ * explicitly granted by configuration.\r
+ *\r
+ * OS509: If a service call is made on an Operating System\r
+ * object that is owned by another OS-Application without state\r
+ * APPLICATION_ACCESSIBLE, then the Operating System module shall return E_OS_ACCESS.\r
+ *\r
+ * OS056: If an OS-object identifier is the parameter of an Operating System module\92s\r
+ * system service, and no sufficient access rights have been assigned to this OS-object\r
+ * at configuration time (Parameter Os[...]AccessingApplication) to the calling\r
+ * Task/Category 2 ISR, the Operating System module\92s system service shall return\r
+ * E_OS_ACCESS.\r
+ *\r
+ * OS311: If OsScalabilityClass is SC3 or SC4 AND a Task OR Category 2 ISR OR\r
+ * Resources OR Counters OR Alarms OR Schedule tables does not belong to exactly\r
+ * one OS-Application the consistency check shall issue an error.\r
+ *\r
+ * Page 52:\r
+ * It is assumed that the Operating System module itself is trusted.\r
+ *\r
+ * Sooo, that gives us:\r
+ * 1. For each\r
+ *\r
+ *\r
+ * 1. App1, NT\r
+ * Task11\r
+ * 2. App2, NT\r
+ * Task21\r
+ * 3. App3, T\r
+ * Task31\r
+ * 4. App4, T\r
+ * Task41\r
+ *\r
+ * * App2->App1: ActivateTask(Task11)\r
+ * This is OK as long as Task11 have granted access to it during configuration\r
+ * * App4->App3: ActivateTask(Task31)\r
+ * This is OK as long as Task31 have granted access to it during configuration\r
+ * * App1->App4: ActivateTask(Task41)\r
+ * It's not really clear if the OS automagically exports all services..\r
+ * But this could also be CallTrustedFunction(ServiceId_AcivateTask,???)\r
+ *
+ */\r
+\r
+\r
+\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
\r
/* STD container : OsApplicationHooks\r
* class: 3,4\r
* management issue, not an access issue.\r
* */\r
\r
-typedef struct OsApplication {\r
+typedef struct OsAppVar {\r
/* 0 - Non-trusted application\r
* 1 - Trusted application */\r
_Bool trusted;\r
\r
/* NOTE! Refs here is memory management issue */\r
\r
- /* The application hooks */\r
- OsAppHooksType hooks;\r
+ /* The current state of the application */\r
+ ApplicationStateType state;\r
\r
/* Trusted functions */\r
/* .... */\r
-} OsApplicationType;\r
+} OsAppVarType;\r
\r
\r
/* NON standard type.\r
* Used for ROM based parameters.... TODO\r
*/\r
-typedef struct OsRomApplication {\r
- uint32 application_id;\r
+typedef struct OsApplication {\r
+ uint32 appId;\r
char name[16];\r
- uint8 trusted;\r
+ _Bool trusted;\r
\r
- /* hooks */\r
+ /* hooks, the names are StartupHook_<name>(), etc. */\r
void (*StartupHook)( void );\r
- void (*ShutdownHook)( Std_ReturnType Error );\r
- void (*ErrorHook)( Std_ReturnType Error );\r
+ void (*ShutdownHook)( StatusType Error );\r
+ void (*ErrorHook)( StatusType Error );\r
+\r
+ /* The application hooks */\r
+// OsAppHooksType hooks;\r
+\r
+\r
+ /* Ref is ~0U terminated */\r
+#if 0\r
+ const uint8_t *alarmRef;\r
+ const uint8_t *counterRef;\r
+ const uint8_t *isrRef;\r
+ const uint8_t *resourceRef;\r
+ const uint8_t *schtblRef;\r
+ const uint8_t *taskRef;\r
+#endif\r
\r
- uint32 isr_mask;\r
- uint32 scheduletable_mask;\r
- uint32 alarm_mask;\r
- uint32 counter_mask;\r
- uint32 resource_mask;\r
- uint32 message_mask;\r
+ int restartTaskId;\r
+} OsAppConstType;\r
\r
-} OsRomApplicationType;\r
+#if OS_APPLICATION_CNT!=0\r
+extern OsAppVarType Os_AppVar[OS_APPLICATION_CNT];\r
+#endif\r
\r
-#endif /* ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) */\r
+#endif /* (OS_USE_APPLICATIONS == STD_ON) */\r
\r
\r
#endif /* APPLICATION_H_ */\r
*\r
* @param pcb Ptr to pcb\r
*/\r
-void Os_ArchSetupContext( OsPcbType *pcb );\r
+void Os_ArchSetupContext( OsTaskVarType *pcb );\r
\r
/**\r
* Get current stack pointer\r
*/\r
unsigned int Os_ArchGetScSize( void );\r
\r
-void Os_ArchSetTaskEntry(OsPcbType *pcbPtr );\r
+void Os_ArchSetTaskEntry(OsTaskVarType *pcbPtr );\r
\r
\r
#endif /*ARCH_H_*/\r
// The counter value ( if software counter )\r
uint32_t val;\r
// Application mask, SWS OS317\r
- uint32_t app_mask;\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+ ApplicationType applOwnerId;\r
+ uint32 accessingApplMask;\r
+#endif\r
// hmm, strange to call it alarm base.... but see spec.\r
AlarmBaseType alarm_base;\r
/* Used only if we configure a GPT timer as os timer */\r
#define EXT_CONFIG_H_\r
\r
/* Created in Os_CfgConfig */\r
-struct OsPcb;\r
+struct OsTaskVar;\r
struct OsAlarm;\r
struct OsCounter;\r
struct OsSchTbl;\r
struct OsResource;\r
struct OsMessage;\r
-#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON )\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
struct OsRomApplication;\r
#endif\r
\r
-#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON )\r
-int Os_CfgGetApplCnt(void);\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+extern const OsAppConstType Os_AppConst[OS_APPLICATION_CNT];\r
+\r
struct OsRomApplication *Os_CfgGetApplObj( ApplicationType application_id );\r
#endif\r
-int Os_CfgGetTaskCnt(void);\r
void *Os_CfgGetIdleProcStack(void);\r
-int Os_CfgGetResourceCnt(void);\r
StatusType Os_CfgGetAlarmBase(AlarmType alarm_id, AlarmBaseRefType info);\r
-uint32 Os_CfgGetAlarmCnt(void);\r
struct OsAlarm *Os_CfgGetAlarmObj( AlarmType alarm_id );\r
struct OsCounter *Os_CfgGetCounter(CounterType);\r
-uint32 Os_CfgGetCounterCnt(void );\r
-uint32 Os_CfgGetSchedCnt( void );\r
struct OsSchTbl *Os_CfgGetSched( ScheduleTableType sched_id );\r
-uint32 Os_CfgGetServiceCnt( void ) ;\r
struct OsResource *Os_CfgGetResource( ResourceType resource );\r
-\r
struct OsMessage *Os_CfgGetMessage(MessageType message_id);\r
-uint32 Os_CfgGetMessageCnt(void );\r
void Os_CfgValidate( void );\r
\r
#endif /*EXT_CONFIG_H_*/\r
*\r
* Os.h\r
* |\r
- * |--- Os_Cfg.h\r
- * |\r
* |--- Std_Types.h\r
* | |--- Platform_Types.h (std?)\r
* | |--- Compiler.h (std?)\r
* |\r
+ * |--- Os_Cfg.h\r
+ * |\r
* |--- MemMap.h\r
*\r
*\r
*/\r
\r
#define ERRORHOOK(x) \\r
- if( os_sys.hooks->ErrorHook != NULL ) { \\r
- os_sys.hooks->ErrorHook(x); \\r
+ if( Os_Sys.hooks->ErrorHook != NULL ) { \\r
+ Os_Sys.hooks->ErrorHook(x); \\r
}\r
\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+#define PROTECTIONHOOK(_x) \\r
+ do { \\r
+ if( Os_Sys.hooks->ProtectionHook != NULL ) { \\r
+ Os_Sys.hooks->ProtectionHook(_x); \\r
+ } \\r
+ } while(0)\r
+\r
+#endif\r
+\r
\r
#define PRETASKHOOK() \\r
- assert( os_sys.curr_pcb->state & ST_RUNNING ); \\r
- assert( os_sys.curr_pcb->flags == SYS_FLAG_HOOK_STATE_EXPECTING_PRE ); \\r
- os_sys.curr_pcb->flags = SYS_FLAG_HOOK_STATE_EXPECTING_POST; \\r
- if( os_sys.hooks->PreTaskHook != NULL ) { \\r
- os_sys.hooks->PreTaskHook(); \\r
+ assert( Os_Sys.currTaskPtr->state & ST_RUNNING ); \\r
+ assert( Os_Sys.currTaskPtr->flags == SYS_FLAG_HOOK_STATE_EXPECTING_PRE ); \\r
+ Os_Sys.currTaskPtr->flags = SYS_FLAG_HOOK_STATE_EXPECTING_POST; \\r
+ if( Os_Sys.hooks->PreTaskHook != NULL ) { \\r
+ Os_Sys.hooks->PreTaskHook(); \\r
}\r
\r
#define POSTTASKHOOK() \\r
- assert( os_sys.curr_pcb->state & ST_RUNNING ); \\r
- assert( os_sys.curr_pcb->flags == SYS_FLAG_HOOK_STATE_EXPECTING_POST ); \\r
- os_sys.curr_pcb->flags = SYS_FLAG_HOOK_STATE_EXPECTING_PRE; \\r
- if( os_sys.hooks->PostTaskHook != NULL ) { \\r
- os_sys.hooks->PostTaskHook(); \\r
+ assert( Os_Sys.currTaskPtr->state & ST_RUNNING ); \\r
+ assert( Os_Sys.currTaskPtr->flags == SYS_FLAG_HOOK_STATE_EXPECTING_POST ); \\r
+ Os_Sys.currTaskPtr->flags = SYS_FLAG_HOOK_STATE_EXPECTING_PRE; \\r
+ if( Os_Sys.hooks->PostTaskHook != NULL ) { \\r
+ Os_Sys.hooks->PostTaskHook(); \\r
}\r
\r
/*\r
* PCB manipulating functions\r
*/\r
\r
+#if 0\r
static inline OsTaskidType get_curr_pid( void ) {\r
- return os_sys.curr_pcb->pid;\r
+ return Os_Sys.currTaskPtr->pid;\r
}\r
+#endif\r
\r
-static inline OsPcbType *get_curr_pcb( void ) {\r
- return os_sys.curr_pcb;\r
+static inline OsTaskVarType *get_curr_pcb( void ) {\r
+ return Os_Sys.currTaskPtr;\r
}\r
\r
-static inline void set_curr_pcb( OsPcbType *pcb ) {\r
- os_sys.curr_pcb = pcb;\r
+static inline void set_curr_pcb( OsTaskVarType *pcb ) {\r
+ Os_Sys.currTaskPtr = pcb;\r
}\r
-\r
-static inline _Bool is_idle_task( OsPcbType *pcb ){\r
+#if 0\r
+static inline _Bool is_idle_task( OsTaskVarType *pcb ){\r
return (pcb->pid == 0);\r
}\r
\r
+\r
static inline OsTaskidType get_curr_prio( void ){\r
- return os_sys.curr_pcb->prio;\r
+ return Os_Sys.currTaskPtr->prio;\r
}\r
\r
-static inline TickType get_os_tick( void ) {\r
- return os_sys.tick;\r
-}\r
\r
-#if ( OS_SC3 == STD_ON ) || ( OS_SC4 == STD_ON )\r
-static inline OsApplicationType *get_curr_application( void ) {\r
- return get_curr_pcb()->application;\r
+static inline TickType get_os_tick( void ) {\r
+ return Os_Sys.tick;\r
}\r
\r
-static inline uint32_t get_curr_application_id( void ) {\r
- return get_curr_pcb()->application->application_id;\r
-}\r
-#endif\r
\r
static inline struct OsResource *os_get_resource_int_p( void ) {\r
- return get_curr_pcb()->resource_int_p;\r
+ return get_curr_pcb()->resourceIntPtr;\r
}\r
+#endif\r
\r
/*\r
* Misc\r
}\r
\r
// task_i.c\r
-OsPcbType *Os_TaskGetTop( void );\r
-OsPcbType *os_find_task( TaskType tid );\r
+OsTaskVarType *Os_TaskGetTop( void );\r
+OsTaskVarType *Os_TaskGet( TaskType tid );\r
\r
// resource.c\r
void Os_ResourceGetInternal(void );\r
void Os_ResourceReleaseInternal( void );\r
-void Os_ResourceAlloc( OsResourceType *rPtr, OsPcbType *pcbPtr);\r
-void Os_ResourceFree( OsResourceType *rPtr , OsPcbType *pcbPtr);\r
+void Os_ResourceAlloc( OsResourceType *rPtr, OsTaskVarType *pcbPtr);\r
+void Os_ResourceFree( OsResourceType *rPtr , OsTaskVarType *pcbPtr);\r
\r
void Os_ResourceInit( void );\r
\r
\r
-static inline void Os_ResourceFreeAll( OsPcbType *pcbPtr ) {\r
+/* Application */\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+void Os_ApplStart( void );\r
+#endif\r
+\r
+static inline void Os_ResourceFreeAll( OsTaskVarType *pcbPtr ) {\r
OsResourceType *rPtr;\r
\r
/* Pop the queue */\r
- TAILQ_FOREACH(rPtr, &pcbPtr->resource_head, listEntry ) {\r
+ TAILQ_FOREACH(rPtr, &pcbPtr->resourceHead, listEntry ) {\r
Os_ResourceFree(rPtr,pcbPtr);\r
}\r
}\r
\r
-#if 0\r
-/**\r
- *\r
- * @return 1 - if any resources were found.\r
- */\r
-static inline _Bool Os_ResourceCheckAndRelease( OsPcbType *pcb ) {\r
- _Bool rv = 0;\r
- if( !TAILQ_EMPTY(&pcb->resource_head) ) {\r
- OsResourceType *rPtr;\r
-\r
- TAILQ_FOREACH(rPtr, &pcb->resource_head, listEntry ) {\r
- ReleaseResource(rPtr->nr);\r
- /* Requirements are a little fuzzy here, no explicit\r
- * requirement for this.\r
- *\r
- * For OSEK this is a req.\r
- */\r
- ERRORHOOK(E_OS_RESOURCE);\r
- rv = 1;\r
- }\r
- }\r
- return rv;\r
+static inline _Bool Os_TaskOccupiesResources( OsTaskVarType *pcb ) {\r
+ return !(TAILQ_EMPTY(&pcb->resourceHead));\r
}\r
-#endif\r
\r
-static inline _Bool Os_TaskOccupiesResources( OsPcbType *pcb ) {\r
- return !(TAILQ_EMPTY(&pcb->resource_head));\r
-}\r
-\r
-/*\r
-static inline void Os_GetSchedulerResource() {\r
- os_sys.scheduler_lock = 1;\r
-}\r
-\r
-static inline void Os_ReleaseSchedulerResource() {\r
- os_sys.scheduler_lock = 0;\r
-}\r
-*/\r
-/*\r
-static inline _Bool Os_SchedulerResourceIsOccupied() {\r
-#if 0\r
- return (os_sys.resScheduler.owner != NO_TASK_OWNER );\r
-#else\r
- return (os_sys.scheduler_lock == 1);\r
-#endif\r
-}\r
-*/\r
#define NO_TASK_OWNER (TaskType)(~0)\r
\r
static inline _Bool Os_SchedulerResourceIsFree() {\r
#if 1\r
- return (os_sys.resScheduler.owner == NO_TASK_OWNER );\r
+ return (Os_Sys.resScheduler.owner == NO_TASK_OWNER );\r
#else\r
- return (os_sys.scheduler_lock == 0);\r
+ return (Os_Sys.scheduler_lock == 0);\r
#endif\r
}\r
\r
// Create.c\r
-OsPcbType * os_alloc_new_pcb( void );\r
+OsTaskVarType * os_alloc_new_pcb( void );\r
\r
void os_dispatch(void);\r
\r
void TailChaining(void *stack);\r
#endif\r
\r
-void *Os_Isr( void *stack, void *pcb_p );\r
+void *Os_Isr( void *stack, int16_t vector);\r
void Os_Dispatch( uint32_t op );\r
\r
#define STACK_PATTERN 0x42\r
\r
-static inline void *Os_StackGetUsage( OsPcbType *pcb ) {\r
+static inline void *Os_StackGetUsage( OsTaskVarType *pcb ) {\r
\r
uint8_t *p = pcb->stack.curr;\r
uint8_t *end = pcb->stack.top;\r
return (void *)end;\r
}\r
\r
-static inline void Os_StackSetEndmark( OsPcbType *pcbPtr ) {\r
+static inline void Os_StackSetEndmark( OsTaskVarType *pcbPtr ) {\r
uint8_t *end = pcbPtr->stack.top;\r
*end = STACK_PATTERN;\r
}\r
\r
-static inline _Bool Os_StackIsEndmarkOk( OsPcbType *pcbPtr ) {\r
+static inline _Bool Os_StackIsEndmarkOk( OsTaskVarType *pcbPtr ) {\r
_Bool rv;\r
uint8_t *end = pcbPtr->stack.top;\r
rv = ( *end == STACK_PATTERN);\r
return rv;\r
}\r
\r
-static inline void Os_StackPerformCheck( OsPcbType *pcbPtr ) {\r
+static inline void Os_StackPerformCheck( OsTaskVarType *pcbPtr ) {\r
#if (OS_STACK_MONITORING == 1)\r
if( !Os_StackIsEndmarkOk(pcbPtr) ) {\r
-#if ( OS_SC1 == 1) || ( OS_SC2 == 1)\r
+#if (OS_SC1 == STD_ON) || (OS_SC2 == STD_ON)\r
/** @req OS068 */\r
ShutdownOS(E_OS_STACKFAULT);\r
-#else\r
-#error SC3 or SC4 not supported. Protection hook should be called here\r
+#elif (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON)\r
+ /** @req OS396 */\r
+ PROTECTIONHOOK(E_OS_STACKFAULT);\r
#endif\r
}\r
#endif\r
\r
\r
int Os_CfgGetTaskCnt(void);\r
-void Os_ContextReInit( OsPcbType *pcbPtr );\r
+void Os_ContextReInit( OsTaskVarType *pcbPtr );\r
\r
\r
static inline _Bool Os_IrqAnyDisabled( void ) {\r
\r
// What application may access this resource. A resource may only be\r
// accessed by one application\r
-#if ( OS_SC3 == STD_ON ) || ( OS_SC4 == STD_ON )\r
- uint32 application_owner_id;\r
+#if defined(SC3) || defined(SC4)\r
+ uint32 accessingApplMask;\r
#endif\r
// What tasks may access this resource. A resource may be be shared\r
// several tasks.\r
#include "application.h"\r
#include "pcb.h"\r
#include "sys.h"\r
+#include "isr.h"\r
+//#include "isr.h"\r
\r
/*-----------------------------------------------------------------*/\r
\r
#define PCB_H\r
\r
struct OsApplication;\r
-struct OsRomPcb;\r
+struct OsTaskConst;\r
\r
#define PID_IDLE 0\r
#define PRIO_IDLE 0\r
#define ST_RUNNING (1<<3)\r
#define ST_NOT_STARTED (1<<4)\r
\r
+#define ST_ISR_RUNNING 1\r
+#define ST_ISR_NOT_RUNNING 2\r
+\r
typedef uint16_t state_t;\r
\r
/* from Os.h types */\r
* Class: ALL\r
*\r
* OsIsrCategory: 1 CATEGORY_1 or CATEGORY_2\r
- * OsIsrResourceRef: 0..1 Reference to OsResource\r
+ * OsIsrResourceRef: 0..* Reference to OsResources\r
* OsIsrTimingProtection[C] 0..1\r
* */\r
\r
+\r
+\r
+\r
/* STD container : OsIsrResourceLock\r
* Class: 2 and 4\r
*\r
* OsIsrResourceLockResourceRef 1 Ref to OsResource\r
* */\r
\r
+typedef struct OsIsrResourceLock {\r
+ uint32_t lockBudget;\r
+ uint32_t lockResourceRef; /* Wrong type */\r
+} OsIsrResourceLockType;\r
+\r
+\r
/* STD container : OsIsrTimingProtection\r
* Class: 2 and 4\r
*\r
* OsIsrExecutionBudget 0..1 float\r
* OsIsrOsInterruptLockBudget 0..1 float\r
* OsIsrTimeFrame 0..1 float\r
- * OsIsrResourceLock[C] 0..1\r
+ * OsIsrResourceLock[C] 0..*\r
* */\r
\r
+typedef struct OsIsrTimingProtection {\r
+ uint32_t allInterruptLockBudget;\r
+ uint32_t executionBudget;\r
+ uint32_t osInterruptLockBudget;\r
+ uint32_t timeFrame;\r
+ uint32_t resourceLock; /* Wrong type */\r
+} OsIsrTimingProtectionType;\r
+\r
\r
\r
/* STD container : OsHooks\r
* */\r
\r
typedef struct OsHooks {\r
-#if ( OS_SC2 == STD_ON ) || ( OS_SC3 == STD_ON ) || ( OS_SC4 == STD_ON )\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
ProtectionHookType ProtectionHook;\r
#endif\r
StartupHookType StartupHook;\r
#define PROC_BASIC 0x1\r
#define PROC_EXTENDED 0x3\r
\r
+#if 0\r
#define PROC_ISR 0x4\r
#define PROC_ISR1 0x4\r
#define PROC_ISR2 0xc\r
+#endif\r
\r
\r
typedef struct {\r
#define SYS_FLAG_HOOK_STATE_EXPECTING_POST 1\r
\r
/* We do ISR and TASK the same struct for now */\r
-typedef struct OsPcb {\r
- OsTaskidType pid; // TASK\r
- OsPriorityType prio;\r
-#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON )\r
- ApplicationType application_id;\r
- uint32 app_mask;\r
-#endif\r
- void (*entry)();\r
- proc_type_t proc_type;\r
- int autostart:1; // TASK\r
+typedef struct OsTaskVar {\r
OsStackType stack; // TASK\r
\r
- int vector; // ISR\r
- char name[TASK_NAME_SIZE];\r
#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )\r
OsTimingProtectionType *timing_protection;\r
#endif\r
\r
state_t state; // TASK\r
- OsEventType ev_wait; // TASK\r
- OsEventType ev_set; // TASK\r
+\r
+ /* Events the task wait for ( what events WaitEvent() was called with) */\r
+ OsEventType ev_wait;\r
+ /* Events that are set by SetEvent() on the task */\r
+ OsEventType ev_set;\r
+ /* The events the task may react on */\r
+ OsEventType ev_react;\r
\r
uint32_t flags;\r
\r
+ /* Priority of the task, this can be different depening on if the\r
+ * task hold resources. Related to priority inversion */\r
+ OsPriorityType activePriority;\r
+#if 0\r
+ void (*entry)();\r
+\r
+ char name[TASK_NAME_SIZE];\r
+\r
+ OsTaskidType pid; // TASK\r
+ OsPriorityType prio;\r
+\r
+ proc_type_t proc_type;\r
+ int autostart; // TASK\r
+\r
enum OsTaskSchedule scheduling; // TASK\r
/* belongs to this application */\r
struct OsApplication *application;\r
-\r
/* OsTaskActivation\r
* The limit from OsTaskActivation. This is 1 for extended tasks */\r
uint8_t activationLimit;\r
- // The number of queued activation of a task\r
- int8_t activations;\r
\r
// A task can hold only one internal resource and only i f\r
// OsTaskSchedule == FULL\r
- OsResourceType *resource_int_p; // TASK\r
+ OsResourceType *resourceIntPtr; // TASK\r
\r
// OsTaskResourceRef\r
// What resources this task have access to\r
// Typically (1<<RES_xxx) | (1<<RES_yyy)\r
uint32_t resourceAccess;\r
\r
+#endif\r
+\r
+ // The number of queued activation of a task\r
+ int8_t activations;\r
\r
// What resource that are currently held by this task\r
// Typically (1<<RES_xxx) | (1<<RES_yyy)\r
uint32_t resourceMaskTaken;\r
\r
- TAILQ_HEAD(head,OsResource) resource_head; // TASK\r
+ TAILQ_HEAD(head,OsResource) resourceHead; // TASK\r
\r
- const struct OsRomPcb *pcb_rom_p;\r
+ const struct OsTaskConst *constPtr;\r
\r
/* TODO: Arch specific regs .. make space for them later...*/\r
uint32_t regs[16]; // TASK\r
/* List of PCB's */\r
- TAILQ_ENTRY(OsPcb) pcb_list; // TASK\r
+// TAILQ_ENTRY(OsTaskVar) pcb_list; // TASK\r
/* ready list */\r
- TAILQ_ENTRY(OsPcb) ready_list; // TASK\r
-} OsPcbType;\r
+ TAILQ_ENTRY(OsTaskVar) ready_list; // TASK\r
+} OsTaskVarType;\r
\r
/*-----------------------------------------------------------------*/\r
\r
-typedef struct OsRomPcb {\r
+\r
+/*-----------------------------------------------------------------*/\r
+\r
+/* STD container : OsTask\r
+ * OsTaskActivation: 1\r
+ * OsTaskPriority: 1\r
+ * OsTaskSchedule: 1\r
+ * OsTaskAccessingApplication: 0..*\r
+ * OsTaskEventRef: 0..*\r
+ * OsTaskResourceRef: 0..*\r
+ * OsTaskAutoStart[C] 0..1\r
+ * OsTaskTimingProtection[C] 0..1\r
+ * */\r
+\r
+\r
+typedef struct OsTaskConst {\r
OsTaskidType pid;\r
OsPriorityType prio;\r
uint32 app_mask;\r
proc_type_t proc_type;\r
uint8 autostart;\r
OsStackType stack;\r
- int vector; // ISR\r
- ApplicationType application_id;\r
+ int vector; // ISR\r
+\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+ /* Application that owns this task */\r
+ ApplicationType applOwnerId;\r
+ /* Applications that may access task when state is APPLICATION_ACCESSIBLE */\r
+ uint32 accessingApplMask;\r
+#endif\r
+\r
char name[16];\r
enum OsTaskSchedule scheduling;\r
uint32_t resourceAccess;\r
// pointer to internal resource\r
// NULL if none\r
- OsResourceType *resource_int_p;\r
+ OsResourceType *resourceIntPtr;\r
OsTimingProtectionType *timing_protection;\r
uint8_t activationLimit;\r
// lockingtime_obj_t\r
-} OsRomPcbType;\r
+} OsTaskConstType;\r
\r
#endif\r
\r
/** @req OS413 */\r
_Bool repeating;\r
\r
+#if defined(SC3) || defined(SC4)\r
+ uint32 accessingApplMask;\r
+#endif\r
+\r
// pointer to this tables counter\r
// OsScheduleTableCounterRef\r
/** @req OS409 */\r
/* NULL if NONE, and non-NULL if EXPLICIT and IMPLICIT */\r
struct OsScheduleTableSync *sync;\r
\r
-#if (OS_SC3 == STD_ON ) || (OS_SC4 == STD_ON )\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
uint32 app_mask;\r
#endif\r
\r
OP_RELEASE_RESOURCE = 64\r
} OpType ;\r
\r
-typedef struct sys_s {\r
+/*\r
+ * Global system structure\r
+ */\r
+typedef struct Os_Sys {\r
// OsApplicationType *curr_application;\r
/* Current running task*/\r
- OsPcbType *curr_pcb;\r
+ OsTaskVarType *currTaskPtr;\r
\r
/* List of all tasks */\r
- OsPcbType *pcb_list;\r
+ OsTaskVarType *pcb_list;\r
\r
- OsPcbType *chainedPcbPtr;\r
+ OsTaskVarType *chainedPcbPtr;\r
/* Interrupt nested count */\r
- uint32 int_nest_cnt;\r
+ uint32 intNestCnt;\r
/* The current operation */\r
uint8_t op;\r
/* Ptr to the interrupt stack */\r
- void *int_stack;\r
+ void *intStack;\r
// The os tick\r
TickType tick;\r
// 1-The scheduler is locked (by GetResource() or something else)\r
/* Current Application mode */\r
AppModeType appMode;\r
\r
-// uint32_t flags;\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+ ApplicationStateType currApplState;\r
+ ApplicationType currApplId;\r
+#endif\r
\r
uint32_t task_cnt;\r
+\r
+ uint32_t isrCnt;\r
/* List of all pcb's,\r
* Only needed for non-static configuration of the kernel\r
*/\r
- TAILQ_HEAD(,OsPcb) pcb_head;\r
+// TAILQ_HEAD(,OsTaskVar) pcb_head;\r
/* Ready queue */\r
- TAILQ_HEAD(,OsPcb) ready_head;\r
+ TAILQ_HEAD(,OsTaskVar) ready_head;\r
+\r
+// TAILQ_HEAD(,OsIsrVar) isrHead;\r
\r
/* Occording to OSEK 8.3 RES_SCHEDULER is accessible to all tasks */\r
OsResourceType resScheduler;\r
-} sys_t;\r
+} Os_SysType;\r
\r
-extern sys_t os_sys;\r
+extern Os_SysType Os_Sys;\r
\r
-static inline OsPcbType *Os_TaskGetCurrent( void ) {\r
- return os_sys.curr_pcb;\r
+static inline OsTaskVarType *Os_TaskGetCurrent( void ) {\r
+ return Os_Sys.currTaskPtr;\r
}\r
\r
#if 0\r
static uint32_t OSErrorGetServiceId( void ) {\r
- return os_sys.serviceId;\r
+ return Os_Sys.serviceId;\r
}\r
#endif\r
\r
#include "Ramlog.h"\r
\r
static inline void os_pcb_print_rq( void ) {\r
- OsPcbType *i_pcb;\r
+ OsTaskVarType *i_pcb;\r
int cnt = 0;\r
\r
- TAILQ_FOREACH(i_pcb,&os_sys.ready_head,ready_list) {\r
+ TAILQ_FOREACH(i_pcb,&Os_Sys.ready_head,ready_list) {\r
//printf("%02d: %02d %s\n",cnt,i_pcb->state,i_pcb->name);\r
cnt++;\r
// assert( i_pcb->state == ST_READY );\r
}\r
\r
// schedule()\r
-static inline void Os_TaskRunningToReady( OsPcbType *pcb ) {\r
+static inline void Os_TaskRunningToReady( OsTaskVarType *pcb ) {\r
assert(pcb->state == ST_RUNNING );\r
pcb->state = ST_READY;\r
}\r
\r
// ActivateTask(pid)\r
// SetEvent(pid)\r
-static inline void Os_TaskMakeReady( OsPcbType *pcb ) {\r
+static inline void Os_TaskMakeReady( OsTaskVarType *pcb ) {\r
if( !( pcb->state & ( ST_READY | ST_RUNNING )) ) {\r
pcb->state = ST_READY;\r
- TAILQ_INSERT_TAIL(& os_sys.ready_head,pcb,ready_list);\r
+ TAILQ_INSERT_TAIL(& Os_Sys.ready_head,pcb,ready_list);\r
OS_DEBUG(D_TASK,"Added %s to ready list\n",pcb->name);\r
}\r
}\r
\r
// WaitEvent\r
-static inline void Os_TaskMakeWaiting( OsPcbType *pcb )\r
+static inline void Os_TaskMakeWaiting( OsTaskVarType *pcb )\r
{\r
assert( pcb->state & (ST_READY|ST_RUNNING) );\r
\r
pcb->state = ST_WAITING;\r
- TAILQ_REMOVE(&os_sys.ready_head,pcb,ready_list);\r
+ TAILQ_REMOVE(&Os_Sys.ready_head,pcb,ready_list);\r
OS_DEBUG(D_TASK,"Removed %s from ready list\n",pcb->name);\r
}\r
\r
// Terminate task\r
-static inline void Os_TaskMakeSuspended( OsPcbType *pcb )\r
+static inline void Os_TaskMakeSuspended( OsTaskVarType *pcb )\r
{\r
assert( pcb->state & (ST_READY|ST_RUNNING) );\r
pcb->state = ST_SUSPENDED;\r
- TAILQ_REMOVE(&os_sys.ready_head,pcb,ready_list);\r
+ TAILQ_REMOVE(&Os_Sys.ready_head,pcb,ready_list);\r
OS_DEBUG(D_TASK,"Removed %s from ready list\n",pcb->name);\r
}\r
\r
*\r
* @params pcb Ptr to pcb\r
*/\r
-static inline void Os_TaskMakeRunning( OsPcbType *pcb ) {\r
+static inline void Os_TaskMakeRunning( OsTaskVarType *pcb ) {\r
pcb->state = ST_RUNNING;\r
}\r
\r
-_Bool os_pcb_pid_valid( OsPcbType *restrict pcb );\r
+_Bool os_pcb_pid_valid( OsTaskVarType *restrict pcb );\r
void Os_TaskStartExtended( void );\r
void Os_TaskStartBasic( void );\r
-void Os_ContextInit( OsPcbType *pcb );\r
-OsPcbType *Os_TaskGetTop( void );\r
+void Os_TaskContextInit( OsTaskVarType *pcb );\r
+OsTaskVarType *Os_TaskGetTop( void );\r
\r
// Added by Mattias in order to avoid compiler warning\r
-TaskType Os_AddTask( OsPcbType *pcb );\r
+TaskType Os_AddTask( OsTaskVarType *pcb );\r
\r
#if 0 // Not used any more\r
-OsPcbType *os_find_higher_priority_task( OsPriorityType prio );\r
+OsTaskVarType *os_find_higher_priority_task( OsPriorityType prio );\r
#endif\r
\r
\r
\r
\r
-extern OsPcbType pcb_list[];\r
-extern const OsRomPcbType rom_pcb_list[];\r
+extern OsTaskVarType Os_TaskVarList[OS_TASK_CNT];\r
+extern OsTaskConstType Os_TaskConstList[OS_TASK_CNT];\r
\r
-static inline OsPcbType * os_get_pcb( OsTaskidType pid ) {\r
- return &pcb_list[pid];\r
+static inline OsTaskVarType * Os_TaskGet( OsTaskidType pid ) {\r
+ return &Os_TaskVarList[pid];\r
}\r
\r
-static inline const OsRomPcbType * os_get_rom_pcb( OsTaskidType pid ) {\r
- return &rom_pcb_list[pid];\r
+#if 0\r
+extern const OsTaskConstType Os_TaskConstList[];\r
+static inline const OsTaskConstType * os_get_rom_pcb( OsTaskidType pid ) {\r
+ return & Os_TaskConstList[pid];\r
}\r
+#endif\r
+\r
\r
-static inline OsPriorityType os_pcb_set_prio( OsPcbType *pcb, OsPriorityType new_prio ) {\r
+#if 0\r
+static inline OsPriorityType os_pcb_set_prio( OsTaskVarType *pcb, OsPriorityType new_prio ) {\r
OsPriorityType old_prio;\r
old_prio = pcb->prio;\r
pcb->prio = new_prio;\r
//printf("set_prio of %s to %d from %d\n",pcb->name,new_prio,pcb->prio);\r
return old_prio;\r
}\r
+#endif\r
\r
#define os_pcb_get_state(pcb) ((pcb)->state)\r
\r
-void Os_TaskSwapContext(OsPcbType *old_pcb, OsPcbType *new_pcb );\r
-void Os_TaskSwapContextTo(OsPcbType *old_pcb, OsPcbType *new_pcb );\r
+void Os_TaskSwapContext(OsTaskVarType *old_pcb, OsTaskVarType *new_pcb );\r
+void Os_TaskSwapContextTo(OsTaskVarType *old_pcb, OsTaskVarType *new_pcb );\r
\r
\r
#endif /*TASK_I_H_*/\r
* for more details.
* -------------------------------- Arctic Core ------------------------------*/
-
+/* ----------------------------[includes]------------------------------------*/
#include <stdlib.h>
#include <string.h>
#include "Os.h"
#include "debug.h"
#include "arch.h"
-extern void Os_CfgGetInterruptStackInfo( OsStackType *stack );
-extern uint32_t McuE_GetSystemClock( void );
-extern OsTickType OsTickFreq;
-
-sys_t os_sys;
+/* ----------------------------[private define]------------------------------*/
+/* ----------------------------[private macro]-------------------------------*/
+/* ----------------------------[private typedef]-----------------------------*/
+/* ----------------------------[private function prototypes]-----------------*/
+/* ----------------------------[private variables]---------------------------*/
+Os_SysType Os_Sys;
Os_IntCounterType Os_IntDisableAllCnt;
Os_IntCounterType Os_IntSuspendAllCnt;
Os_IntCounterType Os_IntSuspendOsCnt;
+/* ----------------------------[private functions]---------------------------*/
+/* ----------------------------[public functions]----------------------------*/
+
+extern void Os_CfgGetInterruptStackInfo( OsStackType *stack );
+extern uint32_t McuE_GetSystemClock( void );
+extern OsTickType OsTickFreq;
+
/**
* Copy rom pcb data(r_pcb) to ram data
* @param r_pcb rom data
*/
-static void os_pcb_rom_copy( OsPcbType *pcb, const OsRomPcbType *r_pcb ) {
+static void copyPcbParts( OsTaskVarType *pcb, const OsTaskConstType *r_pcb ) {
+
+ /* Copy VAR stuff first */
+
+
+
#if 0 //?????
// Check to that the memory is ok
{
- int cnt = sizeof(OsPcbType);
+ int cnt = sizeof(OsTaskVarType);
for(int i=0;i<cnt;i++) {
if( *((unsigned char *)pcb) != 0 ) {
while(1);
}
#endif
-// memset(pcb,sizeof(OsPcbType),0);
- pcb->pid = r_pcb->pid;
- pcb->prio = r_pcb->prio;
-#if ( OS_SC3 == STD_ON ) || ( OS_SC4 == STD_ON )
- pcb->application = Os_CfgGetApplObj(r_pcb->application_id);
+// memset(pcb,sizeof(OsTaskVarType),0);
+// pcb->pid = r_pcb->pid;
+ assert(r_pcb->prio<=OS_TASK_PRIORITY_MAX);
+ pcb->activePriority = r_pcb->prio;
+#if (OS_USE_APPLICATIONS == STD_ON)
+// pcb->accessingApp = Os_CfgGetApplObj(r_pcb->application_id);
#endif
- pcb->entry = r_pcb->entry;
- pcb->proc_type = r_pcb->proc_type;
- pcb->autostart = r_pcb->autostart;
+// pcb->entry = r_pcb->entry;
+// pcb->proc_type = r_pcb->proc_type;
+// pcb->autostart = r_pcb->autostart;
pcb->stack= r_pcb->stack;
- pcb->pcb_rom_p = r_pcb;
- pcb->resource_int_p = r_pcb->resource_int_p;
- pcb->scheduling = r_pcb->scheduling;
- pcb->resourceAccess = r_pcb->resourceAccess;
- pcb->activationLimit = r_pcb->activationLimit;
+ pcb->constPtr = r_pcb;
+// pcb->resourceIntPtr = r_pcb->resourceIntPtr;
+// pcb->scheduling = r_pcb->scheduling;
+// pcb->resourceAccess = r_pcb->resourceAccess;
+// pcb->activationLimit = r_pcb->activationLimit;
// pcb->app = &app_list[r_pcb->app];
// pcb->app_mask = app_mask[r_pcb->app];
- strncpy(pcb->name,r_pcb->name,16);
- pcb->name[15] = '\0';
+// strncpy(pcb->name,r_pcb->name,16);
+// pcb->name[15] = '\0';
}
static _Bool init_os_called = 0;
void InitOS( void ) {
int i;
- OsPcbType *tmp_pcb;
- OsStackType int_stack;
+ OsTaskVarType *tmpPcbPtr;
+ OsStackType intStack;
init_os_called = 1;
DEBUG(DEBUG_LOW,"os_init");
/* Clear sys */
- memset(&os_sys,0,sizeof(sys_t));
+ memset(&Os_Sys,0,sizeof(Os_SysType));
Os_ArchInit();
// Assign pcb list and init ready queue
- os_sys.pcb_list = pcb_list;
- TAILQ_INIT(& os_sys.ready_head);
- TAILQ_INIT(& os_sys.pcb_head);
+ Os_Sys.pcb_list = Os_TaskVarList;
+ TAILQ_INIT(& Os_Sys.ready_head);
+// TAILQ_INIT(& Os_Sys.pcb_head);
// Calc interrupt stack
- Os_CfgGetInterruptStackInfo(&int_stack);
+ Os_CfgGetInterruptStackInfo(&intStack);
// TODO: 16 is arch dependent
- os_sys.int_stack = (void *)((size_t)int_stack.top + (size_t)int_stack.size - 16);
+ Os_Sys.intStack = (void *)((size_t)intStack.top + (size_t)intStack.size - 16);
// Init counter.. with alarms and schedule tables
#if OS_COUNTER_CNT!=0
// TODO: we should really hash on priority here to get speed, but I don't care for the moment
// TODO: Isn't this just EXTENED tasks ???
for( i=0; i < OS_TASK_CNT; i++) {
- tmp_pcb = os_get_pcb(i);
+ tmpPcbPtr = Os_TaskGet(i);
- assert(tmp_pcb->prio<=OS_TASK_PRIORITY_MAX);
+ copyPcbParts(tmpPcbPtr,&Os_TaskConstList[i]);
- os_pcb_rom_copy(tmp_pcb,os_get_rom_pcb(i));
- if( !(tmp_pcb->proc_type & PROC_ISR) ) {
- Os_ContextInit(tmp_pcb);
+#if 1
+ Os_TaskContextInit(tmpPcbPtr);
+#else
+ if( !(tmpPcbPtr->constPtr->proc_type & PROC_ISR) ) {
+ Os_TaskContextInit(tmpPcbPtr);
}
+#endif
- TAILQ_INIT(&tmp_pcb->resource_head);
+ TAILQ_INIT(&tmpPcbPtr->resourceHead);
- Os_AddTask(tmp_pcb);
+#if 0
+ Os_AddTask(tmpPcbPtr);
+#endif
- DEBUG(DEBUG_LOW,"pid:%d name:%s prio:%d\n",tmp_pcb->pid,tmp_pcb->name,tmp_pcb->prio);
+ DEBUG(DEBUG_LOW,"pid:%d name:%s prio:%d\n",tmpPcbPtr->pid,tmpPcbPtr->name,tmpPcbPtr->prio);
}
Os_ResourceInit();
}
static void os_start( void ) {
- OsPcbType *tmp_pcb;
+ uint16_t i;
+ OsTaskVarType *tmpPcbPtr = NULL;
// We will be setting up interrupts,
// but we don't want them to fire just yet
/* TODO: fix ugly */
/* Call the startup hook */
extern struct OsHooks os_conf_global_hooks;
- os_sys.hooks = &os_conf_global_hooks;
- if( os_sys.hooks->StartupHook!=NULL ) {
- os_sys.hooks->StartupHook();
+ Os_Sys.hooks = &os_conf_global_hooks;
+ if( Os_Sys.hooks->StartupHook!=NULL ) {
+ Os_Sys.hooks->StartupHook();
}
+
+#if (OS_USE_APPLICATIONS == STD_ON)
+ /* Start applications */
+ Os_ApplStart();
+#endif
+
+
/* Alarm autostart */
#if OS_ALARM_CNT!=0
Os_AlarmAutostart();
/* Find highest Autostart task */
{
- OsPcbType *iterPcbPtr;
+ OsTaskVarType *iterPcbPtr;
OsPriorityType topPrio = -1;
- TAILQ_FOREACH(iterPcbPtr,& os_sys.pcb_head,pcb_list) {
- if( iterPcbPtr->autostart ) {
- if( iterPcbPtr->prio > topPrio ) {
- tmp_pcb = iterPcbPtr;
- topPrio = iterPcbPtr->prio;
+ for(i=0;i<OS_TASK_CNT;i++) {
+ iterPcbPtr = Os_TaskGet(i);
+ if( iterPcbPtr->constPtr->autostart ) {
+ if( iterPcbPtr->activePriority > topPrio ) {
+ tmpPcbPtr = iterPcbPtr;
+ topPrio = iterPcbPtr->activePriority;
+ }
+ }
+ }
+#if 0
+ TAILQ_FOREACH(iterPcbPtr,& Os_Sys.pcb_head,pcb_list) {
+ if( iterPcbPtr->constPtr->autostart ) {
+ if( iterPcbPtr->activePriority > topPrio ) {
+ tmpPcbPtr = iterPcbPtr;
+ topPrio = iterPcbPtr->activePriority;
}
}
}
+#endif
}
// Swap in prio proc.
{
- // FIXME: Do this in a more structured way.. setting os_sys.curr_pcb manually is not the way to go..
- os_sys.curr_pcb = tmp_pcb;
+ // FIXME: Do this in a more structured way.. setting Os_Sys.currTaskPtr manually is not the way to go..
+ Os_Sys.currTaskPtr = tmpPcbPtr;
+#if (OS_USE_APPLICATIONS == STD_ON)
+ /* Set current application */
+ Os_Sys.currApplId = tmpPcbPtr->constPtr->applOwnerId;
+#endif
// register this auto-start activation
- assert(tmp_pcb->activations < tmp_pcb->activationLimit);
- tmp_pcb->activations++;
+ assert(tmpPcbPtr->activations < tmpPcbPtr->constPtr->activationLimit);
+ tmpPcbPtr->activations++;
// NOTE! We don't go for os_swap_context() here..
// first arg(NULL) is dummy only
- Os_TaskSwapContextTo(NULL,tmp_pcb);
+ Os_TaskSwapContextTo(NULL,tmpPcbPtr);
// We should not return here
assert(0);
}
noooo();
}
- os_sys.appMode = Mode;
+ Os_Sys.appMode = Mode;
Os_CfgValidate();
/** @req OS071 */
void ShutdownOS( StatusType Error ) {
- if( os_sys.hooks->ShutdownHook != NULL ) {
- os_sys.hooks->ShutdownHook(Error);
+ if( Os_Sys.hooks->ShutdownHook != NULL ) {
+ Os_Sys.hooks->ShutdownHook(Error);
}
Irq_Disable();
* for more details.
* -------------------------------- Arctic Core ------------------------------*/
-#if defined(__GNUC__)
#include <sys/types.h>
-#endif
#include <stdint.h>
#include <string.h>
#include "internal.h"
+#include "isr.h"
#include "irq.h"
-#if 0
+//#include "irq_config.h"
-#include <stdint.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <sys/queue.h>
-#include <string.h>
-#include "internal.h"
-
-#endif
+extern const uint8_t Os_VectorToIsr[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];
+extern const OsIsrConstType Os_IsrConstList[OS_ISR_CNT];
-#if defined(CFG_PPC)
-#include "arch_stack.h"
+#if OS_ISR_MAX_CNT!=0
+OsIsrVarType Os_IsrVarList[OS_ISR_MAX_CNT];
#endif
// TODO: remove. Make soft links or whatever
//#include "stm32f10x_arc.h"
#endif
-#if defined(__GNUC__)
-/* Really newlib */
extern caddr_t *sbrk(int);
-#elif defined(__CWCC__)
-extern void *sbrk ( uint32_t delta );
-#endif
#define os_alloc(_x) sbrk(_x)
-OsPcbType * os_alloc_new_pcb( void ) {
- void *h = os_alloc(sizeof(OsPcbType));
- memset(h,0,sizeof(OsPcbType));
+OsTaskVarType * os_alloc_new_pcb( void ) {
+ void *h = os_alloc(sizeof(OsTaskVarType));
+ memset(h,0,sizeof(OsTaskVarType));
assert(h!=NULL);
return h;
}
-#if 0
-typedef void (*Os_IsrEntryType)(void);
+
+//extern TaskType Os_AddTask( OsTaskVarType *pcb );
+
+//static uint8 stackTop = 0x42;
-typedef Os_IsrInfo_s {
- Os_IsrEntryType entry;
- uint32_t vector;
- uint8_t priority;
-} Os_IsrInfoType;
-#endif
+void Os_IsrInit( void ) {
-extern TaskType Os_AddTask( OsPcbType *pcb );
+ /* Attach the interrupts */
+ for (int i = 0; i < sizeof(Os_IsrConstList) / sizeof(OsIsrConstType); i++) {
+ Os_IsrAdd(&Os_IsrConstList[i]);
+ }
+}
-static uint8 stackTop = 0x42;
/**
- * Creates an ISR dynamically
- * @param entry
- * @param prio
- * @param name
+ * Adds an ISR to a list of Isr's. The ISRType (id) is returned
+ * for the "created" ISR.
*
- * @return The PID of the ISR created
+ * @param isrPtr Pointer to const data holding ISR information.
+ * @return
*/
-TaskType Os_Arc_CreateIsr( void (*entry)(void ), uint8_t prio, const char *name )
-{
- OsPcbType *pcb = os_alloc_new_pcb();
- strncpy(pcb->name,name,TASK_NAME_SIZE);
- pcb->vector = -1;
- pcb->prio = prio;
- /* TODO: map to interrupt controller priority */
- assert(prio<=OS_TASK_PRIORITY_MAX);
- pcb->proc_type = PROC_ISR2;
- pcb->state = ST_SUSPENDED;
- pcb->entry = entry;
- pcb->stack.top = &stackTop;
-
- return Os_AddTask(pcb);
+ISRType Os_IsrAdd( const OsIsrConstType * restrict isrPtr ) {
+ ISRType id;
+
+ id = Os_Sys.isrCnt++;
+ /* We have no VAR entires for ISR1 */
+ if( isrPtr->type == ISR_TYPE_2) {
+ Os_IsrVarList[id].constPtr = isrPtr;
+ }
+ Irq_EnableVector( isrPtr->vector, isrPtr->priority, isrPtr->core );
+
+ return id;
+}
+
+const OsIsrConstType * Os_IsrGet( int16_t vector) {
+ return &Os_IsrConstList[Os_VectorToIsr[vector]];
+}
+
+#if 0
+void Os_IsrDisable( ISRType isr) {
+
+}
+
+void Os_IsrEnable( ISRType isr) {
+
}
+#endif
+
+
+/*
+ * Resources:
+ * Irq_VectorTable[]
+ * Irq_IsrTypeTable[]
+ * Irq_PriorityTable[]
+ *
+ * exception table
+ * interrupt table
+ *
+ * Usual HW resources.
+ * - prio in HW (ppc and arm (even cortex m4))
+ *
+ *
+ * TOOL GENERATES ALL
+ * Irq_VectorTable CONST
+ * Irq_IsrTypeTable CONST
+ * Irq_PriorityTable CONST Can probably be a table with ISR_MAX number
+ * of for a CPU with prio registers. For masking
+ * CPUs it's better to keep an array to that indexing
+ * can be used.
+ *
+ * The problem with this approach is that the tool needs to know everything.
+ *
+ * TOOL GENERATES PART
+ * Irq_VectorTable VAR Since we must add vectors later
+ * Irq_IsrTypeTable VAR Since we must add vectors later
+ * Irq_PriorityTable VAR
+ *
+ * We move the
+ *
+ */
+
+
/**
* Before we have proper editor for ISR2 use this function to add resources
}
#if defined(CFG_ARM_CM3)
-extern void Irq_EOI( void );
+extern void Irq_EOI2( void );
void TailChaining(void *stack)
{
- struct OsPcb *pPtr = NULL;
+ struct OsTaskVar *pPtr = NULL;
POSTTASKHOOK();
Os_StackPerformCheck(pPtr);
/* We interrupted a task */
- OsPcbType *new_pcb = Os_TaskGetTop();
+ OsTaskVarType *new_pcb = Os_TaskGetTop();
Os_StackPerformCheck(new_pcb);
- if( (new_pcb == os_sys.curr_pcb) ||
- (os_sys.curr_pcb->scheduling == NON) ||
+ if( (new_pcb == Os_Sys.currTaskPtr) ||
+ (Os_Sys.currTaskPtr->scheduling == NON) ||
!Os_SchedulerResourceIsFree() )
{
/* Just bring the preempted task back to running */
- Os_TaskSwapContextTo(NULL,os_sys.curr_pcb);
+ Os_TaskSwapContextTo(NULL,Os_Sys.currTaskPtr);
} else {
OS_DEBUG(D_TASK,"Found candidate %s\n",new_pcb->name);
Os_TaskSwapContextTo(NULL,new_pcb);
void Os_Isr_cm3( void *isr_p ) {
- struct OsPcb *isrPtr;
+ struct OsTaskVar *isrPtr;
- os_sys.int_nest_cnt++;
+ Os_Sys.intNestCnt++;
/* Grab the ISR "pcb" */
- isrPtr = (struct OsPcb *)isr_p;
+ isrPtr = (struct OsTaskVar *)isr_p;
isrPtr->state = ST_RUNNING;
if( isrPtr->proc_type & ( PROC_EXTENDED | PROC_BASIC ) ) {
Irq_EOI();
- --os_sys.int_nest_cnt;
+ --Os_Sys.intNestCnt;
/* Scheduling is done in PendSV handler for ARM CM3 */
*((uint32_t volatile *)0xE000ED04) = 0x10000000; // PendSV
}
#endif
+
/**
* Handle ISR type 2 interrupts from interrupt controller.
*
- * @param stack Ptr to the current stack
- * @param vector The vector that took the interrupt
+ * @param stack Pointer to the current stack
+ * @param vector
*/
-void *Os_Isr( void *stack, void *isr_p ) {
- struct OsPcb *isrPtr;
- struct OsPcb *pPtr = NULL;
-#if defined(CFG_PPC)
- /* PPC just supplies the stack */
-
-
-
-#endif
+void *Os_Isr( void *stack, int16_t vector ) {
+ uint8_t isrId = Os_VectorToIsr[vector];
+ OsTaskVarType *taskPtr = NULL;
/* Check if we interrupted a task or ISR */
- if( os_sys.int_nest_cnt == 0 ) {
-#if defined(CFG_PPC)
- Os_IsrFrameType *excFrame;
-
-#endif
-
+ if( Os_Sys.intNestCnt == 0 ) {
/* We interrupted a task */
POSTTASKHOOK();
/* Save info for preempted pcb */
- pPtr = get_curr_pcb();
- pPtr->stack.curr = stack;
-
-#if defined(CFG_PPC)
- excFrame = pPtr->stack.curr;
-#endif
- pPtr->state = ST_READY;
- OS_DEBUG(D_TASK,"Preempted %s\n",pPtr->name);
+ taskPtr = get_curr_pcb();
+ taskPtr->stack.curr = stack;
+ taskPtr->state = ST_READY;
+ OS_DEBUG(D_TASK,"Preempted %s\n",taskPtr->name);
- Os_StackPerformCheck(pPtr);
+ Os_StackPerformCheck(taskPtr);
} else {
/* We interrupted an ISR */
}
- os_sys.int_nest_cnt++;
+ Os_Sys.intNestCnt++;
/* Grab the ISR "pcb" */
- isrPtr = (struct OsPcb *)isr_p;
- isrPtr->state = ST_RUNNING;
-
- if( isrPtr->proc_type & ( PROC_EXTENDED | PROC_BASIC ) ) {
- assert(0);
- }
+ Os_IsrVarList[isrId].state = ST_ISR_RUNNING;
Irq_SOI();
-#if !defined(CFG_HCS12D)
+#if defined(CFG_HCS12D)
+ Os_IsrConstList[isrId].entry();
+#else
Irq_Enable();
- isrPtr->entry();
+ Os_IsrConstList[isrId].entry();
Irq_Disable();
-#else
- isrPtr->entry();
#endif
/* Check so that ISR2 haven't disabled the interrupts */
/* Check so that the ISR2 have called ReleaseResource() for each GetResource() */
/** @req OS369 */
- if( Os_TaskOccupiesResources(isrPtr) ) {
- Os_ResourceFreeAll(isrPtr);
+ if( Os_TaskOccupiesResources(taskPtr) ) {
+ Os_ResourceFreeAll(taskPtr);
ERRORHOOK(E_OS_RESOURCE);
}
- isrPtr->state = ST_SUSPENDED;
+ Os_IsrVarList[isrId].state = ST_ISR_NOT_RUNNING;
Irq_EOI();
- --os_sys.int_nest_cnt;
+ --Os_Sys.intNestCnt;
#if defined(CFG_ARM_CM3)
/* Scheduling is done in PendSV handler for ARM CM3 */
*((uint32_t volatile *)0xE000ED04) = 0x10000000; // PendSV
#else
// We have preempted a task
- if( (os_sys.int_nest_cnt == 0) ) {
- OsPcbType *new_pcb = Os_TaskGetTop();
+ if( (Os_Sys.intNestCnt == 0) ) {
+ OsTaskVarType *new_pcb = Os_TaskGetTop();
Os_StackPerformCheck(new_pcb);
- if( (new_pcb == os_sys.curr_pcb) ||
- (os_sys.curr_pcb->scheduling == NON) ||
+ if( (new_pcb == Os_Sys.currTaskPtr) ||
+ (Os_Sys.currTaskPtr->constPtr->scheduling == NON) ||
!Os_SchedulerResourceIsFree() )
{
/* Just bring the preempted task back to running */
- os_sys.curr_pcb->state = ST_RUNNING;
+ Os_Sys.currTaskPtr->state = ST_RUNNING;
PRETASKHOOK();
} else {
OS_DEBUG(D_TASK,"Found candidate %s\n",new_pcb->name);
#include "pcb.h"\r
//#include "app_i.h"\r
#include "sys.h"\r
-#include "arch_stack.h"\r
+#include "application.h"\r
\r
\r
#if defined(__GNUC__)\r
#endif\r
\r
\r
- DECLARE(PCB_T_SIZE, sizeof(OsPcbType));\r
-#if ( OS_SC3 == STD_ON ) || ( OS_SC4 == STD_ON )\r
- DECLARE(APP_T_SIZE, sizeof(OsApplicationType));\r
+ DECLARE(PCB_T_SIZE, sizeof(OsTaskVarType));\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+// DECLARE(APP_T_SIZE, sizeof(OsApplicationType));\r
+\r
#endif\r
- DECLARE(PCB_STACK_CURR_P, offsetof(OsPcbType, stack));\r
- DECLARE(PCB_ENTRY_P, offsetof(OsPcbType, entry));\r
- DECLARE(SYS_CURR_PCB_P, offsetof(sys_t, curr_pcb));\r
- DECLARE(SYS_INT_NEST_CNT, offsetof(sys_t, int_nest_cnt));\r
- DECLARE(SYS_INT_STACK, offsetof(sys_t, int_stack));\r
+ DECLARE(PCB_STACK_CURR_P, offsetof(OsTaskVarType, stack));\r
+ DECLARE(PCB_ENTRY_P, offsetof(OsTaskVarType, entry));\r
+ DECLARE(SYS_CURR_PCB_P, offsetof(Os_SysType, currTaskPtr));\r
+ DECLARE(SYS_INT_NEST_CNT, offsetof(Os_SysType, intNestCnt));\r
+ DECLARE(SYS_INT_STACK, offsetof(Os_SysType, intStack));\r
#if defined(__GNUC__)\r
}\r
#endif\r
# We are compiling the kernel\r
dep-$(CFG_PPC) += arch_offset.h\r
dep-y += asm_offset.h\r
-dep-y += kernel_offset.h\r
+#dep-y += kernel_offset.h\r
dep-$(CFG_ARM_CM3) += arch_offset.h\r
\r
\r
\r
#include "Os.h"\r
\r
-\r
-/* See 8.4.4 */\r
-AccessType CheckISRMemoryAccess( ISRType ISRID,\r
- MemoryStartAddressType Address,\r
- MemorySizeType Size )\r
-{\r
- // get hold of application memory space\r
-\r
-\r
-}\r
-\r
-AccessType CheckTaskMemoryAccess( TaskType TaskID,\r
- MemoryStartAddressType Address,\r
- MemorySizeType Size )\r
-{\r
-\r
-\r
-}\r
-\r
-/* Object access\r
- *\r
- *\r
- * resource\r
- *\r
- *\r
- */\r
-\r
-\r
-\r
-\r
-/* This is probably macros */\r
-ObjectAccessType CheckObjectAccess( ApplicationType ApplID,\r
- ObjectTypeType ObjectType,\r
- void *object )\r
-{\r
- uint32 app_mask = (1<<ApplID);\r
- uint32 rv;\r
-\r
- /* TODO: check id */\r
- switch( ObjectType ) {\r
- case OBJECT_ALARM:\r
- rv = ((OsAlarmType *)object)->app_mask & (app_mask);\r
- break;\r
- case OBJECT_COUNTER:\r
- rv = ((OsCounterType *)object)->app_mask & (app_mask);\r
- break;\r
- case OBJECT_ISR:\r
- break;\r
- case OBJECT_MESSAGE:\r
- case OBJECT_RESOURCE:\r
- case OBJECT_SCHEDULETABLE:\r
- break;\r
- case OBJECT_TASK:\r
- rv = ((OsCounterType *)object)->app_mask & (app_mask);\r
- break;\r
- default:\r
- break;\r
- }\r
-\r
-\r
-\r
-\r
- return ACCESS;\r
-}\r
-\r
-/* return application id for object */\r
-ApplicationType CheckObjectOwnership( ObjectTypeType ObjectType,\r
- void *object )\r
-{\r
- switch( ObjectType ) {\r
- case OBJECT_ALARM:\r
- case OBJECT_COUNTER:\r
- case OBJECT_ISR:\r
- case OBJECT_MESSAGE:\r
- case OBJECT_RESOURCE:\r
- case OBJECT_SCHEDULETABLE:\r
- case OBJECT_TASK:\r
- default:\r
- break;\r
- }\r
-\r
- return (-1);\r
-}\r
\r
int Os_ArcTest_GetTaskActivationLimit( TaskType TaskId ) {\r
\r
- return os_get_pcb(TaskId)->activationLimit;\r
+ return Os_TaskGet(TaskId)->constPtr->activationLimit;\r
}\r
\r
/**\r
\r
void Os_ArcTest_SetIrqNestLevel( int level ) {\r
\r
- os_sys.int_nest_cnt = level;\r
+ Os_Sys.intNestCnt = level;\r
\r
return;\r
}\r
\r
task.rsrcAccessMask & (1 << RES_SCHEDULER)\r
\r
- *
+ *\r
*/\r
\r
/* INFO\r
#define valid_internal_id() (rPtr->nr < OS_RESOURCE_CNT) //&& (rPtr->type == RESOURCE_TYPE_INTERNAL) )\r
\r
\r
-void Os_ResourceAlloc( OsResourceType *rPtr, OsPcbType *pcbPtr) {\r
+void Os_ResourceAlloc( OsResourceType *rPtr, OsTaskVarType *pcbPtr) {\r
/* Save old task prio in resource and set new task prio */\r
- rPtr->owner = pcbPtr->pid;\r
- rPtr->old_task_prio = pcbPtr->prio;\r
- pcbPtr->prio = rPtr->ceiling_priority;\r
+ rPtr->owner = pcbPtr->constPtr->pid;\r
+ rPtr->old_task_prio = pcbPtr->activePriority;\r
+ pcbPtr->activePriority = rPtr->ceiling_priority;\r
\r
if( rPtr->type != RESOURCE_TYPE_INTERNAL ) {\r
- TAILQ_INSERT_TAIL(&pcbPtr->resource_head, rPtr, listEntry);\r
+ TAILQ_INSERT_TAIL(&pcbPtr->resourceHead, rPtr, listEntry);\r
}\r
}\r
\r
-void Os_ResourceFree( OsResourceType *rPtr , OsPcbType *pcbPtr) {\r
- assert( rPtr->owner == pcbPtr->pid );\r
+void Os_ResourceFree( OsResourceType *rPtr , OsTaskVarType *pcbPtr) {\r
+ assert( rPtr->owner == pcbPtr->constPtr->pid );\r
rPtr->owner = NO_TASK_OWNER;\r
- pcbPtr->prio = rPtr->old_task_prio;\r
+ pcbPtr->activePriority = rPtr->old_task_prio;\r
\r
if( rPtr->type != RESOURCE_TYPE_INTERNAL ) {\r
/* The list can't be empty here */\r
- assert( !TAILQ_EMPTY(&pcbPtr->resource_head) );\r
+ assert( !TAILQ_EMPTY(&pcbPtr->resourceHead) );\r
\r
/* The list should be popped in LIFO order */\r
- assert( TAILQ_LAST(&pcbPtr->resource_head, head) == rPtr );\r
+ assert( TAILQ_LAST(&pcbPtr->resourceHead, head) == rPtr );\r
\r
/* Remove the entry */\r
- TAILQ_REMOVE(&pcbPtr->resource_head, rPtr, listEntry);\r
+ TAILQ_REMOVE(&pcbPtr->resourceHead, rPtr, listEntry);\r
}\r
}\r
\r
\r
StatusType GetResource( ResourceType ResID ) {\r
StatusType rv = E_OK;\r
- OsPcbType *pcbPtr = Os_TaskGetCurrent();\r
+ OsTaskVarType *pcbPtr = Os_TaskGetCurrent();\r
OsResourceType *rPtr;\r
uint32_t flags;\r
\r
\r
if( ResID == RES_SCHEDULER ) {\r
\r
- rPtr = &os_sys.resScheduler;\r
+ rPtr = &Os_Sys.resScheduler;\r
} else {\r
/* Check we can access it */\r
- if( (pcbPtr->resourceAccess & ( (uint32_t) 1 << ResID)) == 0 ) {\r
+ if( (pcbPtr->constPtr->resourceAccess & (1<< ResID)) == 0 ) {\r
rv = E_OS_ID;\r
goto err;\r
}\r
\r
/* Check for invalid configuration */\r
if( (rPtr->owner != NO_TASK_OWNER) ||\r
- (pcbPtr->prio > rPtr->ceiling_priority) )\r
+ (pcbPtr->activePriority > rPtr->ceiling_priority) )\r
{\r
rv = E_OS_ACCESS;\r
Irq_Restore(flags);\r
\r
StatusType ReleaseResource( ResourceType ResID) {\r
StatusType rv = E_OK;\r
- OsPcbType *pcbPtr = Os_TaskGetCurrent();\r
+ OsTaskVarType *pcbPtr = Os_TaskGetCurrent();\r
OsResourceType *rPtr;\r
uint32_t flags;\r
\r
Irq_Save(flags);\r
if( ResID == RES_SCHEDULER ) {\r
- rPtr = &os_sys.resScheduler;\r
+ rPtr = &Os_Sys.resScheduler;\r
} else {\r
/* Check we can access it */\r
- if( (pcbPtr->resourceAccess & ( (uint32_t) 1 << ResID) ) == 0 ) {// 960 PC-lint [10.5]: varför klagar? funkar inte heller om (unsigned char)1 )\r
+ if( (pcbPtr->constPtr->resourceAccess & (1<< ResID)) == 0 ) {\r
rv = E_OS_ID;\r
goto err;\r
}\r
goto err;\r
}\r
\r
- if( (pcbPtr->prio < rPtr->ceiling_priority))\r
+ if( (pcbPtr->activePriority < rPtr->ceiling_priority))\r
{\r
rv = E_OS_ACCESS;\r
Irq_Restore(flags);\r
Os_ResourceFree(rPtr,pcbPtr);\r
\r
/* do a rescheduling (in some cases) (see OSEK OS 4.6.1) */\r
- if ( (pcbPtr->scheduling == FULL) &&\r
- (os_sys.int_nest_cnt == 0) &&\r
+ if ( (pcbPtr->constPtr->scheduling == FULL) &&\r
+ (Os_Sys.intNestCnt == 0) &&\r
(Os_SchedulerResourceIsFree()) ) {\r
\r
- OsPcbType* top_pcb = Os_TaskGetTop();\r
+ OsTaskVarType* top_pcb = Os_TaskGetTop();\r
\r
/* only dispatch if some other ready task has higher prio */\r
- if (top_pcb->prio > Os_TaskGetCurrent()->prio) {\r
+ if (top_pcb->activePriority > Os_TaskGetCurrent()->activePriority) {\r
Os_Dispatch(OP_RELEASE_RESOURCE);\r
}\r
}\r
\r
\r
void Os_ResourceGetInternal( void ) {\r
- OsPcbType *pcbPtr = Os_TaskGetCurrent();\r
- OsResourceType *rt = pcbPtr->resource_int_p;\r
+ OsTaskVarType *pcbPtr = Os_TaskGetCurrent();\r
+ OsResourceType *rt = pcbPtr->constPtr->resourceIntPtr;\r
\r
if( rt != NULL ) {\r
OS_DEBUG(D_RESOURCE,"Get IR proc:%s prio:%u old_task_prio:%u\n",\r
}\r
\r
void Os_ResourceReleaseInternal( void ) {\r
- OsPcbType *pcbPtr = Os_TaskGetCurrent();\r
- OsResourceType *rt = pcbPtr->resource_int_p;\r
+ OsTaskVarType *pcbPtr = Os_TaskGetCurrent();\r
+ OsResourceType *rt = pcbPtr->constPtr->resourceIntPtr;\r
\r
if( rt != NULL ) {\r
OS_DEBUG(D_RESOURCE,"Rel IR proc:%s prio:%u old_task_prio:%u\n",\r
* @return\r
*/\r
void Os_ResourceInit( void ) {\r
- //TAILQ_INIT(&pcb_p->resource_head);\r
- OsPcbType *pcb_p;\r
+ //TAILQ_INIT(&pcb_p->resourceHead);\r
+ OsTaskVarType *pcb_p;\r
OsResourceType *rsrc_p;\r
int topPrio;\r
\r
\r
/* For now, assign the scheduler resource here */\r
- os_sys.resScheduler.ceiling_priority = OS_RES_SCHEDULER_PRIO;\r
- strcpy(os_sys.resScheduler.id,"RES_SCHEDULER");\r
- os_sys.resScheduler.nr = RES_SCHEDULER;\r
- os_sys.resScheduler.owner = NO_TASK_OWNER;\r
+ Os_Sys.resScheduler.ceiling_priority = OS_RES_SCHEDULER_PRIO;\r
+ strcpy(Os_Sys.resScheduler.id,"RES_SCHEDULER");\r
+ Os_Sys.resScheduler.nr = RES_SCHEDULER;\r
+ Os_Sys.resScheduler.owner = NO_TASK_OWNER;\r
\r
/* Calculate ceiling priority\r
* We make this as simple as possible. The ceiling priority\r
\r
for( int pi = 0; pi < OS_TASK_CNT; pi++) {\r
\r
- pcb_p = os_get_pcb(pi);\r
+ pcb_p = Os_TaskGet(pi);\r
\r
\r
- if(pcb_p->resourceAccess & ( (uint32_t) 1<<i) ) {\r
- topPrio = MAX(topPrio,pcb_p->prio);\r
+ if(pcb_p->constPtr->resourceAccess & (1<<i) ) {\r
+ topPrio = MAX(topPrio,pcb_p->constPtr->prio);\r
}\r
\r
/* Generator fix, add RES_SCHEDULER */\r
- pcb_p->resourceAccess |= (1 << RES_SCHEDULER) ;\r
+// pcb_p->constPtr->resourceAccess |= (1 << RES_SCHEDULER) ;\r
}\r
rsrc_p->ceiling_priority = topPrio;\r
}\r
const struct OsSchTblAutostart *autoPtr = sPtr->autostartPtr;\r
\r
/* Check appmode */\r
- if( os_sys.appMode & autoPtr->appMode ) {\r
+ if( Os_Sys.appMode & autoPtr->appMode ) {\r
\r
/* Start the schedule table */\r
switch(autoPtr->type) {\r
* for more details.\r
* -------------------------------- Arctic Core ------------------------------*/\r
\r
+/* ----------------------------[includes]------------------------------------*/\r
+\r
#include <stdlib.h>\r
#include "Os.h"\r
\r
#include "arc.h"\r
#include "arch.h"\r
\r
+/* ----------------------------[private define]------------------------------*/\r
+/* ----------------------------[private macro]-------------------------------*/\r
+/* ----------------------------[private typedef]-----------------------------*/\r
+/* ----------------------------[private function prototypes]-----------------*/\r
+/* ----------------------------[private variables]---------------------------*/\r
+#if OS_TASK_CNT!=0\r
+OsTaskVarType Os_TaskVarList[OS_TASK_CNT];\r
+#endif\r
+\r
+/* ----------------------------[private functions]---------------------------*/\r
+/* ----------------------------[public functions]----------------------------*/\r
+\r
+\r
+\r
/** @req OS067 */\r
\r
-_Bool os_pcb_pid_valid( OsPcbType *restrict pcb ) {\r
- return ( pcb->pid > OS_TASK_CNT ) ? 0 : 1;\r
+_Bool os_pcb_pid_valid( OsTaskVarType *restrict pcb ) {\r
+ return ( pcb->constPtr->pid > OS_TASK_CNT ) ? 0 : 1;\r
}\r
/**\r
* Start an extended task.\r
*/\r
void Os_TaskStartExtended( void ) {\r
\r
- OsPcbType *pcb;\r
+ OsTaskVarType *pcb;\r
\r
pcb = Os_TaskGetCurrent();\r
#if 0\r
\r
void Os_TaskStartBasic( void ) {\r
\r
- OsPcbType *pcb;\r
+ OsTaskVarType *pcb;\r
\r
pcb = Os_TaskGetCurrent();\r
#if 0\r
}\r
\r
\r
-static void Os_StackSetup( OsPcbType *pcbPtr ) {\r
+static void Os_StackSetup( OsTaskVarType *pcbPtr ) {\r
uint8_t *bottom;\r
\r
/* Find bottom of the stack so that we can place the\r
*\r
* @param pcbPtr Pointer to the pcb to fill with pattern\r
*/\r
-static void Os_StackFill(OsPcbType *pcbPtr) {\r
+static void Os_StackFill(OsTaskVarType *pcbPtr) {\r
uint8_t *p = pcbPtr->stack.curr;\r
\r
assert(pcbPtr->stack.curr > pcbPtr->stack.top);\r
*\r
* @param pcbPtr\r
*/\r
-static void Os_TaskSetEntry(OsPcbType *pcbPtr ) {\r
+static void Os_TaskSetEntry(OsTaskVarType *pcbPtr ) {\r
\r
}\r
#endif\r
*\r
* @param pcb Ptr to the pcb to setup context for.\r
*/\r
-void Os_ContextInit( OsPcbType *pcb ) {\r
+void Os_TaskContextInit( OsTaskVarType *pcb ) {\r
\r
- if( pcb->autostart ) {\r
+ if( pcb->constPtr->autostart ) {\r
Os_TaskMakeReady(pcb);\r
} else {\r
pcb->state = ST_SUSPENDED;\r
*\r
* @param pcb\r
*/\r
-void Os_ContextReInit( OsPcbType *pcbPtr ) {\r
+void Os_ContextReInit( OsTaskVarType *pcbPtr ) {\r
Os_StackSetup(pcbPtr);\r
}\r
\r
+#if 0\r
/**\r
* Search for a specific task in the pcb list.\r
*\r
* @param tid The task id to search for\r
* @return Ptr to the found pcb or NULL\r
*/\r
-OsPcbType *os_find_task( TaskType tid ) {\r
- OsPcbType *i_pcb;\r
-\r
- /* TODO: Implement this as an array */\r
- TAILQ_FOREACH(i_pcb,& os_sys.pcb_head,pcb_list) {\r
- if(i_pcb->pid == tid ) {\r
+OsTaskVarType *Os_TaskGet( TaskType tid ) {\r
+ OsTaskVarType *i_pcb;\r
+ TAILQ_FOREACH(i_pcb,& Os_Sys.pcb_head,pcb_list) {\r
+ if(i_pcb->constPtr->pid == tid ) {\r
return i_pcb;\r
}\r
}\r
+\r
assert(0);\r
return NULL;\r
}\r
+#endif\r
\r
+#if 0\r
/**\r
* Adds a pcb to the list of pcb's\r
* @param pcb\r
*/\r
-TaskType Os_AddTask( OsPcbType *pcb ) {\r
+TaskType Os_AddTask( OsTaskVarType *pcb ) {\r
long msr;\r
\r
Irq_Save(msr); // Save irq status and disable interrupts\r
\r
- pcb->pid = os_sys.task_cnt;\r
+ pcb->pid = Os_Sys.task_cnt;\r
// Add to list of PCB's\r
- TAILQ_INSERT_TAIL(& os_sys.pcb_head,pcb,pcb_list);\r
- os_sys.task_cnt++;\r
+ TAILQ_INSERT_TAIL(& Os_Sys.pcb_head,pcb,pcb_list);\r
+ Os_Sys.task_cnt++;\r
+ Os_Sys.isrCnt++;\r
\r
Irq_Restore(msr); // Restore interrupts\r
return pcb->pid;\r
}\r
+#endif\r
\r
\r
#define PRIO_ILLEGAL -100\r
* @return\r
*/\r
\r
-OsPcbType *Os_TaskGetTop( void ){\r
- OsPcbType *i_pcb;\r
- OsPcbType *top_prio_pcb = NULL;\r
+OsTaskVarType *Os_TaskGetTop( void ){\r
+ OsTaskVarType *i_pcb;\r
+ OsTaskVarType *top_prio_pcb = NULL;\r
OsPriorityType top_prio = PRIO_ILLEGAL;\r
\r
// OS_DEBUG(D_TASK,"os_find_top_prio_proc\n");\r
\r
- TAILQ_FOREACH(i_pcb,& os_sys.ready_head,ready_list) {\r
+ TAILQ_FOREACH(i_pcb,& Os_Sys.ready_head,ready_list) {\r
// all ready task are canidates\r
if( i_pcb->state & (ST_READY|ST_RUNNING)) {\r
if( top_prio != PRIO_ILLEGAL ) {\r
- if( i_pcb->prio > top_prio ) {\r
- top_prio = i_pcb->prio;\r
+ if( i_pcb->activePriority > top_prio ) {\r
+ top_prio = i_pcb->activePriority;\r
top_prio_pcb = i_pcb;\r
}\r
} else {\r
- top_prio = i_pcb->prio;\r
+ top_prio = i_pcb->activePriority;\r
top_prio_pcb = i_pcb;\r
}\r
} else {\r
* + No need to remove the running process from ready queue\r
*/\r
\r
-OsPcbType *Os_FindTopPrioTask( void ) {\r
+OsTaskVarType *Os_FindTopPrioTask( void ) {\r
\r
\r
return NULL;\r
*\r
*/\r
void Os_Dispatch( uint32_t op ) {\r
- OsPcbType *pcbPtr;\r
- OsPcbType *currPcbPtr = Os_TaskGetCurrent();\r
+ OsTaskVarType *pcbPtr;\r
+ OsTaskVarType *currPcbPtr = Os_TaskGetCurrent();\r
\r
- assert(os_sys.int_nest_cnt == 0);\r
+ assert(Os_Sys.intNestCnt == 0);\r
assert(Os_SchedulerResourceIsFree());\r
\r
/* When calling post hook we must still be in ST_RUNNING */\r
} else if( op & OP_ACTIVATE_TASK ) {\r
Os_TaskMakeReady(currPcbPtr);\r
} else if( op & OP_CHAIN_TASK ) {\r
- assert( os_sys.chainedPcbPtr != NULL );\r
+ assert( Os_Sys.chainedPcbPtr != NULL );\r
\r
/* # from chain top\r
* ----------------------------------------------------------\r
*\r
* - Chained task is always READY when coming from ChainTask()\r
*/\r
- if( currPcbPtr != os_sys.chainedPcbPtr ) {\r
+ if( currPcbPtr != Os_Sys.chainedPcbPtr ) {\r
/* #3 and #4 */\r
--currPcbPtr->activations;\r
if( currPcbPtr->activations <= 0 ) {\r
}\r
/* Chained task is already in READY */\r
}\r
- os_sys.chainedPcbPtr = NULL;\r
+ Os_Sys.chainedPcbPtr = NULL;\r
\r
} else if( op & OP_TERMINATE_TASK ) {\r
/*@req OSEK TerminateTask\r
/* Swap if we found any process or are forced (multiple activations)*/\r
if( pcbPtr != currPcbPtr ) {\r
\r
- if( (op & OP_CHAIN_TASK) && ( currPcbPtr == os_sys.chainedPcbPtr ) ) {\r
+ if( (op & OP_CHAIN_TASK) && ( currPcbPtr == Os_Sys.chainedPcbPtr ) ) {\r
/* #2 */\r
Os_TaskRunningToReady(currPcbPtr);\r
}\r
\r
#if (OS_STACK_MONITORING == 1)\r
if( !Os_StackIsEndmarkOk(currPcbPtr) ) {\r
-#if ( OS_SC1 == 1) || ( OS_SC2 == 1)\r
+#if ( OS_SC1 == STD_ON) || ( OS_SC2 == STD_ON )\r
/** @req OS068 */\r
ShutdownOS(E_OS_STACKFAULT);\r
#else\r
-#error SC3 or SC4 not supported. Protection hook should be called here\r
+ /** @req OS396\r
+ * If a stack fault is detected by stack monitoring AND the configured scalability\r
+ * class is 3 or 4, the Operating System module shall call the ProtectionHook() with\r
+ * the status E_OS_STACKFAULT.\r
+ * */\r
+ PROTECTIONHOOK(E_OS_STACKFAULT);\r
#endif\r
}\r
#endif\r
* Do we need virtual memory??\r
*/\r
\r
-void Os_TaskSwapContext(OsPcbType *old_pcb, OsPcbType *new_pcb ) {\r
+void Os_TaskSwapContext(OsTaskVarType *old_pcb, OsTaskVarType *new_pcb ) {\r
set_curr_pcb(new_pcb);\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+ Os_Sys.currApplId = new_pcb->constPtr->applOwnerId;\r
+#endif\r
Os_ResourceGetInternal();\r
Os_TaskMakeRunning(new_pcb);\r
/* TODO: The pretask hook is not called with the right stack\r
Os_ArchSwapContext(old_pcb,new_pcb);\r
}\r
\r
-void Os_TaskSwapContextTo(OsPcbType *old_pcb, OsPcbType *new_pcb ) {\r
+void Os_TaskSwapContextTo(OsTaskVarType *old_pcb, OsTaskVarType *new_pcb ) {\r
set_curr_pcb(new_pcb);\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+ Os_Sys.currApplId = new_pcb->constPtr->applOwnerId;\r
+#endif\r
Os_ResourceGetInternal();\r
Os_TaskMakeRunning(new_pcb);\r
PRETASKHOOK();\r
\r
\r
void Os_Arc_GetStackInfo( TaskType task, StackInfoType *s) {\r
- OsPcbType *pcb = os_get_pcb(task);\r
+ OsTaskVarType *pcb = Os_TaskGet(task);\r
\r
s->curr = Os_ArchGetStackPtr();\r
s->top = pcb->stack.top;\r
\r
TASK_CHECK_ID(TaskId);\r
\r
- curr_state = os_pcb_get_state(os_get_pcb(TaskId));\r
+ curr_state = os_pcb_get_state(Os_TaskGet(TaskId));\r
\r
// TODO: Lazy impl. for now */\r
switch(curr_state) {\r
\r
/* Test specification say return CALLEVEL if in ISR\r
* but impl. spec says otherwise */\r
- if( os_sys.int_nest_cnt == 0 ) {\r
- if( os_sys.curr_pcb->state & ST_RUNNING ) {\r
- *TaskID = os_sys.curr_pcb->pid;\r
+ if( Os_Sys.intNestCnt == 0 ) {\r
+ if( Os_Sys.currTaskPtr->state & ST_RUNNING ) {\r
+ *TaskID = Os_Sys.currTaskPtr->constPtr->pid;\r
} else {\r
/* This is not a real error since this could\r
- * be the case when called from ErrorHook */
+ * be the case when called from ErrorHook */\r
}\r
}\r
\r
}\r
\r
\r
+/**\r
+ * This service returns the identifier of the currently executing ISR\r
+ *\r
+ * If its caller is not a category 2 ISR (or Hook routines called\r
+ * inside a category 2 ISR), GetISRID() shall return INVALID_ISR.\r
+ *\r
+ * @return\r
+ */\r
ISRType GetISRID( void ) {\r
\r
/** @req OS264 */\r
- if(os_sys.int_nest_cnt == 0 ) {\r
+ if(Os_Sys.intNestCnt == 0 ) {\r
return INVALID_ISR;\r
}\r
\r
/** @req OS263 */\r
- return (ISRType)Os_TaskGetCurrent()->pid;\r
+ return (ISRType)Os_TaskGetCurrent()->constPtr->pid;\r
}\r
\r
-static inline void Os_Arc_SetCleanContext( OsPcbType *pcb ) {\r
- if (pcb->proc_type == PROC_EXTENDED) {\r
+static inline void Os_Arc_SetCleanContext( OsTaskVarType *pcb ) {\r
+ if (pcb->constPtr->proc_type == PROC_EXTENDED) {\r
/** @req OSEK ActivateTask Cleanup events\r
* OSEK,ActivateTask, When an extended task is transferred from suspended\r
* state into ready state all its events are cleared.*/\r
\r
StatusType ActivateTask( TaskType TaskID ) {\r
long msr;\r
- OsPcbType *pcb = os_get_pcb(TaskID);\r
+ OsTaskVarType *pcb = Os_TaskGet(TaskID);\r
StatusType rv = E_OK;\r
\r
OS_DEBUG(D_TASK,"# ActivateTask %s\n",pcb->name);\r
#endif\r
\r
Irq_Save(msr);\r
+\r
+#if (OS_USE_APPLICATIONS == STD_ON)\r
+ /* @req OS504/ActivateTask\r
+ * The Operating System module shall deny access to Operating System\r
+ * objects from other OS-Applications to an OS-Application which is not in state\r
+ * APPLICATION_ACCESSIBLE.\r
+ * */\r
+ if( pcb->constPtr->applOwnerId != Os_Sys.currApplId ) {\r
+ /* We are activating a task in another application */\r
+ if( Os_AppVar[Os_Sys.currApplId].state != APPLICATION_ACCESSIBLE ) {\r
+ rv=E_OS_ACCESS;\r
+ goto err;\r
+ }\r
+ }\r
+#endif\r
+\r
/* @req OS093 ActivateTask */\r
if( Os_IrqAnyDisabled() ) {\r
/* Standard */\r
pcb->activations++;\r
if( os_pcb_get_state(pcb) != ST_SUSPENDED ) {\r
/** @req OSEK_? Too many task activations */\r
- if( pcb->activations >= (pcb->activationLimit + 1) ) {\r
+ if( pcb->activations >= (pcb->constPtr->activationLimit + 1) ) {\r
/* Standard */\r
rv=E_OS_LIMIT;\r
Irq_Restore(msr);\r
}\r
\r
/* Preempt only if we are preemptable and target has higher prio than us */\r
- if( (Os_TaskGetCurrent()->scheduling == FULL) &&\r
- (os_sys.int_nest_cnt == 0) &&\r
- (pcb->prio > Os_TaskGetCurrent()->prio) &&\r
+ if( (Os_TaskGetCurrent()->constPtr->scheduling == FULL) &&\r
+ (Os_Sys.intNestCnt == 0) &&\r
+ (pcb->activePriority > Os_TaskGetCurrent()->activePriority) &&\r
(Os_SchedulerResourceIsFree()))\r
{\r
Os_Dispatch(OP_ACTIVATE_TASK);\r
*/\r
\r
StatusType TerminateTask( void ) {\r
- OsPcbType *curr_pcb = Os_TaskGetCurrent();\r
+ OsTaskVarType *curr_pcb = Os_TaskGetCurrent();\r
StatusType rv = E_OK;\r
uint32_t flags;\r
\r
- OS_DEBUG(D_TASK,"# TerminateTask %s\n",curr_pcb->name);\r
+ OS_DEBUG(D_TASK,"# TerminateTask %s\n",currTaskPtr->name);\r
\r
#if (OS_STATUS_EXTENDED == STD_ON )\r
\r
\r
- if( os_sys.int_nest_cnt != 0 ) {\r
+ if( Os_Sys.intNestCnt != 0 ) {\r
rv = E_OS_CALLEVEL;\r
goto err;\r
}\r
}\r
\r
StatusType ChainTask( TaskType TaskId ) {\r
- OsPcbType *curr_pcb = Os_TaskGetCurrent();\r
+ OsTaskVarType *curr_pcb = Os_TaskGetCurrent();\r
StatusType rv = E_OK;\r
uint32_t flags;\r
- OsPcbType *pcb = os_get_pcb(TaskId);\r
+ OsTaskVarType *pcb = Os_TaskGet(TaskId);\r
\r
\r
- OS_DEBUG(D_TASK,"# ChainTask %s\n",curr_pcb->name);\r
+ OS_DEBUG(D_TASK,"# ChainTask %s\n",currTaskPtr->name);\r
\r
#if (OS_STATUS_EXTENDED == STD_ON )\r
/* extended */\r
TASK_CHECK_ID(TaskId);\r
\r
- if( os_sys.int_nest_cnt != 0 ) {\r
+ if( Os_Sys.intNestCnt != 0 ) {\r
/* extended */\r
rv = E_OS_CALLEVEL;\r
goto err;\r
// if( os_pcb_get_state(pcb) != ST_SUSPENDED ) {\r
if (curr_pcb != pcb) {\r
/** @req OSEK_? Too many task activations */\r
- if( (pcb->activations + 1) > pcb->activationLimit ) {\r
+ if( (pcb->activations + 1) > pcb->constPtr->activationLimit ) {\r
/* standard */\r
rv = E_OS_LIMIT;\r
Irq_Restore(flags);\r
\r
}\r
\r
- os_sys.chainedPcbPtr = pcb;\r
+ Os_Sys.chainedPcbPtr = pcb;\r
\r
Os_Dispatch(OP_CHAIN_TASK);\r
\r
StatusType Schedule( void ) {\r
StatusType rv = E_OK;\r
uint32_t flags;\r
- OsPcbType *curr_pcb = get_curr_pcb();\r
+ OsTaskVarType *curr_pcb = get_curr_pcb();\r
\r
OS_DEBUG(D_TASK,"# Schedule %s\n",Os_TaskGetCurrent()->name);\r
\r
/* Check that we are not calling from interrupt context */\r
- if( os_sys.int_nest_cnt != 0 ) {\r
+ if( Os_Sys.intNestCnt != 0 ) {\r
rv = E_OS_CALLEVEL;\r
goto err;\r
}\r
* FULL - Assigned internal resource OR\r
* No assigned internal resource.\r
* */\r
- if( Os_TaskGetCurrent()->scheduling != NON ) {\r
+ if( Os_TaskGetCurrent()->constPtr->scheduling != NON ) {\r
return E_OK;\r
}\r
\r
Irq_Save(flags);\r
- OsPcbType* top_pcb = Os_TaskGetTop();\r
+ OsTaskVarType* top_pcb = Os_TaskGetTop();\r
/* only dispatch if some other ready task has higher prio */\r
- if (top_pcb->prio > Os_TaskGetCurrent()->prio) {\r
+ if (top_pcb->activePriority > Os_TaskGetCurrent()->activePriority) {\r
Os_Dispatch(OP_SCHEDULE);\r
}\r
\r