]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Cleanup of makefiles. Cleanup of merge.
authortojo <devnull@localhost>
Thu, 3 Mar 2011 15:50:31 +0000 (16:50 +0100)
committertojo <devnull@localhost>
Thu, 3 Mar 2011 15:50:31 +0000 (16:50 +0100)
71 files changed:
arch/arm/arm_cm3/drivers/Adc.c
arch/arm/arm_cm3/drivers/Can.c
arch/arm/arm_cm3/drivers/Gpt.c
arch/arm/arm_cm3/kernel/arch.c
arch/arm/arm_cm3/kernel/arch_krn.sx
arch/arm/arm_cm3/kernel/irq.c
arch/arm/arm_cm3/kernel/sys_tick.c
arch/arm/arm_cr4/drivers/Can.c
arch/arm/arm_cr4/kernel/arch.c
arch/arm/arm_cr4/kernel/arch_krn.sx
arch/arm/arm_cr4/kernel/irq.c
arch/arm/arm_cr4/kernel/sys_tick.c
arch/hc1x/hcs12d/drivers/Adc.c
arch/hc1x/hcs12d/drivers/Can.c
arch/hc1x/hcs12d/drivers/Gpt.c
arch/hc1x/hcs12d/kernel/arch.c
arch/hc1x/hcs12d/kernel/arch_irq.sx
arch/hc1x/hcs12d/kernel/arch_krn.sx
arch/hc1x/hcs12d/kernel/irq.c
arch/hc1x/hcs12d/kernel/sys_tick.c
arch/ppc/mpc55xx/drivers/Adc.c
arch/ppc/mpc55xx/drivers/Can.c
arch/ppc/mpc55xx/drivers/Gpt.c
arch/ppc/mpc55xx/drivers/Lin.c
arch/ppc/mpc55xx/drivers/Mcu.c
arch/ppc/mpc55xx/drivers/sys_tick.c
arch/ppc/mpc55xx/kernel/arch.c
arch/ppc/mpc55xx/kernel/irq.c
arch/ppc/mpc55xx/scripts/linkscript_gcc.ldf
boards/board_common.mk
common/newlib_port.c
common/tcf/sys_monitor.c
examples/blinker_node/config/hcs12_elmicro_card12/Os_Cfg.h
include/Os.h
include/bit.h
include/irq.h
include/isr.h [new file with mode: 0644]
include/os_config_funcs.h
include/os_config_macros.h
makefile
scripts/cc_gcc.mk
scripts/gcc_map_memory.awk [new file with mode: 0644]
scripts/rules.mk
scripts/version_check.mk
system/EcuM/EcuM.c
system/kernel/alarm.c
system/kernel/application.c
system/kernel/asm_offset.c
system/kernel/asm_sample.c
system/kernel/counter.c
system/kernel/event.c
system/kernel/include/alarm_i.h
system/kernel/include/application.h
system/kernel/include/arch.h
system/kernel/include/counter_i.h
system/kernel/include/ext_config.h
system/kernel/include/internal.h
system/kernel/include/kernel.h
system/kernel/include/pcb.h
system/kernel/include/sched_table_i.h
system/kernel/include/sys.h
system/kernel/include/task_i.h
system/kernel/init.c
system/kernel/isr.c
system/kernel/kernel_offset.c
system/kernel/makefile
system/kernel/memory.c
system/kernel/os_arctest.c
system/kernel/resource.c
system/kernel/sched_table.c
system/kernel/task.c

index ed2c6eb2d290b93bed8996a156654c31faba4836..bf0e33db72322b8fa2dba4c68ebb7e5655bccc0e 100644 (file)
@@ -25,7 +25,7 @@
 #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
index 64affcf0cdda0fcafec30264cc32a8ec00fd36de..6368c8ee89da81e4a480536ccc1eaabedab0ff96 100644 (file)
@@ -29,7 +29,7 @@
 #include <stdlib.h>\r
 #include <string.h>\r
 #include "Os.h"
-#include "irq.h"\r
+#include "isr.h"\r
 #include "arc.h"
 \r
 
index e665a5f73d5db40622eed509163ebb46fbb48ca6..f25c4856134d7bf0adc90de8110b26a5aa44895b 100644 (file)
@@ -21,7 +21,7 @@
 #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
