]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Initial commit of changes to add applications. Nothing works....
authormahi <devnull@localhost>
Wed, 22 Dec 2010 06:12:43 +0000 (07:12 +0100)
committermahi <devnull@localhost>
Wed, 22 Dec 2010 06:12:43 +0000 (07:12 +0100)
36 files changed:
arch/arm/arm_cm3/kernel/arch.c
arch/arm/arm_cr4/kernel/arch.c
arch/hc1x/hcs12d/kernel/arch.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
common/tcf/sys_monitor.c
include/Os.h
include/irq.h
include/os_config_funcs.h
include/os_config_macros.h
scripts/cc_gcc.mk
system/kernel/alarm.c
system/kernel/application.c
system/kernel/asm_offset.c
system/kernel/counter.c
system/kernel/event.c
system/kernel/include/alarm_i.h
system/kernel/include/application.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/memory.c
system/kernel/os_arctest.c
system/kernel/resource.c
system/kernel/sched_table.c
system/kernel/task.c

index 4e71d30e47b5673b96bd6e70a7d5a01766405abb..2d5ba5f6160e0af8b7602a3d1e6cbb2e9e162b13 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.curr_pcb->entry();\r
 }\r
 \r
 void *Os_ArchGetStackPtr( void ) {\r
index bd4d0b60b04e44930610970000c2b67770b24fe5..5b556b1b34bc9bb04d52ca6ebbe3415fb006ce35 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.curr_pcb->entry();\r
 }\r
 \r
 void *Os_ArchGetStackPtr( void ) {\r
index 59154642dcdfa85cff3391202e6d94603295c4c1..ff7098e243ffbe8312ae96c962975d0191b1e62c 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.curr_pcb->entry();\r
 }\r
 \r
 void *Os_ArchGetStackPtr( void ) {\r
index 9ec24a14d87083f08581e0a6f7f4c1eb0fbecbea..9b13f19823628eadad39c0951ab65faa297b158f 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 "Os.h"\r
 #include "irq.h"\r
 \r
+/* ----------------------------[private define]------------------------------*/\r
 //#define USE_TRACE 1\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
-/* Function declarations. */\r
-static void Mcu_ConfigureFlash(void);\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
 \r
+/* ----------------------------[private typedef]-----------------------------*/\r
+typedef void (*vfunc_t)();\r
+\r
 typedef struct {\r
        uint32 lossOfLockCnt;\r
        uint32 lossOfClockCnt;\r
@@ -76,23 +90,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
@@ -101,8 +102,13 @@ Mcu_GlobalType Mcu_Global =
                .config = &McuConfigData[0],\r
 };\r
 \r
-//-------------------------------------------------------------------\r
+/* ----------------------------[private functions]---------------------------*/\r
+/* ----------------------------[public functions]----------------------------*/\r
+\r
 \r
+/**\r
+ * ISR wh
+ */\r
 static void Mcu_LossOfLock( void  ) {\r
 #if defined(USE_DEM)\r
        Dem_ReportErrorStatus(MCU_E_CLOCK_FAILURE, DEM_EVENT_STATUS_FAILED);\r
@@ -114,8 +120,10 @@ static void Mcu_LossOfLock( void  ) {
 \r
 }\r
 \r
-//-------------------------------------------------------------------\r
-static void Mcu_LossOfCLock( void  ) {\r
+/**\r
+ *
+ */\r
+static void Mcu_LossOfClock( void  ) {\r
 \r
        /* Should report MCU_E_CLOCK_FAILURE with DEM here */\r
 \r
@@ -250,43 +258,45 @@ static uint32 Mcu_CheckCpu( void ) {
 \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
+       IRQ_DECL_ISR1( PLL_SYNSR_LOLF,  CPU_CORE0, 10, Mcu_LossOfLock  );\r
+       IRQ_DECL_ISR1( PLL_SYNSR_LOCF,  CPU_CORE0, 10, Mcu_LossOfClock );\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( &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( &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
@@ -531,8 +541,10 @@ void McuE_ExitCriticalSection(uint32_t old_state)
 \r
 /**\r
  * Get the peripheral clock in Hz for a specific device\r
+ *
+ * @param type
+ * @return
  */\r
-\r
 uint32_t McuE_GetPeripheralClock(McuE_PeriperalClock_t type)\r
 {\r
 #if defined(CFG_MPC5567)\r
index 7216421efcf8a6c2de90901e58e04d41db7319dc..44adff19da38fd6a402e2f63dcc68aceeba1de13 100644 (file)
  */\r
 void Os_SysTickInit( void ) {\r
        TaskType tid;\r
+#if 1\r
+       IRQ_DECL_ISR2("MyIsr",10,CPU_CORE0, 10,MyIsr,HAVE_SC2_SC4(RES_ID_1),HAVE_SC2_SC4(timing));\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 98127598c60a16e00b4d91f9a3d2c30ed000c2a8..723f42626e3a1fff18c7cd5f393d7d3ef6618256 100644 (file)
@@ -30,8 +30,8 @@ void Os_ArchFirstCall( void )
 \r
        // Assume that regs[0] is setup before and contains the settings\r
        // to switch to user mode.\r
-       register uint32_t msr asm("r3") = os_sys.curr_pcb->regs[0];\r
-       register void *ea asm("r4") = (void *) os_sys.curr_pcb->entry;\r
+       register uint32_t msr asm("r3") = Os_Sys.curr_pcb->regs[0];\r
+       register void *ea asm("r4") = (void *) Os_Sys.curr_pcb->entry;\r
 \r
        // Do the switch\r
        asm volatile(\r
@@ -43,7 +43,7 @@ void Os_ArchFirstCall( void )
 #else\r
 // TODO: This really depends on if scheduling policy\r
        Irq_Enable();\r
-       os_sys.curr_pcb->entry();\r
+       Os_Sys.curr_pcb->entry();\r
 #endif\r
 }\r
 \r
index d95ad9c8f3795ea9b8b6ade8003f63b0491f421f..1708aa6026c7b30e3023235612a8b142e6ff33fd 100644 (file)
  * for more details.\r
  * -------------------------------- Arctic Core ------------------------------*/\r
 \r
+/* ----------------------------[includes]------------------------------------*/\r
+/* ----------------------------[private define]------------------------------*/\r
+/* ----------------------------[private macro]-------------------------------*/\r
+/* ----------------------------[private typedef]-----------------------------*/\r
+/* ----------------------------[private function prototypes]-----------------*/\r
+/* ----------------------------[private variables]---------------------------*/\r
+/* ----------------------------[private functions]---------------------------*/\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
-#if !defined(USE_KERNEL)\r
-#include "Mcu.h"\r
-#endif\r
-\r
-#if defined(USE_KERNEL)\r
 #include "pcb.h"\r
 #include "sys.h"\r
 #include "internal.h"\r
 #include "task_i.h"\r
 #include "hooks.h"\r
-\r
-#if 0\r
-#define INTC_SSCIR0_CLR7                                       7\r
-#define MLB_SERVICE_REQUEST                                    293\r
-#define CRITICAL_INPUT_EXCEPTION                       320\r
-#define DEBUG_EXCEPTION                                                335\r
-#define NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS    336\r
-#endif\r
-\r
 #include "debug.h"\r
-#endif\r
 #include "irq.h"\r
+#include <stdint.h>\r
 \r
-static void dump_exception_regs( uint32_t *regs );\r
-\r
+/* ----------------------------[private define]------------------------------*/\r
+/* ----------------------------[private macro]-------------------------------*/\r
+/* ----------------------------[private typedef]-----------------------------*/\r
 typedef void (*f_t)( uint32_t *);\r
-//typedef void (*func_t)();\r
-//extern vfunc_t Irq_VectorTable[];\r
-extern void exception_tbl(void);\r
 \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
 \r
+static void dumpExceptionRegs( uint32_t *regs );\r
 \r
-#if defined(USE_KERNEL)\r
-extern void * Irq_VectorTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];\r
-extern uint8 Irq_IsrTypeTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];\r
-#else\r
-extern func_t Irq_VectorTable[];\r
-#endif\r
+/* ----------------------------[private variables]---------------------------*/\r
+extern void exception_tbl(void);\r
+\r
+/* ----------------------------[private functions]---------------------------*/\r
+/* ----------------------------[public functions]----------------------------*/\r
 \r
 // write 0 to pop INTC stack\r
 void Irq_Init( void ) {\r
@@ -113,17 +112,6 @@ void Irq_Init( void ) {
          INTC.MCR.B.VTES = 0; // 4 byte offset between entries\r
        #endif\r
 \r
-\r
-         // Pointless in software vector more???\r
-#if 0\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
@@ -193,8 +181,6 @@ void *Irq_Entry( void *stack_p )
                }\r
        }\r
 \r
-#if defined(USE_KERNEL)\r
-\r
        if( Irq_GetIsrType(vector) == ISR_TYPE_1 ) {\r
                // It's a function, just call it.\r
                ((func_t)Irq_VectorTable[vector])();\r
@@ -204,38 +190,8 @@ void *Irq_Entry( void *stack_p )
                // Let the kernel handle the rest,\r
                return Os_Isr(stack, (void *)Irq_VectorTable[vector]);\r
        }\r
-\r
-\r
-#else\r
-               //read address\r
-       t = (func_t)Irq_VectorTable[vector];\r
-\r
-       if( t == ((void *)0) )\r
-       {\r
-               while(1);\r
-       }\r
-\r
-       // Enable nestling interrupts\r
-       Irq_Enable();\r
-       t();\r
-       Irq_Disable();\r
-\r
-       if( vector < INTC_NUMBER_OF_INTERRUPTS )\r
-       {\r
-               // write 0 to pop INTC stack\r
-               intc->EOIR_PRC0.R = 0;\r
-       }\r
-       return NULL;\r
-\r
-#endif\r
 }\r
 \r
-\r
-\r
-#if defined(USE_KERNEL)\r
-\r
-\r
-\r
 static inline int osPrioToCpuPio( uint8_t prio ) {\r
        assert(prio<32);\r
        return prio>>1;         // Os have 32 -> 16\r
@@ -250,6 +206,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
@@ -272,7 +229,33 @@ void Irq_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector,uint8_
        }\r
 \r
 }\r
+#endif\r
 \r
+/**\r
+ *
+ * @param isrPtr
+ * @param type
+ * @param int_ctrl
+ */\r
+ISRType Irq_Attach( const OsIsrType_CONST *isrPtr ) {\r
+//     Os_Sys.isrCnt\r
+       uint32_t vector = isrPtr->vector;\r
+\r
+       Irq_VectorTable[vector] = (uintptr_t)isrPtr;\r
+//     Irq_IsrTypeTable[vector] = type;\r
+\r
+       if (vector < INTC_NUMBER_OF_INTERRUPTS) {\r
+               Irq_SetPriority(CPU_CORE0,vector + IRQ_INTERRUPT_OFFSET, osPrioToCpuPio(isrPtr->prio));\r
+       } else if ((vector >= CRITICAL_INPUT_EXCEPTION)\r
+                       && (vector<= DEBUG_EXCEPTION)) {\r
+       } else {\r
+               /* Invalid vector! */\r
+               assert(0);\r
+       }\r
+       return 0;\r
+}\r
+\r
+#if 0\r
 /**\r
  * Attach a ISR type 2 to the interrupt controller.\r
  *\r
@@ -296,49 +279,9 @@ void Irq_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) {
                assert(0);\r
        }\r
 }\r
-\r
-#endif /* defined(USE_KERNEL) */\r
-\r
-#if !defined(USE_KERNEL)\r
-/**\r
- * Installs a vector in intc vector table. It also sets the priority in the INTC\r
- * internal registers.\r
- *\r
- * This does NOT use the kernel\r
- *\r
- * @param func   The function to install\r
- * @param vector INTC vector to install it to\r
- * @param priority INTC priority. 0 - Low prio. 15- Highest( NMI )\r
- * @param cpu\r
- */\r
-\r
-void Irq_InstallVector(void(*func)(), IrqType vector,\r
-    uint8_t priority, Cpu_t cpu)\r
-{\r
-  VALIDATE( ( 1 == Mcu_Global.initRun ), MCU_INTCVECTORINSTALL_SERVICE_ID, MCU_E_UNINIT );\r
-  DEBUG(DEBUG_LOW,"Installing INTC vector:%d,prio:%d,cpu,%d\n",vector,priority,cpu);\r
-  Irq_VectorTable[vector] = func;\r
-\r
-  if (vector <= MLB_SERVICE_REQUEST)\r
-  {\r
-    INTC.PSR[vector].B.PRC_SEL = cpu;\r
-    INTC.PSR[vector].B.PRI = priority;\r
-\r
-    Irq_VectorTable[vector] = func;\r
-  } else if ((vector >= CRITICAL_INPUT_EXCEPTION)\r
-      && (vector <= DEBUG_EXCEPTION))\r
-  {\r
-    Irq_VectorTable[vector] = func;\r
-  } else\r
-  {\r
-    /* Invalid vector! */\r
-    assert(0);\r
-  }\r
-}\r
 #endif\r
 \r
 \r
-\r
 /**\r
  * Generates a soft interrupt\r
  * @param vector\r
@@ -385,7 +328,7 @@ void IVOR0Exception (uint32_t *regs)
 //     ExceptionSave(srr0,srr1,esr,mcsr,dear;)\r
        // CSRR0, CSSR1\r
        // Nothing more\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
        while (1);\r
 }\r
 \r
@@ -394,7 +337,7 @@ void IVOR1Exception (uint32_t *regs)
 {\r
        // CSRR0, CSSR1\r
        // MCSR - Source of machine check\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
    while (1);\r
 }\r
 // Data Storage Interrupt\r
@@ -402,7 +345,7 @@ void IVOR2Exception (uint32_t *regs)
 {\r
        // SRR0, SRR1\r
        // ESR - lots of stuff\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
    while (1);\r
 }\r
 \r
@@ -411,7 +354,7 @@ void IVOR3Exception (uint32_t *regs)
 {\r
        // SRR0, SRR1\r
        // ESR - lots of stuff\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
    while (1);\r
 }\r
 \r
@@ -421,7 +364,7 @@ void IVOR5Exception (uint32_t *regs)
        // SRR0, SRR1\r
        // ESR - lots of stuff\r
        // DEAR - Address of load store that caused the exception\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
    while (1);\r
 }\r
 \r
@@ -430,7 +373,7 @@ void IVOR6Exception (uint32_t *regs)
 {\r
        // SRR0, SRR1\r
        // ESR - lots of stuff\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
        while (1);\r
 }\r
 \r
@@ -438,7 +381,7 @@ void IVOR6Exception (uint32_t *regs)
 void IVOR7Exception (uint32_t *regs)\r
 {\r
        // SRR0, SRR1\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
    while (1);\r
 }\r
 \r
@@ -447,7 +390,7 @@ void IVOR8Exception (uint32_t *regs)
 {\r
        // SRR0, SRR1\r
        // ESR\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
        while (1);\r
 }\r
 \r
@@ -455,7 +398,7 @@ void IVOR8Exception (uint32_t *regs)
 void IVOR9Exception (uint32_t *regs)\r
 {\r
        // Does not happen on e200\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
        while (1);\r
 }\r
 #if 0\r
@@ -471,7 +414,7 @@ void IVOR10Exception (uint32_t *regs)
 void IVOR11Exception (uint32_t *regs)\r
 {\r
        // SRR0, SRR1\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
        while (1);\r
 }\r
 \r
@@ -479,7 +422,7 @@ void IVOR11Exception (uint32_t *regs)
 void IVOR12Exception (uint32_t *regs)\r
 {\r
        // SRR0, SRR1\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
        while (1);\r
 }\r
 \r
@@ -498,14 +441,14 @@ void IVOR14Exception (uint32_t *regs)
 {\r
        // SRR0, SRR1\r
        // ESR - MIF set, All others cleared\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
        while (1);\r
 }\r
 \r
 void IVOR15Exception (uint32_t *regs)\r
 {\r
        // Debug\r
-       dump_exception_regs(regs);\r
+       dumpExceptionRegs(regs);\r
        while (1);\r
 }\r
 \r
@@ -531,7 +474,7 @@ typedef struct {
 \r
 \r
 \r
-static void dump_exception_regs( uint32_t *regs ) {\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
@@ -542,107 +485,7 @@ static void dump_exception_regs( uint32_t *regs ) {
 }\r
 \r
 #else\r
-static void dump_exception_regs( uint32_t *regs ) {\r
+static void dumpExceptionRegs( uint32_t *regs ) {\r
 }\r
 #endif\r
 \r
-#if !defined(USE_KERNEL)\r
-func_t Irq_VectorTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] __attribute__ ((aligned (0x800))) = {\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 00 - 04 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 05 - 09 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 10 - 14 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 15 - 19 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 20 - 24 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 25 - 29 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 30 - 34 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 35 - 39 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 40 - 44 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 45 - 49 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 50 - 54 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 55 - 59 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 60 - 64 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 55 - 69 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 70 - 74 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 75 - 79 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 80 - 84 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 85 - 89 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 90 - 94 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 95 - 99 */\r
-\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 100 - 104 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 105 - 109 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 110 - 114 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 115 - 119 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 120 - 124 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 125 - 129 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 130 - 134 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 135 - 139 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 140 - 144 */\r
- dummy, dummy, dummy, dummy, dummy /* PIT1 */, /* ISRs 145 - 149 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 150 - 154 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 155 - 159 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 160 - 164 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 155 - 169 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 170 - 174 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 175 - 179 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 180 - 184 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 185 - 189 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 190 - 194 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 195 - 199 */\r
-\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 200 - 204 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 205 - 209 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 210 - 214 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 215 - 219 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 220 - 224 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 225 - 229 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 230 - 234 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 235 - 239 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 240 - 244 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 245 - 249 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 250 - 254 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 255 - 259 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 260 - 264 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 255 - 269 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 270 - 274 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 275 - 279 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 280 - 284 */\r
- dummy, dummy, dummy, dummy, dummy, /* ISRs 285 - 289 */\r
- dummy, dummy, dummy, dummy,        /* ISRs 290 - 293 */\r
-\r
- /* Some reserved vectors between INC interrupts and exceptions. */\r
- dummy,                             /* INTC_NUMBER_OF_INTERRUPTS */\r
-\r
- dummy, dummy, dummy, dummy, dummy,\r
- dummy, dummy, dummy, dummy, dummy,\r
- dummy, dummy, dummy, dummy, dummy,\r
- dummy, dummy, dummy, dummy, dummy,\r
- dummy, dummy, dummy, dummy, dummy,\r
-\r
- IVOR0Exception,                    /* CRITICAL_INPUT_EXCEPTION, */\r
- IVOR1Exception,                    /* MACHINE_CHECK_EXCEPTION */\r
- IVOR2Exception,                    /* DATA_STORAGE_EXCEPTION */\r
- IVOR3Exception,                    /* INSTRUCTION_STORAGE_EXCEPTION */\r
- dummy,                             /* EXTERNAL_INTERRUPT */\r
-                                    /* This is the place where the "normal" interrupts will hit the CPU... */\r
- IVOR5Exception,                    /* ALIGNMENT_EXCEPTION */\r
- IVOR6Exception,                    /* PROGRAM_EXCEPTION */\r
- IVOR7Exception,                    /* FLOATING_POINT_EXCEPTION */\r
- IVOR8Exception,                    /* SYSTEM_CALL_EXCEPTION */\r
- dummy,                             /* AUX_EXCEPTION Not implemented in MPC5516. */\r
- dummy,                             /* DECREMENTER_EXCEPTION */\r
- IVOR11Exception,                   /* FIXED_INTERVAL_TIMER_EXCEPTION */\r
- IVOR12Exception,                   /* WATCHDOG_TIMER_EXCEPTION */\r
- IVOR13Exception,                   /* DATA_TLB_EXCEPTION */\r
- IVOR14Exception,                   /* INSTRUCTION_TLB_EXCEPTION */\r
- IVOR15Exception,                   /* DEBUG_EXCEPTION */\r
-};\r
-\r
-void dummy (void) {\r
-   while (1){\r
-          /* TODO: Rename and check for what spurious interrupt have happend */\r
-   };\r
- }\r
-\r
-#endif\r
-\r
index 92b7368dc3cd54a9903051fbe27973b3d804230c..e1ed00c73c52694e6d4980468c872d55b172c5a4 100644 (file)
@@ -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 ef9c3e109f94d0aec6214a678d4953fb89520453..7d0a87373436699d4c38f5eeaaaf4671084b9e47 100644 (file)
@@ -51,8 +51,18 @@ typedef TaskStateType *TaskStateRefType;
 #define INVALID_OSAPPLICATION (-1)\r
 \r
 /* TODO, I have no idea what this should be*/\r
+#if (OS_SC3==STD_ON) || (OS_SC4==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
@@ -221,6 +231,7 @@ static inline void ResumeOSInterrupts( void ) {
 /*\r
  * Class 2,3 and 4 API\r
  */\r
+#if (OS_SC3==STD_ON) || (OS_SC4==STD_ON)\r
 ApplicationType GetApplicationID( void );\r
 AccessType     CheckISRMemoryAccess(   ISRType ISRID,\r
                                                                        MemoryStartAddressType Address,\r
@@ -230,8 +241,14 @@ AccessType         CheckTaskMemoryAccess(  TaskType TaskID,
                                                                        MemoryStartAddressType Address,\r
                                                                        MemorySizeType Size );\r
 \r
+ObjectAccessType CheckObjectAccess( ApplicationType ApplID, ObjectTypeType ObjectType, uintptr_t objPtr);\r
+ApplicationType CheckObjectOwnership(  ObjectTypeType ObjectType, uintptr_t objPtr );\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 ecee85bd75811f65de68f783658d9cc61e47c846..89afd6e2fe86c54d811db326c80db2b9103a99c2 100644 (file)
@@ -28,7 +28,52 @@ extern uint8_t Irq_IsrTypeTable[];
 #define ISR_TYPE_1                     0\r
 #define ISR_TYPE_2                     1\r
 \r
-typedef _Bool IsrType;\r
+typedef struct {\r
+       char                    name[16];\r
+       uint8_t                 prio;\r
+       uint8_t                 core;\r
+       int                             vector;                                 // ISR\r
+       void                    (*entry)();\r
+} OsIsrType_CONST;\r
+\r
+#define IRQ_DECL_ISR1(_vector, _core, _prio, _entry  ) \\r
+               const OsIsrType_CONST IrqVector ## _ ## _vector = {     \\r
+               .name = "",                                             \\r
+               .prio = (_prio),                                        \\r
+               .vector = (_vector),                            \\r
+               .entry = (_entry),                                      \\r
+               .core = (_core)                                         \\r
+       }\r
+\r
+\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
+#define IRQ_DECL_ISR2(_name, _vector, _core, _prio, _entry, _resource_mask, _timing_prot)\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
+\r
+\r
+// typedef _Bool IsrType;\r
 \r
 /**\r
  * Init the interrupt controller\r
@@ -59,6 +104,8 @@ void *Irq_Entry( uint8_t irq_nr, void *stack );
  */\r
 void *Irq_Entry( void *stack_p );\r
 #endif\r
+\r
+ISRType Irq_Attach( const OsIsrType_CONST *isrPtr );\r
 /**\r
  * Attach an ISR type 1 to the interrupt controller.\r
  *\r
@@ -101,7 +148,7 @@ void Irq_SetPriority( Cpu_t cpu,  IrqType vector, uint8_t prio );
  * @param vector\r
  * @param type\r
  */\r
-static inline void Irq_SetIsrType( IrqType vector, IsrType type ) {\r
+static inline void Irq_SetIsrType( IrqType vector, int8_t type ) {\r
        Irq_IsrTypeTable[vector] = type;\r
 }\r
 \r
@@ -111,7 +158,7 @@ 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
 \r
index 10680126946d268b92a5c288247974fe03754286..a9c9ab2ddc1f32cc6b38311be7674477b0298680 100644 (file)
@@ -65,15 +65,14 @@ trusted_func_t oil_trusted_func_list[SERVICE_CNT];
 #endif\r
 \r
 /*-----------------------------------------------------------------*/\r
+#if 0\r
 #if (  OS_SC3 == STD_ON) || (  OS_SC4==STD_ON)\r
-int Os_CfgGetApplCnt(void) {\r
-       return APPLICATION_CNT;\r
-}\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
@@ -154,7 +153,7 @@ uint32 Os_CfgGetMessageCnt(void ) {
 \r
 #if (  OS_SC3 == STD_ON) || (  OS_SC4 == STD_ON)\r
 uint32 Os_CfgGetServiceCnt( void ) {\r
-       return SERVICE_CNT;\r
+       return OS_SERVICE_CNT;\r
 }\r
 #endif\r
 \r
index 9b395c46f6f478c27d8a383cecd6b6c350b1e5f9..c63ff6d6552246484e902bea334b3cdab785a673 100644 (file)
 \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_APP_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
+\r
+#define APP_ALARM_LIST(_id,...)                const uint8_t Os_AppAlarmList ## _id[] = {__VA_ARGS__}\r
+#define APP_COUNTER(_id,...)           const uint8_t Os_AppCounterList ## _id = { __VA_ARGS__ }\r
+#define APP_ISR_LIST(_id,...)\r
+#define APP_RESOURCE_LIST(_id,...)\r
+#define APP_SCHTBL_LIST(_id,...)\r
+#define APP_TASK_LIST(_id,...)         const uint8_t Os_AppTaskList ## _id = { __VA_ARGS__ };\r
+\r
+#define APP_TASK_NAME(_id)                     (Os_AppTaskList ## _id)\r
+#define APP_ALARM_NAME(_id)                    (Os_AppAlarmList ## _id)\r
+#define APP_COUNTER_NAME(_id)          (Os_AppCounterList ## _id)\r
+\r
+\r
+#define GEN_APPLICATION(       _id,_name,_trusted,_startuphook,_shutdownhook, _errorhook, \\r
+                                               _alarm_list,_counter_list,_isr_list,_resource_list, \\r
+                                               _schtbl_list,_task_list, _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
+       .alarmRef  = _alarm_list,                                       \\r
+       .counterRef  = _counter_list,                           \\r
+       .isrRef = _isr_list,                                            \\r
+       .resourceRef  = _resource_list,                         \\r
+       .schtblRef  = _schtbl_list,                     \\r
+       .taskRef  = _task_list,                                         \\r
+       .restartTaskId = _restart_task                          \\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
@@ -369,9 +382,15 @@ struct OsHooks os_conf_global_hooks = { \
 \r
 #endif\r
 \r
+#if 0\r
+typedef union {\r
+               void (*isr1)(void);     /* ISR1 is just a function call */\r
+\r
+} ;\r
+#endif\r
 \r
 #define GEN_IRQ_VECTOR_TABLE_HEAD      \\r
-                void * Irq_VectorTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] =\r
+                uintptr_t Irq_VectorTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] =\r
 \r
 #define GEN_IRQ_ISR_TYPE_TABLE_HEAD \\r
                 uint8_t Irq_IsrTypeTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS]  =\r
index 9e82c2ba356839ed49b3ebe2be5e010256203381..1bf66bf598dc43827036c41802cdcb9c0514454a 100644 (file)
@@ -34,7 +34,7 @@ cflags-y              += -MMD
 # Warnings\r
 cflags-y          += -Wall\r
 #cflags-y          += -Winline # warn if inline failed\r
-#cflags-y          += -pedantic\r
+cflags-y          += -pedantic\r
 \r
 # Conformance\r
 cflags-y          += -fno-strict-aliasing\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..ae5cc30a3f6f0cfa202ea7f238c44637ff553d81 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_APP_CNT!=0\r
+const OsAppVarType Os_AppVar[OS_APP_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_SC3==STD_ON)||(OS_SC4_STD_ON))\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
+\r
+/**\r
+ * This service determines if the OS-Applications, given by ApplID, is allowed to\r
+ * use the IDs of a Task, ISR, Resource, Counter, Alarm or Schedule Table in API calls.\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
+                                                                       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
+       return ACCESS;\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
+                                                                       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 INVALID_OSAPPLICATION;\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 Application, RestartType RestartOption ) {\r
+\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
+\r
+       /* @req OS497 */\r
+       if( Os_AppVar[AppId].state != APPLICATION_RESTARTING ) {\r
+               return E_OS_STATE;\r
+       }\r
+\r
+       /* @req OS498 */\r
+       Os_AppVar[AppId].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 AppId                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 appId,  ApplicationStateRefType value ) {\r
+       if(appId > OS_APP_CNT ) {\r
+               return E_OS_ID;\r
+       }\r
+\r
+       *value = Os_AppVar[AppId].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
+#endif\r
index e7ad155bd2cb05e4848b94ba877b8d103b1eeb75..ee8c1605a21bc10cc4b0515626cd17043d767920 100644 (file)
@@ -30,9 +30,9 @@
 void  asm_foo(void) {\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(SYS_CURR_PCB_P,         offsetof(Os_SysType, curr_pcb));\r
+       DECLARE(SYS_INT_NEST_CNT, offsetof(Os_SysType, int_nest_cnt));\r
+       DECLARE(SYS_INT_STACK, offsetof(Os_SysType, int_stack));\r
 }\r
 \r
 \r
index 16ba4191a26bdbd1b96568b1945385dd27de5daf..43b2b3949010222bc4a020c87dd9e5d617dd8aa9 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
index e7f07038faad28ca4a834779584d443590aa52e3..78c924ab4b85b71db949dfef90240f8e120ee44d 100644 (file)
@@ -46,7 +46,7 @@ StatusType WaitEvent( EventMaskType Mask ) {
 \r
        OS_DEBUG(D_EVENT,"# WaitEvent %s\n",Os_TaskGetCurrent()->name);\r
 \r
-       if( os_sys.int_nest_cnt != 0 ) {\r
+       if( Os_Sys.int_nest_cnt != 0 ) {\r
                rv =  E_OS_CALLEVEL;\r
                goto err;\r
        }\r
@@ -148,7 +148,7 @@ StatusType SetEvent( TaskType TaskID, EventMaskType Mask ) {
 \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
+                       if( (Os_Sys.int_nest_cnt == 0) &&\r
                                (currPcbPtr->scheduling == FULL) &&\r
                                (dest_pcb->prio > currPcbPtr->prio) &&\r
                                (Os_SchedulerResourceIsFree()) )\r
@@ -216,7 +216,7 @@ StatusType ClearEvent( EventMaskType Mask) {
     StatusType rv = E_OK;\r
        OsPcbType *pcb;\r
 \r
-       if( os_sys.int_nest_cnt != 0 ) {\r
+       if( Os_Sys.int_nest_cnt != 0 ) {\r
                rv =  E_OS_CALLEVEL;\r
                goto err;\r
        }\r
index 6d91ad6accccb9f27d738380a16a838a8e405ed2..e104b99a32445e23f89c3679a24d4fe5a8be411b 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,10 @@ typedef struct OsAlarm {
        /* Reference to counter */\r
        struct OsCounter *counter;\r
 \r
+#if defined(SC3) || defined(SC4)\r
+       uint32 accessingAppMask;\r
+#endif\r
+\r
        CounterType counter_id;\r
        /* cycle, 0 = no cycle */\r
        uint32 alarmtime;\r
index 0ec52e06fbde64482f703876ad37a4b6562cfdd4..7dbdb0045720b8d462d63c77c0ad31afc0905e5d 100644 (file)
@@ -2,6 +2,56 @@
 #ifndef APPLICATION_H_\r
 #define APPLICATION_H_\r
 \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_SC3 == STD_ON) || ( OS_SC4 == STD_ON )\r
 \r
 /* STD container : OsApplicationHooks\r
@@ -36,7 +86,7 @@ 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
@@ -48,30 +98,32 @@ typedef struct OsApplication {
 \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
 \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
+       /* Ref is ~0U terminated */\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
 \r
-} OsRomApplicationType;\r
+       int     restartTaskId;\r
+} OsAppConstType;\r
 \r
 #endif /*  ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) */\r
 \r
index d8d23ed9d10b52c59c3ba977476077a30292db8e..5312ba0b492669dd4185abcfea448ce14e917b58 100644 (file)
@@ -46,7 +46,9 @@ 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 defined(SC3) || defined(SC4)\r
+       uint32 accessingAppMask;\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..5cb0a36a41f147daca3fa5e2751359d018dec81e 100644 (file)
@@ -28,24 +28,17 @@ struct OsRomApplication;
 #endif\r
 \r
 #if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON )\r
-int Os_CfgGetApplCnt(void);\r
+extern const OsAppConstType Os_AppConst[OS_APP_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 36ff57db7da53c20a909b2465a3388be2e662a4f..8aac99fa5c554b1feee82a288ecef36f4bb6e9bb 100644 (file)
  */\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
 \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.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
        }\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.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
        }\r
 \r
 /*\r
  */\r
 \r
 static inline OsTaskidType get_curr_pid( void ) {\r
-       return os_sys.curr_pcb->pid;\r
+       return Os_Sys.curr_pcb->pid;\r
 }\r
 \r
 static inline OsPcbType *get_curr_pcb( void ) {\r
-       return os_sys.curr_pcb;\r
+       return Os_Sys.curr_pcb;\r
 }\r
 \r
 static inline void set_curr_pcb( OsPcbType *pcb ) {\r
-       os_sys.curr_pcb = pcb;\r
+       Os_Sys.curr_pcb = pcb;\r
 }\r
 \r
 static inline _Bool is_idle_task( OsPcbType *pcb ){\r
@@ -165,23 +165,13 @@ static inline _Bool is_idle_task( OsPcbType *pcb ){
 }\r
 \r
 static inline OsTaskidType get_curr_prio( void ){\r
-       return os_sys.curr_pcb->prio;\r
+       return Os_Sys.curr_pcb->prio;\r
 }\r
 \r
 static inline TickType get_os_tick( void ) {\r
-       return os_sys.tick;\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
-}\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
 }\r
@@ -247,19 +237,19 @@ static inline _Bool Os_TaskOccupiesResources( OsPcbType *pcb ) {
 \r
 /*\r
 static inline void Os_GetSchedulerResource() {\r
-       os_sys.scheduler_lock = 1;\r
+       Os_Sys.scheduler_lock = 1;\r
 }\r
 \r
 static inline void Os_ReleaseSchedulerResource() {\r
-       os_sys.scheduler_lock = 0;\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
+       return (Os_Sys.resScheduler.owner != NO_TASK_OWNER );\r
 #else\r
-       return (os_sys.scheduler_lock == 1);\r
+       return (Os_Sys.scheduler_lock == 1);\r
 #endif\r
 }\r
 */\r
@@ -267,9 +257,9 @@ static inline _Bool Os_SchedulerResourceIsOccupied() {
 \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
@@ -326,7 +316,7 @@ static inline void Os_StackPerformCheck( OsPcbType *pcbPtr ) {
                        /** @req OS068 */\r
                        ShutdownOS(E_OS_STACKFAULT);\r
 #else\r
-#error SC3 or SC4 not supported. Protection hook should be called here\r
+#warning SC3 or SC4 not supported. Protection hook should be called here\r
 #endif\r
                }\r
 #endif\r
index 788cd0ec05af1aaddc0fd0223e8843d97e477d33..996f330673395d193392eb4abceb5800b9a9e4cf 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 accessingAppMask;\r
 #endif\r
        // What tasks may access this resource. A resource may be be shared\r
        // several tasks.\r
index 892afbd49fe22a03e2187de9a78a3ef169cd62a3..25f9cea6a8957822e19c9d330d24fb1cef1baf3b 100644 (file)
@@ -63,7 +63,7 @@ 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
 \r
@@ -130,7 +130,6 @@ typedef struct OsPcb {
        int                     autostart:1;                    // TASK\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
@@ -178,6 +177,15 @@ typedef struct OsPcb {
        TAILQ_ENTRY(OsPcb) ready_list;          // TASK\r
 } OsPcbType;\r
 \r
+/*-----------------------------------------------------------------*/\r
+\r
+\r
+typedef struct {\r
+       int a;\r
+       int b;\r
+} OsIsrType_VAR;\r
+\r
+\r
 /*-----------------------------------------------------------------*/\r
 \r
 typedef struct OsRomPcb {\r
@@ -189,7 +197,9 @@ typedef struct OsRomPcb {
        uint8                   autostart;\r
        OsStackType     stack;\r
        int                             vector;                                 // ISR\r
-       ApplicationType application_id;\r
+#if defined(SC3) || defined(SC4)\r
+       uint32 accessingAppMask;\r
+#endif\r
        char                    name[16];\r
        enum OsTaskSchedule scheduling;\r
        uint32_t                resourceAccess;\r
index 3d5aa1be91e035990e8f3f58a465de817fd9b131..372fae5829a048df819c685daff66f4d76f6d8a6 100644 (file)
@@ -150,6 +150,10 @@ typedef struct OsSchTbl {
        /** @req OS413 */\r
        _Bool repeating;\r
 \r
+#if defined(SC3) || defined(SC4)\r
+       uint32 accessingAppMask;\r
+#endif\r
+\r
        // pointer to this tables counter\r
        // OsScheduleTableCounterRef\r
        /** @req OS409 */\r
index 4ac360c40d795687d86dc180123dca5f8486d525..48fba40beab6e91b0a0487aab580cf72eadb22c2 100644 (file)
@@ -28,7 +28,10 @@ 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
@@ -58,9 +61,13 @@ typedef struct sys_s {
        /* Current Application mode */\r
        AppModeType appMode;\r
 \r
-//     uint32_t flags;\r
+#if (OS_SC3==STD_ON) || (OS_SC4==STD_ON)\r
+       ApplicationStateType currAppState;\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
@@ -70,17 +77,17 @@ typedef struct sys_s {
 \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
+       return Os_Sys.curr_pcb;\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..f08779d7ce924853abb93050b04cee642a061e11 100644 (file)
@@ -26,7 +26,7 @@ static inline void os_pcb_print_rq( void ) {
        OsPcbType *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
@@ -45,7 +45,7 @@ static inline void Os_TaskRunningToReady( OsPcbType *pcb ) {
 static inline void Os_TaskMakeReady( OsPcbType *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
@@ -56,7 +56,7 @@ static inline void Os_TaskMakeWaiting( OsPcbType *pcb )
        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
@@ -65,7 +65,7 @@ static inline void Os_TaskMakeSuspended( OsPcbType *pcb )
        {\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
index d09765f4d34d64195acbccfef5f798e4f5605019..abca8589561c2235998bb0f257840d5fa2734e23 100644 (file)
@@ -26,7 +26,7 @@ extern void Os_CfgGetInterruptStackInfo( OsStackType *stack );
 extern uint32_t McuE_GetSystemClock( void );
 extern OsTickType OsTickFreq;
 
-sys_t os_sys;
+Os_SysType Os_Sys;
 
 Os_IntCounterType Os_IntDisableAllCnt;
 Os_IntCounterType Os_IntSuspendAllCnt;
@@ -58,7 +58,7 @@ static void os_pcb_rom_copy( OsPcbType *pcb, const OsRomPcbType *r_pcb ) {
        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);
+//     pcb->accessingApp = Os_CfgGetApplObj(r_pcb->application_id);
 #endif
        pcb->entry = r_pcb->entry;
        pcb->proc_type = r_pcb->proc_type;
@@ -92,19 +92,19 @@ void InitOS( void ) {
        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 = pcb_list;
+       TAILQ_INIT(& Os_Sys.ready_head);
+       TAILQ_INIT(& Os_Sys.pcb_head);
 
        // Calc interrupt stack
        Os_CfgGetInterruptStackInfo(&int_stack);
        // TODO: 16 is arch dependent
-       os_sys.int_stack = (void *)((size_t)int_stack.top + (size_t)int_stack.size - 16);
+       Os_Sys.int_stack = (void *)((size_t)int_stack.top + (size_t)int_stack.size - 16);
 
        // Init counter.. with alarms and schedule tables
 #if OS_COUNTER_CNT!=0
@@ -152,9 +152,9 @@ 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();
        }
 
        /* Alarm autostart */
@@ -178,7 +178,7 @@ static void os_start( void ) {
                OsPcbType *iterPcbPtr;
                OsPriorityType topPrio = -1;
 
-               TAILQ_FOREACH(iterPcbPtr,& os_sys.pcb_head,pcb_list) {
+               TAILQ_FOREACH(iterPcbPtr,& Os_Sys.pcb_head,pcb_list) {
                        if(     iterPcbPtr->autostart ) {
                                if( iterPcbPtr->prio > topPrio ) {
                                        tmp_pcb = iterPcbPtr;
@@ -190,8 +190,8 @@ static void os_start( void ) {
 
        // 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.curr_pcb manually is not the way to go..
+               Os_Sys.curr_pcb = tmp_pcb;
 
                // register this auto-start activation
                assert(tmp_pcb->activations < tmp_pcb->activationLimit);
@@ -243,7 +243,7 @@ void StartOS(AppModeType Mode) {
                noooo();
        }
 
-       os_sys.appMode = Mode;
+       Os_Sys.appMode = Mode;
 
        Os_CfgValidate();
 
@@ -262,8 +262,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 e43e6cc9b9478bcb1659250990253776b04a8501..a48f71b951dbb52fa68e752f1591984c495dde32 100644 (file)
@@ -77,7 +77,7 @@ 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->vector = -1;
        pcb->prio = prio;
        /* TODO: map to interrupt controller priority */
        assert(prio<=OS_TASK_PRIORITY_MAX);
@@ -89,6 +89,60 @@ TaskType Os_Arc_CreateIsr( void (*entry)(void ), uint8_t prio, const char *name
        return Os_AddTask(pcb);
 }
 
+ISRType Os_AddIsr( const OsIsrType_CONST * restrict isrPtr ) {
+       ISRType iid;
+
+       iid = Os_Sys.isrCnt++;
+       return iid;
+}
+
+/*
+ * 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
+ *
+ */
+
+
+#if 0
+void apa( void ) {
+       ISRType iid;
+       static const OsIsrType_CONST isr = {
+                       .name = "MyIsr",
+                       .prio = 12,
+                       .vector = 15,
+                       .entry = MyIsr
+       };
+       iid = Irq_Attach(&isr, ISR_TYPE2, NULL );
+}
+#endif
+
+
 /**
  * Before we have proper editor for ISR2 use this function to add resources
  * to an ISR2
@@ -123,12 +177,12 @@ void TailChaining(void *stack)
 
        Os_StackPerformCheck(new_pcb);
 
-       if(     (new_pcb == os_sys.curr_pcb) ||
-                       (os_sys.curr_pcb->scheduling == NON) ||
+       if(     (new_pcb == Os_Sys.curr_pcb) ||
+                       (Os_Sys.curr_pcb->scheduling == NON) ||
                        !Os_SchedulerResourceIsFree() )
        {
                /* Just bring the preempted task back to running */
-               Os_TaskSwapContextTo(NULL,os_sys.curr_pcb);
+               Os_TaskSwapContextTo(NULL,Os_Sys.curr_pcb);
        } else {
                OS_DEBUG(D_TASK,"Found candidate %s\n",new_pcb->name);
                Os_TaskSwapContextTo(NULL,new_pcb);
@@ -139,7 +193,7 @@ void Os_Isr_cm3( void *isr_p ) {
 
        struct OsPcb *isrPtr;
 
-       os_sys.int_nest_cnt++;
+       Os_Sys.int_nest_cnt++;
 
        /* Grab the ISR "pcb" */
        isrPtr = (struct OsPcb *)isr_p;
@@ -171,7 +225,7 @@ void Os_Isr_cm3( void *isr_p ) {
 
        Irq_EOI();
 
-       --os_sys.int_nest_cnt;
+       --Os_Sys.int_nest_cnt;
 
        /* Scheduling is done in PendSV handler for ARM CM3 */
        *((uint32_t volatile *)0xE000ED04) = 0x10000000; // PendSV
@@ -189,7 +243,7 @@ void *Os_Isr( void *stack, void *isr_p ) {
        struct OsPcb *pPtr = NULL;
 
        /* Check if we interrupted a task or ISR */
-       if( os_sys.int_nest_cnt == 0 ) {
+       if( Os_Sys.int_nest_cnt == 0 ) {
                /* We interrupted a task */
                POSTTASKHOOK();
 
@@ -204,7 +258,7 @@ void *Os_Isr( void *stack, void *isr_p ) {
                /* We interrupted an ISR */
        }
 
-       os_sys.int_nest_cnt++;
+       Os_Sys.int_nest_cnt++;
 
        /* Grab the ISR "pcb" */
        isrPtr = (struct OsPcb *)isr_p;
@@ -242,24 +296,24 @@ void *Os_Isr( void *stack, void *isr_p ) {
 
        Irq_EOI();
 
-       --os_sys.int_nest_cnt;
+       --Os_Sys.int_nest_cnt;
 
 #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) ) {
+       if( (Os_Sys.int_nest_cnt == 0) ) {
                OsPcbType *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.curr_pcb) ||
+                               (Os_Sys.curr_pcb->scheduling == NON) ||
                                !Os_SchedulerResourceIsFree() )
                {
                        /* Just bring the preempted task back to running */
-                       os_sys.curr_pcb->state = ST_RUNNING;
+                       Os_Sys.curr_pcb->state = ST_RUNNING;
                        PRETASKHOOK();
                } else {
                        OS_DEBUG(D_TASK,"Found candidate %s\n",new_pcb->name);
index 43c273e9ba8868ac363df93788c13acb201f0544..b6fb42207796c08d7f12af58a2a58a3dab6157eb 100644 (file)
@@ -35,8 +35,8 @@ void  oil_foo(void) {
 #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(SYS_CURR_PCB_P,         offsetof(Os_SysType, curr_pcb));\r
+       DECLARE(SYS_INT_NEST_CNT,       offsetof(Os_SysType, int_nest_cnt));\r
+       DECLARE(SYS_INT_STACK,          offsetof(Os_SysType, int_stack));\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..31a85f35fb6b3072899503a4627b57c2b1133b1a 100644 (file)
@@ -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.int_nest_cnt = level;\r
 \r
        return;\r
 }\r
index d99e431bcef9505869458931d983c26b244e3224..2756b6b4e9ddfbb4c5d714eb001cb35720b541c4 100644 (file)
@@ -170,7 +170,7 @@ 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 & (1<< ResID)) == 0 ) {\r
@@ -220,7 +220,7 @@ StatusType ReleaseResource( ResourceType ResID) {
 \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 & (1<< ResID)) == 0 ) {\r
@@ -249,7 +249,7 @@ StatusType ReleaseResource( ResourceType ResID) {
 \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
+                (Os_Sys.int_nest_cnt == 0) &&\r
                 (Os_SchedulerResourceIsFree()) ) {\r
 \r
                OsPcbType* top_pcb = Os_TaskGetTop();\r
@@ -306,10 +306,10 @@ void Os_ResourceInit( void ) {
 \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
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 f2696f5080b304fa127c9daf6dd6b063becbfd12..aab90b5c1ba4c81428f329d4aae216918c2ef058 100644 (file)
@@ -202,7 +202,7 @@ OsPcbType *os_find_task( TaskType tid ) {
        OsPcbType *i_pcb;\r
 \r
        /* TODO: Implement this as an array */\r
-       TAILQ_FOREACH(i_pcb,& os_sys.pcb_head,pcb_list) {\r
+       TAILQ_FOREACH(i_pcb,& Os_Sys.pcb_head,pcb_list) {\r
                if(i_pcb->pid == tid ) {\r
                        return i_pcb;\r
                }\r
@@ -220,10 +220,11 @@ TaskType Os_AddTask( OsPcbType *pcb ) {
 \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
@@ -247,7 +248,7 @@ OsPcbType *Os_TaskGetTop( void ){
 \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
@@ -318,7 +319,7 @@ void Os_Dispatch( uint32_t op ) {
        OsPcbType *pcbPtr;\r
        OsPcbType *currPcbPtr = Os_TaskGetCurrent();\r
 \r
-       assert(os_sys.int_nest_cnt == 0);\r
+       assert(Os_Sys.int_nest_cnt == 0);\r
        assert(Os_SchedulerResourceIsFree());\r
 \r
        /* When calling post hook we must still be in ST_RUNNING */\r
@@ -333,7 +334,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 +347,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 +358,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 +383,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
@@ -399,7 +400,7 @@ void Os_Dispatch( uint32_t op ) {
                        /** @req OS068 */\r
                        ShutdownOS(E_OS_STACKFAULT);\r
 #else\r
-#error SC3 or SC4 not supported. Protection hook should be called here\r
+#warning SC3 or SC4 not supported. Protection hook should be called here\r
 #endif\r
                }\r
 #endif\r
@@ -529,9 +530,9 @@ 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.int_nest_cnt == 0 ) {\r
+               if( Os_Sys.curr_pcb->state & ST_RUNNING ) {\r
+                       *TaskID = Os_Sys.curr_pcb->pid;\r
                } else {\r
                        /* This is not a real error since this could\r
                         * be the case when called from ErrorHook */
@@ -545,7 +546,7 @@ StatusType GetTaskID( TaskRefType TaskID ) {
 ISRType GetISRID( void ) {\r
 \r
        /** @req OS264 */\r
-       if(os_sys.int_nest_cnt == 0 ) {\r
+       if(Os_Sys.int_nest_cnt == 0 ) {\r
                return INVALID_ISR;\r
        }\r
 \r
@@ -603,6 +604,22 @@ StatusType ActivateTask( TaskType TaskID ) {
 #endif\r
 \r
        Irq_Save(msr);\r
+#if (OS_SC3==STD_ON) || (OS_SC4==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
+\r
+       if( Os_TaskConst[TaskID].appOwnerId != Os_Sys.currAppId ) {\r
+               /* We are activating a task in another application */\r
+               if( Os_AppVar[Os_Sys.currAppId].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
@@ -629,7 +646,7 @@ StatusType ActivateTask( TaskType TaskID ) {
 \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
+               (Os_Sys.int_nest_cnt == 0) &&\r
                (pcb->prio > Os_TaskGetCurrent()->prio) &&\r
                (Os_SchedulerResourceIsFree()))\r
        {\r
@@ -680,7 +697,7 @@ StatusType TerminateTask( void ) {
 #if (OS_STATUS_EXTENDED == STD_ON )\r
 \r
 \r
-       if( os_sys.int_nest_cnt != 0 ) {\r
+       if( Os_Sys.int_nest_cnt != 0 ) {\r
                rv =  E_OS_CALLEVEL;\r
                goto err;\r
        }\r
@@ -722,7 +739,7 @@ StatusType ChainTask( TaskType TaskId ) {
        /* extended */\r
        TASK_CHECK_ID(TaskId);\r
 \r
-       if( os_sys.int_nest_cnt != 0 ) {\r
+       if( Os_Sys.int_nest_cnt != 0 ) {\r
                /* extended */\r
                rv = E_OS_CALLEVEL;\r
                goto err;\r
@@ -770,7 +787,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
@@ -799,7 +816,7 @@ StatusType Schedule( void ) {
        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.int_nest_cnt != 0 ) {\r
                rv =  E_OS_CALLEVEL;\r
                goto err;\r
        }\r