index 4e71d30e47b5673b96bd6e70a7d5a01766405abb..8cd012b5b9bdf8173ec74fefbf4c2cd8d224f9a6 100644 (file)
@@ -27,7 +27,7 @@ void Os_ArchFirstCall( void )
 {\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
@@ -39,7 +39,7 @@ unsigned int Os_ArchGetScSize( void ) {
        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
@@ -54,7 +54,7 @@ void Os_ArchSetTaskEntry(OsPcbType *pcbPtr ) {
 \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
index c9103fd39b2671d649bcda7132c015b7ad4b439b..f4abc0ed5cdea4f48d06fa9639ee296c5292c7bf 100644 (file)
@@ -10,7 +10,7 @@
 #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
@@ -61,7 +61,7 @@ Irq_Handler:
     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
@@ -163,7 +163,7 @@ Os_ArchSwapContextTo:
 \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
index 172f798e779e32e35bfedefb9e0d5b74adf321c0..44590eabafea21d14e53f5ada2a0fa3a124ea3a3 100644 (file)
@@ -17,7 +17,7 @@
 #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];
 
@@ -147,9 +147,9 @@ static inline int osPrioToCpuPio( uint8_t prio ) {
  * @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));
index 0c060e916bf4882ece82de1cd6245874ddcff306..736316cb33498e46ea1b980f52618447e93b0bc4 100644 (file)
@@ -16,7 +16,7 @@
 #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
index a67635597a946e0f22e7374c2e7615c4d7d14793..9af6facad786c4ba5441a3f545b148cf125e8010 100644 (file)
@@ -22,7 +22,7 @@
 #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
index bd4d0b60b04e44930610970000c2b67770b24fe5..c8683a2c7cb67ff72e18b4c66d50b27bcebdb54a 100644 (file)
@@ -27,7 +27,7 @@ void Os_ArchFirstCall( void )
 {\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
@@ -39,7 +39,7 @@ unsigned int Os_ArchGetScSize( void ) {
        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
@@ -54,7 +54,7 @@ void Os_ArchSetTaskEntry(OsPcbType *pcbPtr ) {
 \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
index 7e35c6b799187dbf1077339984292a313e98318d..311515bb0aa53a4e4ccacf89c5cf7676d9cde018 100644 (file)
@@ -17,7 +17,7 @@
 #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
@@ -106,7 +106,7 @@ Svc_Handler:
     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
@@ -210,7 +210,7 @@ Os_ArchSwapContextTo:
     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
index 2c8008dd2cf166bb735eacabb0ca5334b1a1d065..9f518846e7bff1c229c79859557c317a9b0748cf 100644 (file)
@@ -16,7 +16,7 @@
 #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 );
@@ -74,7 +74,7 @@ void *Irq_Entry( void *stack_p )
        }
 
        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);
@@ -123,9 +123,9 @@ static inline int osPrioToCpuPio( uint8_t prio ) {
  * @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);
 
index 1826b2b9819f9e44a982e507b10ddaae0b7c5908..882e9a0a0d906e075135ebcb9f4b646dcf029e51 100644 (file)
@@ -16,7 +16,7 @@
 #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
index 712b261b8cb451484706bc80fafb6ebc941a7c8c..23afbb85e3afd762c23928fe8ae95983caa804f4 100644 (file)
@@ -20,7 +20,7 @@
 #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
index 09d56acb5e40ab9ac37da120ef704aaa6f8f8322..e99d96bd423d221f2b50450a0c58ca3b3bb8e1da 100644 (file)
@@ -35,7 +35,7 @@
 #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
index f3e78ca7e4cf05d042e6f6080652b0c14c714751..e7ab9bead96bdce77805bdadc6abca13b2f4b0c4 100644 (file)
@@ -26,7 +26,7 @@
 #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
index 59154642dcdfa85cff3391202e6d94603295c4c1..2ac2009325e1847b079a694aec0edb1eac9b4b42 100644 (file)
@@ -25,7 +25,7 @@ void Os_ArchFirstCall( void )
 {\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
@@ -42,7 +42,7 @@ unsigned int Os_ArchGetScSize( void ) {
 }\r
 \r
 \r
-void Os_ArchSetupContext( OsPcbType *pcb ) {\r
+void Os_ArchSetupContext( OsTaskVarType *pcb ) {\r
   // Nothing to be done here\r
 }\r
 \r
@@ -51,7 +51,7 @@ void Os_ArchSetupContext( OsPcbType *pcb ) {
  * @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
index c526ec75a1d12b6e248c65ae70da8371812e2133..87e733cdee63ec350f704be89a598b2e7e114c3e 100644 (file)
@@ -21,7 +21,7 @@
 #include "context.h"\r
 #include "irq_defines.h"\r
 \r
-.extern os_sys\r
+.extern Os_Sys\r
 \r
 \r
 /* \r
index b8454ef6d25adb848fb17b22edc54bd011adbce4..9bae63d00e8997eab41c42d6bf29e6605969be19 100644 (file)
@@ -6,7 +6,7 @@
 #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
@@ -53,7 +53,7 @@ Os_ArchSwapContextTo_get_args:
                \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
index 5d914ed89874efb185045ee4aedf157f22c4e380..df8812ab8ce475b48e5d25a331dad3a171b217e4 100644 (file)
@@ -14,7 +14,7 @@
  * -------------------------------- 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
@@ -94,9 +94,9 @@ void Irq_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector, uint8
  * @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
index 1a269f86becba449bfbd6fb4c77cb089f2a1cb92..7d3e8edcc75315fd24a7757b38079a93a324db1a 100644 (file)
@@ -15,7 +15,7 @@
 \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
index 51618dd0140078e782b5408e1074d61d95b0a9dd..35eae1053dd5fc800148a43297b921ccaafb2649 100644 (file)
@@ -31,7 +31,7 @@
 #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
index a93346753e66e7b8c633f8796661ad9a574ed322..fea2edee731b57bdb7188541c0b84575ed41cdd9 100644 (file)
  * -------------------------------- Arctic Core ------------------------------*/\r
 \r
 \r
-\r
-\r
-\r
-\r
-\r
-\r
 #include "Can.h"\r
 \r
 #ifndef USE_CAN_STUB\r
@@ -36,7 +30,7 @@
 #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
@@ -269,22 +297,6 @@ typedef struct {
 \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
@@ -297,11 +309,13 @@ Can_UnitType CanUnit[CAN_CONTROLLER_CNT] =
     .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
@@ -354,8 +368,7 @@ void Can_B_Isr( void  ) {   Can_Isr(CAN_CTRL_B); }
 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
@@ -364,8 +377,7 @@ void Can_B_Err( void  ) {   Can_Err(CAN_CTRL_B); }
 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
@@ -374,8 +386,7 @@ void Can_B_BusOff( void  ) {        Can_BusOff(CAN_CTRL_B); }
 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
@@ -664,29 +675,9 @@ static void Can_Isr(int unit) {
   }\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
@@ -737,42 +728,53 @@ void Can_Init( const Can_ConfigType *config ) {
       }\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
index 92a9932d3ab10e8b134abaf04681f892c8b40b5b..0a2df55fa9cb52b985d10e8bdb44d7b806c17b73 100644 (file)
@@ -31,7 +31,7 @@
 #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
index 6abbc3f1897a62c749290a91bb1ae385bc9337c7..b539829c3233ee5618b0c1b58244bc6bfe194818 100644 (file)
@@ -30,7 +30,7 @@
 #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
index 0b1db9a3f598f5c119e195842a49d204c72c4488..3977f2fcae88278c854536c84b816fad99a3f00c 100644 (file)
  * -------------------------------- 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
@@ -75,23 +89,10 @@ typedef struct
 \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
@@ -100,9 +101,14 @@ Mcu_GlobalType Mcu_Global =
                .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
@@ -120,8 +126,10 @@ static void Mcu_LossOfLock( void  ) {
 \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
@@ -254,45 +262,52 @@ static uint32 Mcu_CheckCpu( void ) {
 }\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
@@ -537,8 +552,10 @@ void McuE_ExitCriticalSection(uint32_t old_state)
 \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
index 7216421efcf8a6c2de90901e58e04d41db7319dc..0cb0cdf899cf1878dcac6c091db039e546308683 100644 (file)
 \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
index d3e3fa2de8204c61652aad642462b2fe9aac4981..624a4823b899cc219118c4c5134ccff63fb6f84e 100644 (file)
 \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
@@ -107,8 +107,8 @@ unsigned int Os_ArchGetScSize( void ) {
 \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
index 886d5e773ef44ba44eeb639e733f52cb86a56cf2..2aa967c58c1f51d0ca42499d7aaaba43ff168875 100644 (file)
@@ -1,3 +1,4 @@
+\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
@@ -103,17 +115,6 @@ void Irq_Init( void ) {
          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
@@ -130,12 +131,11 @@ void Irq_Init( void ) {
        #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
@@ -143,7 +143,7 @@ void Irq_EOI( void ) {
 #endif\r
 }\r
 \r
-#if 0\r
+\r
 /**\r
  *\r
  * @param stack_p Ptr to the current stack.\r
@@ -154,36 +154,45 @@ void Irq_EOI( void ) {
 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
@@ -198,6 +207,7 @@ void Irq_SetPriority( Cpu_t cpu,  IrqType vector, uint8_t prio ) {
 \r
 \r
 \r
+#if 0\r
 /**\r
  * Attach an ISR type 1 to the interrupt controller.\r
  *\r
@@ -220,7 +230,55 @@ void Irq_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector,uint8_
        }\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
@@ -229,10 +287,10 @@ void Irq_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector,uint8_
  * @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
@@ -244,6 +302,7 @@ void Irq_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) {
                assert(0);\r
        }\r
 }\r
+#endif\r
 \r
 \r
 /**\r
@@ -281,3 +340,175 @@ uint8_t Irq_GetCurrentPriority( Cpu_t cpu) {
 }\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
index 0420f72a204cfbc6082dcf88b84b9e63771c93ef..33bf5e3375b7680d23a54f54ecda8cbd7f77708f 100644 (file)
@@ -10,7 +10,33 @@ OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc")
 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
@@ -114,7 +140,8 @@ __FLS_PROG_START__ = 0;     /* Must be aligned to a sector start. */
 \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
@@ -132,20 +159,54 @@ __FLS_PROG_START__ = 0;   /* Must be aligned to a sector start. */
                __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
@@ -192,6 +253,8 @@ __FLS_PROG_START__ = 0;     /* Must be aligned to a sector start. */
   .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
index 776d51ab2c511a156546d63dc2fff22e4951f39e..2e6efe27c941918e0a16b34c7769c38e3950450b 100644 (file)
@@ -1,4 +1,6 @@
 \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
@@ -295,3 +297,4 @@ VPATH += $(vpath-y)
 \r
 # libs needed by us\r
 #build-lib-y += $(ROOTDIR)/libs/libboard_$(BOARDDIR).a\r
+\r
index ece0313baa0afe2f10504729ba2b4b9421025097..913e1077046c7fa29191a9b1bd0fd2ea052fcfaf 100644 (file)
@@ -450,8 +450,27 @@ int arc_putchar(int fd, int c) {
 \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
@@ -490,12 +509,6 @@ void * sbrk( ptrdiff_t incr )
 \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
index 92b7368dc3cd54a9903051fbe27973b3d804230c..7c93d5314bdf2da652ee788b039360fdf1aadd1b 100644 (file)
@@ -54,7 +54,7 @@ uint16_t handle_SysMonEvent(TCF_Event* event, char* buf){
 \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
@@ -69,7 +69,7 @@ uint16_t handle_SysMonCommand(TCF_Command* command, char* buf) {
 \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
@@ -94,7 +94,7 @@ uint16_t handle_SysMonCommand(TCF_Command* command, char* buf) {
 \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
index 70d0af7c93bb28ebfa685f8fafe46129a837057e..47ba49527b9f763bfaf9d828b7602eb70dec1796 100644 (file)
@@ -65,7 +65,7 @@ void bTask25( void );
 #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
index bc82f74e7128a177e572079df8882a92bf0f0c34..c775d13c1e1dd62287d499d490c7cfdd2d81ec7d 100644 (file)
@@ -72,13 +72,28 @@ typedef TaskStateType *TaskStateRefType;
 \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
@@ -151,6 +166,8 @@ typedef  void * TrustedFunctionParameterRefType;
 #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
@@ -169,7 +186,6 @@ void StartOS( AppModeType Mode );
 \r
 \r
 \r
-ApplicationType GetApplicationID( void );\r
 ISRType GetISRID( void );\r
 StatusType GetActiveApplicationMode( AppModeType* mode);\r
 \r
@@ -247,6 +263,9 @@ static inline void ResumeOSInterrupts( void ) {
 /*\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
@@ -256,8 +275,17 @@ AccessType         CheckTaskMemoryAccess(  TaskType TaskID,
                                                                        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
index 65136bb551f14e1bb4653614c28cfb3415b1e3b0..79aafa43178e2de72de06c62ba97217e3f2d07bc 100644 (file)
@@ -21,6 +21,7 @@
 #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
index ecee85bd75811f65de68f783658d9cc61e47c846..785156b1bae7f54dfe57bcd8ae3864a266eed79a 100644 (file)
 #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
@@ -36,8 +84,6 @@ typedef _Bool IsrType;
 void Irq_Init( void );\r
 \r
 \r
-\r
-\r
 #if defined(CFG_HC1X)\r
 /**\r
  *\r
@@ -59,6 +105,11 @@ void *Irq_Entry( uint8_t irq_nr, void *stack );
  */\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
@@ -90,18 +141,20 @@ void Irq_GenerateSoftInt( IrqType vector );
  */\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
@@ -111,9 +164,10 @@ static inline void Irq_SetIsrType( IrqType vector, IsrType type ) {
  * @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
diff --git a/include/isr.h b/include/isr.h
new file mode 100644 (file)
index 0000000..e644158
--- /dev/null
@@ -0,0 +1,89 @@
+/* -------------------------------- 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
index 10680126946d268b92a5c288247974fe03754286..260bf5cd6681b24f0f28fe0cb844a75dee0e5591 100644 (file)
                                                                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
@@ -65,15 +62,14 @@ trusted_func_t oil_trusted_func_list[SERVICE_CNT];
 #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
@@ -152,9 +148,9 @@ uint32 Os_CfgGetMessageCnt(void ) {
 \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
index 66d5004916e8016b1881f96d710e9692344344a9..d7b314902b6c1c57d4e6049ca1ccde96845b7cbc 100644 (file)
 #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
@@ -364,27 +359,6 @@ struct OsHooks os_conf_global_hooks = { \
                .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
index ccfb623410b861ec10ee766d47f8ef86aa362321..d45c32c4aaefaeb1b06b13a0d1cf41ee5c54db5c 100644 (file)
--- a/makefile
+++ b/makefile
@@ -11,7 +11,7 @@
 #   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
@@ -74,20 +74,17 @@ export objdir = obj_$(BOARDDIR)
 \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
@@ -134,15 +131,17 @@ test:
        @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
index 07372a1ef0cd71cf69acb64f112715fc7eb2c449..977561dc0484c4c979746cbccddfd8a2ead5e72f 100644 (file)
@@ -1,5 +1,11 @@
 \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
diff --git a/scripts/gcc_map_memory.awk b/scripts/gcc_map_memory.awk
new file mode 100644 (file)
index 0000000..cb8ff95
--- /dev/null
@@ -0,0 +1,32 @@
+\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
index aa0b0c5981abbffa0784b35b109faa02b6ccfcdb..ddbfac7e530d9eb2aa3f32ce1ce60c42faeb6f71 100644 (file)
@@ -1,19 +1,30 @@
 \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
@@ -46,7 +57,11 @@ ifneq ($(not_avail),)
 $(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
@@ -57,13 +72,8 @@ $(eval CFG_$(SELECT_OPT)=y)
 \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
@@ -76,13 +86,21 @@ endif
 \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
@@ -103,46 +121,20 @@ endif
 \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
@@ -173,17 +165,53 @@ endef
 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
@@ -199,61 +227,57 @@ endif
 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
index d81e931420682f5fdde9659b7c0dcccd03ee1048..097dc28d93b9dacab9b05ae0c13a9665a52e4f6c 100644 (file)
@@ -6,7 +6,9 @@ CORE_BUILD_SYSTEM_VERSION_MAJOR = 1
 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
index 0369176260152b4a5a049fce5b4cf7a3e016f0da..28ab691f9842d40dfa38d967fbac60520dbf6dc6 100644 (file)
@@ -23,7 +23,7 @@
 #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
@@ -45,7 +45,7 @@ void EcuM_Init( void )
        InitOS();\r
 \r
        // Enable interrupts\r
-       Irq_Init();\r
+       Isr_Init();\r
 \r
        // Determine PostBuild configuration\r
        internal_data.config = EcuM_DeterminePbConfiguration();\r
index e2cd7e7f75e905fe4187deb7b45c32724dbb0808..44877c40a0f894848a19d39c424dcd12a4ff99d1 100644 (file)
@@ -312,7 +312,7 @@ void Os_AlarmAutostart(void) {
                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
index c0de676c2c8e09f0a52668bcdea7e3b050ccf8eb..e275fa41ef936f3a011259563c540cbef3a17b31 100644 (file)
  * 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
index 08d7f3b1729201fa362cf629244dc97cb16b779e..6168c9c4b7765b3de8e873c01a3c1540c34690a2 100644 (file)
@@ -34,12 +34,12 @@ void  asm_foo(void) {
     __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
index b882281d50fb2f8da65d2e7ce6dc5dfdb176a19c..a1fa0ecbe881ea30bdb04a9f840cf78ba0d52b39 100644 (file)
@@ -24,6 +24,8 @@
  *\r
  */\r
 \r
+#include "Os.h"\r
+\r
 void apa(void *);\r
 \r
 void interrupt(void) __attribute__((__interrupt__));\r
@@ -36,6 +38,7 @@ void interrupt( void ) {
 \r
 void func1( int a ) {\r
 \r
+\r
 }\r
 \r
 int func3( int a ) {\r
index 16ba4191a26bdbd1b96568b1945385dd27de5daf..34ce89c63c4b496fc26fbee4cc9649302587e447 100644 (file)
@@ -112,7 +112,7 @@ StatusType GetCounterValue( CounterType counter_id , TickRefType tick_ref)
        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
@@ -192,11 +192,11 @@ void OsTick( void ) {
 \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
@@ -207,7 +207,7 @@ void OsTick( void ) {
 }\r
 \r
 TickType GetOsTick( void ) {\r
-       return get_os_tick();\r
+       return Os_Sys.tick;\r
 }\r
 \r
 \r
index e7f07038faad28ca4a834779584d443590aa52e3..0baee21b29c5f95d6738aa6ca01ed2444e7ebf38 100644 (file)
 \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
@@ -71,7 +71,7 @@ StatusType WaitEvent( EventMaskType Mask ) {
                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
@@ -101,8 +101,8 @@ StatusType WaitEvent( EventMaskType Mask ) {
 \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
@@ -112,15 +112,25 @@ StatusType SetEvent( TaskType TaskID, EventMaskType Mask ) {
                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
@@ -139,24 +149,24 @@ StatusType SetEvent( TaskType TaskID, EventMaskType Mask ) {
         * 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
@@ -183,7 +193,7 @@ StatusType SetEvent( TaskType TaskID, EventMaskType Mask ) {
  */\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
@@ -191,12 +201,12 @@ StatusType GetEvent( TaskType TaskId, EventMaskRefType Mask) {
                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
@@ -214,16 +224,16 @@ StatusType GetEvent( TaskType TaskId, EventMaskRefType Mask) {
  */\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
index 87a8f91f1a0b665facf13d8114d87d0a4e30df53..5a652251e35bf7731d3172c287be52932e2e3865 100644 (file)
@@ -82,7 +82,7 @@ typedef struct OsAlarmAutostart {
 } 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
@@ -92,6 +92,11 @@ typedef struct OsAlarm {
        /* 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
index 0ec52e06fbde64482f703876ad37a4b6562cfdd4..5852536038af64ff666f7e24053494610ee5a7db 100644 (file)
@@ -2,7 +2,57 @@
 #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
@@ -36,44 +86,56 @@ typedef struct OsAppHooks {
  *       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
index fc27f15e56d59f26723e5c9a02aa610b0ea910eb..ae602753363a03bc656e7f32bca9264a0dc0401d 100644 (file)
@@ -67,7 +67,7 @@ void Os_ArchSwapContextTo(void *old,void *new);
  *\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
@@ -117,7 +117,7 @@ void Os_ArchReboot( int type );
  */\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
index d8d23ed9d10b52c59c3ba977476077a30292db8e..465d93063d81f5b893fec02f5e517746fb72d7ad 100644 (file)
@@ -46,7 +46,10 @@ typedef struct OsCounter {
        // 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
index 09d0b3e597b64a09a72ad1527def544c06e4725e..fc44b5f13cb187f645d424a156e369428773763a 100644 (file)
 #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
index 35ce5af7f8c64a157392cf5f5807a35963667d31..33e0d1cc4a0eb5187fd8fa9da273b0ece35d8aa6 100644 (file)
  *\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
@@ -195,86 +201,48 @@ static inline uint32_t os_task_nr_to_mask( uint32_t nr ) {
 }\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
@@ -285,12 +253,12 @@ void Os_Isr_cm3( void *isr_p );
 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
@@ -301,12 +269,12 @@ static inline void *Os_StackGetUsage( OsPcbType *pcb ) {
        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
@@ -319,14 +287,15 @@ static inline _Bool Os_StackIsEndmarkOk( OsPcbType *pcbPtr ) {
        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
@@ -334,7 +303,7 @@ static inline void Os_StackPerformCheck( OsPcbType *pcbPtr ) {
 \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
index 7264ccfbecfacd153902254d1d1305d93eebd077..b1e9b624d40e923286409ef8ac56a3a3960084b7 100644 (file)
@@ -148,8 +148,8 @@ typedef struct OsResource {
 \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
@@ -204,6 +204,8 @@ typedef struct OsTimingProtection {
 #include "application.h"\r
 #include "pcb.h"\r
 #include "sys.h"\r
+#include "isr.h"\r
+//#include "isr.h"\r
 \r
 /*-----------------------------------------------------------------*/\r
 \r
index 892afbd49fe22a03e2187de9a78a3ef169cd62a3..971624b38db201b8dbd83114b6254a62a71b8c17 100644 (file)
@@ -16,7 +16,7 @@
 #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
@@ -27,6 +27,9 @@ struct OsRomPcb;
 #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
@@ -45,10 +48,13 @@ typedef sint8 OsPriorityType;
  * 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
@@ -56,6 +62,12 @@ typedef sint8 OsPriorityType;
  * 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
@@ -63,9 +75,17 @@ typedef sint8 OsPriorityType;
  * 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
@@ -78,7 +98,7 @@ typedef sint8 OsPriorityType;
  * */\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
@@ -102,9 +122,11 @@ typedef uint8_t proc_type_t;
 #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
@@ -118,69 +140,93 @@ typedef struct {
 #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
@@ -188,18 +234,25 @@ typedef struct OsRomPcb {
        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
index f8bc70827a7daccff57b9422abf29eb454b38398..5a8d08b1c7c3b91575c04849c2c7bdf41ad7fdae 100644 (file)
@@ -150,6 +150,10 @@ typedef struct OsSchTbl {
        /** @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
@@ -161,7 +165,7 @@ typedef struct OsSchTbl {
        /* 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
index ace52e1d2ce616b1ac2583fa592b66eefddd6c30..36ae721351b8a7af99777a1afaab2708029a3dae 100644 (file)
@@ -28,21 +28,24 @@ typedef enum  {
        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
@@ -59,29 +62,36 @@ typedef struct sys_s {
        /* 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
index b1c2ff3d5d737f891247ca449b98530365c34961..94a87f6fd7ef9b0af6fe1ad7d4f59432d68bef28 100644 (file)
 #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
@@ -34,7 +34,7 @@ static inline void os_pcb_print_rq( void ) {
 }\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
@@ -42,30 +42,30 @@ static inline void Os_TaskRunningToReady( OsPcbType *pcb ) {
 \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
@@ -75,49 +75,55 @@ static inline void Os_TaskMakeSuspended( OsPcbType *pcb )
  *\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
index d09765f4d34d64195acbccfef5f798e4f5605019..af238d10bcc19b0eab6aa672a297a90b573bbb3f 100644 (file)
@@ -13,7 +13,7 @@
  * 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
@@ -40,12 +48,17 @@ Os_IntCounterType Os_IntSuspendOsCnt;
  * @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);
@@ -54,25 +67,26 @@ static void os_pcb_rom_copy( OsPcbType *pcb, const OsRomPcbType *r_pcb ) {
        }
 #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;
@@ -84,27 +98,27 @@ 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
@@ -119,20 +133,25 @@ void InitOS( void ) {
        // 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();
@@ -141,7 +160,8 @@ void InitOS( void ) {
 }
 
 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
@@ -152,11 +172,18 @@ static void os_start( void ) {
        /* 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();
@@ -175,31 +202,46 @@ static void os_start( void ) {
 
        /* 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);
        }
@@ -243,7 +285,7 @@ void StartOS(AppModeType Mode) {
                noooo();
        }
 
-       os_sys.appMode = Mode;
+       Os_Sys.appMode = Mode;
 
        Os_CfgValidate();
 
@@ -262,8 +304,8 @@ void StartOS(AppModeType Mode) {
 /** @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();
index 29e42c62bb9a703d5b6169c812b20a545e4169d5..3bd38c9ac6f63b5c6310a7a2294a907895a2e8dc 100644 (file)
  * 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
@@ -112,11 +145,11 @@ StatusType Os_IsrAddResource( TaskType isr, ResourceType resource ) {
 }
 
 #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();
 
@@ -129,16 +162,16 @@ void TailChaining(void *stack)
        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);
@@ -147,12 +180,12 @@ void TailChaining(void *stack)
 
 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 ) ) {
@@ -181,72 +214,53 @@ void Os_Isr_cm3( void *isr_p ) {
 
        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 */
@@ -258,33 +272,33 @@ void *Os_Isr( void *stack, void *isr_p ) {
 
        /* 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);
index d576b3ca6fcf2231cc446718b82e470d8b3946dd..ff625b69da7ecc91c2cd6acaa06945427874ffb4 100644 (file)
@@ -21,7 +21,7 @@
 #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
@@ -40,15 +40,16 @@ void  oil_foo(void) {
 #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
index adf792f11fb2cc8f7283180e95bf5417e06eb449..0e4348d8035889fec90c74187377793473fe27b6 100644 (file)
@@ -36,7 +36,7 @@ obj-y += irq.o
 # 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
index 9e3db4af9c15b8793e4d912b1311452ab2a2cac9..996e4bd553862c211e2d370b21937ebecebf39c6 100644 (file)
 \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
index 7f60111a910a1e0504f43e3bfec055e742c513aa..fafe026694454dec33d34b82c4f8ad884aced074 100644 (file)
@@ -21,7 +21,7 @@
 \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
@@ -32,7 +32,7 @@ int Os_ArcTest_GetTaskActivationLimit( TaskType TaskId ) {
 \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
index 4785edcdf9f65d883a687a1ccbde3779abfee0bc..d784bc6d94ab390b119eab8bb319c7352d96f4db 100644 (file)
@@ -62,7 +62,7 @@ TODO:
 \r
   task.rsrcAccessMask & (1 << RES_SCHEDULER)\r
 \r
- *
+ *\r
  */\r
 \r
 /* INFO\r
@@ -106,31 +106,31 @@ TODO:
 #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
@@ -162,7 +162,7 @@ void Os_ResourceFree( OsResourceType *rPtr , OsPcbType *pcbPtr) {
 \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
@@ -170,10 +170,10 @@ StatusType GetResource( ResourceType ResID ) {
 \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
@@ -183,7 +183,7 @@ StatusType GetResource( ResourceType ResID ) {
 \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
@@ -214,16 +214,16 @@ StatusType GetResource( ResourceType ResID ) {
 \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
@@ -238,7 +238,7 @@ StatusType ReleaseResource( ResourceType ResID) {
                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
@@ -248,14 +248,14 @@ StatusType ReleaseResource( ResourceType ResID) {
        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
@@ -266,8 +266,8 @@ StatusType ReleaseResource( ResourceType ResID) {
 \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
@@ -279,8 +279,8 @@ void Os_ResourceGetInternal( void ) {
 }\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
@@ -299,17 +299,17 @@ void Os_ResourceReleaseInternal( void ) {
  * @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
@@ -324,15 +324,15 @@ void Os_ResourceInit( void ) {
 \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
index f1223779c6db9ad2188f064fdc905692a52872f1..541a954d0c8d404f5572a8b6f3c5079245529842 100644 (file)
@@ -582,7 +582,7 @@ void Os_SchTblAutostart( void ) {
                        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
index 814b34fa60426797941e67d0ca4168260076f794..7d0c1373671fe2893cd0cc7247b2386ee432608f 100644 (file)
@@ -13,6 +13,8 @@
  * 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
@@ -35,7 +51,7 @@ _Bool os_pcb_pid_valid( OsPcbType *restrict pcb ) {
  */\r
 void Os_TaskStartExtended( void ) {\r
 \r
-       OsPcbType *pcb;\r
+       OsTaskVarType *pcb;\r
 \r
        pcb = Os_TaskGetCurrent();\r
 #if 0\r
@@ -83,7 +99,7 @@ void Os_TaskStartExtended( void ) {
 \r
 void Os_TaskStartBasic( void ) {\r
 \r
-       OsPcbType *pcb;\r
+       OsTaskVarType *pcb;\r
 \r
        pcb = Os_TaskGetCurrent();\r
 #if 0\r
@@ -114,7 +130,7 @@ void Os_TaskStartBasic( void ) {
 }\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
@@ -140,7 +156,7 @@ static void Os_StackSetup( OsPcbType *pcbPtr ) {
  *\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
@@ -156,7 +172,7 @@ static void Os_StackFill(OsPcbType *pcbPtr) {
  *\r
  * @param pcbPtr\r
  */\r
-static void Os_TaskSetEntry(OsPcbType *pcbPtr ) {\r
+static void Os_TaskSetEntry(OsTaskVarType *pcbPtr ) {\r
 \r
 }\r
 #endif\r
@@ -169,9 +185,9 @@ static void Os_TaskSetEntry(OsPcbType *pcbPtr ) {
  *\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
@@ -188,46 +204,50 @@ void Os_ContextInit( OsPcbType *pcb ) {
  *\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
@@ -240,23 +260,23 @@ TaskType Os_AddTask( OsPcbType *pcb ) {
  * @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
@@ -296,7 +316,7 @@ OsPcbType *Os_TaskGetTop( void ){
  *    + 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
@@ -315,10 +335,10 @@ OsPcbType *Os_FindTopPrioTask( void ) {
  *\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
@@ -333,7 +353,7 @@ void Os_Dispatch( uint32_t op ) {
        } 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
@@ -346,7 +366,7 @@ void Os_Dispatch( uint32_t op ) {
                 *\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
@@ -357,7 +377,7 @@ void Os_Dispatch( uint32_t op ) {
                        }\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
@@ -382,7 +402,7 @@ void Os_Dispatch( uint32_t op ) {
        /* 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
@@ -395,11 +415,16 @@ void Os_Dispatch( uint32_t op ) {
 \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
@@ -439,8 +464,11 @@ void Os_Dispatch( uint32_t op ) {
  *  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
@@ -449,8 +477,11 @@ void Os_TaskSwapContext(OsPcbType *old_pcb, OsPcbType *new_pcb ) {
        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
@@ -460,7 +491,7 @@ void Os_TaskSwapContextTo(OsPcbType *old_pcb, OsPcbType *new_pcb ) {
 \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
@@ -491,7 +522,7 @@ StatusType GetTaskState(TaskType TaskId, TaskStateRefType State) {
 \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
@@ -521,12 +552,12 @@ StatusType GetTaskID( TaskRefType TaskID ) {
 \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
@@ -534,19 +565,27 @@ StatusType GetTaskID( TaskRefType TaskID ) {
 }\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
@@ -584,7 +623,7 @@ static inline void Os_Arc_SetCleanContext( OsPcbType *pcb ) {
 \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
@@ -595,6 +634,22 @@ StatusType ActivateTask( TaskType TaskID ) {
 #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
@@ -605,7 +660,7 @@ StatusType ActivateTask( TaskType TaskID ) {
        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
@@ -620,9 +675,9 @@ StatusType ActivateTask( TaskType TaskID ) {
        }\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
@@ -663,16 +718,16 @@ StatusType ActivateTask( TaskType TaskID ) {
  */\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
@@ -702,19 +757,19 @@ StatusType TerminateTask( void ) {
 }\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
@@ -745,7 +800,7 @@ StatusType ChainTask( TaskType TaskId ) {
 //     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
@@ -762,7 +817,7 @@ StatusType ChainTask( TaskType TaskId ) {
 \r
        }\r
 \r
-       os_sys.chainedPcbPtr = pcb;\r
+       Os_Sys.chainedPcbPtr = pcb;\r
 \r
        Os_Dispatch(OP_CHAIN_TASK);\r
 \r
@@ -786,12 +841,12 @@ StatusType ChainTask( TaskType TaskId ) {
 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
@@ -809,14 +864,14 @@ StatusType Schedule( void ) {
         * 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