From 4040e90a7852d0c9cc330e761836aee8938e268f Mon Sep 17 00:00:00 2001 From: mahi Date: Wed, 3 Feb 2010 20:37:18 +0100 Subject: [PATCH] Again, loads of refactoring and removing and adding files. Added requirement tracking and have about 15 left. example/simple only one compiling --- arch/arm/arm_cm3/drivers/Adc.c | 24 +- arch/arm/arm_cm3/drivers/Pwm.c | 10 +- arch/arm/arm_cm3/kernel/Frt.c | 6 +- arch/arm/arm_cm3/kernel/arch.c | 10 +- arch/arm/arm_cm3/kernel/arch_krn.sx | 14 +- arch/arm/arm_cm3/kernel/{int_ctrl.c => irq.c} | 19 +- .../arm/arm_cm3/kernel/{irq.h => irq_types.h} | 0 arch/ppc/mpc55xx/drivers/Adc.c | 20 +- arch/ppc/mpc55xx/drivers/Can.c | 20 +- arch/ppc/mpc55xx/drivers/Frt.c | 14 +- arch/ppc/mpc55xx/drivers/Gpt.c | 4 +- arch/ppc/mpc55xx/drivers/Lin.c | 4 +- arch/ppc/mpc55xx/drivers/Mcu.c | 8 +- arch/ppc/mpc55xx/drivers/Mcu_Exceptions.sx | 4 +- arch/ppc/mpc55xx/drivers/Pwm.c | 4 +- arch/ppc/mpc55xx/drivers/Spi.c | 4 +- arch/ppc/mpc55xx/kernel/arch.c | 104 +- arch/ppc/mpc55xx/kernel/arch_krn.sx | 16 +- arch/ppc/mpc55xx/kernel/{int_ctrl.c => irq.c} | 38 +- .../ppc/mpc55xx/kernel/{irq.h => irq_types.h} | 15 - common/newlib_port.c | 2 +- examples/blinker_node/Hooks.c | 2 +- examples/pwm_node/Hooks.c | 2 +- examples/pwm_node2/Hooks.c | 2 +- examples/pwm_node2/config/Os_Cfg.c | 14 +- examples/simple/config/Os_Cfg.c | 4 +- examples/simple/config/Os_Cfg.h | 2 +- examples/simple/simple_main.c | 7 +- examples/switch_node/Hooks.c | 2 +- examples/switch_node/config/Os_Cfg.c | 14 +- examples/tiny/tiny.c | 6 +- include/Mcu.h | 8 +- include/Os.h | 272 +-- include/Std_Types.h | 26 +- include/Trace.h | 5 - include/arc.h | 59 +- include/{int_ctrl.h => irq.h} | 28 +- include/os_config_funcs.h | 47 +- include/os_config_macros.h | 77 +- include/ppc/Cpu.h | 9 +- include/xtoa.h | 14 - makefile | 6 +- readme.txt | 36 + scripts/cc_gcc.mk | 3 +- scripts/guess_cc.sh | 28 +- scripts/req-os.xlsx | Bin 0 -> 33785 bytes scripts/req-os.xml | 2059 +++++++++++++++++ scripts/req.sh | 56 + scripts/req_extract.r | 228 ++ system/EcuM/EcuM.c | 4 +- system/kernel/alarm.c | 30 +- system/kernel/asm_offset.c | 23 +- system/kernel/com_internal.c | 18 +- system/kernel/counter.c | 248 +- system/kernel/create.c | 69 - system/kernel/event.c | 89 +- system/kernel/include/alarm_i.h | 101 +- system/kernel/include/application.h | 79 + system/kernel/include/arch.h | 61 +- system/kernel/include/com_internal.h | 60 + system/kernel/include/counter_i.h | 55 +- system/kernel/include/debug.h | 43 +- system/kernel/include/ext_config.h | 44 +- system/kernel/include/hooks.h | 34 - system/kernel/include/internal.h | 260 ++- system/kernel/include/kernel.h | 336 +-- system/kernel/include/pcb.h | 248 +- system/kernel/include/sched_table_i.h | 134 +- system/kernel/include/swap.h | 16 +- system/kernel/include/sys.h | 24 +- system/kernel/include/task_i.h | 58 +- system/kernel/init.c | 101 +- system/kernel/isr.c | 93 +- system/kernel/kernel_offset.c | 15 +- system/kernel/makefile | 16 +- system/kernel/memory.c | 59 +- system/kernel/os_arctest.c | 22 + system/kernel/resource.c | 66 +- system/kernel/sched_table.c | 442 ++-- system/kernel/swap.c | 147 -- system/kernel/task.c | 595 ++++- system/kernel/task_i.c | 227 -- system/kernel/testsystem/config/Os_Cfg.c | 45 +- system/kernel/testsystem/config/Os_Cfg.h | 15 +- system/kernel/testsystem/makefile | 17 +- system/kernel/testsystem/os_test.h | 6 +- system/kernel/testsystem/test_01_task.c | 203 ++ system/kernel/testsystem/test_02_resource.c | 32 + system/kernel/testsystem/test_03_alarm.c | 35 + system/kernel/testsystem/test_04_stable.c | 35 + .../{stack.c => testsystem/test_05_const.c} | 77 +- .../{pool.c => testsystem/test_06_event.c} | 65 +- system/kernel/testsystem/test_07_misc.c | 104 + system/kernel/testsystem/test_master.c | 36 +- system/kernel/testsystem/test_sup_01.c | 68 +- system/kernel/testsystem/test_sup_02.c | 23 +- system/kernel/testsystem/test_sup_04.c | 6 +- system/kernel/testsystem/test_sup_05.c | 8 +- system/kernel/testsystem/test_sup_irq.c | 26 +- system/kernel/trusted.c | 20 +- tools/t32/load.cmm | 5 +- tools/t32/start.cmm | 5 +- 102 files changed, 5541 insertions(+), 2463 deletions(-) rename arch/arm/arm_cm3/kernel/{int_ctrl.c => irq.c} (89%) rename arch/arm/arm_cm3/kernel/{irq.h => irq_types.h} (100%) rename arch/ppc/mpc55xx/kernel/{int_ctrl.c => irq.c} (94%) rename arch/ppc/mpc55xx/kernel/{irq.h => irq_types.h} (99%) rename include/{int_ctrl.h => irq.h} (76%) create mode 100644 scripts/req-os.xlsx create mode 100644 scripts/req-os.xml create mode 100644 scripts/req.sh create mode 100644 scripts/req_extract.r delete mode 100644 system/kernel/create.c create mode 100644 system/kernel/include/application.h create mode 100644 system/kernel/include/com_internal.h create mode 100644 system/kernel/os_arctest.c delete mode 100644 system/kernel/swap.c delete mode 100644 system/kernel/task_i.c create mode 100644 system/kernel/testsystem/test_01_task.c create mode 100644 system/kernel/testsystem/test_02_resource.c create mode 100644 system/kernel/testsystem/test_03_alarm.c create mode 100644 system/kernel/testsystem/test_04_stable.c rename system/kernel/{stack.c => testsystem/test_05_const.c} (66%) rename system/kernel/{pool.c => testsystem/test_06_event.c} (71%) create mode 100644 system/kernel/testsystem/test_07_misc.c diff --git a/arch/arm/arm_cm3/drivers/Adc.c b/arch/arm/arm_cm3/drivers/Adc.c index f75b34ad..34e20fa0 100644 --- a/arch/arm/arm_cm3/drivers/Adc.c +++ b/arch/arm/arm_cm3/drivers/Adc.c @@ -9,7 +9,7 @@ #include "Det.h" #if defined(USE_KERNEL) #include "Os.h" -#include "int_ctrl.h" +#include "irq.h" #endif @@ -83,8 +83,8 @@ Std_ReturnType Adc_Init (const Adc_ConfigType *ConfigPtr) // Connect interrupt to correct isr TaskType tid; - tid = Os_CreateIsr(Adc_Group0ConversionComplete,6/*prio*/,"DMA1"); - IntCtrl_AttachIsr2(tid,NULL, DMA1_Channel1_IRQn); + tid = Os_Arc_CreateIsr(Adc_Group0ConversionComplete,6/*prio*/,"DMA1"); + Irq_AttachIsr2(tid,NULL, DMA1_Channel1_IRQn); /* Enable DMA1 channel1 */ DMA_Cmd(DMA1_Channel1, ENABLE); @@ -265,25 +265,25 @@ void Adc_ConfigureEQADCInterrupts (void) #if defined(USE_KERNEL) TaskType tid; - tid = Os_CreateIsr(Adc_EQADCError,EQADC_FISR_OVER_PRIORITY,"Adc_Err"); - IntCtrl_AttachIsr2(tid,NULL,EQADC_FISR_OVER); + tid = Os_Arc_CreateIsr(Adc_EQADCError,EQADC_FISR_OVER_PRIORITY,"Adc_Err"); + Irq_AttachIsr2(tid,NULL,EQADC_FISR_OVER); - tid = Os_CreateIsr(Adc_Group0ConversionComplete,EQADC_FIFO0_END_OF_QUEUE_PRIORITY,"Adc_Grp0"); - IntCtrl_AttachIsr2(tid,NULL,EQADC_FISR0_EOQF0); + tid = Os_Arc_CreateIsr(Adc_Group0ConversionComplete,EQADC_FIFO0_END_OF_QUEUE_PRIORITY,"Adc_Grp0"); + Irq_AttachIsr2(tid,NULL,EQADC_FISR0_EOQF0); - tid = Os_CreateIsr(Adc_Group1ConversionComplete,EQADC_FIFO1_END_OF_QUEUE_PRIORITY,"Adc_Grp1"); - IntCtrl_AttachIsr2(tid,NULL,EQADC_FISR1_EOQF1); + tid = Os_Arc_CreateIsr(Adc_Group1ConversionComplete,EQADC_FIFO1_END_OF_QUEUE_PRIORITY,"Adc_Grp1"); + Irq_AttachIsr2(tid,NULL,EQADC_FISR1_EOQF1); #else - IntCtrl_InstallVector (Adc_EQADCError, + Irq_InstallVector (Adc_EQADCError, EQADC_FISR_OVER, EQADC_FISR_OVER_PRIORITY, CPU_Z1); - IntCtrl_InstallVector (Adc_Group0ConversionComplete, + Irq_InstallVector (Adc_Group0ConversionComplete, EQADC_FISR0_EOQF0, EQADC_FIFO0_END_OF_QUEUE_PRIORITY, CPU_Z1); - IntCtrl_InstallVector (Adc_Group1ConversionComplete, + Irq_InstallVector (Adc_Group1ConversionComplete, EQADC_FISR1_EOQF1, EQADC_FIFO1_END_OF_QUEUE_PRIORITY, CPU_Z1); diff --git a/arch/arm/arm_cm3/drivers/Pwm.c b/arch/arm/arm_cm3/drivers/Pwm.c index e6388c26..3c5e2f97 100644 --- a/arch/arm/arm_cm3/drivers/Pwm.c +++ b/arch/arm/arm_cm3/drivers/Pwm.c @@ -147,11 +147,11 @@ void Pwm_Init( const Pwm_ConfigType *ConfigPtr ) #if PWM_NOTIFICATION_SUPPORTED==ON // Create a task for our interrupt service routine. - TaskType tid = Os_CreateIsr(Pwm_Isr, 6 /*prio*/, "PwmIsr"); - IntCtrl_AttachIsr2(tid,NULL, TIM1_CC_IRQn); - IntCtrl_AttachIsr2(tid,NULL, TIM2_IRQn); - IntCtrl_AttachIsr2(tid,NULL, TIM3_IRQn); - IntCtrl_AttachIsr2(tid,NULL, TIM4_IRQn); + TaskType tid = Os_Arc_CreateIsr(Pwm_Isr, 6 /*prio*/, "PwmIsr"); + Irq_AttachIsr2(tid,NULL, TIM1_CC_IRQn); + Irq_AttachIsr2(tid,NULL, TIM2_IRQn); + Irq_AttachIsr2(tid,NULL, TIM3_IRQn); + Irq_AttachIsr2(tid,NULL, TIM4_IRQn); #endif Pwm_ModuleState = PWM_STATE_INITIALIZED; diff --git a/arch/arm/arm_cm3/kernel/Frt.c b/arch/arm/arm_cm3/kernel/Frt.c index 867b074a..2bb30400 100644 --- a/arch/arm/arm_cm3/kernel/Frt.c +++ b/arch/arm/arm_cm3/kernel/Frt.c @@ -19,15 +19,15 @@ #include "internal.h" #include "stm32f10x.h" #include "core_cm3.h" -#include "int_ctrl.h" +#include "irq.h" /** * Init of free running timer. */ void Frt_Init( void ) { TaskType tid; - tid = Os_CreateIsr(OsTick,6/*prio*/,"OsTick"); - IntCtrl_AttachIsr2(tid,NULL, SysTick_IRQn); + tid = Os_Arc_CreateIsr(OsTick,6/*prio*/,"OsTick"); + Irq_AttachIsr2(tid,NULL, SysTick_IRQn); } /** diff --git a/arch/arm/arm_cm3/kernel/arch.c b/arch/arm/arm_cm3/kernel/arch.c index d08ccede..fd8a8e34 100644 --- a/arch/arm/arm_cm3/kernel/arch.c +++ b/arch/arm/arm_cm3/kernel/arch.c @@ -45,26 +45,26 @@ void os_arch_first_call( void ) os_sys.curr_pcb->entry(); } -void *os_arch_get_stackptr( void ) { +void *Os_ArchGetStackPtr( void ) { return (void *)__get_MSP(); } -unsigned int os_arch_get_sc_size( void ) { +unsigned int Os_ArchGetScSize( void ) { return SC_SIZE; } -void os_arch_setup_context( pcb_t *pcb ) { +void os_arch_setup_context( OsPcbType *pcb ) { // TODO: Add lots of things here, see ppc55xx uint32_t *context = (uint32_t *)pcb->stack.curr; context[C_CONTEXT_OFFS/4] = SC_PATTERN; /* Set LR to start function */ if( pcb->proc_type == PROC_EXTENDED ) { - context[VGPR_LR_OFF/4] = (uint32_t)os_proc_start_extended; + context[VGPR_LR_OFF/4] = (uint32_t)Os_TaskStartExtended; } else if( pcb->proc_type == PROC_BASIC ) { - context[VGPR_LR_OFF/4] = (uint32_t)os_proc_start_basic; + context[VGPR_LR_OFF/4] = (uint32_t)Os_TaskStartBasic; } os_arch_stack_set_endmark(pcb); // os_arch_setup_context_asm(pcb->stack.curr,NULL); diff --git a/arch/arm/arm_cm3/kernel/arch_krn.sx b/arch/arm/arm_cm3/kernel/arch_krn.sx index 14337e4e..193a2deb 100644 --- a/arch/arm/arm_cm3/kernel/arch_krn.sx +++ b/arch/arm/arm_cm3/kernel/arch_krn.sx @@ -26,7 +26,7 @@ Irq_Handler: mov.w r4,#LC_PATTERN str r4,[sp,#C_CONTEXT_OFFS] mov r0,sp // stack as first arg - bl IntCtrl_Entry + bl Irq_Entry mov sp, r0 // pop from returned stack b os_lc_restore @@ -42,9 +42,9 @@ Irq_Handler: * ---------- <- JABBA * */ - .global os_arch_swap_context - .type os_arch_swap_context, %function -os_arch_swap_context: + .global Os_ArchSwapContext + .type Os_ArchSwapContext, %function +Os_ArchSwapContext: // mov r2, sp push {r4-r8,r10,r11,lr} @@ -61,9 +61,9 @@ os_arch_swap_context: str r4,[r0,#PCB_STACK_CURR_P] // R1 - new PCB - .global os_arch_swap_context_to - .type os_arch_swap_context_to, %function -os_arch_swap_context_to: + .global Os_ArchSwapContextTo + .type Os_ArchSwapContextTo, %function +Os_ArchSwapContextTo: // Get stack for new task ldr r2,[r1,#PCB_STACK_CURR_P] diff --git a/arch/arm/arm_cm3/kernel/int_ctrl.c b/arch/arm/arm_cm3/kernel/irq.c similarity index 89% rename from arch/arm/arm_cm3/kernel/int_ctrl.c rename to arch/arm/arm_cm3/kernel/irq.c index 603947da..f946916e 100644 --- a/arch/arm/arm_cm3/kernel/int_ctrl.c +++ b/arch/arm/arm_cm3/kernel/irq.c @@ -18,19 +18,18 @@ #include "internal.h" #include "task_i.h" #include "hooks.h" -#include "swap.h" #include "stm32f10x.h" #include "misc.h" -#include "int_ctrl.h" +#include "irq.h" #include "core_cm3.h" extern void *Irq_VectorTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS]; -void IntCtrl_Init( void ) { +void Irq_Init( void ) { NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); } -void IntCtrl_EOI( void ) { +void Irq_EOI( void ) { } @@ -54,7 +53,7 @@ static uint32_t NVIC_GetActiveVector( void) { * The stack holds C, NVGPR, VGPR and the EXC frame. * */ -void *IntCtrl_Entry( void *stack_p ) +void *Irq_Entry( void *stack_p ) { uint32_t vector = 0; uint32_t *stack; @@ -85,7 +84,7 @@ void *IntCtrl_Entry( void *stack_p ) * @param vector * @param prio */ -void IntCtrl_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector, uint8_t prio) { +void Irq_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector, uint8_t prio) { // TODO: Use NVIC_Init here /* @@ -113,8 +112,8 @@ static inline int osPrioToCpuPio( uint8_t prio ) { * @param int_ctrl * @param vector */ -void IntCtrl_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) { - pcb_t *pcb; +void Irq_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) { + OsPcbType *pcb; NVIC_InitTypeDef irqInit; pcb = os_find_task(tid); @@ -137,7 +136,7 @@ void IntCtrl_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) { * * @param vector */ -void IntCtrl_GenerateSoftInt( IrqType vector ) { +void Irq_GenerateSoftInt( IrqType vector ) { NVIC->STIR = (vector + 16); } @@ -147,7 +146,7 @@ void IntCtrl_GenerateSoftInt( IrqType vector ) { * @param cpu * @return */ -uint8_t IntCtrl_GetCurrentPriority( Cpu_t cpu) { +uint8_t Irq_GetCurrentPriority( Cpu_t cpu) { uint8_t prio = 0; diff --git a/arch/arm/arm_cm3/kernel/irq.h b/arch/arm/arm_cm3/kernel/irq_types.h similarity index 100% rename from arch/arm/arm_cm3/kernel/irq.h rename to arch/arm/arm_cm3/kernel/irq_types.h diff --git a/arch/ppc/mpc55xx/drivers/Adc.c b/arch/ppc/mpc55xx/drivers/Adc.c index 9227a556..7baa50a4 100644 --- a/arch/ppc/mpc55xx/drivers/Adc.c +++ b/arch/ppc/mpc55xx/drivers/Adc.c @@ -31,7 +31,7 @@ #include "Det.h" #if defined(USE_KERNEL) #include "Os.h" -#include "int_ctrl.h" +#include "irq.h" #endif @@ -703,25 +703,25 @@ void Adc_ConfigureEQADCInterrupts (void) #if defined(USE_KERNEL) TaskType tid; - tid = Os_CreateIsr(Adc_EQADCError,EQADC_FISR_OVER_PRIORITY,"Adc_Err"); - IntCtrl_AttachIsr2(tid,NULL,EQADC_FISR_OVER); + tid = Os_Arc_CreateIsr(Adc_EQADCError,EQADC_FISR_OVER_PRIORITY,"Adc_Err"); + Irq_AttachIsr2(tid,NULL,EQADC_FISR_OVER); - tid = Os_CreateIsr(Adc_Group0ConversionComplete,EQADC_FIFO0_END_OF_QUEUE_PRIORITY,"Adc_Grp0"); - IntCtrl_AttachIsr2(tid,NULL,EQADC_FISR0_EOQF0); + tid = Os_Arc_CreateIsr(Adc_Group0ConversionComplete,EQADC_FIFO0_END_OF_QUEUE_PRIORITY,"Adc_Grp0"); + Irq_AttachIsr2(tid,NULL,EQADC_FISR0_EOQF0); - tid = Os_CreateIsr(Adc_Group1ConversionComplete,EQADC_FIFO1_END_OF_QUEUE_PRIORITY,"Adc_Grp1"); - IntCtrl_AttachIsr2(tid,NULL,EQADC_FISR1_EOQF1); + tid = Os_Arc_CreateIsr(Adc_Group1ConversionComplete,EQADC_FIFO1_END_OF_QUEUE_PRIORITY,"Adc_Grp1"); + Irq_AttachIsr2(tid,NULL,EQADC_FISR1_EOQF1); #else - IntCtrl_InstallVector (Adc_EQADCError, + Irq_InstallVector (Adc_EQADCError, EQADC_FISR_OVER, EQADC_FISR_OVER_PRIORITY, CPU_Z1); - IntCtrl_InstallVector (Adc_Group0ConversionComplete, + Irq_InstallVector (Adc_Group0ConversionComplete, EQADC_FISR0_EOQF0, EQADC_FIFO0_END_OF_QUEUE_PRIORITY, CPU_Z1); - IntCtrl_InstallVector (Adc_Group1ConversionComplete, + Irq_InstallVector (Adc_Group1ConversionComplete, EQADC_FISR1_EOQF1, EQADC_FIFO1_END_OF_QUEUE_PRIORITY, CPU_Z1); diff --git a/arch/ppc/mpc55xx/drivers/Can.c b/arch/ppc/mpc55xx/drivers/Can.c index aeddc2eb..0b9dde2f 100644 --- a/arch/ppc/mpc55xx/drivers/Can.c +++ b/arch/ppc/mpc55xx/drivers/Can.c @@ -33,7 +33,7 @@ #include #if defined(USE_KERNEL) #include "Os.h" -#include "int_ctrl.h" +#include "irq.h" #endif @@ -648,21 +648,21 @@ static void Can_Isr(int unit) { #define INSTALL_HANDLERS( _can_name,_boff,_err,_start,_stop) \ do { \ TaskType tid; \ - tid = Os_CreateIsr(_can_name ## _BusOff,1/*prio*/,"Can"); \ - IntCtrl_AttachIsr2(tid,NULL,_boff); \ - tid = Os_CreateIsr(_can_name ## _Err,1/*prio*/,"Can"); \ - IntCtrl_AttachIsr2(tid,NULL,_err); \ + tid = Os_Arc_CreateIsr(_can_name ## _BusOff,1/*prio*/,"Can"); \ + Irq_AttachIsr2(tid,NULL,_boff); \ + tid = Os_Arc_CreateIsr(_can_name ## _Err,1/*prio*/,"Can"); \ + Irq_AttachIsr2(tid,NULL,_err); \ for(i=_start;i<=_stop;i++) { \ - tid = Os_CreateIsr(_can_name ## _Isr,1/*prio*/,"Can"); \ - IntCtrl_AttachIsr2(tid,NULL,i); \ + tid = Os_Arc_CreateIsr(_can_name ## _Isr,1/*prio*/,"Can"); \ + Irq_AttachIsr2(tid,NULL,i); \ } \ } while(0); #else #define INSTALL_HANDLERS( _can_name,_boff,_err,_start,_stop) \ - IntCtrl_InstallVector(_can_name ## _BusOff, _boff, 1, CPU_Z1); \ - IntCtrl_InstallVector(_can_name ## _Err, _err, 1, CPU_Z1); \ + Irq_InstallVector(_can_name ## _BusOff, _boff, 1, CPU_Z1); \ + Irq_InstallVector(_can_name ## _Err, _err, 1, CPU_Z1); \ for(i=_start;i<=_stop;i++) { \ - IntCtrl_InstallVector(_can_name ## _Isr, i, 1, CPU_Z1); \ + Irq_InstallVector(_can_name ## _Isr, i, 1, CPU_Z1); \ } #endif diff --git a/arch/ppc/mpc55xx/drivers/Frt.c b/arch/ppc/mpc55xx/drivers/Frt.c index 1675857b..c75cc6e3 100644 --- a/arch/ppc/mpc55xx/drivers/Frt.c +++ b/arch/ppc/mpc55xx/drivers/Frt.c @@ -14,18 +14,17 @@ * -------------------------------- Arctic Core ------------------------------*/ #include "Os.h" -#include "sys.h" -#include "pcb.h" -#include "internal.h" -#include "int_ctrl.h" +#include "internal.h" +#include "irq.h" +#include "arc.h" /** * Init of free running timer. */ void Frt_Init( void ) { TaskType tid; - tid = Os_CreateIsr(OsTick,6/*prio*/,"OsTick"); - IntCtrl_AttachIsr2(tid,NULL,7); + tid = Os_Arc_CreateIsr(OsTick,6/*prio*/,"OsTick"); + Irq_AttachIsr2(tid,NULL,7); } /** @@ -64,7 +63,8 @@ void Frt_Start(uint32_t period_ticks) { * * @return */ - + +/** @req OS383 */ uint32_t Frt_GetTimeElapsed( void ) { uint32_t timer = get_spr(SPR_DECAR) - get_spr(SPR_DEC); diff --git a/arch/ppc/mpc55xx/drivers/Gpt.c b/arch/ppc/mpc55xx/drivers/Gpt.c index 42a81fcd..d6518eb1 100644 --- a/arch/ppc/mpc55xx/drivers/Gpt.c +++ b/arch/ppc/mpc55xx/drivers/Gpt.c @@ -186,7 +186,7 @@ void Gpt_Init(const Gpt_ConfigType *config) { if (cfg->GptNotification != NULL) { - IntCtrl_InstallVector(Gpt_Isr, PIT_PITFLG_RTIF + ch, 1, CPU_Z1); + Irq_InstallVector(Gpt_Isr, PIT_PITFLG_RTIF + ch, 1, CPU_Z1); } } #if defined(USE_KERNEL) @@ -195,7 +195,7 @@ void Gpt_Init(const Gpt_ConfigType *config) else if (ch == GPT_CHANNEL_DEC) { // Decrementer event is default an exception. Use software interrupt 7 as wrapper. - IntCtrl_InstallVector(config[i].GptNotification, INTC_SSCIR0_CLR7, 1, CPU_Z1); + Irq_InstallVector(config[i].GptNotification, INTC_SSCIR0_CLR7, 1, CPU_Z1); } #endif diff --git a/arch/ppc/mpc55xx/drivers/Lin.c b/arch/ppc/mpc55xx/drivers/Lin.c index a80d069c..bfa9f953 100644 --- a/arch/ppc/mpc55xx/drivers/Lin.c +++ b/arch/ppc/mpc55xx/drivers/Lin.c @@ -329,11 +329,11 @@ void Lin_InitChannel( uint8 Channel, const Lin_ChannelConfigType* Config ) // Install the interrupt if (Channel > 3) { - IntCtrl_InstallVector(aIntFnc[Channel],SCI_E_COMB + Channel,LIN_PRIO,CPU_Z1); + Irq_InstallVector(aIntFnc[Channel],SCI_E_COMB + Channel,LIN_PRIO,CPU_Z1); } else { - IntCtrl_InstallVector(aIntFnc[Channel],SCI_A_COMB + Channel,LIN_PRIO,CPU_Z1); + Irq_InstallVector(aIntFnc[Channel],SCI_A_COMB + Channel,LIN_PRIO,CPU_Z1); } esciHw->CR2.B.MDIS = 0;/* The module is enabled by writing the ESCIx_CR2[MDIS] bit to 0. */ diff --git a/arch/ppc/mpc55xx/drivers/Mcu.c b/arch/ppc/mpc55xx/drivers/Mcu.c index 8c69af70..89499ba3 100644 --- a/arch/ppc/mpc55xx/drivers/Mcu.c +++ b/arch/ppc/mpc55xx/drivers/Mcu.c @@ -29,7 +29,7 @@ #include "Cpu.h" #include "Ramlog.h" #include "Os.h" -#include "int_ctrl.h" +#include "irq.h" //#define USE_TRACE 1 //#define USE_DEBUG 1 @@ -255,22 +255,20 @@ void Mcu_Init(const Mcu_ConfigType *configPtr) // Mcu_ConfigureFlash(); - Irq_Enable(); - Mcu_Global.config = configPtr; Mcu_Global.initRun = 1; if( Mcu_Global.config->McuClockSrcFailureNotification == TRUE ){ // Enable loss of lock interrupt - IntCtrl_AttachIsr1(Mcu_LossOfLock, NULL, PLL_SYNSR_LOLF,10 ); + Irq_AttachIsr1(Mcu_LossOfLock, NULL, PLL_SYNSR_LOLF,10 ); #if defined(CFG_MPC5516) // FMPLL.SYNCR.B.LOCIRQ = 1; TODO: Kolla denna bortkommentering med Mårten. FMPLL.ESYNCR2.B.LOLIRQ = 1; #elif defined(CFG_MPC5554) || defined(CFG_MPC5567) FMPLL.SYNCR.B.LOLIRQ = 1; #endif - IntCtrl_AttachIsr1(Mcu_LossOfCLock, NULL, PLL_SYNSR_LOCF,10 ); + Irq_AttachIsr1(Mcu_LossOfCLock, NULL, PLL_SYNSR_LOCF,10 ); #if defined(CFG_MPC5516) // FMPLL.SYNCR.B.LOCIRQ = 1; TODO: Kolla denna bortkommentering med Mårten. FMPLL.ESYNCR2.B.LOCIRQ = 1; diff --git a/arch/ppc/mpc55xx/drivers/Mcu_Exceptions.sx b/arch/ppc/mpc55xx/drivers/Mcu_Exceptions.sx index 9f880149..dad45a07 100644 --- a/arch/ppc/mpc55xx/drivers/Mcu_Exceptions.sx +++ b/arch/ppc/mpc55xx/drivers/Mcu_Exceptions.sx @@ -99,8 +99,8 @@ on_int_stack: #endif - lis r3, IntCtrl_Entry@h - ori r3, r3,IntCtrl_Entry@l + lis r3, Irq_Entry@h + ori r3, r3,Irq_Entry@l mtlr r3 mr r3,r4 /* "old" stack as arg1 */ diff --git a/arch/ppc/mpc55xx/drivers/Pwm.c b/arch/ppc/mpc55xx/drivers/Pwm.c index dbb84423..e6b4d708 100644 --- a/arch/ppc/mpc55xx/drivers/Pwm.c +++ b/arch/ppc/mpc55xx/drivers/Pwm.c @@ -116,7 +116,7 @@ void Pwm_Init(const Pwm_ConfigType* ConfigPtr) { #if PWM_NOTIFICATION_SUPPORTED==STD_ON // Create a task for our interrupt service routine. - TaskType tid = Os_CreateIsr(Pwm_Isr, PWM_ISR_PRIORITY /*prio*/, "PwmIsr"); + TaskType tid = Os_Arc_CreateIsr(Pwm_Isr, PWM_ISR_PRIORITY /*prio*/, "PwmIsr"); #endif /* Clock scaler uses system clock (~64MHz) as source, so prescaler 64 => 1MHz. */ @@ -150,7 +150,7 @@ void Pwm_Init(const Pwm_ConfigType* ConfigPtr) { // Pwm_DisableNotification(channel); // Install ISR - IntCtrl_AttachIsr2(tid, NULL, EMISOS200_FLAG_F0 + channel); + Irq_AttachIsr2(tid, NULL, EMISOS200_FLAG_F0 + channel); ChannelRuntimeStruct[channel].NotificationRoutine = ConfigPtr->NotificationHandlers[channel_iterator]; #endif diff --git a/arch/ppc/mpc55xx/drivers/Spi.c b/arch/ppc/mpc55xx/drivers/Spi.c index bfb29945..2745a64c 100644 --- a/arch/ppc/mpc55xx/drivers/Spi.c +++ b/arch/ppc/mpc55xx/drivers/Spi.c @@ -1003,11 +1003,11 @@ static void Spi_InitController( uint32 unit ) { spiHw->MCR.B.MDIS = 0; #if defined(__DMA_INT) - IntCtrl_InstallVector(Spi_Isr_DMA, 16 , 1, CPU_Z1); + Irq_InstallVector(Spi_Isr_DMA, 16 , 1, CPU_Z1); #endif // Install EOFQ int.. - IntCtrl_InstallVector(Spi_Isr_Info[unit].entry, Spi_Isr_Info[unit].vector, + Irq_InstallVector(Spi_Isr_Info[unit].entry, Spi_Isr_Info[unit].vector, Spi_Global.configPtr->SpiHwConfig[unit].IsrPriority, Spi_Isr_Info[unit].cpu); } diff --git a/arch/ppc/mpc55xx/kernel/arch.c b/arch/ppc/mpc55xx/kernel/arch.c index 5256eb99..d8ef2b6f 100644 --- a/arch/ppc/mpc55xx/kernel/arch.c +++ b/arch/ppc/mpc55xx/kernel/arch.c @@ -12,19 +12,10 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - -#include "types.h" -#include "Cpu.h" +#include "internal.h" #include "asm_ppc.h" -#include "asm_book_e.h" -#include "sys.h" -#include "arch.h" -#include "task_i.h" -#include "internal.h" #include "mpc55xx.h" -#include +#include "asm_book_e.h" #define USE_DEBUG #include "Trace.h" @@ -60,7 +51,7 @@ void os_arch_first_call( void ) /* TODO: This actually gives the stack ptr here...not the callers stack ptr * Should probably be a macro instead..... in some arch part.. */ -void *os_arch_get_stackptr( void ) { +void *Os_ArchGetStackPtr( void ) { void *stackp; // Get stack ptr(r1) from current context asm volatile(" mr %0,1":"=r" (stackp)); @@ -68,38 +59,15 @@ void *os_arch_get_stackptr( void ) { return stackp; } -unsigned int os_arch_get_sc_size( void ) { +unsigned int Os_ArchGetScSize( void ) { return SC_SIZE; } extern void os_arch_setup_context_asm( void *context,unsigned int msr); -#define STACK_PATTERN 0x42 - -#if 0 - -_Bool os_arch_stack_endmark_ok( pcb_t *pcb ) { - uint8_t *end = pcb->stack.top; - return ( *end == STACK_PATTERN); -} - - -void *os_arch_get_stack_usage( pcb_t *pcb ) { - - uint8_t *p = pcb->stack.curr; - uint8_t *end = pcb->stack.top; - - while( (*end == STACK_PATTERN) && (endstack.size < (STACK_SIZE_MIN) ) { - os_arch_stack_to_small(pcb, STACK_SIZE_MIN); - } #if 0 - // Fill stack with a nice pattern STACK_PATTERN - { - uint8_t *p = pcb->stack.curr; - - assert(pcb->stack.curr>pcb->stack.top); - - while(p > (uint8_t *)pcb->stack.top) { - --p; - *p = STACK_PATTERN; - } + if( pcb->stack.size < (STACK_SIZE_MIN) ) { + os_arch_stack_to_small(pcb, STACK_SIZE_MIN); } #endif + msr = MSR_EE; #if defined(CFG_SPE) msr |= MSR_SPE; #endif - + +#if ( OS_SC3 == STD_ON) || ( OS_SC4== STD_ON) if( !pcb->application->trusted ) { // Non-trusted = User mode.. msr |= MSR_PR | MSR_DS | MSR_IS; - } - pcb->regs[0] = msr; - - { - uint32_t *context = (uint32_t *)pcb->stack.curr; - - context[C_CONTEXT_OFF/4] = SC_PATTERN; - - /* Set LR to start function */ - if( pcb->proc_type == PROC_EXTENDED ) { - context[C_LR_OFF/4] = (uint32_t)os_proc_start_extended; - } else if( pcb->proc_type == PROC_BASIC ) { - context[C_LR_OFF/4] = (uint32_t)os_proc_start_basic; - } } - - os_arch_stack_set_endmark(pcb); +#endif + pcb->regs[0] = msr; } + +/** + * + * @param pcbPtr + */ + +void OsArch_SetTaskEntry(OsPcbType *pcbPtr ) { + uint32_t *context = (uint32_t *)pcbPtr->stack.curr; + + context[C_CONTEXT_OFF/4] = SC_PATTERN; + + /* Set LR to start function */ + if( pcbPtr->proc_type == PROC_EXTENDED ) { + context[C_LR_OFF/4] = (uint32_t)Os_TaskStartExtended; + } else if( pcbPtr->proc_type == PROC_BASIC ) { + context[C_LR_OFF/4] = (uint32_t)Os_TaskStartBasic; + } +} #define C_CONTEXT_OFF 12 #define C_LR_OFF 16 #define C_CR_OFF 20 -void os_arch_print_context( char *str, pcb_t *pcb ) { +void os_arch_print_context( char *str, OsPcbType *pcb ) { uint32_t *stack; dbg_printf("%s CONTEXT: %d\n",str, pcb->pid); diff --git a/arch/ppc/mpc55xx/kernel/arch_krn.sx b/arch/ppc/mpc55xx/kernel/arch_krn.sx index b81aa03b..7a1be861 100644 --- a/arch/ppc/mpc55xx/kernel/arch_krn.sx +++ b/arch/ppc/mpc55xx/kernel/arch_krn.sx @@ -2,7 +2,7 @@ /* * IVOR4 * 1. Save stack frames: EXC, VGPR, NVGPR and C - * 2. Call IntCtrl_Entry(void *curr_stack) + * 2. Call Irq_Entry(void *curr_stack) * 2.1 Check for exception * 2.2 If softint, clear it. * 2.3 If PROC_ISR1, then just call the function @@ -68,10 +68,16 @@ dummy_int: // TODO: this assumes that both are in user mode?.. can this happen under trusted functions? // When I get here we're ALWAYS in kernel mode -.global os_arch_swap_context_to -.global os_arch_swap_context +.global Os_ArchSwapContextToW +.global Os_ArchSwapContextTo +.global Os_ArchSwapContext .section .text -os_arch_swap_context: + +Os_ArchSwapContextToW: + mr r1,r5 + b Os_ArchSwapContextTo + +Os_ArchSwapContext: // allocate space for context+nvgpr // (no need for proper stack-frame here) stwu r1,-(C_SIZE+NVGPR_SIZE)(r1) @@ -98,7 +104,7 @@ os_arch_swap_context: // TODO: If we change application we must change mmu setup -os_arch_swap_context_to: +Os_ArchSwapContextTo: // Get stack for new task lwz sp,PCB_STACK_CURR_P(r4) diff --git a/arch/ppc/mpc55xx/kernel/int_ctrl.c b/arch/ppc/mpc55xx/kernel/irq.c similarity index 94% rename from arch/ppc/mpc55xx/kernel/int_ctrl.c rename to arch/ppc/mpc55xx/kernel/irq.c index c33925b7..6495119d 100644 --- a/arch/ppc/mpc55xx/kernel/int_ctrl.c +++ b/arch/ppc/mpc55xx/kernel/irq.c @@ -13,16 +13,13 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ -#include "typedefs.h" +#include "internal.h" #include "asm_book_e.h" -#include "irq.h" +#include "irq_types.h" #include "mpc55xx.h" #if !defined(USE_KERNEL) #include "Mcu.h" #endif -#include -#include "Ramlog.h" -//#include #if defined(USE_KERNEL) #include "pcb.h" @@ -30,7 +27,6 @@ #include "internal.h" #include "task_i.h" #include "hooks.h" -#include "swap.h" #if 0 #define INTC_SSCIR0_CLR7 7 @@ -42,7 +38,7 @@ #include "Trace.h" #endif -#include "int_ctrl.h" +#include "irq.h" static void dump_exception_regs( uint32_t *regs ); @@ -61,7 +57,7 @@ extern func_t Irq_VectorTable[]; #endif // write 0 to pop INTC stack -void IntCtrl_Init( void ) { +void Irq_Init( void ) { // Check alignment for the exception table assert(((uint32)exception_tbl & 0xfff)==0); set_spr(SPR_IVPR,(uint32)exception_tbl); @@ -148,7 +144,7 @@ void IntCtrl_Init( void ) { } -void IntCtrl_EOI( void ) { +void Irq_EOI( void ) { #if defined(CFG_MPC5516) struct INTC_tag *intc = &INTC; intc->EOIR_PRC0.R = 0; @@ -166,7 +162,7 @@ void IntCtrl_EOI( void ) { * The stack holds C, NVGPR, VGPR and the EXC frame. * */ -void *IntCtrl_Entry( void *stack_p ) +void *Irq_Entry( void *stack_p ) { uint32_t vector; uint32_t *stack = (uint32_t *)stack_p; @@ -200,7 +196,7 @@ void *IntCtrl_Entry( void *stack_p ) #if defined(USE_KERNEL) - if( IntCtrl_GetIsrType(vector) == ISR_TYPE_1 ) { + if( Irq_GetIsrType(vector) == ISR_TYPE_1 ) { // It's a function, just call it. ((func_t)Irq_VectorTable[vector])(); return stack; @@ -246,7 +242,7 @@ static inline int osPrioToCpuPio( uint8_t prio ) { return prio>>1; // Os have 32 -> 16 } -void IntCtrl_SetPriority( Cpu_t cpu, IrqType vector, uint8_t prio ) { +void Irq_SetPriority( Cpu_t cpu, IrqType vector, uint8_t prio ) { #if defined(CFG_MPC5516) INTC.PSR[vector].B.PRC_SEL = cpu; #endif @@ -263,12 +259,12 @@ void IntCtrl_SetPriority( Cpu_t cpu, IrqType vector, uint8_t prio ) { * @param vector * @param prio */ -void IntCtrl_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector,uint8_t prio) { +void Irq_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector,uint8_t prio) { Irq_VectorTable[vector] = (void *)entry; - IntCtrl_SetIsrType(vector, ISR_TYPE_1); + Irq_SetIsrType(vector, ISR_TYPE_1); if (vector < INTC_NUMBER_OF_INTERRUPTS) { - IntCtrl_SetPriority(CPU_CORE0,vector + IRQ_INTERRUPT_OFFSET, osPrioToCpuPio(prio)); + Irq_SetPriority(CPU_CORE0,vector + IRQ_INTERRUPT_OFFSET, osPrioToCpuPio(prio)); } else if ((vector >= CRITICAL_INPUT_EXCEPTION) && (vector <= DEBUG_EXCEPTION)) { } else { @@ -285,15 +281,15 @@ void IntCtrl_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector,ui * @param int_ctrl * @param vector */ -void IntCtrl_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) { - pcb_t *pcb; +void Irq_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) { + OsPcbType *pcb; pcb = os_find_task(tid); Irq_VectorTable[vector] = (void *)pcb; Irq_IsrTypeTable[vector] = PROC_ISR2; if (vector < INTC_NUMBER_OF_INTERRUPTS) { - IntCtrl_SetPriority(CPU_CORE0,vector + + IRQ_INTERRUPT_OFFSET, osPrioToCpuPio(pcb->prio)); + Irq_SetPriority(CPU_CORE0,vector + + IRQ_INTERRUPT_OFFSET, osPrioToCpuPio(pcb->prio)); } else if ((vector >= CRITICAL_INPUT_EXCEPTION) && (vector <= DEBUG_EXCEPTION)) { } else { @@ -317,7 +313,7 @@ void IntCtrl_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) { * @param cpu */ -void IntCtrl_InstallVector(void(*func)(), IrqType vector, +void Irq_InstallVector(void(*func)(), IrqType vector, uint8_t priority, Cpu_t cpu) { VALIDATE( ( 1 == Mcu_Global.initRun ), MCU_INTCVECTORINSTALL_SERVICE_ID, MCU_E_UNINIT ); @@ -348,7 +344,7 @@ void IntCtrl_InstallVector(void(*func)(), IrqType vector, * Generates a soft interrupt * @param vector */ -void IntCtrl_GenerateSoftInt( IrqType vector ) { +void Irq_GenerateSoftInt( IrqType vector ) { if( vector > INTC_SSCIR0_CLR7 ) { assert(0); } @@ -361,7 +357,7 @@ void IntCtrl_GenerateSoftInt( IrqType vector ) { * @param cpu * @return */ -uint8_t IntCtrl_GetCurrentPriority( Cpu_t cpu) { +uint8_t Irq_GetCurrentPriority( Cpu_t cpu) { uint8_t prio; diff --git a/arch/ppc/mpc55xx/kernel/irq.h b/arch/ppc/mpc55xx/kernel/irq_types.h similarity index 99% rename from arch/ppc/mpc55xx/kernel/irq.h rename to arch/ppc/mpc55xx/kernel/irq_types.h index 98f8bea0..0c0ae2c5 100644 --- a/arch/ppc/mpc55xx/kernel/irq.h +++ b/arch/ppc/mpc55xx/kernel/irq_types.h @@ -14,21 +14,6 @@ * -------------------------------- Arctic Core ------------------------------*/ - - - - - - -/* - * irq.h - * - * Defines some additional types used for mpc55xx - * - * Created on: Jul 13, 2009 - * Author: mahi - */ - #ifndef IRQ_H #define IRQ_H diff --git a/common/newlib_port.c b/common/newlib_port.c index 6f416a8d..1952c2ec 100644 --- a/common/newlib_port.c +++ b/common/newlib_port.c @@ -24,7 +24,7 @@ #include "Ramlog.h" #if defined(CFG_ARM_CM3) -#include "irq.h" +#include "irq_types.h" #include "core_cm3.h" #endif diff --git a/examples/blinker_node/Hooks.c b/examples/blinker_node/Hooks.c index 9c063939..6f912480 100644 --- a/examples/blinker_node/Hooks.c +++ b/examples/blinker_node/Hooks.c @@ -89,7 +89,7 @@ void PostTaskHook( void ) { } #if 0 -struct os_conf_global_hooks_s os_conf_global_hooks = { +struct OsHooks os_conf_global_hooks = { .StartupHook = StartupHook, .ProtectionHook = ProtectionHook, .ShutdownHook = ShutdownHook, diff --git a/examples/pwm_node/Hooks.c b/examples/pwm_node/Hooks.c index 12cb6531..e3d43cbc 100644 --- a/examples/pwm_node/Hooks.c +++ b/examples/pwm_node/Hooks.c @@ -90,7 +90,7 @@ void PostTaskHook( void ) { } #if 0 -struct os_conf_global_hooks_s os_conf_global_hooks = { +struct OsHooks os_conf_global_hooks = { .StartupHook = StartupHook, .ProtectionHook = ProtectionHook, .ShutdownHook = ShutdownHook, diff --git a/examples/pwm_node2/Hooks.c b/examples/pwm_node2/Hooks.c index bdd94ef8..6dd145b5 100644 --- a/examples/pwm_node2/Hooks.c +++ b/examples/pwm_node2/Hooks.c @@ -79,7 +79,7 @@ void PostTaskHook( void ) { } #if 0 -struct os_conf_global_hooks_s os_conf_global_hooks = { +struct OsHooks os_conf_global_hooks = { .StartupHook = StartupHook, .ProtectionHook = ProtectionHook, .ShutdownHook = ShutdownHook, diff --git a/examples/pwm_node2/config/Os_Cfg.c b/examples/pwm_node2/config/Os_Cfg.c index 5bb91eec..a0a9f584 100644 --- a/examples/pwm_node2/config/Os_Cfg.c +++ b/examples/pwm_node2/config/Os_Cfg.c @@ -52,7 +52,7 @@ uint32 os_dbg_mask = // ############################### APPLICATION ############################## // A single, non-configurable application for now -rom_app_t rom_app_list[] = { +OsRomApplicationType rom_app_list[] = { { .application_id = APPLICATION_ID_application_1, .name = "application_1", @@ -71,7 +71,7 @@ rom_app_t rom_app_list[] = { // ################################# COUNTERS ############################### -counter_obj_t counter_list[] = { +OsCounterType counter_list[] = { { .name = "OsTick", .type = COUNTER_TYPE_HARD, @@ -85,7 +85,7 @@ counter_obj_t counter_list[] = { CounterType Os_Arc_OsTickCounter = COUNTER_ID_OsTick; // ################################## ALARMS ################################ -alarm_obj_t alarm_list[] = { +OsAlarmType alarm_list[] = { { .name = "ComAlarm", .counter = &counter_list[COUNTER_ID_OsTick], @@ -105,7 +105,7 @@ alarm_obj_t alarm_list[] = { // ################################ RESOURCES ############################### -resource_obj_t resource_list[] = { +OsResourceType resource_list[] = { { .nr = RES_SCHEDULER, .type = RESOURCE_TYPE_STANDARD, @@ -122,10 +122,10 @@ uint8_t stack_OsIdle[PRIO_STACK_SIZE]; uint8_t stack_StartupTask[PRIO_STACK_SIZE]; // ##################### TIMING PROTECTIONS (TASKS, ISRS) ################### -timing_protection_t timing_protection_list[] = { +OsTimingProtectionType timing_protection_list[] = { }; -rom_pcb_t rom_pcb_list[] = { +OsRomPcbType rom_pcb_list[] = { // ################################## TASKS ################################# { .pid = TASK_ID_ComTask, @@ -172,7 +172,7 @@ GEN_IRQ_PRIORITY_TABLE_HEAD {}; // ################################## HOOKS ################################## -struct os_conf_global_hooks_s os_conf_global_hooks = { +struct OsHooks os_conf_global_hooks = { .StartupHook = StartupHook, .ProtectionHook = ProtectionHook, .ShutdownHook = ShutdownHook, diff --git a/examples/simple/config/Os_Cfg.c b/examples/simple/config/Os_Cfg.c index 6e4e5cc4..5c7b77b3 100644 --- a/examples/simple/config/Os_Cfg.c +++ b/examples/simple/config/Os_Cfg.c @@ -29,7 +29,8 @@ OsTickType OsTickFreq = 1000; // atleast 1 #define SERVICE_CNT 1 - + +#if ( OS_SC3 == STD_ON) || ( OS_SC4==STD_ON) GEN_TRUSTEDFUNCTIONS_LIST //--- APPLICATIONS ---- @@ -41,6 +42,7 @@ GEN_APPLICATION_HEAD { true, NULL,NULL,NULL , 0,0,0,0,0,0 ) }; +#endif // --- RESOURCES --- diff --git a/examples/simple/config/Os_Cfg.h b/examples/simple/config/Os_Cfg.h index a0e5c814..b03f941d 100644 --- a/examples/simple/config/Os_Cfg.h +++ b/examples/simple/config/Os_Cfg.h @@ -52,7 +52,7 @@ void btask_3( void ); // NOT GENERATED( for test system only ) #define SYSTEM_COUNTER_PERIOD 100 -#define PRIO_STACK_SIZE 2600 +#define PRIO_STACK_SIZE 5000 //2600 #define OS_INTERRUPT_STACK_SIZE 2048 // Just define them if you want to use them. diff --git a/examples/simple/simple_main.c b/examples/simple/simple_main.c index c171d229..13ebccdb 100644 --- a/examples/simple/simple_main.c +++ b/examples/simple/simple_main.c @@ -16,6 +16,7 @@ #include "Os.h" #include "Mcu.h" +#include "arc.h" #define USE_DEBUG #include "Trace.h" @@ -34,7 +35,7 @@ void btask_3( void ) { dbg_printf("[%08d] btask_3 start\n", GetOsTick() ); GetTaskID(&currTask); - Os_GetStackInfo(currTask,&si); + Os_Arc_GetStackInfo(currTask,&si); dbg_printf("btask_3: Stack usage %d%%\n",OS_STACK_USAGE(&si)); TerminateTask(); @@ -58,7 +59,7 @@ void etask_1( void ) { ClearEvent(2); tryFloatingPoint += 1.0F; GetTaskID(&currTask); - Os_GetStackInfo(currTask,&si); + Os_Arc_GetStackInfo(currTask,&si); dbg_printf("etask_1: Stack usage %d%% \n",OS_STACK_USAGE(&si)); } @@ -79,7 +80,7 @@ void etask_2( void ) { StackInfoType si; TaskType currTask; GetTaskID(&currTask); - Os_GetStackInfo(currTask,&si); + Os_Arc_GetStackInfo(currTask,&si); dbg_printf("etask_1: Stack usage %d%% \n",OS_STACK_USAGE(&si)); } } diff --git a/examples/switch_node/Hooks.c b/examples/switch_node/Hooks.c index bdd94ef8..6dd145b5 100644 --- a/examples/switch_node/Hooks.c +++ b/examples/switch_node/Hooks.c @@ -79,7 +79,7 @@ void PostTaskHook( void ) { } #if 0 -struct os_conf_global_hooks_s os_conf_global_hooks = { +struct OsHooks os_conf_global_hooks = { .StartupHook = StartupHook, .ProtectionHook = ProtectionHook, .ShutdownHook = ShutdownHook, diff --git a/examples/switch_node/config/Os_Cfg.c b/examples/switch_node/config/Os_Cfg.c index 4702acda..945fa5c9 100644 --- a/examples/switch_node/config/Os_Cfg.c +++ b/examples/switch_node/config/Os_Cfg.c @@ -52,7 +52,7 @@ uint32 os_dbg_mask = 0; // ############################### APPLICATION ############################## // A single, non-configurable application for now -rom_app_t rom_app_list[] = { +OsRomApplicationType rom_app_list[] = { { .application_id = APPLICATION_ID_application_1, .name = "application_1", @@ -71,7 +71,7 @@ rom_app_t rom_app_list[] = { // ################################# COUNTERS ############################### -counter_obj_t counter_list[] = { +OsCounterType counter_list[] = { { .name = "OsTick", .type = COUNTER_TYPE_HARD, @@ -85,7 +85,7 @@ counter_obj_t counter_list[] = { CounterType Os_Arc_OsTickCounter = COUNTER_ID_OsTick; // ################################## ALARMS ################################ -alarm_obj_t alarm_list[] = { +OsAlarmType alarm_list[] = { { .name = "ComAlarm", .counter = &counter_list[COUNTER_ID_OsTick], @@ -120,7 +120,7 @@ alarm_obj_t alarm_list[] = { // ################################ RESOURCES ############################### -resource_obj_t resource_list[] = { +OsResourceType resource_list[] = { { .nr = RES_SCHEDULER, .type = RESOURCE_TYPE_STANDARD, @@ -138,10 +138,10 @@ uint8_t stack_ReadSwitches[PRIO_STACK_SIZE]; uint8_t stack_StartupTask[PRIO_STACK_SIZE]; // ##################### TIMING PROTECTIONS (TASKS, ISRS) ################### -timing_protection_t timing_protection_list[] = { +OsTimingProtectionType timing_protection_list[] = { }; -rom_pcb_t rom_pcb_list[] = { +OsRomPcbType rom_pcb_list[] = { // ################################## TASKS ################################# { .pid = TASK_ID_ComTask, @@ -199,7 +199,7 @@ GEN_IRQ_PRIORITY_TABLE_HEAD {}; // ################################## HOOKS ################################## -struct os_conf_global_hooks_s os_conf_global_hooks = { +struct OsHooks os_conf_global_hooks = { .StartupHook = StartupHook, .ProtectionHook = ProtectionHook, .ShutdownHook = ShutdownHook, diff --git a/examples/tiny/tiny.c b/examples/tiny/tiny.c index 1dba85ad..5802384f 100644 --- a/examples/tiny/tiny.c +++ b/examples/tiny/tiny.c @@ -34,7 +34,7 @@ void btask_3( void ) { dbg_printf("[%08d] btask_3 start\n", GetOsTick() ); GetTaskID(&currTask); - Os_GetStackInfo(currTask,&si); + Os_Arc_GetStackInfo(currTask,&si); dbg_printf("btask_3: Stack usage %d%%\n",OS_STACK_USAGE(&si)); TerminateTask(); @@ -58,7 +58,7 @@ void etask_1( void ) { ClearEvent(2); tryFloatingPoint += 1.0F; GetTaskID(&currTask); - Os_GetStackInfo(currTask,&si); + Os_Arc_GetStackInfo(currTask,&si); dbg_printf("etask_1: Stack usage %d%% \n",OS_STACK_USAGE(&si)); } @@ -79,7 +79,7 @@ void etask_2( void ) { StackInfoType si; TaskType currTask; GetTaskID(&currTask); - Os_GetStackInfo(currTask,&si); + Os_Arc_GetStackInfo(currTask,&si); dbg_printf("etask_1: Stack usage %d%% \n",OS_STACK_USAGE(&si)); } } diff --git a/include/Mcu.h b/include/Mcu.h index 4a328651..7f28ad8a 100644 --- a/include/Mcu.h +++ b/include/Mcu.h @@ -28,7 +28,7 @@ #define MCU_SW_PATCH_VERSION 0 #include "Cpu.h" -#include "irq.h" +#include "irq_types.h" //#include "mpc55xx_aos.h" /* Service ID's */ @@ -108,9 +108,9 @@ void Mcu_SetMode( const Mcu_ModeType McuMode ); typedef uint32_t imask_t; /* ArcCore extensions */ -void IntCtrl_InstallVector(void (*func)(), IrqType vector, uint8_t priority, Cpu_t cpu ); -void IntCtrl_GenerateSoftInt( IrqType vector ); -uint8_t IntCtrl_GetCurrentPriority( Cpu_t cpu); +void Irq_InstallVector(void (*func)(), IrqType vector, uint8_t priority, Cpu_t cpu ); +void Irq_GenerateSoftInt( IrqType vector ); +uint8_t Irq_GetCurrentPriority( Cpu_t cpu); uint32_t McuE_GetSystemClock( void ); #if defined(CFG_MPC55XX) uint32_t McuE_GetPeripheralClock( McuE_PeriperalClock_t type ); diff --git a/include/Os.h b/include/Os.h index 9b7ca5f3..528cfb86 100644 --- a/include/Os.h +++ b/include/Os.h @@ -21,7 +21,8 @@ #define OS_SW_MAJOR_VERSION 1 #define OS_SW_MINOR_VERSION 0 #define OS_SW_PATCH_VERSION 0 - + +#include #include "Std_Types.h" #if !defined(CC_KERNEL) #include "Os_Cfg.h" @@ -29,17 +30,10 @@ #include "MemMap.h" #include "Cpu.h" -/* TODO: remove this... */ -// #include "pcb.h" -/* 13.5.1 */ -/* -typedef procid_t TaskType; -typedef event_t EventMaskType; -*/ -typedef uint32 EventMaskType; -typedef EventMaskType *EventMaskRefType; -typedef uint16 TaskType; -typedef TaskType *TaskRefType; +typedef uint32_t EventMaskType; +typedef EventMaskType * EventMaskRefType; +typedef uint16_t TaskType; +typedef TaskType * TaskRefType; typedef enum { TASK_STATE_WAITING, @@ -49,56 +43,6 @@ typedef enum { } TaskStateType; -/* - * Macros for error handling - * Registers service id of the erroneous function and the applicable parameters - * to os_error. Functions that have less than three parameters do not touch - * os_error.param3. Same rule follows for other parameter counts. - */ - -/* Error handling for functions that take no arguments */ -#define OS_STD_END(_service_id) \ - goto ok; \ - err: \ - os_error.serviceId=_service_id;\ - ERRORHOOK(rv); \ - ok: \ - return rv; - -/* Error handling for functions that take one argument */ -#define OS_STD_END_1(_service_id, _p1) \ - goto ok; \ - err: \ - os_error.serviceId=_service_id;\ - os_error.param1 = (uint32_t) _p1; \ - ERRORHOOK(rv); \ - ok: \ - return rv; - -/* Error handling for functions that take two arguments */ -#define OS_STD_END_2(_service_id, _p1,_p2) \ - goto ok; \ - err: \ - os_error.serviceId=_service_id;\ - os_error.param1 = (uint32_t) _p1; \ - os_error.param2 = (uint32_t) _p2; \ - ERRORHOOK(rv); \ - ok: \ - return rv; - -/* Error handling for functions that take three arguments */ -#define OS_STD_END_3(_service_id,_p1,_p2,_p3) \ - goto ok; \ - err: \ - os_error.serviceId=_service_id;\ - os_error.param1 = (uint32_t) _p1; \ - os_error.param2 = (uint32_t) _p2; \ - os_error.param3 = (uint32_t) _p3; \ - ERRORHOOK(rv); \ - ok: \ - return rv; - - typedef TaskStateType *TaskStateRefType; /* FIXME: OSMEMORY_IS__ , see 8.2*/ @@ -116,7 +60,6 @@ typedef sint32 AppModeType; typedef uint16 ScheduleTableType; typedef uint16 GlobalTimeTickType; - typedef enum { SCHEDULETABLE_STOPPED, SCHEDULETABLE_NEXT, @@ -178,7 +121,6 @@ void PostTaskHook( void ); typedef uint16 TrustedFunctionIndexType; typedef void * TrustedFunctionParameterRefType; - /* See 8.3.9 */ #define INVALID_ISR ((sint16)(-1)) typedef sint16 ISRType; @@ -186,7 +128,6 @@ typedef sint16 ISRType; typedef void * MemoryStartAddressType; typedef uint32 MemorySizeType; -//#define WaitEvent(...) _WaitEvent(__VA_ARGS__) #if 0 #define WaitEvent(...) SC_CALL(WaitEvent,1,1,__VA_ARGS__) #define SetEvent(...) SC_CALL(SetEvent,2,2,__VA_ARGS__) @@ -196,82 +137,132 @@ StatusType WaitEvent( EventMaskType Mask ); StatusType SetEvent( TaskType TaskID, EventMaskType Mask ); StatusType ClearEvent( EventMaskType Mask); StatusType GetEvent( TaskType TaskId, EventMaskRefType Mask); + +void InitOS( void ); +void StartOS( AppModeType Mode ); + ApplicationType GetApplicationID( void ); ISRType GetISRID( void ); + +typedef int8_t Os_IntCounterType; - -#define EnableAllInterrupts() Irq_Enable() -#define DisableAllInterrupts() Irq_Disable() -#define ResumeAllInterrupts() Irq_Enable() -#define SuspendAllInterrupts() Irq_Disable() -#define ResumeOSInterrupts() Irq_Enable() -#define SuspendOSInterrupts() Irq_Disable() - -#if 0 -void EnableAllInterrups( void ) Irq_Enable() -void DisableAllInterrupts( void ) Irq_Disable() -void ResumeAllInterrupts( void ) Irq_Enable() -void SuspendAllInterrupts( void ) Irq_Disable() -void ResumeOSInterrupts( void ) Irq_Enable() -void SuspendOSInterrupts( void ) Irq_Disable() -#endif - +/* requirements here: OS368(ISR2), OS092 */ + +extern Os_IntCounterType Os_IntDisableAllCnt; +extern Os_IntCounterType Os_IntSuspendAllCnt; +extern Os_IntCounterType Os_IntSuspendOsCnt; + + + +/** @req OS299 */ +/* OSEK: States that " service does not support nesting", but says + * nothing what to do about it. + * + * OS092: " If EnableAllInterrupts()/ResumeAllInterrupts()/ResumeOSInterrupts() + * are called and no corresponding DisableAllInterupts()/SuspendAllInterrupts()/ + * SuspendOSInterrupts() was done before, the Operating System shall not + * perform this OS service. + */ +static inline void DisableAllInterrupts( void ) { + Irq_Disable(); + Os_IntDisableAllCnt++; + /* No nesting allowed */ + assert(Os_IntDisableAllCnt>1); +} + +static inline void EnableAllInterrupts( void ) { + + if(Os_IntDisableAllCnt==0) { + /** @req OS092 EnableAllInterrupts */ + } else { + Os_IntDisableAllCnt--; + Irq_Enable(); + } +} + +static inline void SuspendAllInterrupts( void ) { + Irq_SuspendAll(); + Os_IntSuspendAllCnt++; +} + +static inline void ResumeAllInterrupts( void ) { + + if(Os_IntSuspendAllCnt==0) { + /** @req OS092 ResumeAllInterrupts */ + } else { + Os_IntSuspendAllCnt--; + Irq_ResumeAll(); + } +} + +/* Only ISR2 interrupts should be suspended but this can NEVER be + * done in a more efficient way than to disable all, so let's + * do that for all targets. + */ + +static inline void SuspendOSInterrupts( void ) { + Irq_SuspendOs(); + Os_IntSuspendOsCnt++; +} + +static inline void ResumeOSInterrupts( void ) { + + if(Os_IntSuspendOsCnt==0) { + /** @req OS092 ResumeOSInterrupts */ + } else { + Os_IntSuspendOsCnt--; + Irq_ResumeOs(); + } +} + +#if 0 +/* Can't find these anymore, removed from Autosar? */ StatusType EnableInterruptSource( ISRType EnableISR ); StatusType DisableInterruptSource( ISRType EnableISR ); +#endif - +/* + * Class 2,3 and 4 API + */ ApplicationType GetApplicationID( void ); -ISRType GetISRID( void ); -AccessType CheckISRMemoryAccess( ISRType ISRID, - MemoryStartAddressType Address, - MemorySizeType Size ); - -AccessType CheckTaskMemoryAccess( TaskType TaskID, +AccessType CheckISRMemoryAccess( ISRType ISRID, MemoryStartAddressType Address, MemorySizeType Size ); -void InitOS( void ); -void StartOS( AppModeType Mode ); - -StatusType CallTrustedFunction( TrustedFunctionIndexType FunctionIndex, - TrustedFunctionParameterRefType FunctionParams ); -StatusType GetTaskID( TaskRefType TaskID ); -StatusType GetTaskState(TaskType task_id, TaskStateRefType state); - -void ShutdownOS( StatusType ); -StatusType ActivateTask( TaskType TaskID ); -StatusType TerminateTask( void ); -StatusType ChainTask( TaskType TaskID ); -StatusType Schedule( void ); - -/* TODO: This def. is wrong wrong wrong */ - -/* Hmm, OS188 indicates that we must have a locking time here ..*/ -/* and we at least have prio here */ -//typedef const uint32 ResourceType; -#if 0 +AccessType CheckTaskMemoryAccess( TaskType TaskID, + MemoryStartAddressType Address, + MemorySizeType Size ); -#define DeclareResource(x) extern ResourceType *(x); +StatusType CallTrustedFunction( TrustedFunctionIndexType FunctionIndex, + TrustedFunctionParameterRefType FunctionParams ); -StatusType GetResource( ResourceType *ResID ); -StatusType ReleaseResource( ResourceType *ResID); +StatusType GetTaskID( TaskRefType TaskID ); +StatusType GetTaskState( TaskType task_id, TaskStateRefType state); -#else +void ShutdownOS( StatusType ); +StatusType ActivateTask( TaskType TaskID ); +StatusType TerminateTask( void ); +StatusType ChainTask( TaskType TaskID ); +StatusType Schedule( void ); typedef uint32 ResourceType; #define DeclareResource(x) extern ResourceType (x); StatusType GetResource( ResourceType ResID ); StatusType ReleaseResource( ResourceType ResID); - -#endif - -#define RES_SCHEDULER 0 -//DeclareResource(RES_SCHEDULER); + +/* + * Define the scheduler resource as 0 + */ +#define RES_SCHEDULER 0 + +/* + * Priorities of tasks and resources + */ #define OS_TASK_PRIORITY_MIN 0 #define OS_TASK_PRIORITY_MAX 31 -// logical prio higher than normal tasks +/* Logical priority is higher higher than normal tasks */ #define OS_RES_SCHEDULER_PRIO 32 typedef struct OsDriver_s { @@ -406,6 +397,12 @@ extern os_error_t os_error; #define OSError_ShutdownHook_Error ((StatusType) os_error.param1) #define OSError_GetTaskState_TaskId ((TaskType) os_error.param1) #define OSError_GetTaskState_State ((TaskStateRefType) os_error.param2) + +/** @req OS398 */ +#if defined(LOCALMESSAGESONLY) +#error LOCALMESSAGESONLY shall not be defined +#endif + /*------------------------------------------------------------------- * COM ( TODO : move ) @@ -443,14 +440,7 @@ StatusType ReceiveMessage( MessageType message_id, ApplicationDataRef dataRef ); TickType GetOsTick(); void OsTick(void); void OsIdle(void); - -// Generate conversion macro' -// Todo -#define OS_TICK2NS_OS_TICK_COUNTER(_x) -#define OS_TICK2US_OS_TICK_COUNTER(_x) -#define OS_TICK2MS_OS_TICK_COUNTER(_x) -#define OS_TICK2SEC_OS_TICK_COUNTER(_x) - + #define OS_ISR_TYPE2 0 #define OS_ISR_TYPE1 1 @@ -459,32 +449,4 @@ union isr_attr { void (*entry)(void); }; -typedef struct StackInfo_s { - void *at_swap; // This task was swapped in with this stack - void *top; // Top of the stack - int size; // Size of the stack - - void *curr; // current stack ptr - void *usage; // Usage in % -} StackInfoType; - -void Os_GetStackInfo( TaskType pid, StackInfoType *s ); - -#define OS_STACK_USAGE(_x) ((((_x)->size - (uint32_t)((_x)->usage - (_x)->top))*100)/(_x)->size) - -int simple_printf(const char *format, ...); - -#define ARRAY_SIZE(_x) sizeof(_x)/sizeof((_x)[0]) - -#define OS_STR__(x) #x -#define OS_STRSTR__(x) OS_STR__(x) - - -TaskType Os_CreateIsr( void (*entry)(void), uint8_t prio, const char *name ); -#if 0 -void IntCtrl_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector,uint8_t prio); -void IntCtrl_AttachIsr2(TaskType tid,void *int_ctrl, IrqType vector ); -#endif - - #endif /*OS_H_*/ diff --git a/include/Std_Types.h b/include/Std_Types.h index ddba61b2..9278b25c 100644 --- a/include/Std_Types.h +++ b/include/Std_Types.h @@ -13,13 +13,6 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - #ifndef _STD_TYPES_H #define _STD_TYPES_H @@ -28,18 +21,13 @@ // TODO: we haven't really defined the autosar types yet. // the standard types are uint8, etc. -#ifndef NULL -#define NULL 0 -#endif - -#if !defined(USE_KERNEL) -#include "typedefs.h" -#else #include -#endif - #include "Platform_Types.h" // TODO: move #include "Compiler.h" + +#ifndef NULL +#define NULL 0 +#endif //typedef uint8_t uint8; //typedef uint16_t uint16; @@ -114,8 +102,6 @@ typedef enum { E_NOT_OK, } StatusType; - -// TODO: really ??? typedef uint8 Std_ReturnType; @@ -128,13 +114,13 @@ typedef unsigned char StatusType; #define E_NOT_OK 1 #define STD_HIGH 0x01 -#define STD_LOW 0x00 +#define STD_LOW 0x00 #define STD_ACTIVE 0x01 #define STD_IDLE 0x00 #define STD_ON 0x01 -#define STD_OFF 0x00 +#define STD_OFF 0x00 #endif diff --git a/include/Trace.h b/include/Trace.h index 77fe5f57..61186402 100644 --- a/include/Trace.h +++ b/include/Trace.h @@ -15,11 +15,6 @@ - - - - - #ifndef TRACE_H_ #define TRACE_H_ diff --git a/include/arc.h b/include/arc.h index d2d473a3..7a2dcdd4 100644 --- a/include/arc.h +++ b/include/arc.h @@ -1,15 +1,60 @@ -/* - * arc.h - * - * Created on: 28 sep 2009 - * Author: mahi - */ #ifndef ARC_H_ #define ARC_H_ -#include "arc.h" +#define ARRAY_SIZE(_x) sizeof(_x)/sizeof((_x)[0]) + +#define OS_STR__(x) #x +#define OS_STRSTR__(x) OS_STR__(x) + +#ifndef MIN +#define MIN(_x,_y) (((_x) < (_y)) ? (_x) : (_y)) +#endif +#ifndef MAX +#define MAX(_x,_y) (((_x) > (_y)) ? (_x) : (_y)) +#endif + +/** + * Holds information about stack usage + */ +typedef struct StackInfo_s { + /* This task was swapped in with this stack */ + void * at_swap; + /* Pointer to the top of the stack */ + void * top; + /* The size of the stack in bytes */ + int size; + /* Pointer to the current place of the stack */ + void * curr; + /* Calculated usage in % of total */ + void * usage; +} StackInfoType; + +/** + * Converts OSEK StatusType to a string for easy printing + */ const char *Arc_StatusToString(StatusType); +void Os_Arc_GetStackInfo( TaskType pid, StackInfoType *s ); + +#define OS_STACK_USAGE(_x) ((((_x)->size - (uint32_t)((_x)->usage - (_x)->top))*100)/(_x)->size) + +// int simple_printf(const char *format, ...); + +TaskType Os_Arc_CreateIsr( void (*entry)(void), uint8_t prio, const char *name ); + +/** + * Get the task activation limit + * @param task + */ +int Os_ArcTest_GetTaskActivationLimit( TaskType task ); + +/** + * Fake Irq. Used for API testing. + * @param level The level + */ +void Os_ArcTest_SetIrqNestLevel( int level ); + + #endif /* ARC_H_ */ diff --git a/include/int_ctrl.h b/include/irq.h similarity index 76% rename from include/int_ctrl.h rename to include/irq.h index 6bdd91d7..71a35aed 100644 --- a/include/int_ctrl.h +++ b/include/irq.h @@ -14,10 +14,10 @@ * -------------------------------- Arctic Core ------------------------------*/ -#ifndef INT_CTRL_H_ -#define INT_CTRL_H_ +#ifndef IRQ_H_ +#define IRQ_H_ -#include "irq.h" +#include "irq_types.h" #include "bit.h" typedef void ( * func_t)(void); @@ -33,12 +33,12 @@ typedef _Bool IsrType; /** * Init the interrupt controller */ -void IntCtrl_Init( void ); +void Irq_Init( void ); /** * End-Of-Interrupt. Called by the OS it wants to clear the interrupt. */ -void IntCtrl_EOI( void ); +void Irq_EOI( void ); /** @@ -48,7 +48,7 @@ void IntCtrl_EOI( void ); * The stack holds C, NVGPR, VGPR and the EXC frame. * */ -void *IntCtrl_Entry( void *stack_p ); +void *Irq_Entry( void *stack_p ); /** * Attach an ISR type 1 to the interrupt controller. @@ -58,7 +58,7 @@ void *IntCtrl_Entry( void *stack_p ); * @param vector * @param prio */ -void IntCtrl_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector, uint8_t prio); +void Irq_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector, uint8_t prio); /** * Attach a ISR type 2 to the interrupt controller. @@ -67,32 +67,32 @@ void IntCtrl_AttachIsr1( void (*entry)(void), void *int_ctrl, uint32_t vector, u * @param int_ctrl The interrupt controller, The is NULL for now. * @param vector The vector to attach to */ -void IntCtrl_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ); +void Irq_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ); /** * Generates a soft interrupt * @param vector */ -void IntCtrl_GenerateSoftInt( IrqType vector ); +void Irq_GenerateSoftInt( IrqType vector ); /** * Get the current priority from the interrupt controller. * @param cpu * @return */ -uint8_t IntCtrl_GetCurrentPriority( Cpu_t cpu); +uint8_t Irq_GetCurrentPriority( Cpu_t cpu); /** * Set the priority in the interrupt controller for vector */ -void IntCtrl_SetPriority( Cpu_t cpu, IrqType vector, uint8_t prio ); +void Irq_SetPriority( Cpu_t cpu, IrqType vector, uint8_t prio ); /** * * @param vector * @param type */ -static inline void IntCtrl_SetIsrType( IrqType vector, IsrType type ) { +static inline void Irq_SetIsrType( IrqType vector, IsrType type ) { Irq_IsrTypeTable[vector + IRQ_INTERRUPT_OFFSET ] = type; } @@ -102,7 +102,7 @@ static inline void IntCtrl_SetIsrType( IrqType vector, IsrType type ) { * @return 0 - Isr1 * 1 - Isr2 */ -static inline IsrType IntCtrl_GetIsrType( IrqType vector ) { +static inline IsrType Irq_GetIsrType( IrqType vector ) { return Irq_IsrTypeTable[vector + IRQ_INTERRUPT_OFFSET ]; } @@ -114,4 +114,4 @@ typedef struct { #endif -#endif /* INT_CTRL_H_ */ +#endif /* IRQ_H_ */ diff --git a/include/os_config_funcs.h b/include/os_config_funcs.h index e8bccec2..2524b0c9 100644 --- a/include/os_config_funcs.h +++ b/include/os_config_funcs.h @@ -12,20 +12,19 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - - /* * This file only be use with the Os_Cfg.c file and os_config_macros.h */ #include "kernel.h" #include "Os_Cfg.h" + +/** @req OS327 */ +#if (OS_SC3 == STD_ON) || (OS_SC4 == STD_ON) +#if (OS_STATUS_STANDARD == STD_ON ) +#error req OS327 not fullfilled +#endif +#endif + // COUNTER, RESOURCE, TSAK, must be at least 1 #define COUNTER_CNT ARRAY_SIZE(counter_list) @@ -80,14 +79,16 @@ trusted_func_t oil_trusted_func_list[SERVICE_CNT]; #endif #endif -/*-----------------------------------------------------------------*/ +/*-----------------------------------------------------------------*/ +#if ( OS_SC3 == STD_ON) || ( OS_SC4==STD_ON) int Oil_GetApplCnt(void) { return APPLICATION_CNT; } -rom_app_t *Oil_GetApplObj( ApplicationType application_id ) { +OsRomApplicationType *Oil_GetApplObj( ApplicationType application_id ) { return &rom_app_list[application_id]; -} +} +#endif /*-----------------------------------------------------------------*/ int Oil_GetTaskCnt(void) { @@ -95,7 +96,7 @@ int Oil_GetTaskCnt(void) { } /*-----------------------------------------------------------------*/ -resource_obj_t *Oil_GetResource( ResourceType resource ) { +OsResourceType *Oil_GetResource( ResourceType resource ) { return &resource_list[resource]; } @@ -105,13 +106,13 @@ int Oil_GetResourceCnt() { /*-----------------------------------------------------------------*/ -counter_obj_t *Oil_GetCounter(CounterType count_id) { +OsCounterType *Oil_GetCounter(CounterType count_id) { return &counter_list[count_id]; } uint32 Oil_GetCounterCnt(void ) { return COUNTER_CNT; -// return sizeof(counter_list)/sizeof(counter_obj_t); +// return sizeof(counter_list)/sizeof(OsCounterType); } /*-----------------------------------------------------------------*/ @@ -119,7 +120,7 @@ uint32 Oil_GetSchedCnt( void ) { return SCHEDULETABLE_CNT; } -sched_table_t *Oil_GetSched( ScheduleTableType sched_id ) { +OsSchTblType *Oil_GetSched( ScheduleTableType sched_id ) { #if defined(SCHEDULETABLE_USE) if(sched_id < SCHEDULETABLE_CNT) { return &sched_list[sched_id]; @@ -137,7 +138,7 @@ uint32 Oil_GetAlarmCnt(void) { return ALARM_CNT; } -alarm_obj_t *Oil_GetAlarmObj( AlarmType alarm_id ) { +OsAlarmType *Oil_GetAlarmObj( AlarmType alarm_id ) { #if defined(ALARM_USE) if( alarm_id < ALARM_CNT) { return &alarm_list[alarm_id]; @@ -164,8 +165,9 @@ StatusType Oil_GetAlarmBase(AlarmType alarm_id, AlarmBaseRefType info) { /*-----------------------------------------------------------------*/ - -message_obj_t *Oil_GetMessage(MessageType message_id) { + +#if 0 +OsMessageType *Oil_GetMessage(MessageType message_id) { #if MESSAGE_CNT!=0 return &message_list[message_id]; #else @@ -176,17 +178,20 @@ message_obj_t *Oil_GetMessage(MessageType message_id) { uint32 Oil_GetMessageCnt(void ) { return MESSAGE_CNT; } +#endif /*-----------------------------------------------------------------*/ - + +#if ( OS_SC3 == STD_ON) || ( OS_SC4 == STD_ON) uint32 Oil_GetServiceCnt( void ) { return SERVICE_CNT; } +#endif /*-----------------------------------------------------------------*/ -void Oil_GetInterruptStackInfo( stack_t *stack ) { +void Oil_GetInterruptStackInfo( OsStackType *stack ) { stack->top = os_interrupt_stack; stack->size = sizeof(os_interrupt_stack); } diff --git a/include/os_config_macros.h b/include/os_config_macros.h index 3b69df58..097cd37a 100644 --- a/include/os_config_macros.h +++ b/include/os_config_macros.h @@ -13,27 +13,21 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - -/* - * Hold macros for the generator - */ #ifndef _OS_CONFIG_MACROS_H #define _OS_CONFIG_MACROS_H #define false 0 #define true 1 + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(_x) (sizeof(_x)/sizeof((_x)[0])) +#endif + // +1 here.. easy to have a reference.. #define GEN_TRUSTEDFUNCTIONS_LIST trusted_func_t os_cfg_trusted_list[SERVICE_CNT]; -#define GEN_APPLICATION_HEAD rom_app_t rom_app_list[] = +#define GEN_APPLICATION_HEAD OsRomApplicationType rom_app_list[] = #define GEN_APPLICATON( _id,_name,_trusted,_startuphook,_shutdownhook, \ _errorhook,_isr_mask,_scheduletable_mask, _alarm_mask, \ @@ -54,11 +48,11 @@ } -#define GEN_TASK_HEAD const rom_pcb_t rom_pcb_list[] = +#define GEN_TASK_HEAD const OsRomPcbType rom_pcb_list[] = -#if !defined(OS_CFG_API_VERSION) +#if !( OS_CFG_API_VERSION) #define GEN_ETASK( _id, _priority, _autostart, _timing_protection, _application_id, _resource_int_p ) \ { \ @@ -96,7 +90,7 @@ #else #define GEN_ETASK( _id, _priority, _autostart, _timing_protection, _application_id, \ - _resource_int_p, _scheduling, _resource_mask, _activation ) \ + _resource_int_p, _scheduling, _resource_mask ) \ { \ .pid = TASK_ID_##_id, \ .name = #_id, \ @@ -110,8 +104,8 @@ .application_id = _application_id, \ .resource_int_p = _resource_int_p, \ .scheduling = _scheduling, \ - .resourceAccess = _resource_mask \ - .activationLimit = _activation, \ + .resourceAccess = _resource_mask, \ + .activationLimit = 1, \ } #define GEN_BTASK( _id, _priority, _autostart, _timing_protection, _application_id, \ @@ -174,9 +168,10 @@ .vector = _vector, \ } -#define GEN_PCB_LIST() uint8_t pcb_list[PCB_T_SIZE*ARRAY_SIZE(rom_pcb_list)]; +//#define GEN_PCB_LIST() uint8_t pcb_list[PCB_T_SIZE*ARRAY_SIZE(rom_pcb_list)]; +#define GEN_PCB_LIST() OsPcbType pcb_list[ARRAY_SIZE(rom_pcb_list)]; -#define GEN_RESOURCE_HEAD resource_obj_t resource_list[] = +#define GEN_RESOURCE_HEAD OsResourceType resource_list[] = #define GEN_RESOURCE( _id, _type, _ceiling_priority, _application_id, _task_mask) \ { \ .nr= _id, \ @@ -212,7 +207,7 @@ * NOT USED. Set to 0 */ -#define GEN_COUNTER_HEAD counter_obj_t counter_list[] = +#define GEN_COUNTER_HEAD OsCounterType counter_list[] = #define GEN_COUNTER( _id, _name, _type, _unit, \ _maxallowedvalue, \ _ticksperbase, \ @@ -223,11 +218,14 @@ .unit = _unit, \ .alarm_base.maxallowedvalue = _maxallowedvalue, \ .alarm_base.tickperbase = _ticksperbase, \ - .alarm_base.mincycle = _mincycle, \ - .driver.OsGptChannelRef = _gpt_ch \ + .alarm_base.mincycle = _mincycle, \ } +#if 0 + // For now... + .driver.OsGptChannelRef = _gpt_ch +#endif -#define GEN_ALARM_HEAD alarm_obj_t alarm_list[] = +#define GEN_ALARM_HEAD OsAlarmType alarm_list[] = /** * _id @@ -293,7 +291,7 @@ }, \ } -#define GEN_SCHEDULETABLE_HEAD sched_table_t sched_list[] = +#define GEN_SCHEDULETABLE_HEAD OsSchTblType sched_list[] = #define GEN_SCHEDULETABLE( _id, _name, _counter, _repeating, _length, _application_mask, \ _action_cnt, _action_expire_ref, \ _autostart_active, _autostart_type, _autostart_rel_offset, _autostart_appmode, \ @@ -321,16 +319,29 @@ .maxRetard = _adj_max_retard, \ } \ } - + +#if ( OS_SC3 == STD_ON) || ( OS_SC4 == STD_ON) #define GEN_HOOKS( _startup, _protection, _shutdown, _error, _pretask, _posttask ) \ -struct os_conf_global_hooks_s os_conf_global_hooks = { \ - .StartupHook = _startup, \ - .ProtectionHook = _protection, \ +struct OsHooks os_conf_global_hooks = { \ + .StartupHook = _startup, \ + .ProtectionHook = _protection, \ .ShutdownHook = _shutdown, \ .ErrorHook = _error, \ .PreTaskHook = _pretask, \ .PostTaskHook = _posttask, \ }; +#else +#define GEN_HOOKS( _startup, _protection, _shutdown, _error, _pretask, _posttask ) \ +struct OsHooks os_conf_global_hooks = { \ + .StartupHook = _startup, \ + .ShutdownHook = _shutdown, \ + .ErrorHook = _error, \ + .PreTaskHook = _pretask, \ + .PostTaskHook = _posttask, \ +}; + +#endif + #define GEN_IRQ_VECTOR_TABLE_HEAD \ void * Irq_VectorTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] = @@ -354,6 +365,16 @@ struct os_conf_global_hooks_s os_conf_global_hooks = { \ #undef MESSAGE_CNT #undef EVENT_CNT #undef SERVICE_CNT + +/* + * OsOs container + */ +#define OS_SC1 STD_ON /* | OS_SC2 | OS_SC3 | OS_SC4 */ +#define OS_STACK_MONITORING STD_ON +#define OS_STATUS_EXTENDED STD_ON /* OS_STATUS_STANDARD */ +#define OS_USE_GET_SERVICE_ID STD_ON +#define OS_USE_PARAMETER_ACCESS STD_ON +#define OS_RES_SCHEDULER STD_ON #endif diff --git a/include/ppc/Cpu.h b/include/ppc/Cpu.h index ad516446..2c6edbc4 100644 --- a/include/ppc/Cpu.h +++ b/include/ppc/Cpu.h @@ -125,7 +125,14 @@ #define msync() asm volatile(" msync"); #define Irq_Disable() asm volatile (" wrteei 0"); -#define Irq_Enable() asm volatile (" wrteei 1"); +#define Irq_Enable() asm volatile (" wrteei 1"); + +#define Irq_SuspendAll() Irq_Disable() +#define Irq_ResumeAll() Irq_Enable() + +#define Irq_SuspendOs() Irq_Disable() +#define Irq_ResumeOs() Irq_Enable() + /*-----------------------------------------------------------------*/ diff --git a/include/xtoa.h b/include/xtoa.h index 823f56c1..441f2348 100644 --- a/include/xtoa.h +++ b/include/xtoa.h @@ -13,20 +13,6 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - -/* - * xtoa.h - * - * Created on: May 3, 2009 - * Author: mahi - */ - #ifndef XTOA_H_ #define XTOA_H_ diff --git a/makefile b/makefile index 58cb70a7..76a53783 100644 --- a/makefile +++ b/makefile @@ -35,7 +35,8 @@ USE_DBG_PRINTF?=y Q?=@ export Q export TOPDIR = $(CURDIR) -export RELEASE = n +export CFG_RELEASE = n +export CFG_DEBUG = y export PATH ifneq ($(filter clean_all,$(MAKECMDGOALS)),clean_all) @@ -47,9 +48,6 @@ endif USE_T32_SIM?=n export USE_T32_SIM -export BUILD_TREE=y -export RELEASE_TREE=n - override BDIR := system/kernel ${BDIR} # Tools diff --git a/readme.txt b/readme.txt index 731b5bcf..c4c5a7af 100644 --- a/readme.txt +++ b/readme.txt @@ -1,4 +1,40 @@ +GOAL: + Implement Autosar OS scalability Class 1 + +Limitations: + Only extended error checking is used (Scalbility class 3 and 4) + +Ongoing: + - Autostart of tasks does not work + - + +Bugs: +- OsIsrResourceRef ? + +APIs for the OS: +Os.h - External API for OS +internal.h - Internal Kernel ONLY. +kernel.h - Types shared between kernel and config + +Do we really want to have Os_Cfg.h when compiling the kernel? + os_config_macros.h + os_config_funcs.h + +Add file: os_config_if.h (used only by the kernel) + extern int Oil_GetResourceCnt(); + OsCfg_GetResourceCnt() + +internal.h + OsStack_IsEndMarkOk() + +kernel.h + types that are not in it's own header file. + + +=========== OLD =========== + + Urgent: Problems with paths and stuff: - New project diff --git a/scripts/cc_gcc.mk b/scripts/cc_gcc.mk index 4e34720d..d9039a8c 100644 --- a/scripts/cc_gcc.mk +++ b/scripts/cc_gcc.mk @@ -14,7 +14,8 @@ endif # CCFLAGS - compile flags CC = $(CROSS_COMPILE)gcc -cflags-y += -O0 +cflags-$(CFG_RELEASE) += -O3 +cflags-$(CFG_DEBUG) += -O0 #cflags-y += -O0 #cflags-y += -O3 diff --git a/scripts/guess_cc.sh b/scripts/guess_cc.sh index f706f89f..396fbc04 100644 --- a/scripts/guess_cc.sh +++ b/scripts/guess_cc.sh @@ -1,4 +1,8 @@ #/bin/bash +# +# Tries to get a compiler depending on SHELL/OS. On Windows it defaults +# to CodeSourcery installed at c:\devtools\Codesourcery\ +# UNAME=`uname` echo $UNAME @@ -8,32 +12,32 @@ if [ "$ARCH" == "PPC" ]; then if test x${UNAME:0:7} = xMINGW32; then COMPILER=/c/devtools/Codesourcery/freescale-4.3/bin/powerpc-eabi- elif test x${UNAME:0:9} = xCYGWIN_NT; then - COMPILER=/cygdrive/c/devtools/Codesourcery/freescale-4.3/bin/powerpc-eabi- + COMPILER=/cygdrive/c/devtools/Codesourcery/freescale-4.3/bin/powerpc-eabi- elif test x${UNAME:0:5} = xDarwin; then COMPILER=/opt/powerpc-eabi/bin/powerpc-eabi- else echo No default path for $UNAME set. Quitting. - fi -elif [ "$ARCH" == "ARM" ]; then + fi +elif [ "$ARCH" == "ARM" ]; then if test x${UNAME:0:7} = xMINGW32; then COMPILER=/c/devtools/Codesourcery/arm-2009q1/bin/arm-none-eabi- elif test x${UNAME:0:9} = xCYGWIN_NT; then - COMPILER=/cygdrive/c/devtools/Codesourcery/arm-2009q1/bin/arm-none-eabi- + COMPILER=/cygdrive/c/devtools/Codesourcery/arm-2009q1/bin/arm-none-eabi- elif test x${UNAME:0:5} = xDarwin; then - COMPILER=/opt/arm-elf/bin/arm-none-eabi- + COMPILER=/opt/arm-elf/bin/arm-none-eabi- else echo No default path for $UNAME set. Quitting. - fi -else + fi +else echo baaaad fi -if [ -f ${COMPILER}gcc ]; then +if [ -f ${COMPILER}gcc ]; then echo Using compiler: ${COMPILER} -else +else echo ${COMPILER} does not exist... - exit 1 -fi + exit 1 +fi -export CROSS_COMPILE=$COMPILER +export CROSS_COMPILE=$COMPILER diff --git a/scripts/req-os.xlsx b/scripts/req-os.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..05334fafcbfad1fd111a7e4db0f6e284c7a23e36 GIT binary patch literal 33785 zcmeFXbyQc|w?0gFmvl>)geZ-4OLs|kcZVRQbV+w3-6h?nbV_$O$Zvnp<2mPk?;Yd) z>;30mhcbrFz1EuZna_OY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ZruV8ecTIVtrl5YvN*e1qFwJD-N?3C%BZaXA9>i&W;WD4DomC(sc2fVcz&`$vEDT z0yTYA`Yg)40i6$xrFT`MIfy6hu=seS@WU!GcUPL{aL~Wyz?5<$SZ9I4CYRU!4Xfqh zip>j*ul?KZO=gu3oAUMJ>Yc#HsrY9AgM!h2%$QIhFdy#_gE&?sK!tsT@b?ew=|7OC z|GsGp+uJ#t+Bxg1csQ6k>HZ_86{P>&;NMB&|0?hPxGMDj=8FF*{CBwWzX}gN_T~SM zTK?1LPk!#-PBI_eWd5M({we;G`1-ea;iK2ghxkwa>z@XHQtN4E4|Tv-3xx&4#e_4mHeWByl{ztXNh_vO#-J%78{ z^Ze!VcQ2nmrGGXy`CIz2)bJla!|Bg9Cx1Hpd4u-11FXwm4*zny_NVsGr2KEKqT65E zKT`BR^?&B5f9nI>|I+_Q#`>qjzb7_->p?(bzk-1LN1F4e{NLxNf0aXf|BL*8W-A40 W$d3!}A2S&;2;K+re8~47ul^667D%4} literal 0 HcmV?d00001 diff --git a/scripts/req-os.xml b/scripts/req-os.xml new file mode 100644 index 00000000..87d65394 --- /dev/null +++ b/scripts/req-os.xml @@ -0,0 +1,2059 @@ + + + + 1,2,3,4 + code + code + The Operating System shall only allow Alarm Callbacks in Scalability Class +1. + + + 1,2,3,4 + code + code + The OS shall not define the symbol LOCALMESSAGESONLY + + + 1,2,3,4 + code + code + If in a call to SetRelAlarm() the parameter “increment” is set to zero, the +service shall return E_OS_VALUE in standard and extended status . + + + 1,2,3,4 + code + code + The first call to StartOS() (for starting the Operating System) shall not +return. + + + 1,2,3,4 + code + code + If ShutdownOS() is called and ShutdownHook() returns then the operating +system shall disable all interrupts and enter an endless loop. + + + 1,2,3,4 + code + code + The Operating System shall provide the services DisableAllInterrupts(), +EnableAllInterrupts(), SuspendAllInterrupts(), ResumeAllInterrupts() +prior to calling StartOS() and after calling ShutdownOS(). (It is assumed that the +static variables of these functions are initialized). + + + 1,2,3,4 + code + code + The Operating System shall provide the ability to increment a software +counter as an alternative action on alarm expiry. + + + 1,2,3,4 + code + code + The OS shall provide an API call to increment a software counter. + + + 1,2,3,4 + code + code + The Operating System shall handle all the initialization and configuration of +timers used directly by the OS and not handled by the GPT driver. + + + 1,2,3,4 + code + code + The Operating System shall provide a service to read the current count value +of a counter (returning either the hardware timer ticks if counter is driven by hardware +or the software ticks when user drives counter). + + + 1,2,3,4 + code + code + The Operating System shall provide a service to get the number of ticks +between the current tick value and a previously read tick value. + + + 1,2,3,4 + code + code + The Operating System shall adjust the read out values of hardware timers +(which drive counters) in such that the lowest value is zero and consecutive reads +return an increasing count value until the timer wraps at its modulus. + + + 1,2,3,4 + code,generator + code + A schedule table shall have at least one expiry point + + + 1,2,3,4 + code,generator + code + An expiry point shall contain a (possibly empty) set of tasks to activate. + + + 1,2,3,4 + code,generator + code + An expiry point shall contain a (possibly empty) set of events to set. + + + 1,2,3,4 + code,generator + code + An expiry point shall contain an offset in ticks from the start of the schedule +table. + + + 1,2,3,4 + code,generator + code + An expiry point shall activate at least one task OR set at least one event + + + 1,2,3,4 + code,generator + code + Each expiry point on a given schedule table shall have a unique offset. + + + 1,2,3,4 + code,generator + code + The Initial Offset shall be zero OR in the range OsCounterMinCycle .. +OsCounterMaxAllowedValue of the underlying counter. + + + 1,2,3,4 + code,generator + code + The delay between adjacent expiry points shall be in the range +OsCounterMinCycle .. OsCounterMaxAllowedValue of the underlying counter. + + + 1,2,3,4 + code,generator + code + The value of Final Delay shall be in the range OsCounterMinCycle .. +OsCounterMaxAllowedValue of the underlying counter. + + + 1,2,3,4 + code + code + The OS shall drive an iterator over schedule table expiry points, processing +each expiry point from the InitialExpiryPoint to the FinalExpiryPoint in order of +increasing offset. + + + 1,2,3,4 + code + code + The Operating System shall permit multiple schedule tables to be processed +concurrently. + + + 1,2,3,4 + code + code + A schedule table shall be driven by exactly one counter. + + + 1,2,3,4 + code + code + The Operating System shall be able to process at least one schedule table +per counter at any given time. + + + 1,2,3,4 + code + code + One tick on the counter shall correspond to one tick on the schedule table. + + + 1,2,3,4 + code + code + The OS shall process all task activations on an expiry point first and then set +events. + + + 1,2,3,4 + code,generator + code + The schedule table shall be configurable as either single-shot or repeating. + + + 1,2,3,4 + code + code + If the schedule table is single-shot, the Operating System shall stop the +processing of the schedule table Final Delay ticks after the Final Expiry Point is processed. + + + 1,2,3,4 + code + code + The Operating System shall allow the Final Delay for a single-shot schedule +table to be zero. + + + 1,2,3,4 + code + code + If the schedule table is repeating, the Operating System shall process the +Initial Expiry Point Final Delay plus Initial Offset ticks have elapsed after processing +the Final Expiry Point. + + + 1,2,3,4 + code + code + The Operating System shall provide a service to start the processing of a +schedule table at an absolute value “Start” on the underlying counter. (The Initial Expiry Point shall be processed when the value of the underlying counter equals Start + InitialOffset). + + + 1,2,3,4 + code + code + The Operating System shall provide a service to start the processing of a +schedule table at “Offset” relative to the “Now” value on the underlying counter (The +Initial Expiry Point shall be processed when the value of the underlying counter +equals Now + Offset + InitialOffset). + + + 1,2,3,4 + code + code + The Operating System shall provide a service to cancel the processing of a +schedule table immediately at any point while the schedule table is running. + + + 1,2,3,4 + code + code + If schedule table processing has been cancelled before reaching the Final +Expiry Point and is subsequently restarted then OS358/OS347 means that the re-start occurs from the start of the schedule table. + + + 1,2,3,4 + code + code + The Operating System shall provide a service to switch the processing from +one schedule table to another schedule table. + + + 1,2,3,4 + code + code + When a schedule table switch is requested, the OS shall continue to process +expiry points on the current schedule table up and including the Final Expiry Point hen delay for Final Delay ticks before processing the Initial Expiry Point on the switched-to schedule table (after the initial offset). + + + 1,2,3,4 + code + code + The Operating System shall provide a service to query the state of a +schedule table + + + 2,4 + code + code + The Operating System shall provide the ability to synchronize the processing +of schedule table to known counter values. + + + 2,4 + code + code + A schedule table that is implicitly synchronized shall have a Duration equal to +OsCounterMaxAllowedValue + 1 of its associated OSEK OS counter. + + + 2,4 + code + code + The OS shall prevent a schedule table that is implicitly synchronized from +being started at a relative count value. + + + 2,4 + code + code + A schedule table that is explicitly synchronized shall have a duration +no greater than modulus of the drive counter. + + + 2,4 + code + code + A schedule table that is explicitly synchronized shall have a duration +equal to the modulus of the synchronization counter. + + + 2,4 + code + code + The synchronization counter shall have the same resolution as the +drive counter associated with the schedule table. This means that a tick on the schedule table has the same duration as a tick on the synchronization counter. + + + 2,4 + code + code + An explicitly synchronized schedule table started at an absolute or relative +counter value shall have state “running” when the service call returns. + + + 2,4 + code + code + The Operating system shall provide a service to start an explicitly +synchronized schedule table. The Initial Expiry Point will be processed after (Duration – Value) + Initial Offset ticks of the driver counter have elapsed where Value is the absolute value of the synchronization count provided to the schedule table. + + + 2,4 + code + code + An explicitly synchronized schedule table started synchronously shall have +state “waiting” when the service call returns. + + + 2,4 + code + code + The Operating System shall provide a service to provide the schedule table +with a synchronization count and start synchronization. + + + 2,4 + code + code + An expiry point shall permit the configuration of a OsScheduleTableMaxRetard that defines the maximum number of ticks that can be subtracted from expiry point offset. + + + 2,4 + code + code + An expiry point shall permit the configuration of a OsScheduleTableMaxAdvance that defines the maximum number of ticks that can be added to expiry point offset. + + + 2,4 + code + code + The value of (Offset - OsScheduleTableMaxRetard ) of an expiry point shall +be greater than (Offset + OsCounterMinCycle) of the pervious expiry point. + + + 2,4 + code + code + The value of (Offset+OsScheduleTableMaxAdvance) of an expiry point shall +be less than the duration of the schedule table. + + + 1,2,3,4 + code + code + A schedule table shall define a precision bound with a value in the range 0 +to duration. + + + 2,4 + code + code + When a new synchronization count is provided, the Operating System shall +calculate the current deviation between the explicitly synchronized scheduled table and the synchronization count. + + + 2,4 + code + code + The OS shall start to synchronise an explicitly synchronized schedule table +after a synchronization count is provided. + + + 2,4 + code + code + The OS shall set the state of an explicitly synchronized schedule table to +“running and synchronous” if the absolute value of the deviation between schedule table value the synchronization count is less than the configured +OsScheduleTblExplicitPrecision threshold. + + + 1,2,3,4 + code + code + The OS shall set the state of an explicitly synchronized schedule table to +“running” if the absolute value of the deviation between schedule table value the synchronization count is greater than or equal to the configured +OsScheduleTblExplicitPrecision threshold. + + + 1,2,3,4 + code + code + If the deviation is negative and the next expiry point is adjustable then the +OS shall set the delay to the next expiry point to +Delay+min(OsScheduleTableMaxAdvance,Deviation) + + + 1,2,3,4 + code + code + If the deviation is positive and the next expiry point is adjustable then the OS +shall set the delay to the next expiry point to Delay- +min(OsScheduleTableMaxRetard, Deviation) + + + 1,2,3,4 + code + code + The OS shall provide a service to cancel synchronization being performed at +adjustable expiry points on a schedule table. + + + 1,2,3,4 + code + code + The Operating System shall extend the service from OS359 to query the +state of a schedule table with respect to synchronization. + + + 1,2,3,4 + code,generator + code + The Operating System shall offer a stack monitoring which detects possible +stack faults of Task(s)/Category 2 OsIsr(s). + + + 1,2,3,4 + code + code + If a stack fault is detected by stack monitoring AND the configured scalability +class is 1 or 2, the Operating System shall call the ShutdownOS() service with the status E_OS_STACKFAULT. + + + 1,2,3,4 + code + code + If a stack fault is detected by stack monitoring AND the configured scalability +class is 3 or 4, the Operating System shall call the ProtectionHook() with the +status E_OS_STACKFAULT. + + + 1,2,3,4 + code + code + The Operating System shall support OS-Applications which are a +composition of (at least one Task OR OsIsr) AND (zero or more Alarms, Schedule tables, Counters or Resources) AND (zero or one hooks for startup, error and shutdown). + + + 3,4 + code + code + The Operating System shall support the notion of trusted and not trustet OS- +Applications. + + + ,3,4 + code + code + Trusted OS-Applications may offer services (“trusted services”) to other +(even non-trusted) OS-Applications. + + + 3,4 + code + code + The Operating System shall provide a service to determine the currently +running OS-Application (a unique identifier shall be allocated to each application). + + + 3,4 + code + code + The Operating System shall provide a service to determine to which OS- +Application a given Task, OsIsr, Resource, Counter, Alarm or Schedule Table +belongs. + + + 3,4 + code + code + The Operating System shall provide a service to determine which OS- +Applications are allowed to use the IDs of a Task, OsIsr, Resource, Counter, Alarm or Schedule Table in API calls. + + + 3,4 + code + code + The Operating System shall provide a service to terminate the OS- +Application to which the calling Task/Category 2 OsIsr/application specific error hook belongs. (This is an OS-Application level variant of the TerminateTask() service) + + + 3,4 + code + code + Terminating an OS-Application means to: +- terminate all running, ready and waiting Tasks/OsIsrs of the OS-Application +AND +- disabling all interrupts of the OS-Application AND +- stop all active alarms of the OS-Applications AND +- stop all schedule tables of the OS-Application. + + + 3,4 + code + code + OS-Applications, trusted or non-trusted, shall by default have only access +rights to objects belonging to this OS-Application. Access rights from other OS-Applications shall be granted explicitely by configuration. + + + 3,4 + code + code + The Operating System shall prevent write access to its own data sections +and its own stack from non-trusted OS-Applications. + + + 3,4 + code + code + The Operating System may prevent read access to an OS-Application’s data +section attempted by other non-trusted OS-Applications. + + + 3,4 + code + code + The Operating System shall permit an OS-Application read and write access +to that OS-Application’s own private data sections. + + + 3,4 + code + code + The Operating System shall prevent write access to the OS-Application’s +private data sections from other non-trusted OS-Applications. + + + 3,4 + code + code + The Operating System shall permit a Task/Category 2 OsIsr read and write +access to that Task’s/Category 2 OsIsr’s own private stack. + + + 3,4 + code + code + The Operating System may prevent write access to the private stack of +Tasks/Category 2 OsIsrs of a non-trusted application from all other Tasks/OsIsrs in the same OS-Application. + + + 3,4 + code + code + The Operating System shall prevent write access to all private stacks of +Tasks/Category 2 OsIsrs of an OS-Application from other non-trusted OS- +Applications. + + + 3,4 + code + code + The Operating System shall permit a Task/Category 2 OsIsr read and write +access to that Task’s/Category 2 OsIsr’s own private data sections. + + + 3,4 + code + code + The Operating System may prevent write access to the private data sections +of a Task/Category 2 OsIsr of a non-trusted application from all other Tasks/OsIsrs in the same OS-Application. + + + 3,4 + code + code + The Operating System shall prevent write access to all private data sections +of a Task/Category 2 OsIsr of an OS-Application from other non-trusted OS- +Applications. + + + 3,4 + code + code + The Operating System may provide an OS-Application the ability to protect +its code sections against executing by non-trusted OS-Applications. + + + 3,4 + code + code + The Operating System shall provide the ability to provide shared library code +in sections that are executable by all OS-Applications. + + + 3,4 + code + code + The Operating System shall permit trusted OS-Applications read and write +access to peripherals. + + + 3,4 + code + code + The Operating System shall allow non-trusted OS-Applications to write to +their assigned peripherals only (incl. reads that have the side effect of writing to a memory location). + + + 3,4 + code + code + If a memory access violation is detected, the Operating System shall call the +Protection Hook with status code E_OS_PROTECTION_MEMORY. + + + 3,4 + code + code + In a non-trusted OS-Application, the Operating System shall apply timing +protection to every Task/Category 2 OsIsr of this non-trusted OS-Application. + + + 2,4 + code + code + In a trusted OS-Application, the Operating System shall offer the ability to +apply timing protection to Tasks/Category 2 OsIsrs of this OS-Application. + + + 2 + code + code + If no OS-Application is configured, the Operating System shall be able to +apply timing protection to Tasks/Category 2 OsIsrs. + + + 2,4 + code + code + If a task’s OsTaskExecutionBudget is reached then the Operating System +shall call the ProtectionHook() with E_OS_PROTECTION_TIME. + + + 2,4 + code + code + The Operating System shall reset a task’s OsTaskExecutionBudget on a +transition to the SUSPENDED or WAITING states. + + + 2,4 + code + code + The Operating System shall limit the inter-arrival time of tasks to one per +OsTaskTimeFrame. + + + 2,4 + code + code + The Operating System shall start an OsTaskTimeFrame when a task is +activated successfully. + + + 2,4 + code + code + The Operating System shall start an OsTaskTimeFrame when a task is +released successfully. + + + 2,4 + code + code + If an attempt is made to activate a task before the end of an +OsTaskTimeFrame then the Operating System shall not perform the activation AND +shall call the ProtectionHook() with E_OS_PROTECTION_ARRIVAL. + + + 2,4 + code + code + If an attempt is made to release a task before the end of an +OsTaskTimeFrame then the Operating System shall not perform the release AND +shall call the ProtectionHook() with E_OS_PROTECTION_ARRIVAL. + + + 2,4 + code + code + If a Category 2 OsIsr’s OsIsrExecutionBudget is reached then the Operating +System shall call the ProtectionHook() with E_OS_PROTECTION_TIME. + + + 2,4 + code + code + The Operating System shall rest an OsIsr’s OsIsrExecutionBudget when the +OsIsr returns control to the Operating terminates. + + + 2,4 + code + code + The Operating System shall limit the inter-arrival time of Category 2 OsIsrs to +one per OsIsrTimeFrame. + + + 2,4 + code + code + The Operating System shall measure the start of an OsIsrTimeFrame from +the point at which it recognises the interrupt (i.e. in the Operating System interrupt +wrapper). + + + 2,3,4 + code + code + If Category 2 interrupt occurs before the end of the OsIsrTimeFrame then the +Operating System shall not execute the user provided OsIsr AND shall call the ProtectionHook() with E_OS_PROTECTION_ARRIVAL. + + + 2,3,4 + code + code + If a Task/Category 2 OsIsr holds an OSEK Resource and exceeds the +Os[Task|Isr]ResourceLockBudget, the Operating System shall call the +ProtectionHook() with E_OS_PROTECTION_LOCKED. + + + 2,3,4 + code + code + If a Task/Category 2 OsIsr disables interrupts (via +Suspend/Disable|All/OS|Interrupts()) and exceeds the configured +Os[Task|Isr][All|OS]InterruptLockBudget, the Operating System shall call the +ProtectionHook() with E_OS_PROTECTION_LOCKED. + + + 3,4 + code + code + If an invalid address (address is not writable by this OS-Application) is +passed as an out-parameter to an OS service, the Operating System shall return the +status code E_OS_ILLEGAL_ADDRESS. + + + 3,4 + code + code + If an OS-Application makes a service call from the wrong context AND is +currently not inside a Category 1 OsIsr the Operating System shall not perform the requested action (the service call shall have no effect), and return E_OS_CALLEVEL or the “invalid value” of the service. + + + 1,2,3,4 + code + code + If a task returns from its entry function without making a TerminateTask() +or ChainTask() call, the Operating System shall terminate the task (and call the +PostTaskHook() if configured). + + + 1,2,3,4 + code + code + If a task returns from its entry function without making a TerminateTask() or +ChainTask() call AND the error hook is configured, the Operating System shall call the ErrorHook() (this is done regardless of whether the task causes other errors, e.g. E_OS_RESOURCE) with status E_OS_MISSINGEND before the task leaves the RUNNING state. + + + 1,2,3,4 + code + code + If a task returns from the entry function without making a TerminateTask() +or ChainTask() call and still holds OSEK Resources, the Operating System shall release them. + + + 1,2,3,4 + code + code + If a task returns from the entry function without making a TerminateTask() +or ChainTask() call and interrupts are still disabled, the Operating System shall enable them. + + + 1,2,3,4 + code + code + If a Category 2 OsIsr calls DisableAllInterupts() / +SuspendAllInterrupts() / SuspendOSInterrupts() and ends (returns) without +calling the corresponding EnableAllInterrupts() / ResumeAllInterrupts() / +ResumeOSInterrupts(), the Operating System shall perform the missing service and shall call the ErrorHook() (if configured) with the status E_OS_DISABLEDINT. + + + 1,2,3,4 + code + code + If a Category 2 OsIsr calls GetResource() and ends (returns) without calling +the corresponding ReleaseResource(), the Operating System shall perform the ReleaseResource() call and shall call the ErrorHook() (if configured) with the status E_OS_RESOURCE. + + + 1,2,3,4 + code + code + If the PostTaskHook() is configured, the Operating System shall not call the +hook if ShutdownOS() is called + + + 1,2,3,4 + code + code + If EnableAllInterrupts() / ResumeAllInterrupts() / +ResumeOSInterrupts() are called and no corresponding DisableAllInterupts() +/ SuspendAllInterrupts() / SuspendOSInterrupts() was done before, the +Operating System shall not perform this OS service. + + + 1,2,3,4 + code + code + If interrupts are disabled/suspended by a Task/OsIsr and the Task/OsIsr +calls any OS service (excluding the interrupt services) then the Operating System shall ignore the service AND shall return E_OS_DISABLEDINT if the service returns a StatusType value. + + + 3,4 + code + code + The Operating System shall ignore calls to ShutdownOS() from non-trusted +OS-Applications. + + + 3,4 + code + code + If an OS-object identifier is the parameter of a system service, and no +sufficient access rights have been assigned at configuration time (Parameter +Os[...]AccessingApplication) to the calling Task/Category 2 OsIsr, the system +service shall return E_OS_ACCESS. + + + 3,4 + code + code + CheckTaskMemoryAccess and CheckIsrMemoryAccess check the memory +access. Memory access checking is possible for all OS-Applications and from all OS- +Applications and does not need granted rights (This is an exception to OS056). + + + 3,4 + code + code + CheckObjectAccess checks the access rights for OS objects. Checking +object access is possible for all OS-Applications and from all OS-Applications and +does not need granted rights (This is an exception to OS056). + + + 3,4 + code + code + If supported by hardware, the Operating System shall execute non-trusted +OS-Applications in non-privileged mode. + + + 3,4 + code + code + As far as supported by hardware, the Operating System shall not allow non- +trusted OS-Applications to access control registers managed by the Operating +System. + + + 3,4 + code + code + If an instruction exception occurs (e.g. division by zero) the operating system +shall call the protection hook with E_OS_PROTECTION_EXCEPTION. + + + 3,4 + code + code + The Operating System shall allow to export services from trusted OS- +Applications. + + + 3,4 + code + code + The Operating System shall provide a mechanism to call a trusted function +from a (trusted or non-trusted) OS-Application. + + + 3,4 + code + code + If a called trusted function is not configured the Operating System shall call +the ErrorHook with E_OS_SERVICEID. + + + 3,4 + code + code + The Operating System shall offer OS-Applications a service to check if a +memory region is write/read/execute accessible from a Task/Category 2 OsIsr and +also return information if the memory region is part of the stack space. + + + 3,4 + code + code + The Operating System shall execute the ProtectionHook() with the same +permissions as the Operating System. + + + 2,3,4 + code + code + The Operating System shall perform one of the following reactions +depending on the return value of the ProtectionHook(): +o Do nothing +o Forcibly terminate the faulty Task/Category 2 OsIsr OR +o Forcibly terminate the faulty OS-Application OR +o Forcibly terminate the faulty OS-Application and restart the OS- +Application. OR +o Call ShutdownOS(). + + + 2,3,4 + code + code + If no ProtectionHook() is configured and a protection error occurs, the +Operating System shall call ShutdownOS(). + + + 2,3,4 + code + code + If the reaction is to do nothing and the ProtectionHook() was not called with +E_OS_PROTECTION_ARRIVAL then the Operating System shall call ShutdownOS() + + + 3,4 + code + code + If the reaction is to forcibly terminate the Task/Category 2 OsIsr and no Task +or OsIsr can be associated with the error, the running OS-Application is forcibly +terminated by the Operating System. + + + 3,4 + code + code + If the reaction is to forcibly terminate the faulty OS-Application and no OS- +Application can be assigned, ShutdownOS()is called. + + + 3,4 + code + code + If the Operating System forcibly terminates a task, it terminates the task (no +PostTaskHook() for the task will be called), releases all allocated OSEK resources +and calls EnableAllInterrupts()/ ResumeOSInterrupts() / +ResumeAllInterrupts() if the Task called DisableAllInterrupts() / +SuspendOSInterrupts() / SuspendAllInterrupts() before without the +corresponding EnableAllInterrupts()/ ResumeOSInterrupts() / +ResumeAllInterrupts() call. + + + 3,4 + code + code + If the Operating System forcibly terminates an interrupt service routine, it +clears the interrupt request, aborts the interrupt service routine (The interrupt source +stays in the current state.) and releases all OSEK resources the interrupt service +routine has allocated and calls EnableAllInterrupts() / ResumeOSInterrupts() / +ResumeAllInterrupts() if the interrupt called DisableAllInterrupts() / +SuspendOSInterrupts() / SuspendAllInterrupts() before without the +corresponding EnableAllInterrupts()/ ResumeOSInterrupts() / +ResumeAllInterrupts() call. + + + 3,4 + code + code + If the Operating System forcibly terminates an OS-Application, it: +o forcibly terminates all Tasks/OsIsrs of the OS-Application AND +o cancels all alarms of the OS-Application AND +o stops schedule tables of the OS-Application AND +o disables interrupt sources of Category 2 OsIsrs belonging to the OS- +Application + + + 3,4 + code + code + When the Operating System restarts an OS-Application it activates the +configured OsRestartTask. + + + 1,2,3,4 + none + inspection + If an implementation of a lower scalability class supports features of higher +classes then the interfaces for the features must comply with this specification. + + + 1,2,3,4 + none + inspection + The operating system shall support the features according to the configured +scalability class. (See Tab. 2) + + + 1,2,3,4 + code + code + The operating system shall always use extended status in Scalability Class 3 +and 4. + + + 1,2,3,4 + code + code + The Operating System shall offer the OSEK error macros (OSError…()) to all +configured error hooks AND there shall be two (like in OIL) global configuration +parameter to switch these macros on or off. + + + 3,4 + code + code + If an application-specific startup hook is configured for an OS-Application +<App>, the Operating System shall call StartupHook_<App> on startup of the OS. + + + 3,4 + code + code + The Operating System shall execute an application-specific startup hook with +the access rights of the associated OS-Application. + + + 3,4 + code + code + If both a system-specific and one (or more) application specific startup +hook(s) are configured, the Operating System shall call the system-specific startup +hook before the application-specific startup hook(s). + + + 3,4 + code + code + If an application-specific shutdown hook is configured for an OS-Application +<App>, the Operating System shall call ShutdownHook_<App> on shutdown of the +OS. + + + 3,4 + code + code + The Operating System shall execute an application-specific shutdown hook +with the access rights of the associated OS-Application. + + + 3,4 + code + code + If both a system-specific and one (or more) application specific shutdown +hook(s) are configured, the Operating System shall call the system-specific shutdown +hook after the application-specific shutdown hook(s). + + + 3,4 + code + code + When an error occurs AND an application-specific error hook is configured +for the faulty OS-Application <App>, the Operating System shall call that application- +specific error hook ErrorHook_<App> after the system specific error hook is called (if +configured). + + + 3,4 + code + code + The Operating System shall execute an application-specific error hook with +the access rights of the associated OS-Application. + + + 1,2,3,4 + code + code + Operating System services which do not return a StatusType shall not raise +the error hook(s). + + + 3,4 + code + code + GetApplicationID() shall return the application identifier to which +the executing Task/OsIsr/hook belongs. + + + 3,4 + code + code + If no OS-Application is running, GetApplicationID() shall return +INVALID_OSAPPLICATION. + + + 1,2,3,4 + code + code + If called from category 2 OsIsr (or Hook routines called inside a category +2 OsIsr), GetISRID() shall return the identifier of the currently executing OsIsr. + + + 1,2,3,4 + code + code + If its caller is not a category 2 OsIsr (or Hook routines called inside a category 2 OsIsr), +GetISRID() shall return INVALID_ISR. + + + 3,4 + code + code + If <FunctionIndex> is a defined function index, +CallTrustedFunction() shall switch the processor into privileged mode AND +shall call the function <FunctionIndex> out of a list of implementation specific +trusted functions AND shall return E_OK after completion. + + + 3,4 + code + code + The called trusted function must conform to the following C prototype: +void TRUSTED_<name_of_the_trusted_service>( +TrustedFunctionIndexType,TrustedFunctionParameterRefType); +(The arguments are the same as the arguments of CallTrustedFunction). + + + 3,4 + code + code + When the function <FunctionIndex> is called, it shall get the same +permissions (access rights) as the associated trusted OS-Application. + + + 3,4 + code + code + If the trusted function is called from a Category 2 OsIsr context it shall +continue to run on the same interrupt priority and be allowed to call all system +services defined for Category 2 OsIsr (see table in chapter 7.7.3.2). + + + 3,4 + code + code + If the trusted function is called from a task context it shall continue to run +on the same priority and be allowed to call all system services defined for tasks +(see table in chapter 7.7.3.2). + + + 3,4 + code + code + If the function index <FunctionIndex> is undefined, +CallTrustedFunction() shall return E_OS_SERVICEID. + + + 3,4 + code + code + If the OsIsr reference <ISRID> is valid, CheckISRMemoryAccess() shall +return the access rights of the OsIsr on the specified memory area. + + + 3,4 + code + code + If an access right (e.g. “read”) is not valid for the whole specified memory +area CheckISRMemoryAccess() shall yield no access regarding this right. + + + 3,4 + code + code + If the OsIsr reference <ISRID> is not valid, CheckISRMemoryAccess() +shall yield no access rights. + + + 3,4 + code + code + If the Task reference <TaskID> is valid, CheckTaskMemoryAccess() +shall return the access rights of the task on the specified memory area. + + + 3,4 + code + code + If an access right (e.g. “read”) is not valid for the whole specified memory +area CheckTaskMemoryAccess() shall yield no access regarding this right. + + + 3,4 + code + code + If the Task reference <TaskID> is not valid, CheckTaskMemoryAccess() +shall yield no access rights. + + + 3,4 + code + code + If the OS-Application <ApplID> has access to the queried object, +CheckObjectAccess() shall return ACCESS. + + + 3,4 + code + code + If the OS-Application <ApplID> has no access to the queried object, +CheckObjectAccess() shall return NO_ACCESS. + + + 3,4 + code + code + If the object to be examined is not a valid object OR <ApplID> is invalid +OR <ObjectType> is invalid THEN the the CheckObjectAccess() shall return +NO_ACCESS. + + + 3,4 + code + code + If the object type is OBJECT_RESOURCE AND the object to be examined is +the RES_SCHEDULER CheckObjectAccess() shall always return ACCESS. + + + 3,4 + code + code + If the specified object ObjectType exists, CheckObjectOwnership() +shall return the identifier of the OS-Application to which the object belongs. + + + 3,4 + code + code + If the specified object ObjectType is invalid OR the argument of the type +(the “…”) is invalid , CheckObjectOwnership() shall return +INVALID_OSAPPLICATION. + + + 3,4 + code + code + If the object to be examined is the RES_SCHEDULER +CheckObjectOwnership() shall always return INVALID_OSAPPLICATION. + + + 1,2,3,4 + code + code + If the schedule table <ScheduleTableID> is not valid, +StartScheduleTableRel() shall return E_OS_ID. + + + 2,4 + code + code + If the schedule table <ScheduleTableID> is implicitely synchronized +(OsScheduleTblSyncStrategy = IMPLICIT), +StartScheduleTableRel() shall return E_OS_ID. + + + 1,2,3,4 + code + code + If <Offset> is zero StartScheduleTableRel() shall return +E_OS_VALUE. + + + 1,2,3,4 + code + code + If the offset <Offset> is greater than OsCounterMaxAllowedValue of +the underlying counter minus the Initial Offset, StartScheduleTableRel() +shall return E_OS_VALUE. + + + 1,2,3,4 + code + code + If the schedule table <ScheduleTableID> is not in the state +SCHEDULETABLE_STOPPED, StartScheduleTableRel() shall return +E_OS_STATE. + + + 1,2,3,4 + code + code + If its input parameters are valid and the state of schedule table +<ScheduleTableID> is SCHEDULETABLE_STOPPED, then +StartScheduleTableRel() shall start the processing of a schedule table +<ScheduleTableID>. The Initial Expiry Point shall be processed after <Offset> + +Initial Offset ticks have elapsed on the underlying counter. The state of +<ScheduleTableID> to SCHEDULETABLE_RUNNING. + + + 1,2,3,4 + code + code + If the schedule table <ScheduleTableID> is not valid, +StartScheduleTableAbs() shall return E_OS_ID. + + + 1,2,3,4 + code + code + If the <Tickvalue> is greater than the OsCounterMaxAllowedValue of +the underlying counter, StartScheduleTableAbs() shall return E_OS_VALUE. + + + 1,2,3,4 + code + code + If the schedule table <ScheduleTableID> is not in the state +SCHEDULETABLE_STOPPED, StartScheduleTableAbs() shall return +E_OS_STATE. + + + 1,2,3,4 + code + code + If its input parameters are valid and <ScheduleTableID> is in the state +SCHEDULETABLE_STOPPED, StartScheduleTableAbs() shall start the +processing of schedule table <ScheduleTableID> at count value <Start> and shall +set the state of <ScheduleTableID> to SCHEDULETABLE_RUNNING. The Initial +Expiry Point will be processed when the underlying counter equals <Start>+Initial +Offset. + + + 1,2,3,4 + code + code + If the schedule table identifier <ScheduleTableID> is not valid, +StopScheduleTable() shall return E_OS_ID. + + + 1,2,3,4 + code + code + If the schedule table with identifier <ScheduleTableID> is in state +SCHEDULETABLE_STOPPED, StopScheduleTable() shall return +E_OS_NOFUNC. + + + 1,2,3,4 + code + code + If its input parameters are valid, StopScheduleTable()shall set the +state of <ScheduleTableID> to SCHEDULETABLE_STOPPED and (stop the +schedule table <ScheduleTableID> from processing any further expiry points and) +shall return E_OK. + + + 1,2,3,4 + code + code + If the input parameter <ScheduleTableID_From> or +<ScheduleTableID_To> is not valid, NextScheduleTable() shall return +E_OS_ID. + + + 1,2,3,4 + code + code + If schedule table <ScheduleTableID_To> is driven by different counter than +schedule table <ScheduleTableID_From> then NextScheduleTable() shall +return an error E_OS_ID. + + + 1,2,3,4 + code + code + : If the schedule table <ScheduleTableID_From> is in state +SCHEDULETABLE_STOPPED OR in state SCHEDULETABLE_NEXT, +NextScheduleTable() shall leave the state of <ScheduleTable_From> and +<ScheduleTable_To> unchanged and return E_OS_NOFUNC.. + + + 1,2,3,4 + code + code + : If the schedule table <ScheduleTableID_To> is not in state +SCHEDULETABLE_STOPPED, NextScheduleTable() shall leave the state of +<ScheduleTable_From> and <ScheduleTable_To> unchanged and return +E_OS_STATE. + + + 1,2,3,4 + code + code + If the input parameters are valid then NextScheduleTable() shall start +the processing of schedule table <ScheduleTableID_To> +<ScheduleTableID_From>.FinalDelay ticks after the Final Expiry Point on +<ScheduleTableID_From> is processed and shall return E_OK. The Initial Expiry +Point on <ScheduleTableID_To> shall be processed at +<ScheduleTableID_From>.Final Delay + <ScheduleTable_To>.Initial Offset ticks +after the Final Expiry Point on <ScheduleTableID_From> is processed . + + + 1,2,3,4 + code + code + If the input parameters are valid AND the <ScheduleTableID_From> +already has a “next” schedule table then the <ScheduleTableID_To> shall replace +the previous “next” schedule table and the old “next” schedule table state becomes +SCHEDULETABLE_STOPPED. + + + 1,2,3,4 + code + code + The synchronization strategy of the <ScheduleTableID_To> shall come into +effect when the Operating System processes the first expiry point of +<ScheduleTableID_To>. + + + 1,2,3,4 + code + code + If the <ScheduleTableID_From> is stopped, the “next” schedule table +does not start and its state changes to SCHEDULETABLE_STOPPED. + + + 2,4 + code + code + If the schedule table <ScheduleTableID> is not valid OR the schedule +table <ScheduleTableID> is not explicitly synchronized +(OsScheduleTblSyncStrategy = EXPLICIT) +StartScheduleTableSynchron() shall return E_OS_ID. + + + 2,4 + code + code + If the schedule table <ScheduleTableID> is not in the state +SCHEDULETABLE_STOPPED, the service shall return E_OS_STATE. + + + 2,4 + code + code + If <ScheduleTableID> is valid, StartScheduleTableSynchron() +shall set the state of <ScheduleTableID> to SCHEDULETABLE_WAITING and +start the processing of schedule table <ScheduleTableID> after the +synchronization count of the schedule table is set via SyncScheduleTable(). +The Initial Expiry Point shall processed when (Duration-SyncValue)+InitialOffset +ticks have elapsed on the synchronization counter where: +- Duration is <ScheduleTableID>.OsScheduleTableDuration +- SyncValue is the <Value> parameter passed to the SyncScheduleTable() +- InitialOffset is the shortest expiry point offset in <ScheduleTableID> + + + 2,4 + code + code + If the <ScheduleTableID> is not valid OR schedule table can not be +explicitely synchronized (OsScheduleTblSyncStrategy is not equal to +EXPLICIT) the service shall return E_OS_ID. + + + 2,4 + code + code + If the <Value> is greater than the OsScheduleTableDuration, +SyncScheduleTableAbs() shall return E_OS_VALUE. + + + 2,4 + code + code + If the state of the schedule table <ScheduleTableID> is equal to +SCHEDULETABLE_STOPPED or SCHEDULETABLE_NEXT the service shall return +E_OS_STATE. + + + 2,4 + code + code + If the parameters are valid, the service provides the operating system with +the current synchronization count for the given schedule table. (It is used to +synchronize the processing of the schedule table to the synchronization counter.) + + + 2,4 + code + code + If OsScheduleTblSyncStrategy of <ScheduleTableID> equals to +EXPLICIT then SetScheduleTableAsync() shall set the status of +<ScheduleTableID> to SCHEDULETABLE_RUNNING. + + + 2,4 + code + code + If SetScheduleTableAsync() is called for a running schedule table +the OS shall stop further synchronization until a SyncScheduleTable() call is +made. + + + 2,4 + code + code + If SetScheduleTableAsync() is called for a running schedule table +the OS shall continue to process expiry points on the schedule table. + + + 2,4 + code + code + If OsScheduleTblSyncStrategy of <ScheduleTableID> is not equal +to EXPLICIT then the service call shall return E_OS_ID + + + 1,2,3,4 + code + code + If the schedule table <ScheduleTableID> is NOT started, +GetScheduleTableStatus() shall pass back SCHEDULETABLE_STOPPED via +the reference parameter <ScheduleStatus> AND shall return E_OK. + + + 1,2,3,4 + code + code + If the schedule table <ScheduleTableID> was used in a +NextScheduleTable() call AND waits for the end of the current schedule +table, GetScheduleTableStatus() shall return SCHEDULETABLE_NEXT via +the reference parameter <ScheduleStatus> AND shall return E_OK + + + 2,4 + code + code + If the schedule table <ScheduleTableID> is configured with explicit +synchronization AND no synchronization count was provided to the Operating +System, GetScheduleTableStatus() shall return SCHEDULETABLE_WAITING via the reference parameter <ScheduleStatus> AND shall return E_OK. + + + 1,2,3,4 + code + code + If the schedule table <ScheduleTableID> is started AND synchronous, +GetScheduleTableStatus() shall pass back +SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS via the reference parameter +<ScheduleStatus> AND shall return E_OK + + + 1,2,3,4 + code + code + If the schedule table <ScheduleTableID> is started AND NOT +synchronous (deviation is not within the precision interval OR the schedule table +has been set asynchronous), GetScheduleTableStatus() shall pass back +SCHEDULETABLE_RUNNING via the reference parameter ScheduleStatus AND +shall return E_OK. + + + 1,2,3,4 + code + code + If the identifier <ScheduleTableID> is NOT valid, +GetScheduleTableStatus() shall return E_OS_ID. + + + 1,2,3,4 + code + code + If the input parameter <CounterID> is not valid OR the counter is a +hardware counter, IncrementCounter() shall return E_OS_ID. + + + 1,2,3,4 + code + code + If its input parameter is valid, IncrementCounter() shall increment the +counter <CounterID> by one (if any alarm connected to this counter expires, the +given action, e.g. task activation, is done) and shall return E_OK. + + + 1,2,3,4 + code + code + If an error happens during the execution of an alarm action, e.g. +E_OS_LIMIT caused by a task activation, the error hook(s) are called, but the +IncrementCounter() service itself will return E_OK. + + + 1,2,3,4 + code + code + If the input parameter <CounterID> is not valid, the service should return +E_OS_ID. + + + 1,2,3,4 + code + code + If its input parameter is valid, GetCounterValue() shall return the +current tick value of the counter via <Value> and return E_OK. + + + 1,2,3,4 + code + code + If the input parameter <CounterID> is not valid the service will return +E_OS_ID. + + + 1,2,3,4 + code + code + If the <Value> is larger than the max allowed value of the <CounterID>, +the service will return E_OS_VALUE. + + + 1,2,3,4 + code + code + If its input parameter are valid, GetElapsedCounterValue() shall +return the number of elapsed ticks since the given <Value> value via +<ElapsedValue> and shall return E_OK. + + + 1,2,3,4 + code + code + In the <Value> parameter the current tick value of the counter is +returned. + + + 3,4 + code + code + If called from allowed context – see table [7.7.3.2.1] --, +TerminateApplication() shall terminate the calling OS-Application (i.e. to +kill all tasks, disable the interrupt sources of those OsIsrs which belong to the OS- +Application and free all other OS resources associated with the application). + + + 3,4 + code + code + If called from wrong context, TerminateApplication() shall return +E_OS_CALLEVEL. + + + 3,4 + code + code + If the <RestartOption> is invalid, the service shall retrun E_OS_VALUE. + + + 3,4 + code + code + If RestartOption equals RESTART, TerminateApplication() shall +activate the configured OsRestartTask of the terminated OS-Application. + + + 2,3,4 + code + code + If an invalid value is returned the Operating System shall take the same +action as if no protection hook is configured. + + + 1,2,3,4 + container + code + OsAlarmIncrementCounter{INCREMENTCOUNTER} + + + 1,2,3,4 + container + code + OsApplication{APPLICATION} + + + 3,4 + container + code + OsTrusted {TRUSTED} + + + 3,4 + container + code + OsAppAlarmRef + + + 3,4 + container + code + OsAppCounterRef + + + 3,4 + container + code + Same as OS234 + + + 3,4 + container + code + OsAppIsrRef + + + 3,4 + container + code + OsAppResourceRef + + + 3,4 + container + code + Same as OS248 + + + 3,4 + container + code + OsAppScheduleTableRef + + + 3,4 + container + code + Same as OS230 + + + 3,4 + container + code + OsAppTaskRef + + + 3,4 + container + code + Same as OS116 + + + 3,4 + container + code + OsRestartTask {RESTARTTASK} + + + 3,4 + container + code + OsAppErrorHook {ERRORHOOK} + + + 3,4 + container + code + OsAppShutdownHook {SHUTDOWNHOOK} + + + 3,4 + container + code + OsAppStartupHook {STARTUPHOOK} + + + 3,4 + container + code + OsTrustedFunctionName + + + 1,2,3,4 + container + code + OsCounterType {TYPE} + + + 1,2,3,4 + container + code + OsDriver{DRIVER} + + + 2,3,4 + container + code + OsProtectionHook {PROTECTIONHOOK} + + + 2,4 + container + code + OsIsrResourceLock{LOCKINGTIME} +OsIsrResourceLockBudget {MAXRESOURCELOCKTIME} +OsIsrResourceLockResourceRef {RESOURCE} +OsIsrAllInterruptLockBudget {MAXALLINTERRUPTLOCKTIME} +OsIsrOsInterruptLockBudget {MAXOSINTERRUPTLOCKTIME} + + + 2,4 + container + code + OsIsrTimingProtection{TIMING_PROTECTION} + + + 2,4 + container + code + OsIsrExecutionBudget {EXECUTIONTIME} + + + 2,4 + container + code + OsIsrTimeFrame {TIMEFRAME} + + + 1,2,3,4 + container + code + OsScalabilityClass {SCALABILITYCLASS} + + + 1,2,3,4 + container + code + OsStackMonitoring {STACKMONITORING} + + + 1,2,3,4 + container + code + OsResource{RESOURCE} + + + 1,2,3,4 + container + code + OsScheduleTable{SCHEDULETABLE} +OsScheduleTableRepeating {REPEATING} + + + 1,2,3,4 + container + code + OsScheduleTableCounterRef {COUNTER} + + + 1,2,3,4 + container + code + OsScheduleTableAutostart{AUTOSTART} + + + 1,2,3,4 + container + code + OsScheduleTableExpiryPoint{ACTION} + + + 2,4 + container + code + OsTaskTimingProtection{TIMING_PROTECTION} + + + 2,4 + container + code + OsTaskExecutionBudget {EXECUTIONBUDGET} +OsTaskTimeFrame {TIMEFRAME} + + + 1,2,3,4 + container + code + OsTimeConstant{TIMECONSTANTS} + + + 1,2,3,4 + generator + code + The generator shall provide the user the ability of reading the information of +a selectable configuration file. + + + 1,2,3,4 + generator + code + The generator shall provide the user the ability of performing a consistency +check of the current configuration. + + + 1,2,3,4 + generator + code + If service protection is required and OsStatus is not equal to EXTENDED (all +the associated error handling is provided), the consistency check shall issue an error. + + + 2,4 + generator + code + If timing protection is configured together with OSEK OS Category 1 +interrupts, the consistency check shall issue a warning. + + + 1,2,3,4 + generator + code + If configured attributes do not match the configured scalability class (e.g. +defining an execution time budget in Tasks or Category 2 OsIsrs and selected +scalability class is 1) the consistency check shall issue a warning. + + + 1,2,3,4 + generator + code + If OsScalabilityClass is SC3 or SC4 AND a Task OR Category 2 OsIsr OR +Resources OR Counters OR Alarms OR Schedule tables does not belong to exactly +one OS-Application the consistency check shall issue an error.. RES_SCHEDULER +as the only exception does not belong to any OS-Application. + + + 1,2,3,4 + generator + code + If OsScalabilityClass is SC3 or SC4 AND a Category 1 OsIsr does not +belong to exactly one trusted OS-Application the consistency check shall issue an +error + + + 1,2,3,4 + generator + code + If OsScalabilityClass is SC3 or SC4 AND an interrupt source that is used +by the OS is assigned to an OS-Application, the consistency check shall issue an +error. + + + 1,2,3,4 + generator + code + If OsAlarmIncrementCounter is configured as action on alarm expiry AND +the alarm is driven directly or indirectly (a cyclic chain of alarm actions with +OsAlarmIncrementCounter) by that counter, the consistency check shall issue a +warning.. + + + 1,2,3,4 + generator + code + If OsStatus is STANDARD and OsScalabilityClass is SC3 or SC4 the +consistency check shall issue an error. + + + 1,2,3,4 + generator + code + If OsScalabilityClass is SC3 or SC4 AND a task is referenced within a +schedule table object AND the OS-Application of the schedule table has no access to +the task, the consistency check shall issue an error. + + + 1,2,3,4 + generator + code + If OsScalabilityClass is SC3 or SC4 AND a task is referenced within an +alarm object AND the OS-Application of the alarm has no access to the task, the +consistency check shall issue an error. + + + 2,4 + generator + code + If a schedule table has OsScheduleTblSyncStrategy = IMPLICIT and the +OsCounterMaxAllowedValue+1 of the associated counter is not equal to the +duration of the schedule table then the consitency check shall issue an error. + + + 1,2,3,4 + generator + code + If a GPT channel is configured as a hardware counter driver the consitency +check shall issue an error if the selected GPT channel is not configured for +continuous mode. + + + 1,2,3,4 + generator + code + If OsScalabilityClass is SC2, SC3 or SC4 AND Alarm Callbacks are +configured the conistency check shall isuue an error. + + + 1,2,3,4 + generator + code + If the consistency check of the read-in configuration file has not run free of +errors, the generator shall not generate/configure the operating system. + + + 1,2,3,4 + generator + code + The generator shall generate a relocatable memory section containing the +interrupt vector table. + + + 1,2,3,4 + generator + code + The generator shall print out information about timers used internally by the +OS during generation (e.g. on console, list file). + + + 1,2,3,4 + generator + code + The generator shall create conversation macros to convert counter ticks +(given as argument) into real time. The format of the macro is +OS_TICKS2<Unit>_<Counter>(ticks) whereas <Unit> is one of NS +(nanoseconds), US (microseconds), MS (milliseconds) or SEC (seconds) and +<Counter> is the name of the counter; E.g. OS_TICKS2MS_MyCounter()) + + \ No newline at end of file diff --git a/scripts/req.sh b/scripts/req.sh new file mode 100644 index 00000000..80490d25 --- /dev/null +++ b/scripts/req.sh @@ -0,0 +1,56 @@ +#/bin/bash +# +# $ req (OS|xxx) (get|diff) ... [filter ] +# ls : Print all requirements +# : +# get : +# diff <1> <2> : <> = req | code | test +# filter : +# +# Diff the requirements against the code +# $ req OS diff req code +# +# Diff the requirements against the code +# $ req OS diff req test +# +# Get the requiment for OS123 +# $ req OS get OS123 +# +# Get the requiment for OS123 +# $ req OS get OS123 "=1" +# $ scripts/req.sh diff OS code "Class=1" + +REBOL=/C/devtools/utils/r3-a96.exe + +#case $2 in +# get) echo "get";; +# diff) echo "diff";; +# *) echo "default"; +#esac + +#echo $2 +#echo $3 +#echo $4 + + +# exit + +# req-diff req code "=2" +# req-ls req +# req-ls code "=1" +# req-ls test + +SCRIPT_DIR=`dirname $0` +cmd.exe /S /K "$REBOL $SCRIPT_DIR\extract_req.r $1 $2 $3 \"$4\" > result.txt && exit" +#powershell -Command "$REBOL $SCRIPT_DIR\extract_req.r $1 $2 $3 \"$4\" > result.txt" +#powershell -Command $REBOL $SCRIPT_DIR/extract_req.r $1 $2 $3 \"$4\" +cat result.txt + + + + + + + + + diff --git a/scripts/req_extract.r b/scripts/req_extract.r new file mode 100644 index 00000000..aa66b142 --- /dev/null +++ b/scripts/req_extract.r @@ -0,0 +1,228 @@ +comment { + Rebol 3.0 Alpha version ONLY + May be run with from msys: + $ powershell -Command "r3-a96.exe scripts\extract_req.r > result.txt" + OR + $ cmd.exe /S /K "r3-a96.exe scripts\extract_req.r > result.txt && exit" +} + +REBOL [ + Title: "Requirements extractor" + Date: 6-Jan-2010 + File: %extract_req.r + Author: "mahi" + Version: 0.0.1 +] + +usage: does [ +; do/args %scripts/req_extract.r ["diff" "OS" "req" "Class=1"] + print "Usage: do/args %extract_req [ ^"^" ^"[....]^" ]" + print " req.sh diff OS req ^"Class=1^"" + print " = (diff|ls) " + print " diff (code|test) " + print " ls " + quit +] + +;======================================================= +; See http://www.rebol.com/r3/docs/functions/secure.html +secure [ + net quit + file allow ; Allow Read/write to files. +] + +;======================================================= +right: func [s [string!] n [integer!]] [ + copy/part at s (length? s) - n + 1 n +] + +;======================================================= + +find-files: func [dir list /local files] [ + files: sort load dir + + ; Get files that match the above types: + foreach file files [ + if find file-types suffix? file [ + append list dir/:file + ] + ] + ; Search sub-directories: + foreach file files [ + if find file "/" [find-files dir/:file list] + ] +] + +;======================================================= + +req-xml: func[ + filename [file!] + filter [string!] + "Filters separated with a ," +][ + ; print filename + ; Get a good rebol3 xml parser.. + if not any-function? :load-xml [ + do http://www.ross-gill.com/r/r3xml.r + ] + + filter-split: parse/all filter "," + doc: load-xml/dom filename + body: doc/get-by-tag + list: [] + foreach j filter-split [print j] + + print "go........" + ; Go over all req tags. + foreach iter body [ + ; Look for any matching filter + fail: false + foreach i filter-split [ + val: parse i "=" + if/else find (iter/get to-tag val/1) val/2 [ + ] [ + fail: true + break + ] + ] + if fail == false [ append list iter/get #id ] + ] + return list +] + +comment { +req-xml: func[ + filename [file!] + filter [string!] + "Filters separated with a ," +][ + ; print filename + ; Get a good rebol3 xml parser.. + if not any-function? :load-xml [ + do http://www.ross-gill.com/r/r3xml.r + ] + + filter-split: parse/all filter "=" + doc: load-xml/dom filename + body: doc/get-by-tag + list: [] + print ["Filter:" filter-split/1 filter-split/2] + foreach iter body [ + foreach filter-entry filter-split [ + if/else find (iter/get to-tag filter-split/1) filter-split/2 [ + append list iter/get #id + ] [ break ] + ] + ] + return list +] +} + +;======================================================= +req-source: func[ + dir-list [block!] +][ + file-types: [%.c %.h] + file-list: [] + req-list: [] + text: string! +; text2: string! + + ; Grab the file-list... + foreach dir dir-list [ + print dir + foreach file load dir [ + if find file-types suffix? file [append file-list dir/:file] + ] + ] + + rule:[ + any [ + thru "@req " copy text to [ newline | "*/"] + (append req-list first parse text none) +; (text2: first parse text none) +; (append req-list text2) +; (probe text2) + ] + ] + + clear req-list + foreach file file-list [ + ;clear text + text: "" + content: read/string file +; probe file + parse content rule +; print text + ;append req-list first parse text none + ;parse content [ any [thru "@req" begin: to [ newline | "*/" ] fin: (append req-list trim copy/part at begin 0 ((index? fin) - (index? begin)) )]] + ] + return req-list +] + +;======================================================= + +; Simplest to keep all requirement files in one directory: +; e.g req-os.xml, req-can.xml + +; Rebol strange argument passing... +if/else (found? system/options/args) [ + ; Used from real command line + args: system/options/args +] [ + if/else(found? system/script/args) [ + ; Used when running from within rebol, e.g. do/args... + args: system/script/args + ] [ usage ] +] + +foreach a args [print ["arg:" a]] +cmd: pick args 1 + +print length? args +; Check args +switch cmd [ + "diff" [ if (length? args) != 4 [usage]] + "ls" [ if (length? args) != 4 [usage]] +] + +path-info: [ + ["OS" %req-os.xml [%../system/kernel/ %../system/kernel/include/ %../include/ ] "Class=1,2,3,4"] + ["CAN" %req-can.xml [%../arch/ppc/mpc55xx/drivers] ] +] + +print length? path-info +;foreach a path-info/1 [print a] +;print length? path-info/1 +;print path-info/1/1 +;print dir? path-info/1/3 +;print path-info/1/2 +;print exists? path-info/1/2 + +list-xml: req-xml path-info/1/2 pick args 4 ;"Class=1" +list-source: req-source path-info/1/3 + +print length? list-xml +print length? list-source + +print ["Requirements for module:" (pick args 2) "with filter:" pick args 4 ] +probe sort list-xml +print newline + +print "Requirements for from source" +probe sort list-source +print newline + +print "Requirements diff" +probe exclude list-xml list-source +print newline + +comment { + none +} + + + + + + diff --git a/system/EcuM/EcuM.c b/system/EcuM/EcuM.c index 100efedb..ecae88c9 100644 --- a/system/EcuM/EcuM.c +++ b/system/EcuM/EcuM.c @@ -28,7 +28,7 @@ #include "EcuM_Cbk.h" #include "Mcu.h" #include "Det.h" -#include "int_ctrl.h" +#include "irq.h" EcuM_GobalType internal_data; @@ -58,7 +58,7 @@ void EcuM_Init( void ) InitOS(); // Enable interrupts - IntCtrl_Init(); + Irq_Init(); // Determine PostBuild configuration diff --git a/system/kernel/alarm.c b/system/kernel/alarm.c index 0420d803..e0f41878 100644 --- a/system/kernel/alarm.c +++ b/system/kernel/alarm.c @@ -13,26 +13,10 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - - -#include "Os.h" -#include "types.h" -#include "counter_i.h" -#include "ext_config.h" -#include "alarm_i.h" -#include -#include -#include "hooks.h" +#include +#include +#include "Os.h" #include "internal.h" -#include "alarm_i.h" - /** * The system service GetAlarmBase reads the alarm base @@ -90,7 +74,7 @@ StatusType GetAlarm(AlarmType AlarmId, TickRefType Tick) { StatusType SetRelAlarm(AlarmType AlarmId, TickType Increment, TickType Cycle){ StatusType rv = E_OK; - alarm_obj_t *a_obj; + OsAlarmType *a_obj; ALARM_CHECK_ID(AlarmId); @@ -104,7 +88,7 @@ StatusType SetRelAlarm(AlarmType AlarmId, TickType Increment, TickType Cycle){ (Cycle < COUNTER_MIN_CYCLE(a_obj)) || (Cycle > COUNTER_MAX(a_obj)) ) { - /* See SWS, OS304 */ + /** @req OS304 */ rv = E_OS_VALUE; goto err; } @@ -136,7 +120,7 @@ StatusType SetRelAlarm(AlarmType AlarmId, TickType Increment, TickType Cycle){ StatusType SetAbsAlarm(AlarmType AlarmId, TickType Start, TickType Cycle) { - alarm_obj_t *a_p; + OsAlarmType *a_p; long flags; StatusType rv = E_OK; @@ -175,7 +159,7 @@ StatusType SetAbsAlarm(AlarmType AlarmId, TickType Start, TickType Cycle) { StatusType CancelAlarm(AlarmType AlarmId) { StatusType rv = E_OK; - alarm_obj_t *a_obj; + OsAlarmType *a_obj; long flags; ALARM_CHECK_ID(AlarmId); diff --git a/system/kernel/asm_offset.c b/system/kernel/asm_offset.c index f61eade3..4c1a2ee7 100644 --- a/system/kernel/asm_offset.c +++ b/system/kernel/asm_offset.c @@ -12,14 +12,6 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - /* A steal in an idea from * http://blogs.sun.com/nickstephen/entry/some_assembly_required_-_down @@ -30,26 +22,17 @@ */ #include +#include "internal.h" #define DECLARE(sym,val) \ __asm("#define\t" #sym "\t%0" : : "n" ((val))) -#include "pcb.h" -#include "sys.h" -#include "kernel.h" - void asm_foo(void) { - DECLARE(PCB_STACK_CURR_P, offsetof(pcb_t, stack)); - DECLARE(PCB_ENTRY_P, offsetof(pcb_t, entry)); + DECLARE(PCB_STACK_CURR_P, offsetof(OsPcbType, stack)); + DECLARE(PCB_ENTRY_P, offsetof(OsPcbType, entry)); DECLARE(SYS_CURR_PCB_P, offsetof(sys_t, curr_pcb)); DECLARE(SYS_INT_NEST_CNT, offsetof(sys_t, int_nest_cnt)); DECLARE(SYS_INT_STACK, offsetof(sys_t, int_stack)); - -/* - DECLARE(SYS_HOOK_P, offsetof(sys_t, hooks)); - DECLARE(HOOKS_PRETASK_P, offsetof(structos_conf_global_hooks_s, PreTaskHook)); -*/ -// DECLARE(SYS_HOOK_POSTTASK_P,offsetof(sys_t, PostTaskHook)); } diff --git a/system/kernel/com_internal.c b/system/kernel/com_internal.c index 31e01cf4..15bc5bb2 100644 --- a/system/kernel/com_internal.c +++ b/system/kernel/com_internal.c @@ -12,21 +12,9 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - #include "Os.h" -#include "kernel.h" -#include "ext_config.h" -#include -#include - +#include "internal.h" /* Queued message * The messages are put in a queue. Copied to the destination... @@ -46,7 +34,7 @@ StatusType SendMessage( MessageType message_id, ApplicationDataRef dataRef ) { - message_obj_t *msg; + OsMessageType *msg; // Is the message valid ? if( message_id > Oil_GetMessageCnt() ) { @@ -87,7 +75,7 @@ StatusType SendMessage( MessageType message_id, ApplicationDataRef dataRef ) { } StatusType ReceiveMessage( MessageType message_id, ApplicationDataRef dataRef ) { - message_obj_t *msg; + OsMessageType *msg; // Check if valid // Copy from container to dataRef diff --git a/system/kernel/counter.c b/system/kernel/counter.c index b48925e4..5b866b51 100644 --- a/system/kernel/counter.c +++ b/system/kernel/counter.c @@ -13,30 +13,11 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - -#include "Os.h" -#include "types.h" -#include "counter_i.h" -#include "ext_config.h" -#include "alarm_i.h" -#include -#include -#include "hooks.h" -#include "sched_table_i.h" -#include "internal.h" - -#define MIN(_x,_y) (((_x) < (_y)) ? (_x) : (_y)) -#define MAX(_x,_y) (((_x) > (_y)) ? (_x) : (_y)) - - -#define COUNTER_MAX(x) (x)->counter->alarm_base.maxallowedvalue +#include +#include +#include "Os.h" +#include "internal.h" +#include "arc.h" #define COUNTER_STD_END \ goto ok; \ @@ -46,51 +27,42 @@ return rv; -/* Accessor functions */ -static inline Stbl_AdjustableExpPointType *getAdjExpPoint( sched_table_t *stblPtr ) { +/* Accessor functions */ +#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON ) +static inline OsSchTblAdjExpPointType *getAdjExpPoint( OsSchTblType *stblPtr ) { return &stblPtr->adjExpPoint; -} +} +#endif + -static inline struct sched_table_autostart_s *getAutoStart( sched_table_t *stblPtr ) { +static inline struct OsSchTblAutostart *getAutoStart( OsSchTblType *stblPtr ) { return &stblPtr->autostart; } - -static inline struct sched_table_sync_s *getSync( sched_table_t *stblPtr ) { + +#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON ) +static inline struct OsScheduleTableSync *getSync( OsSchTblType *stblPtr ) { return &stblPtr->sync; } - - -/** - * - * @param curr - * @param max - * @param add - * @return - */ -static TickType os_calc_modulo( TickType curr, TickType max, TickType add ) { - TickType diff = max - curr; -// return (diff > add ) ? (curr + add) : -// (add - curr); - return (add>diff) ? (add-diff) : (curr+add); -} +#endif + /** * * @param a_obj */ -static void AlarmProcess( alarm_obj_t *a_obj ) { +static void AlarmProcess( OsAlarmType *a_obj ) { if( a_obj->cycletime == 0 ) { a_obj->active = 0; } else { // Calc new expire value.. - a_obj->expire_val = os_calc_modulo( a_obj->expire_val, - COUNTER_MAX(a_obj), + a_obj->expire_val = Os_CounterCalcModulo( a_obj->expire_val, + Os_CounterGetMaxValue(a_obj->counter), a_obj->cycletime); } } -static void check_alarms( counter_obj_t *c_p ) { - alarm_obj_t *a_obj; +static void check_alarms( OsCounterType *c_p ) { + OsAlarmType *a_obj; SLIST_FOREACH(a_obj,&c_p->alarm_head,alarm_list) { if( a_obj->active && (c_p->val == a_obj->expire_val) ) { @@ -102,8 +74,8 @@ static void check_alarms( counter_obj_t *c_p ) { switch( a_obj->action.type ) { case ALARM_ACTION_ACTIVATETASK: - if( ActivateTask(a_obj->action.task_id) != E_OK ) { - assert(0); + if( ActivateTask(a_obj->action.task_id) != E_OK ) { + /* We actually do thing here, See 0S321 */ } AlarmProcess(a_obj); break; @@ -116,8 +88,10 @@ static void check_alarms( counter_obj_t *c_p ) { break; case ALARM_ACTION_ALARMCALLBACK: /* TODO: not done */ - break; - case ALARM_ACTION_INCREMENTCOUNTER: + break; + + case ALARM_ACTION_INCREMENTCOUNTER: + /** @req OS301 */ /* Huh,, recursive....*/ IncrementCounter(a_obj->action.counter_id); break; @@ -133,8 +107,11 @@ static void check_alarms( counter_obj_t *c_p ) { * * @param c_p Pointer to counter object */ -static void check_stbl( counter_obj_t *c_p ) { - sched_table_t *sched_obj; + +/** @req OS002 */ +/** @req OS007 */ +static void check_stbl(OsCounterType *c_p) { + OsSchTblType *sched_obj; /* Iterate through the schedule tables */ SLIST_FOREACH(sched_obj,&c_p->sched_head,sched_list) { @@ -142,7 +119,8 @@ static void check_stbl( counter_obj_t *c_p ) { if( sched_obj->state == SCHEDULETABLE_STOPPED ) { continue; } - + +#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON ) if( sched_obj->sync.syncStrategy == IMPLICIT ) { // .... @@ -166,29 +144,32 @@ static void check_stbl( counter_obj_t *c_p ) { sched_obj->state = SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS; } } +#endif /* Check if the expire point have been hit */ if( (sched_obj->state == SCHEDULETABLE_RUNNING || SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS ) && - (c_p->val >= sched_obj->expire_val) ) { - sched_action_t * action; + (c_p->val >= sched_obj->expire_val) ) + { + OsScheduleTableActionType * action; action = SA_LIST_GET(&sched_obj->action_list,sched_obj->expire_curr_index); - switch( action->type ) { - case SCHEDULE_ACTION_ACTIVATETASK: - ActivateTask(action->task_id); - break; - - case SCHEDULE_ACTION_SETEVENT: - SetEvent( action->task_id, action->event_id); - break; - - default: - assert(0); - } + switch( action->type ) { + case SCHEDULE_ACTION_ACTIVATETASK: + ActivateTask(action->task_id); + break; + + case SCHEDULE_ACTION_SETEVENT: + SetEvent( action->task_id, action->event_id); + break; + + default: + /** @req OS407 */ + assert(0); + } // Calc new expire val - os_stbl_calc_expire(sched_obj); + Os_SchTblCalcExpire(sched_obj); } } @@ -200,7 +181,7 @@ static void check_stbl( counter_obj_t *c_p ) { * * @param counter Ptr to a counter object */ -static void IncCounter( counter_obj_t *counter ) { +static void IncCounter( OsCounterType *counter ) { // Check for wrap of type if( (counter->val+1) < (counter->val) ) { counter->val = 0; // This wraps @@ -212,68 +193,103 @@ static void IncCounter( counter_obj_t *counter ) { } } } + + +#define IsCounterValid(_counterId) ((_counterId) <= Oil_GetCounterCnt()) /** * * @param counter_id * @return */ - + +/** @req OS399 */ StatusType IncrementCounter( CounterType counter_id ) { StatusType rv = E_OK; - - /* Check the alarms associated with this timer */ - counter_obj_t *counter; - counter = Oil_GetCounter(counter_id); + OsCounterType *counter; + counter = Oil_GetCounter(counter_id); + + /** @req OS376 */ + if( !IsCounterValid(counter_id) ) { + rv = E_OS_ID; + goto err; + } /* Check param */ - + /** @req OS285 */ if( ( counter->type != COUNTER_TYPE_SOFT ) || ( counter_id >= Oil_GetCounterCnt() ) ) { rv = E_OS_ID; goto err; } - + + /** @req OS286 */ IncCounter(counter); - /* TODO: the other alarm_base.xxx values are still not done */ check_alarms(counter); check_stbl(counter); - + + /** @req OS321 */ COUNTER_STD_END; } -TickType GetCounterValue_( counter_obj_t *c_p ) { - if( c_p->type == COUNTER_TYPE_HARD ) { - /* Grab the GPT */ -#if 0 - // TODO: Move this outside the OS?? - // Is this the HW value?? - // No good way to check if something went wrong here. Can check for != 0 - // but that can really happen - return (TickType)Gpt_GetTimeElapsed(c_p->driver.OsGptChannelRef ); -#else - return Frt_GetTimeElapsed(); -#endif - } else { - return c_p->val; - } -} - - StatusType GetCounterValue( CounterType counter_id , TickRefType tick_ref) -{ - counter_obj_t *counter; - counter = Oil_GetCounter(counter_id); +{ + StatusType rv = E_OK; + OsCounterType *cPtr; + cPtr = Oil_GetCounter(counter_id); + + /** @req OS376 */ + if( !IsCounterValid(counter_id) ) { + rv = E_OS_ID; + goto err; + } + + /** @req OS377 */ + if( cPtr->type == COUNTER_TYPE_HARD ) { + if( cPtr->driver == NULL ) { + /* It's OSINTERNAL */ + *tick_ref = os_sys.tick; + } else { +#if 0 + /* We support only GPT for now */ + *tick_ref = (TickType)Gpt_GetTimeElapsed(cPtr->driver.OsGptChannelRef); +#endif + + } + } else { + *tick_ref = cPtr->val; + } - *tick_ref = GetCounterValue_(counter); - return E_OK; + COUNTER_STD_END; } StatusType GetElapsedCounterValue( CounterType counter_id, TickRefType val, TickRefType elapsed_val) -{ - return E_OK; +{ + StatusType rv = E_OK; + OsCounterType *cPtr; + TickType tick; + + cPtr = Oil_GetCounter(counter_id); + + /** @req OS381 */ + if( !IsCounterValid(counter_id) ) { + rv = E_OS_ID; + goto err; + } + + /** @req OS391 */ + if( *val > Os_CounterGetMaxValue(cPtr) ) { + rv = E_OS_VALUE; + goto err; + } + + GetCounterValue(counter_id,&tick); + +#warning missing....OS382 + + COUNTER_STD_END; } /* @@ -296,7 +312,7 @@ void OsTick( void ) { // if not used, os_tick_counter < 0 if (Os_Arc_OsTickCounter >= 0) { - counter_obj_t *c_p = Oil_GetCounter(Os_Arc_OsTickCounter); + OsCounterType *c_p = Oil_GetCounter(Os_Arc_OsTickCounter); os_sys.tick++; @@ -309,23 +325,7 @@ void OsTick( void ) { } } -#if 0 -void OsIdle( void ) { - for(;;); -} -#endif - TickType GetOsTick( void ) { return get_os_tick(); } -#if 0 -StatusType InitCounter(AlarmType alarm_id ) { - - return E_OK; -} - -StatusType StartCounter( AlarmType alarm_id ) { - return E_OK; -} -#endif diff --git a/system/kernel/create.c b/system/kernel/create.c deleted file mode 100644 index 7708f7d9..00000000 --- a/system/kernel/create.c +++ /dev/null @@ -1,69 +0,0 @@ -/* -------------------------------- Arctic Core ------------------------------ - * Arctic Core - the open source AUTOSAR platform http://arccore.com - * - * Copyright (C) 2009 ArcCore AB - * - * This source code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by the - * Free Software Foundation; See . - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * -------------------------------- Arctic Core ------------------------------*/ - - -#include -#include -#include -#include -#include -#include "sys.h" -#include "pcb.h" -#include "Os.h" - -extern caddr_t *sbrk(int); - -#define os_alloc(_x) sbrk(_x) - -pcb_t * os_alloc_new_pcb( void ) { - void *h = os_alloc(sizeof(pcb_t)); - memset(h,0,sizeof(pcb_t)); - assert(h!=NULL); - return h; -} - -#if 0 -typedef void (*Os_IsrEntryType)(void); - - -typedef Os_IsrInfo_s { - Os_IsrEntryType entry; - uint32_t vector; - uint8_t priority; -} Os_IsrInfoType; -#endif - - -extern TaskType os_add_task( pcb_t *pcb ); - -static uint8 stackTop = 0x42; - -TaskType Os_CreateIsr( void (*entry)(void ), uint8_t prio, const char *name ) -{ - pcb_t *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_add_task(pcb); -} - diff --git a/system/kernel/event.c b/system/kernel/event.c index d771ec7a..5cfb1fac 100644 --- a/system/kernel/event.c +++ b/system/kernel/event.c @@ -13,23 +13,10 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - +#include +#include #include "Os.h" -#include "pcb.h" -#include "sys/queue.h" -#include "sys.h" -#include #include "internal.h" -#include "swap.h" -#include "task_i.h" -#include "hooks.h" #define VALIDATE_W_RV(_exp,_rv) \ if( (_exp) ) { \ @@ -54,7 +41,7 @@ StatusType WaitEvent( EventMaskType Mask ) { - pcb_t *curr_pcb = get_curr_pcb(); + OsPcbType *curr_pcb = get_curr_pcb(); StatusType rv = E_OK; if( os_sys.int_nest_cnt != 0 ) { @@ -65,17 +52,13 @@ StatusType WaitEvent( EventMaskType Mask ) { /* Remove from ready queue */ Irq_Disable(); - // Reschedule if mask not set already + // OSEK/VDX footnote 5. The call of WaitEvent does not lead to a waiting state if one of the events passed in the event mask to + // WaitEvent is already set. In this case WaitEvent does not lead to a rescheduling. if( !(curr_pcb->ev_set & Mask) ) { curr_pcb->ev_wait = Mask; - os_pcb_make_waiting(curr_pcb); - { - pcb_t *pcb; - pcb = os_find_top_prio_proc(); - assert(pcb!=NULL); - os_swap_context(curr_pcb,pcb); - } + Os_TaskMakeWaiting(curr_pcb); + Os_Dispatch(0); } Irq_Enable(); @@ -100,10 +83,18 @@ StatusType WaitEvent( EventMaskType Mask ) { StatusType SetEvent( TaskType TaskID, EventMaskType Mask ) { StatusType rv = E_OK; - pcb_t *dest_pcb; + OsPcbType *dest_pcb; + OsPcbType *currPcbPtr; + uint32_t flags; - dest_pcb = os_get_pcb(TaskID); - Irq_Disable(); + dest_pcb = os_get_pcb(TaskID); + +#warning OS327 Scalability class 3 and 4 should always use extended status + + if( TaskID >= Oil_GetTaskCnt() ) { + rv = E_OS_ID; + goto err; + } if( (dest_pcb->state & ST_SUSPENDED ) ) { rv = E_OS_STATE; @@ -114,22 +105,46 @@ StatusType SetEvent( TaskType TaskID, EventMaskType Mask ) { rv = E_OS_ACCESS; goto err; } - - // If at least one of the events match, taskID from waiting to ready - // (if not already) - if( Mask & dest_pcb->ev_wait ) { - os_pcb_make_ready(dest_pcb); - } - + + Irq_Save(flags); + + /* Calling SetEvent causes the task to be transferred + * to the ready state, if it was waiting for at least one of the + * events specified in . + * + * OSEK/VDX 4.6.1, rescheduling is performed in all of the following cases: + * .. + * Setting an event to a waiting task at task level (e.g. system service SetEvent, + * see chapter 13.5.3.1, message notification mechanism, alarm expiration, if event setting + * defined, see chapter 9.2) + * ... */ + if( (Mask & dest_pcb->ev_wait) ) { + /* We have a an event match */ + if( dest_pcb->state & ST_WAITING) { + Os_TaskMakeReady(dest_pcb); + + currPcbPtr = Os_TaskGetCurrent(); + /* Checking "4.6.2 Non preemptive scheduling" it does not dispatch if NON */ + if( (os_sys.int_nest_cnt == 0) && + (currPcbPtr->scheduling == FULL) ) + { + Os_Dispatch(0); + } + + } else if(dest_pcb->state & ST_READY ) { + /* Hmm, we do nothing */ + } + } + dest_pcb->ev_set |= Mask; - Irq_Enable(); + Irq_Restore(flags); OS_STD_END_2(OSServiceId_SetEvent,TaskID, Mask); } StatusType GetEvent( TaskType TaskId, EventMaskRefType Mask) { - pcb_t *dest_pcb; + OsPcbType *dest_pcb; StatusType rv = E_OK; dest_pcb = os_get_pcb(TaskId); @@ -147,7 +162,7 @@ StatusType GetEvent( TaskType TaskId, EventMaskRefType Mask) { StatusType ClearEvent( EventMaskType Mask) { StatusType rv = E_OK; - pcb_t *pcb; + OsPcbType *pcb; if( os_sys.int_nest_cnt != 0 ) { rv = E_OS_CALLEVEL; diff --git a/system/kernel/include/alarm_i.h b/system/kernel/include/alarm_i.h index e8736645..198752bc 100644 --- a/system/kernel/include/alarm_i.h +++ b/system/kernel/include/alarm_i.h @@ -13,19 +13,30 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ +#ifndef ALARM_I_H_ +#define ALARM_I_H_ + +#include "counter_i.h" +/* STD container : OsAlarmSetEvent + * OsAlarmSetEventRef: 1 + * OsAlarmSetEventTaskRef: 1 + * */ +/* STD container : OsAlarmActivateTask + * OsAlarmActivateTaskRef: 1 + * */ +/* STD container : OsAlarmCallback + * OsAlarmCallbackName: 1 Function Ptr + * */ +/* STD container : OsAlarmIncrementCounter + * OsAlarmIncrementCounterRef: 1 Ref to counter + * */ - - -#ifndef ALARM_I_H_ -#define ALARM_I_H_ - -#include "counter_i.h" -struct counter_obj_s; +struct OsCounter; typedef enum alarm_action_type_e { ALARM_ACTION_ACTIVATETASK=0, @@ -34,26 +45,43 @@ typedef enum alarm_action_type_e { ALARM_ACTION_INCREMENTCOUNTER, /* SWS OS302 */ } alarm_action_type_t; - -typedef struct alarm_action_s { + +/* STD container : OsAlarmAction + * OsAlarmActivateTask: 0..1 + * OsAlarmCallback: 0..1 + * OsAlarmIncrementCounter: 0..1 + * OsAlarmSetEvent: 0..1 + * */ +typedef struct OsAlarmAction { alarm_action_type_t type; TaskType task_id; EventMaskType event_id; CounterType counter_id; -} alarm_action_t; - -typedef struct alarm_autostart_s { +} OsAlarmActionType; + +/* STD container : OsAlarmAutostart + * OsAlarmAlarmTime: 1 Int + * OsAlarmAutoStartType: 1 Int, ABSOLUTE, RELATIVE + * OsAlarmCycleTime: 1 Int + * OsAlarmAppModeRef: 1..* + */ +typedef struct OsAlarmAutostart { _Bool active; uint32 alarmtime; uint32 cycletime; uint32 appmode_mask; -} alarm_autostart_t; - -typedef struct alarm_obj_s { - - char name[16]; +} OsAlarmAutostartType; + +/* STD container : OsAlarm + * OsAlarmAccessionApplication: 0..* Ref to OS application + * OsAlamCounterRef: 1 Ref to counter + * OsAlarmAction[C] 1 Action when alarm expires + * OsAlarmAutostart[C] 0..1 Autostart + */ +typedef struct OsAlarm { + char name[16]; /* Reference to counter */ - struct counter_obj_s *counter; + struct OsCounter *counter; CounterType counter_id; /* cycle, 0 = no cycle */ @@ -61,32 +89,27 @@ typedef struct alarm_obj_s { uint32 cycletime; uint32 appmode_mask; - alarm_autostart_t autostart; - uint32 app_mask; /* if the alarm is active or not */ - _Bool active; + _Bool active; /* expire value */ - uint32 expire_val; - - - // Action attributes when alarm expires. - alarm_action_t action; -/* - alarm_action_type_t action_type; - TaskType action_pid; - EventMaskType action_event; - CounterType action_counter; -*/ + uint32 expire_val; + /* Action attributes when alarm expires. */ + OsAlarmActionType action; + + /* Autostart */ + OsAlarmAutostartType autostart; + /* List of alarms connected to the same counter */ - SLIST_ENTRY(alarm_obj_s) alarm_list; - /* TODO: OS242, callback in scalability class 1 only..*/ -#if 0 - void (*cb)(void); -#endif -} alarm_obj_t; - + SLIST_ENTRY(OsAlarm) alarm_list; + +#if (OS_SC1 == STD_ON) +#warning Alarm callbacks NOT implemented + /* TODO: OS242, callback in scalability class 1 only..*/ + /** @req OS242 */ +#endif +} OsAlarmType; #endif /*ALARM_I_H_*/ diff --git a/system/kernel/include/application.h b/system/kernel/include/application.h new file mode 100644 index 00000000..30fd569e --- /dev/null +++ b/system/kernel/include/application.h @@ -0,0 +1,79 @@ + +#ifndef APPLICATION_H_ +#define APPLICATION_H_ + +#if ( OS_SC3 == STD_ON) || ( OS_SC4 == STD_ON ) + +/* STD container : OsApplicationHooks + * class: 3,4 + * OsAppErrorHook: 1 Bool + * OsAppShutdownHook: 1 Bool + * OsAppStartupHook: 1 Bool + */ + +typedef struct OsAppHooks { + void (*startup)( void ); + void (*shutdown)( Std_ReturnType Error ); + void (*error)( Std_ReturnType Error ); +} OsAppHooksType; + + +/* STD container : OsApplication + * OsTrusted: 1 Bool + * OsAppAlarmRef: 0..* + * OsAppCounterRef: 0..* + * OsAppIsrRef: 0..* + * OsAppResourceRef: 0..* + * OsAppScheduleTableRef: 0..* + * OsAppTaskRef: 0..* + * OsRestartTask: 0..1 Ref to system restart task + * OsApplicatinHooks[C] 1 + * OsApplictionTrustedFunction[C]: 0..* + * + * Note! referenced objects also can be accessed by multiple applications. + * Note! speed is needed when looking up the accessing application, not vice versa. + * Note! The application knowledge about what objects belong to it is just a memory + * management issue, not an access issue. + * */ + +typedef struct OsApplication { + /* 0 - Non-trusted application + * 1 - Trusted application */ + _Bool trusted; + + /* NOTE! Refs here is memory management issue */ + + /* The application hooks */ + OsAppHooksType hooks; + + /* Trusted functions */ + /* .... */ +} OsApplicationType; + + +/* NON standard type. + * Used for ROM based parameters.... TODO + */ +typedef struct OsRomApplication { + uint32 application_id; + char name[16]; + uint8 trusted; + + /* hooks */ + void (*StartupHook)( void ); + void (*ShutdownHook)( Std_ReturnType Error ); + void (*ErrorHook)( Std_ReturnType Error ); + + uint32 isr_mask; + uint32 scheduletable_mask; + uint32 alarm_mask; + uint32 counter_mask; + uint32 resource_mask; + uint32 message_mask; + +} OsRomApplicationType; + +#endif /* ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) */ + + +#endif /* APPLICATION_H_ */ diff --git a/system/kernel/include/arch.h b/system/kernel/include/arch.h index bf6b8070..a859302d 100644 --- a/system/kernel/include/arch.h +++ b/system/kernel/include/arch.h @@ -13,13 +13,6 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - /* * Porting interface. Should really be called port.h or something. @@ -31,6 +24,20 @@ #define ARCH_H_ #define STACK_PATTERN 0x42 + + + +/** + * Swap context with a context. The difference between this + * function and Os_ArchSwapContext is that the later use + * the current stack. This one uses stack from context. + * + * @param old always NULL + * @param new Ptr to pcb. + * @param context Ptr to context + * @return + */ +void Os_ArchSwapContextToW(void *old,void *new, void *context ); /** * Swap context. @@ -39,15 +46,15 @@ * @param old - old ptr to pcb * @return */ -void os_arch_swap_context(void *old,void *new); +void Os_ArchSwapContext(void *old,void *new); /** * Swap context for the first time for a task * * The only way to call this function right now is to: - * os_swap_context_to(NULL,); + * Os_TaskSwapContextTo(NULL,); */ -void os_arch_swap_context_to(void *old,void *new); +void Os_ArchSwapContextTo(void *old,void *new); /** * Setup a pcb before use. @@ -60,14 +67,14 @@ void os_arch_swap_context_to(void *old,void *new); * * @param pcb Ptr to pcb */ -void os_arch_setup_context( pcb_t *pcb ); +void os_arch_setup_context( OsPcbType *pcb ); /** * Get current stack pointer * * @return current stack pointer */ -void *os_arch_get_stackptr( void ); +void *Os_ArchGetStackPtr( void ); /** * Initialize the hardware. @@ -93,37 +100,17 @@ void os_arch_first_call( void ); * * @return The small context size in bytes */ -unsigned int os_arch_get_sc_size( void ); +unsigned int Os_ArchGetScSize( void ); + +void OsArch_SetTaskEntry(OsPcbType *pcbPtr ); #if 0 -void *os_arch_get_stack_usage( pcb_t * ); +void *os_arch_get_stack_usage( OsPcbType * ); -_Bool os_arch_stack_endmark_ok( pcb_t *); +_Bool os_arch_stack_endmark_ok( OsPcbType *); #endif -static inline void os_arch_stack_set_endmark( pcb_t *pcb ) { - uint8_t *end = pcb->stack.top; - *end = STACK_PATTERN; -} - -static inline _Bool os_arch_stack_endmark_ok( pcb_t *pcb ) { - uint8_t *end = pcb->stack.top; - return ( *end == STACK_PATTERN); -} - - -static inline void *os_arch_get_stack_usage( pcb_t *pcb ) { - - uint8_t *p = pcb->stack.curr; - uint8_t *end = pcb->stack.top; - - while( (*end == STACK_PATTERN) && (endalarm_base.maxallowedvalue; +} -TickType GetCounterValue_( counter_obj_t *c_p ); +static inline TickType Os_CounterGetValue( OsCounterType *cPtr ) { + return cPtr->val; +} + + +/** + * + * @param curr + * @param max + * @param add + * @return + */ +static inline TickType Os_CounterCalcModulo( TickType curr, TickType max, TickType add ) { + TickType diff = max - curr; + return (diff >= add ) ? (curr + add) : (add - curr); +} + + #endif /*COUNTER_I_H_*/ diff --git a/system/kernel/include/debug.h b/system/kernel/include/debug.h index 28936633..90404288 100644 --- a/system/kernel/include/debug.h +++ b/system/kernel/include/debug.h @@ -13,46 +13,9 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - #ifndef DEBUG_H_ #define DEBUG_H_ - -#include - -#ifdef USE_DBG_PRINTF - -#define DBG_T32_TERMINAL 1 -// Swap hook -#define DGB_HOOK_SWAP 1 - -#define DBG_START_OS 1 - -#define DBG_EXCEPTION 1 - -// C99, see gcc manual for more info if no args.. -// WARNING!! This eats lots and lots of stack, about 500bytes ?? - -//#defineos_printf(format,...) printf(format,__VA_ARGS__) -#define os_printf(format,...) simple_printf(format,__VA_ARGS__) -// #define os_printf(format,...) iprintf(format,__VA_ARGS__) - -// Macro's that don't take the whole stack... -// #define os_print_hex() -// #define os_print(char *str); - -#else - -#define os_printf(format,...) - -#endif - - - - + +#error debug.h is obsolete + #endif /*DEBUG_H_*/ diff --git a/system/kernel/include/ext_config.h b/system/kernel/include/ext_config.h index bc65d7fa..47d0d8a9 100644 --- a/system/kernel/include/ext_config.h +++ b/system/kernel/include/ext_config.h @@ -13,46 +13,38 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - #ifndef EXT_CONFIG_H_ #define EXT_CONFIG_H_ /* Created in Oil_Config */ -struct pcb_s; -struct alarm_obj_s; -struct counter_obj_s; -struct sched_table_s; -//struct app_s; -struct rom_app_s; -struct resource_obj_s; -struct rom_app_s; -struct message_obj_s; -//extern struct pcb_s pcb_list[]; -//extern struct app_s app_list[]; -//extern struct rom_app_s rom_app_list[]; - +struct OsPcb; +struct OsAlarm; +struct OsCounter; +struct OsSchTbl; +struct OsResource; +struct OsMessage; +#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) +struct OsRomApplication; +#endif + +#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) int Oil_GetApplCnt(void); -struct rom_app_s *Oil_GetApplObj( ApplicationType application_id ); +struct OsRomApplication *Oil_GetApplObj( ApplicationType application_id ); +#endif int Oil_GetTaskCnt(void); void *Oil_GetIdleProcStack(void); int Oil_GetResourceCnt(void); StatusType Oil_GetAlarmBase(AlarmType alarm_id, AlarmBaseRefType info); uint32 Oil_GetAlarmCnt(void); -struct alarm_obj_s *Oil_GetAlarmObj( AlarmType alarm_id ); -struct counter_obj_s *Oil_GetCounter(CounterType); +struct OsAlarm *Oil_GetAlarmObj( AlarmType alarm_id ); +struct OsCounter *Oil_GetCounter(CounterType); uint32 Oil_GetCounterCnt(void ); uint32 Oil_GetSchedCnt( void ); -struct sched_table_s *Oil_GetSched( ScheduleTableType sched_id ); +struct OsSchTbl *Oil_GetSched( ScheduleTableType sched_id ); uint32 Oil_GetServiceCnt( void ) ; -struct resource_obj_s *Oil_GetResource( ResourceType resource ); +struct OsResource *Oil_GetResource( ResourceType resource ); -struct message_obj_s *Oil_GetMessage(MessageType message_id); +struct OsMessage *Oil_GetMessage(MessageType message_id); uint32 Oil_GetMessageCnt(void ); #endif /*EXT_CONFIG_H_*/ diff --git a/system/kernel/include/hooks.h b/system/kernel/include/hooks.h index 00438f1e..e0a1cd45 100644 --- a/system/kernel/include/hooks.h +++ b/system/kernel/include/hooks.h @@ -13,41 +13,7 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - #ifndef HOOKS_H_ #define HOOKS_H_ -#include "sys.h" -#include "pcb.h" -#include "kernel.h" - -/* Called for sequence of error hook calls in case a service - * does not return with E_OK. Note that in this case the general error hook and the OS- - * Application specific error hook are called. - */ - -#define ERRORHOOK(x) \ - if( os_sys.hooks->ErrorHook != NULL ) { \ - os_sys.hooks->ErrorHook(x); \ - } - - -#define PRETASKHOOK() \ - if( os_sys.hooks->PreTaskHook != NULL ) { \ - os_sys.hooks->PreTaskHook(); \ - } - -#define POSTTASKHOOK() \ - if( os_sys.hooks->PostTaskHook != NULL ) { \ - os_sys.hooks->PostTaskHook(); \ - } - - - #endif /*HOOKS_H_*/ diff --git a/system/kernel/include/internal.h b/system/kernel/include/internal.h index eda95dc6..a5d95867 100644 --- a/system/kernel/include/internal.h +++ b/system/kernel/include/internal.h @@ -14,13 +14,53 @@ * -------------------------------- Arctic Core ------------------------------*/ #ifndef INTERNAL_H_ -#define INTERNAL_H_ - -#include -#include "Ramlog.h" -#include "simple_printf.h" - -extern uint32 os_dbg_mask; +#define INTERNAL_H_ + +/* Using internal.h + * + * Os.h + * | + * |--- Os_Cfg.h + * | + * |--- Std_Types.h + * | |--- Platform_Types.h (std?) + * | |--- Compiler.h (std?) + * | + * |--- MemMap.h + * + * + * task.c + * |--- Os.h + * |--- internal.h + * + * + * + * kernel.h (shared types between config and OS source... pointless?) + * | + * |------------------| + * Os_Cfg.c internal.h + * + * + * API's + * ------------------------------------- + * Os.h - OS API and types + * os_config_func.h - Inline API for Os_Cfg.c + * ext_config.h - API for os_config_func.h, used by kernel + * internal.h - Internal API for kernel, do NOT expose outside kernel + * + * os_types.h - Internal types for the kernel + * + * + */ + + + + +#include +#include +#include + +extern uint32_t os_dbg_mask; /* * 0 master print normal, 1-print @@ -41,7 +81,7 @@ extern uint32 os_dbg_mask; * 0x7 */ -extern uint32 os_dbg_mask; +extern uint32_t os_dbg_mask; #define STR_TASK "OS_TASK" #define STR_ALARM "OS_ALARM" @@ -79,78 +119,125 @@ extern uint32 os_dbg_mask; ramlog_printf(format,## __VA_ARGS__ ); \ } \ } - -#if 0 -#define os_isr_printf(D_TASK,format,...) \ - if( (os_dbg_mask | OS_DBG_ISR_MASTER_PRINT | OS_DBG_TASK) \ - == os_dbg_mask ) { \ - simple_printf("[%08d] %s: ",GetOsTick(), STR_TASK); \ - simple_printf(format,## __VA_ARGS__ ); \ - } - -#define os_dbg_task_printf(format,...) \ - if( (os_dbg_mask | OS_DBG_MASTER_PRINT | OS_DBG_TASK) \ - == os_dbg_mask ) { \ - simple_printf("[%08d] %s: ",GetOsTick(), STR_TASK); \ - simple_printf(format,## __VA_ARGS__ ); \ - } -#endif - -#if 0 -static inline void Irq_Disable( void ) { - Irq_Disable(); -} - -static inline void Irq_Enable( void ) { - Irq_Enable(); -} -#endif - - -#if 0 -#define os_dbg_m_printf(_x,format,...) \ - if( (os_dbg_mask | OS_DBG_ISR_MASTER_PRINT | (_x)) == os_dbg_mask) { \ - simple_printf(format,## __VA_ARGS__ ); \ - } -#endif + + +#include "kernel.h" +#include "task_i.h" +#include "ext_config.h" + + + +/* + * Macros for error handling + * Registers service id of the erroneous function and the applicable parameters + * to os_error. Functions that have less than three parameters do not touch + * os_error.param3. Same rule follows for other parameter counts. + */ + +/* Error handling for functions that take no arguments */ +#define OS_STD_END(_service_id) \ + goto ok; \ + err: \ + os_error.serviceId=_service_id;\ + ERRORHOOK(rv); \ + ok: \ + return rv; + +/* Error handling for functions that take one argument */ +#define OS_STD_END_1(_service_id, _p1) \ + goto ok; \ + err: \ + os_error.serviceId=_service_id;\ + os_error.param1 = (uint32_t) _p1; \ + ERRORHOOK(rv); \ + ok: \ + return rv; + +/* Error handling for functions that take two arguments */ +#define OS_STD_END_2(_service_id, _p1,_p2) \ + goto ok; \ + err: \ + os_error.serviceId=_service_id;\ + os_error.param1 = (uint32_t) _p1; \ + os_error.param2 = (uint32_t) _p2; \ + ERRORHOOK(rv); \ + ok: \ + return rv; + +/* Error handling for functions that take three arguments */ +#define OS_STD_END_3(_service_id,_p1,_p2,_p3) \ + goto ok; \ + err: \ + os_error.serviceId=_service_id;\ + os_error.param1 = (uint32_t) _p1; \ + os_error.param2 = (uint32_t) _p2; \ + os_error.param3 = (uint32_t) _p3; \ + ERRORHOOK(rv); \ + ok: \ + return rv; + + + +/* Called for sequence of error hook calls in case a service + * does not return with E_OK. Note that in this case the general error hook and the OS- + * Application specific error hook are called. + */ + +#define ERRORHOOK(x) \ + if( os_sys.hooks->ErrorHook != NULL ) { \ + os_sys.hooks->ErrorHook(x); \ + } + + +#define PRETASKHOOK() \ + if( os_sys.hooks->PreTaskHook != NULL ) { \ + os_sys.hooks->PreTaskHook(); \ + } + +#define POSTTASKHOOK() \ + if( os_sys.hooks->PostTaskHook != NULL ) { \ + os_sys.hooks->PostTaskHook(); \ + } /* * PCB manipulating functions */ -static inline procid_t get_curr_pid( void ) { +static inline OsTaskidType get_curr_pid( void ) { return os_sys.curr_pcb->pid; } -static inline pcb_t *get_curr_pcb( void ) { +static inline OsPcbType *get_curr_pcb( void ) { return os_sys.curr_pcb; } -static inline void set_curr_pcb( pcb_t *pcb ) { +static inline void set_curr_pcb( OsPcbType *pcb ) { os_sys.curr_pcb = pcb; } -static inline _Bool is_idle_task( pcb_t *pcb ){ +static inline _Bool is_idle_task( OsPcbType *pcb ){ return (pcb->pid == 0); } -static inline procid_t get_curr_prio( void ){ +static inline OsTaskidType get_curr_prio( void ){ return os_sys.curr_pcb->prio; } static inline TickType get_os_tick( void ) { return os_sys.tick; } - -static inline app_t *get_curr_application( void ) { + +#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) +static inline OsApplicationType *get_curr_application( void ) { return get_curr_pcb()->application; } static inline uint32_t get_curr_application_id( void ) { return get_curr_pcb()->application->application_id; } +#endif -static inline struct resource_obj_s *os_get_resource_int_p( void ) { +static inline struct OsResource *os_get_resource_int_p( void ) { return get_curr_pcb()->resource_int_p; } @@ -163,19 +250,76 @@ static inline uint32_t os_task_nr_to_mask( uint32_t nr ) { } // task_i.c -pcb_t *os_find_top_prio_proc( void ); -pcb_t *os_find_task( TaskType tid ); +OsPcbType *Os_TaskGetTop( void ); +OsPcbType *os_find_task( TaskType tid ); // resource.c -void os_resource_get_internal(void ); -void os_resource_release_internal( void ); -// Create.c -pcb_t * os_alloc_new_pcb( void ); +void Os_ResourceGetInternal(void ); +void Os_ResourceReleaseInternal( void ); + + +static inline void Os_ResourceCheckAndRelease( OsPcbType *pcb ) { + if( !TAILQ_EMPTY(&pcb->resource_head) ) { + OsResourceType *rPtr; + + TAILQ_FOREACH(rPtr, &pcb->resource_head, listEntry ) { + ReleaseResource(rPtr->nr); + /* Requirements are a little fuzzy here, no explicit + * requirement for this. + */ + ERRORHOOK(E_OS_RESOURCE); + } + } +} + +// Create.c +OsPcbType * os_alloc_new_pcb( void ); + +void os_dispatch(void); void OsTick( void ); -void *Os_Isr( void *stack, void *pcb_p ); - +void *Os_Isr( void *stack, void *pcb_p ); +void Os_Dispatch( _Bool force ); + +#define STACK_PATTERN 0x42 + +static inline void *Os_StackGetUsage( OsPcbType *pcb ) { + + uint8_t *p = pcb->stack.curr; + uint8_t *end = pcb->stack.top; + + while( (*end == STACK_PATTERN) && (endstack.top; + *end = STACK_PATTERN; +} + +static inline _Bool Os_StackIsEndmarkOk( OsPcbType *pcbPtr ) { + uint8_t *end = pcbPtr->stack.top; + return ( *end == STACK_PATTERN); +} + + +int Oil_GetTaskCnt(void); +void Os_ContextReInit( OsPcbType *pcbPtr ); + + +static inline _Bool Os_IrqAnyDisabled( void ) { + return ((Os_IntDisableAllCnt | Os_IntSuspendAllCnt | Os_IntSuspendOsCnt) != 0); +} + +static inline void Os_IrqClearAll( void ) { + Os_IntDisableAllCnt = 0; + Os_IntSuspendAllCnt = 0; + Os_IntSuspendOsCnt = 0; +} + #endif /*INTERNAL_H_*/ diff --git a/system/kernel/include/kernel.h b/system/kernel/include/kernel.h index f247bff4..89403a33 100644 --- a/system/kernel/include/kernel.h +++ b/system/kernel/include/kernel.h @@ -17,155 +17,66 @@ #ifndef KERNEL_H_ #define KERNEL_H_ -#include -#include "Os.h" -#include "counter_i.h" -#include "alarm_i.h" -#include "sched_table_i.h" +#include +#include "Os.h" +#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) typedef void ( * trusted_func_t)( TrustedFunctionIndexType , TrustedFunctionParameterRefType ); - -/*-----------------------------------------------------------------*/ -/* Global Hooks( non-application specific ) */ - -typedef struct os_conf_global_hooks_s { - ProtectionHookType ProtectionHook; - StartupHookType StartupHook; - ShutdownHookType ShutdownHook; - ErrorHookType ErrorHook; - PreTaskHookType PreTaskHook; - PostTaskHookType PostTaskHook; -} os_conf_global_hooks_t; - -/*-----------------------------------------------------------------*/ - -/* - * The only information about the COM that is valid is - * in the COM specification ..SWS_COM.pdf. - * - * The most important requirements are COM010 and COM013 - * - * Com_Init() - * Com_DeInit() - * - * No error hooks.. - * No. GetMessageStatus() - * No. SendZeroMessage() - * No. SendDynamicMessage(), RecieveDynamicMessage() - * - * See http://www.altium.com/files/AltiumDesigner6/LearningGuides/GU0102%20TSK51x%20TSK52x%20RTOS.pdf - * - * Yes. SendMessage() - * - * */ - -typedef enum message_property_e { - // ??? - SEND_STATIC_INTERNAL, - // messages are not consumed during read - RECEIVE_UNQUEUED_INTERNAL, - // We have an internal queue - RECEIVE_QUEUE_INTERNAL, -} message_property_t; - - - -typedef enum message_notification_action_e { - MESSAGE_NOTIFICATION_ACTION_NONE=0, - MESSAGE_NOTIFICATION_ACTION_ACTIVATETASK, - MESSAGE_NOTIFICATION_ACTION_SETEVENT, -} message_notification_action_t; - -typedef struct message_notification_s { - message_notification_action_t type; - TaskType task_id; - EventMaskType event_id; -} message_notification_t; +#endif - -typedef struct message_obj_s { - message_property_t property; // send/recieve... - int q_size; // 0-Not queued - message_notification_t notification; - // TODO: This is not a good solution but it will have to do for now - void *data; - int data_size; -} message_obj_t; - -/* OsTask/OsTaskSchedule */ -enum OsTaskSchedule { - FULL, - NON -}; - -/*-----------------------------------------------------------------*/ - -typedef uint8_t proc_type_t; - -#define PROC_PRIO 0x1 -#define PROC_BASIC 0x1 -#define PROC_EXTENDED 0x3 - -#define PROC_ISR 0x4 -#define PROC_ISR1 0x4 -#define PROC_ISR2 0xc - - -typedef struct { - void *curr; // Current stack ptr( at swap time ) - void *top; // Top of the stack( low address ) - uint32 size; // The size of the stack -} stack_t; - -typedef struct rom_app_s { - uint32 application_id; - char name[16]; - uint8 trusted; - - /* hooks */ - void (*StartupHook)( void ); - void (*ShutdownHook)( Std_ReturnType Error ); - void (*ErrorHook)( Std_ReturnType Error ); - - uint32 isr_mask; - uint32 scheduletable_mask; - uint32 alarm_mask; - uint32 counter_mask; - uint32 resource_mask; - uint32 message_mask; - -} rom_app_t; - -/*-----------------------------------------------------------------*/ - -typedef struct lockingtime_obj_s { - char id[16]; - int resource; - int resource_clock_time; - int all_interrupt_clock_time; - int os_interrupt_clock_time; - int locking_type; -} lockingtime_obj_t; - +/* STD container : OsOs. OSEK properties + * Class: ALL + * + * OsScalabilityClass: 0..1 SC1,SC2,SC3,SC4 + * OsStackMonitoring: 1 Stack monitoring of tasks/category 2 + * OsStatus 1 EXTENDED or STANDARD status + * OsUseGetServiceId 1 We can use the OSErrorGetServiceId() function + * OsUseParameterAccess 1 We save the parameters in OSError_XX_YY() + * OsUseResScheduler 1 + * OsHooks[C] 1 + * + * From OSEK/VDX oil: + * + * OS ExampleOS { + * STATUS = STANDARD; + * STARTUPHOOK = TRUE; + * ERRORHOOK = TRUE; + * SHUTDOWNHOOK = TRUE; + * PRETASKHOOK = FALSE; + * POSTTASKHOOK = FALSE; + * USEGETSERVICEID = FALSE; + * USEPARAMETERACCESS = FALSE; + * USERESSCHEDULER = TRUE; + * }; + * + * OS_SC1 | OS_SC2 | OS_SC3 | OS_SC4 + * OS_STACK_MONITORING + * OS_STATUS_EXTENDED / OS_STATUS_STANDARD + * OS_USE_GET_SERVICE_ID + * OS_USE_PARAMETER_ACCESS + * OS_RES_SCHEDULER + * */ + typedef enum { - // the normal behaviour + /* External resource */ RESOURCE_TYPE_STANDARD, - // ?? + /* ?? */ RESOURCE_TYPE_LINKED, - // Used for grouping tasks + /* Internal resource */ RESOURCE_TYPE_INTERNAL -} resource_type_t; +} OsResourceTypeType; -typedef struct { - resource_type_t type; - // used only if type is RESOURCE_TYPE_LINKED +typedef struct { + + OsResourceTypeType type; + /* used only if type is RESOURCE_TYPE_LINKED */ ResourceType linked_resource; -} resource_property_t; +} OsResourcePropertyType; /*-----------------------------------------------------------------*/ -typedef struct resource_obj_s { +typedef struct OsResource { char id[16]; // The running number, starting at RES_SCHEDULER=0 int nr; @@ -183,35 +94,22 @@ typedef struct resource_obj_s { // Owner of the resource... TaskType owner; - resource_type_t type; + OsResourceTypeType type; // used only if type is RESOURCE_TYPE_LINKED ResourceType linked_resource; /* List of resources for each task. */ - TAILQ_ENTRY(resource_obj_s) listEntry; + TAILQ_ENTRY(OsResource) listEntry; -} resource_obj_t; +} OsResourceType; typedef enum { LOCK_TYPE_RESOURCE, LOCK_TYPE_INTERRUPT, -} lock_type_t; - -/* -typedef struct { - ResourceType resource; - uint64 locktime; -} resource_locktime_t; - -typedef struct { - uint64 all; - uint64 os; -} interrupt_locktime_t; -*/ +} OsLocktypeType; -typedef struct lockingtime_s { -// lock_type_t type; - lock_type_t type; +typedef struct OsLockingtime { + OsLocktypeType type; union { struct { ResourceType id; @@ -223,12 +121,9 @@ typedef struct lockingtime_s { uint64 os; } interrupt; } u; -// resource_locktime_t resource; -// interrupt_locktime_t interrupt; -// } locktime; -} lockingtime_t; +} OsLockingtimeType; -typedef struct timing_protection_s { +typedef struct OsTimingProtection { // ROM, worst case execution budget in ns uint64 execution_budget; // ROM, the frame in ns that timelimit may execute in. @@ -236,127 +131,46 @@ typedef struct timing_protection_s { // ROM, time in ns that the task/isr may with a timeframe. uint64 timelimit; // ROM, resource/interrupt locktimes - lockingtime_t *lockingtime; - -// interrupt_locktime_t interrupt_locktime; - // ROM, resource lock times -// const resource_locktime_t *resource_locktime_list; -// lockingtime_t *lockingtime; -} timing_protection_t; - - -/*-----------------------------------------------------------------*/ - -typedef struct rom_pcb_s { - TaskType pid; - uint8 prio; - uint32 app_mask; - void (*entry)(); - proc_type_t proc_type; - uint8 autostart; - stack_t stack; - int vector; // ISR - ApplicationType application_id; - char name[16]; - enum OsTaskSchedule scheduling; - uint32_t resourceAccess; -// uint64 execution_budget; -// uint32 count_limit; -// uint64 time_limit; - // pointer to internal resource - // NULL if none - resource_obj_t *resource_int_p; - timing_protection_t *timing_protection; -// lockingtime_obj_t -} rom_pcb_t; - - -/*-----------------------------------------------------------------*/ - -typedef struct sched_action_s { - int type; // 0 - activate task, 1 - event - uint64 offset; // for debug only??? - uint64 delta; // delta to next action - TaskType task_id; - EventMaskType event_id; // used only if event.. -} sched_action_t; - -/*-----------------------------------------------------------------*/ - - -/* - -typedef enum message_type_e { - // ??? - SEND_STATIC_INTERNAL, - // messages are not consumed during read - RECEIVE_UNQUEUED_INTERNAL, - // We have an internal queue - RECEIVE_QUEUE_INTERNAL, -} message_type_t; -*/ - -#if 0 -typedef struct message_obj_s { - char name[16]; - message_type_t type; - void * - char name[16]; - uint32 accessingapplications_mask; - // TODO: Below types are NOT OK !!!!!!! - void* cdatatype; - void* initialvalue; - uint32 queuesize; - message_property_t messageproperty; - void * callbackroutine; - uint32 callbackMessage; - void* flagname; - uint32 notification; - -} message_obj_t; -#endif - + OsLockingtimeType *lockingtime; +} OsTimingProtectionType; + +#include "counter_i.h" +#include "alarm_i.h" +#include "sched_table_i.h" +#include "application.h" +#include "pcb.h" +#include "sys.h" /*-----------------------------------------------------------------*/ -typedef struct memory_s { - uint32_t flags; - /* ptr to start of memory region */ - void *start; - /* size in bytes */ - uint32_t size; -} memory_t; - /*-----------------------------------------------------------------*/ /* * debug settings for os_debug_mask * */ -#define OS_DBG_MASTER_PRINT (1<<0) -#define OS_DBG_ISR_MASTER_PRINT (1<<1) +#define OS_DBG_MASTER_PRINT (1<<0) +#define OS_DBG_ISR_MASTER_PRINT (1<<1) #define OS_DBG_STDOUT (1<<2) #define OS_DBG_ISR_STDOUT (1<<3) // Enable print dbg_XXXX (not dbg_isr_XXX though) -#define D_MASTER_PRINT (1<<0) +#define D_MASTER_PRINT (1<<0) // Enable print for all dbg_isr_XXX -#define D_ISR_MASTER_PRINT (1<<1) +#define D_ISR_MASTER_PRINT (1<<1) // print to STDOUT. If not set it prints to ramlog -#define D_STDOUT (1<<2) -#define D_RAMLOG 0 +#define D_STDOUT (1<<2) +#define D_RAMLOG 0 // print to STDOUT, If not set print to ramlog -#define D_ISR_STDOUT (1<<3) -#define D_ISR_RAMLOG 0 +#define D_ISR_STDOUT (1<<3) +#define D_ISR_RAMLOG 0 #define D_TASK (1<<16) -#define D_ALARM (1<<18) +#define D_ALARM (1<<18) -#define OS_DBG_TASK (1<<16) +#define OS_DBG_TASK (1<<16) #define OS_DBG_ALARM (1<<18) - - - + #endif /* KERNEL_H_ */ diff --git a/system/kernel/include/pcb.h b/system/kernel/include/pcb.h index 209b1b97..ac59459f 100644 --- a/system/kernel/include/pcb.h +++ b/system/kernel/include/pcb.h @@ -12,141 +12,191 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - #ifndef PCB_H #define PCB_H + +struct OsApplication; +struct OsRomPcb; -#include "types.h" -#include "sys/queue.h" -#include "Os.h" -#include "kernel.h" -#include "counter_i.h" -#include -//#include "app_i.h" - -#define PID_IDLE 0 -#define PRIO_IDLE 0 +#define PID_IDLE 0 +#define PRIO_IDLE 0 -#define ST_READY 1 -#define ST_WAITING (1<<1) -#define ST_SUSPENDED (1<<2) -#define ST_RUNNING (1<<3) -#define ST_NOT_STARTED (1<<4) +#define ST_READY 1 +#define ST_WAITING (1<<1) +#define ST_SUSPENDED (1<<2) +#define ST_RUNNING (1<<3) +#define ST_NOT_STARTED (1<<4) typedef uint16_t state_t; /* from Os.h types */ -typedef TaskType procid_t; -typedef EventMaskType event_t; +typedef TaskType OsTaskidType; +typedef EventMaskType OsEventType; /* Lets have 32 priority levels * 0 - Highest prio * 31- Lowest */ -typedef sint8 prio_t; +typedef sint8 OsPriorityType; #define TASK_NAME_SIZE 16 + + +/* STD container : OsIsr + * Class: ALL + * + * OsIsrCategory: 1 CATEGORY_1 or CATEGORY_2 + * OsIsrResourceRef: 0..1 Reference to OsResource + * OsIsrTimingProtection[C] 0..1 + * */ + +/* STD container : OsIsrResourceLock + * Class: 2 and 4 + * + * OsIsrResourceLockBudget 1 Float in seconds (MAXRESOURCELOCKINGTIME) + * OsIsrResourceLockResourceRef 1 Ref to OsResource + * */ + +/* STD container : OsIsrTimingProtection + * Class: 2 and 4 + * + * OsIsrAllInterruptLockBudget 0..1 float + * OsIsrExecutionBudget 0..1 float + * OsIsrOsInterruptLockBudget 0..1 float + * OsIsrTimeFrame 0..1 float + * OsIsrResourceLock[C] 0..1 + * */ + + + +/* STD container : OsHooks + * OsErrorHooks: 1 + * OsPostTaskHook: 1 + * OsPreTaskHook: 1 + * OsProtectionHook: 0..1 Class 2,3,4 it's 1 instance + * OsShutdownHook: 1 + * OsStartupkHook: 1 + * */ + +typedef struct OsHooks { +#if ( OS_SC2 == STD_ON ) || ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) + ProtectionHookType ProtectionHook; +#endif + StartupHookType StartupHook; + ShutdownHookType ShutdownHook; + ErrorHookType ErrorHook; + PreTaskHookType PreTaskHook; + PostTaskHookType PostTaskHook; +} OsHooksType; + +/* OsTask/OsTaskSchedule */ +enum OsTaskSchedule { + FULL, + NON +}; + +/*-----------------------------------------------------------------*/ + +typedef uint8_t proc_type_t; + +#define PROC_PRIO 0x1 +#define PROC_BASIC 0x1 +#define PROC_EXTENDED 0x3 + +#define PROC_ISR 0x4 +#define PROC_ISR1 0x4 +#define PROC_ISR2 0xc + + +typedef struct { + void *curr; // Current stack ptr( at swap time ) + void *top; // Top of the stack( low address ) + uint32 size; // The size of the stack +} OsStackType; + + -#if 0 -/* Application */ -typedef struct { - /* Application id */ - uint32_t application_id; - /* Name of the application */ - char name[16]; - /* We let the application have a pool */ - void *pool; - /* if this application is trusted or not */ - uint8 trusted:1; - /* Attached counters */ - counter_obj_t *counter; -} app_t; -#endif -typedef rom_app_t app_t; - - -struct rom_pcb_s; /* We do ISR and TASK the same struct for now */ -typedef struct pcb_s { - procid_t pid; // TASK - prio_t prio; - ApplicationType application_id; - uint32 app_mask; - void (*entry)(); - proc_type_t proc_type; - uint8 autostart:1; // TASK - stack_t stack; // TASK - /* belongs to this application */ - app_t *application; - - int vector; // ISR - char name[TASK_NAME_SIZE]; - - timing_protection_t *timing_protection; - - state_t state; // TASK - event_t ev_wait; // TASK - event_t ev_set; // TASK - - enum OsTaskSchedule scheduling; // TASK - - // OsTaskActivation - // The limit from OsTaskActivation +typedef struct OsPcb { + OsTaskidType pid; // TASK + OsPriorityType prio; +#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) + ApplicationType application_id; + uint32 app_mask; +#endif + void (*entry)(); + proc_type_t proc_type; + uint8 autostart:1; // TASK + OsStackType stack; // TASK + + int vector; // ISR + char name[TASK_NAME_SIZE]; +#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON ) + OsTimingProtectionType *timing_protection; +#endif + + state_t state; // TASK + OsEventType ev_wait; // TASK + OsEventType ev_set; // TASK + + enum OsTaskSchedule scheduling; // TASK + /* belongs to this application */ + struct OsApplication *application; + + /* OsTaskActivation + * The limit from OsTaskActivation. This is 1 for extended tasks */ uint8_t activationLimit; // The number of queued activation of a task - uint8_t activations; + int8_t activations; // A task can hold only one internal resource and only i f // OsTaskSchedule == FULL - resource_obj_t *resource_int_p; // TASK + OsResourceType *resource_int_p; // TASK + // OsTaskResourceRef // What resources this task have access to // Typically (1<prio; - pcb->prio = new_prio; - //simple_printf("set_prio of %s to %d from %d\n",pcb->name,new_prio,pcb->prio); - return old_prio; -} - -#define os_pcb_get_state(pcb) ((pcb)->state) + TAILQ_ENTRY(OsPcb) ready_list; // TASK +} OsPcbType; + +/*-----------------------------------------------------------------*/ + +typedef struct OsRomPcb { + TaskType pid; + uint8 prio; + uint32 app_mask; + void (*entry)(); + proc_type_t proc_type; + uint8 autostart; + OsStackType stack; + int vector; // ISR + ApplicationType application_id; + char name[16]; + enum OsTaskSchedule scheduling; + uint32_t resourceAccess; + // pointer to internal resource + // NULL if none + OsResourceType *resource_int_p; + OsTimingProtectionType *timing_protection; + uint8_t activationLimit; +// lockingtime_obj_t +} OsRomPcbType; #endif diff --git a/system/kernel/include/sched_table_i.h b/system/kernel/include/sched_table_i.h index 09cf9d6b..5445ad69 100644 --- a/system/kernel/include/sched_table_i.h +++ b/system/kernel/include/sched_table_i.h @@ -13,13 +13,6 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - #ifndef SCHED_TABLE_I_H_ #define SCHED_TABLE_I_H_ @@ -31,16 +24,21 @@ #include "alist_i.h" #include "counter_i.h" -struct counter_obj_s; - +struct OsCounter; + +#define SINGLE_SHOT 0 +#define REPEATING 1 + +#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON ) enum OsScheduleTableSyncStrategy { - /* Support for sync */ + /* Support for sync, this is same as no OS */ NONE, /* synchronize with "external" counter */ EXPLICIT, /* sync internal */ IMPLICIT, }; +#endif enum OsScheduleTableAutostartType { // Start with StartScheduleTableAbs() @@ -51,8 +49,24 @@ enum OsScheduleTableAutostartType { SYNCHRONE, }; - -typedef struct sched_table_sync_s { + +typedef struct OsScheduleTableAction { + // 0 - activate task, 1 - event + /** @req OS402 */ + /** @req OS403 */ + int type; + // for debug only??? + uint64 offset; + // delta to next action + /** @req OS404 */ + uint64 delta; + TaskType task_id; + // used only if event.. + EventMaskType event_id; +} OsScheduleTableActionType; + +#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON ) +typedef struct OsScheduleTableSync { /* SPEC */ enum OsScheduleTableSyncStrategy syncStrategy; @@ -69,22 +83,41 @@ typedef struct sched_table_sync_s { // Calculated as 'driver count' - 'global time count from SyncScheduleTable()' int deviation; -} sched_table_sync_t; +} OsScheduleTableSyncType; + /* SPEC */ -typedef struct Stbl_AdjustableExpPoint { +typedef struct OsSchTblAdjExpPoint { uint8_t maxAdvance; uint8_t maxRetard; -} Stbl_AdjustableExpPointType; - -struct sched_table_autostart_s { +} OsSchTblAdjExpPointType; +#endif + +/* STD container: OsScheduleTableAutostart + * OsScheduleTableAbsValue 1 Int + * OsScheduleTableAutostartType 1 Enum + * OsScheduleTableRelOffset 1 Int + * OsScheduleTableAppModeRef 1..* Ref to OsAppMode + */ +struct OsSchTblAutostart { _Bool active; enum OsScheduleTableAutostartType type; uint32_t relOffset; uint32_t appModeRef; // TODO }; - -typedef struct sched_table_s { + + +/* STD container: OsScheduleTable + * OsScheduleTableDuration: 1 Int + * OsScheduleTableRepeating: 1 Bool + * OsSchTblAccessingApplication 0..* Ref + * OsScheduleTableCounterRef: 1 Ref + * OsScheduleTableAutostart[C] 0..1 + * OsScheduleTableExpiryPoint[C] 1..* + * OsScheduleTableSync 0..1 + */ + +typedef struct OsSchTbl { // Configuration @@ -92,26 +125,31 @@ typedef struct sched_table_s { int duration; // If true, the schedule is periodic, OS009 - // OsScheduleTableRepeating + // OsScheduleTableRepeating , 0 - SINGLE_SHOT _Bool repeating; // Application mask uint32 app_mask; // pointer to this tables counter - // OsScheduleTableCounterRef - struct counter_obj_s *counter; + // OsScheduleTableCounterRef + /** @req OS409 */ + struct OsCounter *counter; - struct sched_table_autostart_s autostart; - - struct sched_table_sync_s sync; - - struct Stbl_AdjustableExpPoint adjExpPoint; + struct OsSchTblAutostart autostart; + + /* NULL if NONE, and non-NULL if EXPLICIT and IMPLICIT */ + struct OsScheduleTableSync *sync; + +#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON ) + struct OsSchTblAdjExpPoint adjExpPoint; +#endif // Private stuff - uint32_t final_offset; // used? - uint32_t init_offset; // used? + uint32_t finalOffset; + + uint32_t initialOffset; // Name... char *name; @@ -120,29 +158,38 @@ typedef struct sched_table_s { uint64 length; uint32 id; + + /* The current index into the expire list + * The value is updated at each expire point. + * */ + int expire_curr_index; + + /* When this table expires the next time + * This value should be compared to the counter that drives + * the counter to check if it has expired. + * The value is updated at each expire point. + */ + TickType expire_val; - int expire_curr_index; - // When this table expires the next time - TickType expire_val; // if true, the table is active //_Bool active; ScheduleTableStatusType state; // Pointer to next schedule table, if any // (don't use normal lists here since we have no list head) - struct sched_table_s *next; + struct OsSchTbl *next; /* Head of static action list */ - SA_LIST_HEAD(alist,sched_action_s) action_list; + SA_LIST_HEAD(alist,OsScheduleTableAction) action_list; /* Entry in the list of schedule tables connected to a specfic * counter */ - SLIST_ENTRY(sched_table_s) sched_list; + SLIST_ENTRY(OsSchTbl) sched_list; // TableDuration // -} sched_table_t; +} OsSchTblType; /* #define os_stbl_get_action(x) SA_LIST_GET(&(x)->action_list,(x)->expire_curr_index) @@ -152,7 +199,18 @@ typedef struct sched_table_s { #define os_stbl_get_action_event(x) os_stbl_get_action(x)->event */ -void os_stbl_init( void ); -void os_stbl_calc_expire( sched_table_t *stbl); +void Os_SchTblInit( void ); +void Os_SchTblCalcExpire( OsSchTblType *stbl ); + +static inline TickType Os_SchTblGetInitialOffset( OsSchTblType *sPtr ) { + return SA_LIST_GET(&sPtr->action_list,0)->offset; +} + +static inline TickType Os_SchTblGetFinalOffset( OsSchTblType *sPtr ) { + return (sPtr->duration - + SA_LIST_GET(&sPtr->action_list, SA_LIST_CNT(&sPtr->action_list))->offset); +} + + #endif /*SCHED_TABLE_I_H_*/ diff --git a/system/kernel/include/swap.h b/system/kernel/include/swap.h index 2f283be1..d2d9b175 100644 --- a/system/kernel/include/swap.h +++ b/system/kernel/include/swap.h @@ -14,18 +14,4 @@ * -------------------------------- Arctic Core ------------------------------*/ - - - - - - -#ifndef SWAP_H_ -#define SWAP_H_ - -#include "pcb.h" - -void os_swap_context(pcb_t *old_pcb, pcb_t *new_pcb ); -void os_swap_context_to(pcb_t *old_pcb, pcb_t *new_pcb ); - -#endif /*SWAP_H_*/ +#error obsolete, remove.. diff --git a/system/kernel/include/sys.h b/system/kernel/include/sys.h index 3c3ac523..46d44255 100644 --- a/system/kernel/include/sys.h +++ b/system/kernel/include/sys.h @@ -13,27 +13,17 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - #ifndef SYS_H_ #define SYS_H_ -#include "types.h" -#include "pcb.h" - struct os_conf_global_hook_s; typedef struct sys_s { -// app_t *curr_application; +// OsApplicationType *curr_application; /* Current running task*/ - pcb_t *curr_pcb; + OsPcbType *curr_pcb; /* List of all tasks */ - pcb_t *pcb_list; + OsPcbType *pcb_list; /* Interrupt nested count */ uint32 int_nest_cnt; /* Ptr to the interrupt stack */ @@ -43,7 +33,7 @@ typedef struct sys_s { // 1-The scheduler is locked (by GetResource() or something else) int scheduler_lock; /* Hooks */ - struct os_conf_global_hooks_s *hooks; + struct OsHooks *hooks; // parameters for functions, used by OSErrorXXX() uint32_t param1; @@ -55,14 +45,14 @@ typedef struct sys_s { /* List of all pcb's, * Only needed for non-static configuration of the kernel */ - TAILQ_HEAD(,pcb_s) pcb_head; + TAILQ_HEAD(,OsPcb) pcb_head; /* Ready queue */ - TAILQ_HEAD(,pcb_s) ready_head; + TAILQ_HEAD(,OsPcb) ready_head; } sys_t; extern sys_t os_sys; -static inline pcb_t *os_get_curr_pcb( void ) { +static inline OsPcbType *Os_TaskGetCurrent( void ) { return os_sys.curr_pcb; } diff --git a/system/kernel/include/task_i.h b/system/kernel/include/task_i.h index 8afa465b..ad07d4de 100644 --- a/system/kernel/include/task_i.h +++ b/system/kernel/include/task_i.h @@ -19,10 +19,11 @@ #include #include #include "internal.h" +#include "simple_printf.h" #include "Ramlog.h" static inline void os_pcb_print_rq( void ) { - pcb_t *i_pcb; + OsPcbType *i_pcb; int cnt = 0; TAILQ_FOREACH(i_pcb,&os_sys.ready_head,ready_list) { @@ -33,7 +34,7 @@ static inline void os_pcb_print_rq( void ) { } // schedule() -static inline void os_pcb_running_to_ready( pcb_t *pcb ) { +static inline void Os_TaskRunningToReady( OsPcbType *pcb ) { assert(pcb->state == ST_RUNNING ); pcb->state = ST_READY; } @@ -41,8 +42,7 @@ static inline void os_pcb_running_to_ready( pcb_t *pcb ) { // ActivateTask(pid) // SetEvent(pid) -// os_pcb_make_virgin(pcb_t*) -static inline void os_pcb_make_ready( pcb_t *pcb ) { +static inline void Os_TaskMakeReady( OsPcbType *pcb ) { if( pcb->state != ST_READY ) { pcb->state = ST_READY; TAILQ_INSERT_TAIL(& os_sys.ready_head,pcb,ready_list); @@ -51,7 +51,7 @@ static inline void os_pcb_make_ready( pcb_t *pcb ) { } // WaitEvent -static inline void os_pcb_make_waiting( pcb_t *pcb ) +static inline void Os_TaskMakeWaiting( OsPcbType *pcb ) { assert( pcb->state & (ST_READY|ST_RUNNING) ); @@ -61,7 +61,7 @@ static inline void os_pcb_make_waiting( pcb_t *pcb ) } // Terminate task -static inline void os_pcb_make_suspended( pcb_t *pcb ) +static inline void Os_TaskMakeSuspended( OsPcbType *pcb ) { assert( pcb->state & (ST_READY|ST_RUNNING) ); pcb->state = ST_SUSPENDED; @@ -75,25 +75,49 @@ static inline void os_pcb_make_suspended( pcb_t *pcb ) * * @params pcb Ptr to pcb */ -static inline void os_pcb_make_running( pcb_t *pcb ) { +static inline void Os_TaskMakeRunning( OsPcbType *pcb ) { pcb->state = ST_RUNNING; } - -_Bool os_pcb_pid_valid( pcb_t *restrict pcb ); -void os_proc_start_extended( void ); -void os_proc_start_basic( void ); -void os_setup_context( pcb_t *pcb ); -pcb_t *os_find_top_prio_proc( void ); - -void os_pcb_make_virgin( pcb_t *pcb ); +_Bool os_pcb_pid_valid( OsPcbType *restrict pcb ); +void Os_TaskStartExtended( void ); +void Os_TaskStartBasic( void ); +void Os_ContextInit( OsPcbType *pcb ); +OsPcbType *Os_TaskGetTop( void ); // Added by Mattias in order to avoid compiler warning -TaskType os_add_task( pcb_t *pcb ); +TaskType Os_AddTask( OsPcbType *pcb ); #if 0 // Not used any more -pcb_t *os_find_higher_priority_task( prio_t prio ); +OsPcbType *os_find_higher_priority_task( OsPriorityType prio ); #endif + + + +extern OsPcbType pcb_list[]; +extern const OsRomPcbType rom_pcb_list[]; + +static inline OsPcbType * os_get_pcb( OsTaskidType pid ) { + return &pcb_list[pid]; +} + +static inline const OsRomPcbType * os_get_rom_pcb( OsTaskidType pid ) { + return &rom_pcb_list[pid]; +} + +static inline OsPriorityType os_pcb_set_prio( OsPcbType *pcb, OsPriorityType new_prio ) { + OsPriorityType old_prio; + old_prio = pcb->prio; + pcb->prio = new_prio; + //simple_printf("set_prio of %s to %d from %d\n",pcb->name,new_prio,pcb->prio); + return old_prio; +} + +#define os_pcb_get_state(pcb) ((pcb)->state) + +void os_swap_context(OsPcbType *old_pcb, OsPcbType *new_pcb ); +void Os_TaskSwapContextTo(OsPcbType *old_pcb, OsPcbType *new_pcb ); + #endif /*TASK_I_H_*/ diff --git a/system/kernel/init.c b/system/kernel/init.c index 27e2dae0..d74413b9 100644 --- a/system/kernel/init.c +++ b/system/kernel/init.c @@ -14,36 +14,31 @@ * -------------------------------- Arctic Core ------------------------------*/ -#include "Os.h" -#include "sys.h" #include #include -#include "ext_config.h" -//#include "Pool.h" -//#include "ppc_asm.h" -#include "arch.h" -#include "kernel.h" -#include "swap.h" -#include "hooks.h" -#include "task_i.h" -#include "alarm_i.h" -#include "sched_table_i.h" +#include "Os.h" +#include "internal.h" +#include "arc.h" #include "Trace.h" +#include "arch.h" - -extern void Oil_GetInterruptStackInfo( stack_t *stack ); +extern void Oil_GetInterruptStackInfo( OsStackType *stack ); extern uint32_t McuE_GetSystemClock( void ); extern OsTickType OsTickFreq; sys_t os_sys; +Os_IntCounterType Os_IntDisableAllCnt; +Os_IntCounterType Os_IntSuspendAllCnt; +Os_IntCounterType Os_IntSuspendOsCnt; + /** * Initialize alarms and schedule-tables for the counters */ static void os_counter_init( void ) { - counter_obj_t *counter; - alarm_obj_t *alarm_obj; - sched_table_t *sched_obj; + OsCounterType *counter; + OsAlarmType *alarm_obj; + OsSchTblType *sched_obj; /* Create a list from the counter to the alarms */ for(int i=0; i < Oil_GetCounterCnt() ; i++) { counter = Oil_GetCounter(i); @@ -73,10 +68,10 @@ static void os_counter_init( void ) { * @param pcb_p * @return */ -static os_resource_init( void ) { +static void os_resource_init( void ) { //TAILQ_INIT(&pcb_p->resource_head); - pcb_t *pcb_p; - resource_obj_t rsrc_p; + OsPcbType *pcb_p; + OsResourceType *rsrc_p; int topPrio; /* Calculate ceiling priority @@ -102,9 +97,9 @@ static os_resource_init( void ) { * with scheduling=NON */ for( int i; i < Oil_GetTaskCnt(); i++) { - pcb_p = os_get_pcb(pi); + pcb_p = os_get_pcb(i); if(pcb_p->scheduling == NON ) { - + pcb_p->prio = OS_RES_SCHEDULER_PRIO; } } } @@ -117,12 +112,12 @@ static os_resource_init( void ) { * @param r_pcb rom data */ -static void os_pcb_rom_copy( pcb_t *pcb, rom_pcb_t *r_pcb ) { +static void os_pcb_rom_copy( OsPcbType *pcb, const OsRomPcbType *r_pcb ) { #if 0 //????? // Check to that the memory is ok { - int cnt = sizeof(pcb_t); + int cnt = sizeof(OsPcbType); for(int i=0;ipid = r_pcb->pid; pcb->prio = r_pcb->prio; +#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) pcb->application = Oil_GetApplObj(r_pcb->application_id); +#endif pcb->entry = r_pcb->entry; pcb->proc_type = r_pcb->proc_type; pcb->autostart = r_pcb->autostart; @@ -143,6 +140,7 @@ static void os_pcb_rom_copy( pcb_t *pcb, rom_pcb_t *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->app = &app_list[r_pcb->app]; // pcb->app_mask = app_mask[r_pcb->app]; strncpy(pcb->name,r_pcb->name,16); @@ -157,8 +155,8 @@ static _Bool init_os_called = 0; void InitOS( void ) { int i; - pcb_t *tmp_pcb; - stack_t int_stack; + OsPcbType *tmp_pcb; + OsStackType int_stack; init_os_called = 1; @@ -180,7 +178,7 @@ void InitOS( void ) { // Init counter.. with alarms and schedule tables os_counter_init(); - os_stbl_init(); + Os_SchTblInit(); os_resource_init(); // Put all tasks in the pcb list @@ -194,10 +192,10 @@ void InitOS( void ) { os_pcb_rom_copy(tmp_pcb,os_get_rom_pcb(i)); if( !(tmp_pcb->proc_type & PROC_ISR) ) { - os_pcb_make_virgin(tmp_pcb); + Os_ContextInit(tmp_pcb); } - os_add_task(tmp_pcb); + Os_AddTask(tmp_pcb); DEBUG(DEBUG_LOW,"pid:%d name:%s prio:%d\n",tmp_pcb->pid,tmp_pcb->name,tmp_pcb->prio); } @@ -206,16 +204,13 @@ void InitOS( void ) { } static void os_start( void ) { - pcb_t *tmp_pcb; + OsPcbType *tmp_pcb; assert(init_os_called); - /* find highest prio process and run it */ - tmp_pcb = os_find_top_prio_proc(); - /* TODO: fix ugly */ /* Call the startup hook */ - extern struct os_conf_global_hooks_s os_conf_global_hooks; + extern struct OsHooks os_conf_global_hooks; os_sys.hooks = &os_conf_global_hooks; if( os_sys.hooks->StartupHook!=NULL ) { os_sys.hooks->StartupHook(); @@ -223,10 +218,10 @@ static void os_start( void ) { /* handle autostart */ for(int j=0; j < Oil_GetAlarmCnt(); j++ ) { - alarm_obj_t *alarmPtr; + OsAlarmType *alarmPtr; alarmPtr = Oil_GetAlarmObj(j); if(alarmPtr->autostart.active) { - alarm_autostart_t *autoPtr = &alarmPtr->autostart; + OsAlarmAutostartType *autoPtr = &alarmPtr->autostart; SetAbsAlarm(j,autoPtr->alarmtime, autoPtr->cycletime); } @@ -239,6 +234,19 @@ static void os_start( void ) { Frt_Start(sys_freq/OsTickFreq); } + /* Find highest Autostart task */ + { + OsPcbType *iterPcbPtr; + OsPriorityType topPrio = 0; + + TAILQ_FOREACH(iterPcbPtr,& os_sys.pcb_head,pcb_list) { + if( iterPcbPtr->autostart ) { + if( iterPcbPtr->prio > topPrio ) { + tmp_pcb = iterPcbPtr; + } + } + } + } // Swap in prio proc. { @@ -246,7 +254,7 @@ static void os_start( void ) { os_sys.curr_pcb = tmp_pcb; // NOTE! We don't go for os_swap_context() here.. // first arg(NULL) is dummy only - os_swap_context_to(NULL,tmp_pcb); + Os_TaskSwapContextTo(NULL,tmp_pcb); // We should not return here assert(0); } @@ -279,19 +287,21 @@ int main( void ) * @param Mode - Application mode to start in * */ -void StartOS( AppModeType Mode ) { +void StartOS(AppModeType Mode) { /* Check link file */ - if( TEST_DATA != test_data ) { + if (TEST_DATA != test_data) { noooo(); } - if( test_bss != 0 ) { + if (test_bss != 0) { noooo(); } - os_start(); + os_start(); + /** @req OS424 */ + assert(0); } /** @@ -300,15 +310,16 @@ void StartOS( AppModeType Mode ) { * @param Error - Reason for shutdown */ +/** @req OS071 */ void ShutdownOS( StatusType Error ) { if( os_sys.hooks->ShutdownHook != NULL ) { os_sys.hooks->ShutdownHook(Error); } - /* TODO: */ - while(1) { - } + Irq_Disable(); + /** @req OS425 */ + while(1) { } } diff --git a/system/kernel/isr.c b/system/kernel/isr.c index 4fe4d417..62417334 100644 --- a/system/kernel/isr.c +++ b/system/kernel/isr.c @@ -13,19 +13,74 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ +#include #include -#include "sys.h" -#include "pcb.h" +#include #include "internal.h" -#include "hooks.h" -#include "swap.h" +#include "irq.h" +#if 0 + + +#include +#include +#include +#include +#include +#include "internal.h" + +#endif + + // TODO: remove. Make soft links or whatever #if defined(CFG_ARM_CM3) -#include "irq.h" +#include "irq_types.h" //#include "stm32f10x.h" //#include "stm32f10x_arc.h" #endif -#include "int_ctrl.h" + +extern caddr_t *sbrk(int); + +#define os_alloc(_x) sbrk(_x) + +OsPcbType * os_alloc_new_pcb( void ) { + void *h = os_alloc(sizeof(OsPcbType)); + memset(h,0,sizeof(OsPcbType)); + assert(h!=NULL); + return h; +} + +#if 0 +typedef void (*Os_IsrEntryType)(void); + + +typedef Os_IsrInfo_s { + Os_IsrEntryType entry; + uint32_t vector; + uint8_t priority; +} Os_IsrInfoType; +#endif + + +extern TaskType Os_AddTask( OsPcbType *pcb ); + +static uint8 stackTop = 0x42; + +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); +} + /** * Handle ISR type 2 interrupts from interrupt controller. @@ -34,8 +89,8 @@ * @param vector The vector that took the interrupt */ void *Os_Isr( void *stack, void *pcb_p ) { - struct pcb_s *pcb; - struct pcb_s *preempted_pcb; + struct OsPcb *pcb; + struct OsPcb *preempted_pcb; os_sys.int_nest_cnt++; @@ -47,7 +102,7 @@ void *Os_Isr( void *stack, void *pcb_p ) { POSTTASKHOOK(); - pcb = (struct pcb_s *)pcb_p; + pcb = (struct OsPcb *)pcb_p; pcb->state = ST_RUNNING; set_curr_pcb(pcb); @@ -64,10 +119,19 @@ void *Os_Isr( void *stack, void *pcb_p ) { pcb->entry(); Irq_Disable(); + /** @req OS368 */ + if( Os_IrqAnyDisabled() ) { + Os_IrqClearAll(); + ERRORHOOK(E_OS_DISABLEDINT); + } + + /** @req OS369 */ + Os_ResourceCheckAndRelease(pcb); + pcb->state = ST_SUSPENDED; POSTTASKHOOK(); - IntCtrl_EOI(); + Irq_EOI(); --os_sys.int_nest_cnt; @@ -81,14 +145,13 @@ void *Os_Isr( void *stack, void *pcb_p ) { * if we find a new task: * - just switch in the new context( don't save the old because * its already saved ) - * */ - pcb_t *new_pcb; - new_pcb = os_find_top_prio_proc(); + OsPcbType *new_pcb; + new_pcb = Os_TaskGetTop(); if( new_pcb != preempted_pcb ) { os_isr_printf(D_TASK,"Found candidate %s\n",new_pcb->name); -//#warning os_swap_context_to should call the pretaskswaphook - os_swap_context_to(NULL,new_pcb); +//#warning Os_TaskSwapContextTo should call the pretaskswaphook + Os_TaskSwapContextTo(NULL,new_pcb); } else { if( new_pcb == NULL ) { assert(0); diff --git a/system/kernel/kernel_offset.c b/system/kernel/kernel_offset.c index 28decaa2..d308c821 100644 --- a/system/kernel/kernel_offset.c +++ b/system/kernel/kernel_offset.c @@ -19,19 +19,22 @@ #define DECLARE(sym,val) \ __asm("#define " #sym " %0" : : "i" ((val))) -#include "Os.h" +#include "Os.h" +#include "kernel.h" #include "pcb.h" //#include "app_i.h" #include "sys.h" -#include "kernel.h" + void oil_foo(void) { - DECLARE(PCB_T_SIZE, sizeof(pcb_t)); - DECLARE(APP_T_SIZE, sizeof(app_t)); - DECLARE(PCB_STACK_CURR_P, offsetof(pcb_t, stack)); - DECLARE(PCB_ENTRY_P, offsetof(pcb_t, entry)); + DECLARE(PCB_T_SIZE, sizeof(OsPcbType)); +#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) + DECLARE(APP_T_SIZE, sizeof(OsApplicationType)); +#endif + DECLARE(PCB_STACK_CURR_P, offsetof(OsPcbType, stack)); + DECLARE(PCB_ENTRY_P, offsetof(OsPcbType, entry)); DECLARE(SYS_CURR_PCB_P, offsetof(sys_t, curr_pcb)); DECLARE(SYS_INT_NEST_CNT, offsetof(sys_t, int_nest_cnt)); DECLARE(SYS_INT_STACK, offsetof(sys_t, int_stack)); diff --git a/system/kernel/makefile b/system/kernel/makefile index 170902fd..42d14bc4 100644 --- a/system/kernel/makefile +++ b/system/kernel/makefile @@ -10,24 +10,26 @@ obj-y += arch_krn.o # object files obj-y += event.o obj-y += init.o -obj-y += trusted.o +#obj-y += trusted.o obj-y += arch.o obj-y += task.o -obj-y += task_i.o +#obj-y += task_i.o obj-y += resource.o -obj-y += swap.o +#obj-y += swap.o obj-y += alarm.o obj-y += sched_table.o obj-y += counter.o -obj-y += com_internal.o -obj-y += create.o +#obj-y += com_internal.o +#obj-y += create.o obj-y += Frt.o -obj-y += stack.o +#obj-y += stack.o obj-y += isr.o +obj-y += os_arctest.o # These are VERY cpu dependent.. remove -obj-y += int_ctrl.o +#obj-y += int_ctrl.o +obj-y += irq.o # We are compiling the kernel def-y+=CC_KERNEL diff --git a/system/kernel/memory.c b/system/kernel/memory.c index dfca13db..faf417f0 100644 --- a/system/kernel/memory.c +++ b/system/kernel/memory.c @@ -13,12 +13,7 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - +#error Do not use this file, SC3 or SC4 is not supported yet. #include "Os.h" @@ -26,28 +21,28 @@ /* See 8.4.4 */ AccessType CheckISRMemoryAccess( ISRType ISRID, - MemoryStartAddressType Address, - MemorySizeType Size ) + MemoryStartAddressType Address, + MemorySizeType Size ) { // get hold of application memory space - - + + } AccessType CheckTaskMemoryAccess( TaskType TaskID, - MemoryStartAddressType Address, - MemorySizeType Size ) + MemoryStartAddressType Address, + MemorySizeType Size ) { - + } /* Object access - * - * - * resource - * - * + * + * + * resource + * + * */ @@ -60,37 +55,37 @@ ObjectAccessType CheckObjectAccess( ApplicationType ApplID, { uint32 app_mask = (1<app_mask & (app_mask); + rv = ((OsAlarmType *)object)->app_mask & (app_mask); break; case OBJECT_COUNTER: - rv = ((counter_obj_t *)object)->app_mask & (app_mask); + rv = ((OsCounterType *)object)->app_mask & (app_mask); break; - case OBJECT_ISR: + case OBJECT_ISR: break; case OBJECT_MESSAGE: - case OBJECT_RESOURCE: + case OBJECT_RESOURCE: case OBJECT_SCHEDULETABLE: break; case OBJECT_TASK: - rv = ((counter_obj_t *)object)->app_mask & (app_mask); + rv = ((OsCounterType *)object)->app_mask & (app_mask); break; default: - break; + break; } - - - - + + + + return ACCESS; } /* return application id for object */ ApplicationType CheckObjectOwnership( ObjectTypeType ObjectType, - void *object ) + void *object ) { switch( ObjectType ) { case OBJECT_ALARM: @@ -103,6 +98,6 @@ ApplicationType CheckObjectOwnership( ObjectTypeType ObjectType, default: break; } - + return (-1); -} +} diff --git a/system/kernel/os_arctest.c b/system/kernel/os_arctest.c new file mode 100644 index 00000000..cd4b24b0 --- /dev/null +++ b/system/kernel/os_arctest.c @@ -0,0 +1,22 @@ +/* + * os_arctest.c + * + * Created on: 19 jan 2010 + * Author: mahi + */ + +#include "internal.h" + + +int Os_ArcTest_GetTaskActivationLimit( TaskType task ) { + + return 0; +} + +void Os_ArcTest_SetIrqNestLevel( int level ) { + + return; +} + + + diff --git a/system/kernel/resource.c b/system/kernel/resource.c index b7276916..96780e9c 100644 --- a/system/kernel/resource.c +++ b/system/kernel/resource.c @@ -13,16 +13,8 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ -#include "types.h" #include "Os.h" -#include "assert.h" -#include "sys.h" -#include "stdlib.h" -#include "kernel.h" #include "internal.h" -#include "hooks.h" -#include "task_i.h" -#include "ext_config.h" /* INFO * - If OsTaskSchedule = NON, Task it not preemptable, no internal resource may be assigned to a task @@ -57,7 +49,7 @@ * - Keep allocated resources as stack to comply with LIFO order. * - A linked resource is just another name for an existing resource. See OsResource in Autosar SWS OS. * This means that no resource object should be generated, just the define in Os_Cfg.h - * - A task with Scheduling=NON does have priority (although it's internal priority is 32) + * - A task with Scheduling=NON have priority (although it's internal priority is 32) * */ @@ -65,11 +57,11 @@ #define valid_internal_id() (rid->nr < Oil_GetResourceCnt()) //&& (rid->type == RESOURCE_TYPE_INTERNAL) ) -static StatusType GetResource_( resource_obj_t * ); -StatusType ReleaseResource_( resource_obj_t * ); +static StatusType GetResource_( OsResourceType * ); +StatusType ReleaseResource_( OsResourceType * ); StatusType GetResource( ResourceType ResID ) { - resource_obj_t *rid = Oil_GetResource(ResID); + OsResourceType *rid = Oil_GetResource(ResID); StatusType rv = GetResource_(rid); if (rv != E_OK) @@ -84,23 +76,24 @@ StatusType GetResourceInternal( ResourceType ResID ) { } #endif -static StatusType GetResource_( resource_obj_t * rid ) { +static StatusType GetResource_( OsResourceType * rid ) { StatusType rv = E_OK; if( rid->nr == RES_SCHEDULER ) { - // Lock the sheduler + // Lock the scheduler os_sys.scheduler_lock = 1; - //simple_printf("RES_SCHEDULER, NOT supported yet\n"); - //while(1); } - // Check if valid resource + + /* Check if valid resource */ if( !valid_standard_id() ) { rv = E_OS_ID; goto err; } // Check that the resource does not belong to another application or task if( ( (os_task_nr_to_mask(get_curr_pid()) & rid->task_mask ) == 0 ) +#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) || ( get_curr_application_id() != rid->application_owner_id) +#endif || ( rid->owner != (TaskType)(-1))) { rv = E_OS_ACCESS; @@ -108,10 +101,10 @@ static StatusType GetResource_( resource_obj_t * rid ) { } rid->owner = get_curr_pid(); - rid->old_task_prio = os_pcb_set_prio(os_get_curr_pcb() ,rid->ceiling_priority); + rid->old_task_prio = os_pcb_set_prio(Os_TaskGetCurrent() ,rid->ceiling_priority); if( rid->type != RESOURCE_TYPE_INTERNAL ) { - TAILQ_INSERT_TAIL(&os_get_curr_pcb()->resource_head, rid, listEntry); + TAILQ_INSERT_TAIL(&Os_TaskGetCurrent()->resource_head, rid, listEntry); } goto ok; @@ -126,7 +119,7 @@ StatusType ReleaseResource( ResourceType ResID) { if( ResID == RES_SCHEDULER ) { os_sys.scheduler_lock=0; } else { - resource_obj_t *rid = Oil_GetResource(ResID); + OsResourceType *rid = Oil_GetResource(ResID); rv = ReleaseResource_(rid); } @@ -136,50 +129,41 @@ StatusType ReleaseResource( ResourceType ResID) { OS_STD_END_1(OSServiceId_ReleaseResource,ResID); } -StatusType ReleaseResource_( resource_obj_t * rid ) { +StatusType ReleaseResource_( OsResourceType * rid ) { if (!valid_standard_id()) { return E_OS_ID; } else { // Release it... rid->owner = (TaskType) (-1); - TAILQ_REMOVE(&os_get_curr_pcb()->resource_head, rid, listEntry); - os_pcb_set_prio(os_get_curr_pcb(), rid->old_task_prio); + TAILQ_REMOVE(&Os_TaskGetCurrent()->resource_head, rid, listEntry); + os_pcb_set_prio(Os_TaskGetCurrent(), rid->old_task_prio); return E_OK; } } -#if 0 -// TODO: Remove this function later.. this is done in oil generator -// instead. -void os_resource_calc_attributes( void ) { - // Calc ceiling -// ResourceType *rsrc; - for( int i=0;iname, rt->ceiling_priority,rt->old_task_prio); GetResource_(rt); } - //GetResourceInternal(os_get_curr_pcb()->resource_internal); + //GetResourceInternal(Os_TaskGetCurrent()->resource_internal); } -void os_resource_release_internal( void ) { - resource_obj_t *rt = os_get_resource_int_p(); +void Os_ResourceReleaseInternal( void ) { + OsResourceType *rt = os_get_resource_int_p(); if( rt != NULL ) { //simple_printf("Rel IR proc:%s prio:%d old_task_prio:%d\n",get_curr_pcb()->name,rt->ceiling_priority,rt->old_task_prio); ReleaseResource_(rt); } - //ReleaseResource(os_get_curr_pcb()->resource_internal); + //ReleaseResource(Os_TaskGetCurrent()->resource_internal); } diff --git a/system/kernel/sched_table.c b/system/kernel/sched_table.c index be941c56..d145cd7d 100644 --- a/system/kernel/sched_table.c +++ b/system/kernel/sched_table.c @@ -13,24 +13,18 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ +#include "Os.h" +#include "internal.h" +#include "alist_i.h" - - - - - - - -#include "Os.h" -#include "types.h" -#include "counter_i.h" -#include "pcb.h" -#include "sched_table_i.h" -#include "ext_config.h" -#include "hooks.h" -#include -#include "alist_i.h" -#include +/* + * Generic requirements this module can handle + */ + /** @req OS007 */ + /** @req OS410 */ + /** @req OS411 */ + /** @req OS347 */ + /** @req OS358 */ /* * How Autosar sees the scheduletable @@ -79,17 +73,14 @@ ERRORHOOK(rv); \ return rv; -extern TickType GetCountValue( counter_obj_t *counter ); - -static TickType os_calc_modulo( TickType curr, TickType max, TickType add ) { - TickType diff = max - curr; - return (diff >= add ) ? (curr + add) : - (add - curr); -} - -enum OsScheduleTableSyncStrategy getSyncStrategy( sched_table_t *stblPtr ) { +extern TickType GetCountValue( OsCounterType *counter ); + + +#if 0 +enum OsScheduleTableSyncStrategy getSyncStrategy( OsSchTblType *stblPtr ) { return stblPtr->sync.syncStrategy; } +#endif /** @@ -100,61 +91,104 @@ enum OsScheduleTableSyncStrategy getSyncStrategy( sched_table_t *stblPtr ) { * * @return */ -static void ScheduleTableConsistenyCheck( sched_table_t *s_p ) { - - // OS440 +static void ScheduleTableConsistenyCheck( OsSchTblType *s_p ) { + +#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON ) + /** @req OS440 */ if( s_p->sync.syncStrategy == IMPLICIT ) { assert( s_p->duration == (s_p->counter->alarm_base.maxallowedvalue +1) ); } - // OS431 + /** @req OS431 */ if( s_p->sync.syncStrategy == EXPLICIT ) { assert( s_p->duration <= (s_p->counter->alarm_base.maxallowedvalue +1) ); - } + } +#endif + + /** @req OS401 */ + assert(SA_LIST_CNT(&s_p->action_list)>=1); + } - -// TODO: OS452,OS278 StatusType StartScheduleTableRel(ScheduleTableType sid, TickType offset) { StatusType rv = E_OK; - sched_table_t *s_tbl; - TickType max_offset; + OsSchTblType *s_tbl; + TickType max_offset; + + +#if (OS_STATUS_EXTENDED == STD_ON ) + /** @req OS275 */ + SCHED_CHECK_ID(sid); +#endif + s_tbl = Oil_GetSched(sid); + +#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON ) + if( s_tbl->sync != NULL ) { + /* EXPLICIT or IMPLICIT */ + + /** @req OS452 */ + if( s_tbl->sync->syncStrategy == IMPLICIT ) { + rv = E_OS_ID; + goto err; + } + } +#endif + +#if (OS_STATUS_EXTENDED == STD_ON ) - (void)offset; - // OS275 - SCHED_CHECK_ID(sid); - s_tbl = Oil_GetSched(sid); - // OS276 - max_offset = s_tbl->counter->alarm_base.maxallowedvalue; - if( (offset == 0) || (offset > max_offset )) { + max_offset = Os_CounterGetMaxValue(s_tbl->counter); + /** @req OS276 */ + /** @req OS332 */ + if( (offset == 0) || ((offset + Os_SchTblGetInitialOffset()) > max_offset ) ) { rv = E_OS_VALUE; goto err; - } + } +#endif - // OS277 + /** @req OS277 */ if( s_tbl->state != SCHEDULETABLE_STOPPED ) { - rv = E_OS_STATE; goto err; + rv = E_OS_STATE; + goto err; } - - s_tbl->state = SCHEDULETABLE_RUNNING; - // calculate the expire value.. - s_tbl->expire_val = os_calc_modulo( GetCounterValue_(s_tbl->counter), max_offset, offset ); -// s_tbl->expire_val = offset + SA_LIST_GET(&s_tbl->action_list,0)->offset; -// ALIST_RESET(&s_tbl->action_list); + + Irq_Disable(); + /* calculate the expire value.. */ + /** @req OS278 */ + s_tbl->expire_val = Os_CounterCalcModulo( Os_CounterGetValue(s_tbl->counter), max_offset, offset ); s_tbl->state = SCHEDULETABLE_RUNNING; - - // s_tbl->action_list_index = 0; + Irq_Enable(); SCHED_STD_END; } -StatusType StartScheduleTableAbs(ScheduleTableType sid, TickType val ){ - StatusType rv = E_OK; - (void)val; +StatusType StartScheduleTableAbs(ScheduleTableType sid, TickType start ){ + StatusType rv = E_OK; + OsSchTblType *sTblPtr; + + /** @req OS348 */ SCHED_CHECK_ID(sid); - - SCHED_STD_END; + + /** @req OS349 */ + if( start > Os_CounterGetMaxValue(sTblPtr->counter) ) { + rv = E_OS_VALUE; + goto err; + } + + /** @req OS350 */ + if( sTblPtr->state != SCHEDULETABLE_STOPPED ) { + rv = E_OS_STATE; + goto err; + } + + + Irq_Disable(); + /** @req OS351 */ + sTblPtr->expire_val = start + Os_SchTblGetInitialOffset(sTblPtr); + sTblPtr->state = SCHEDULETABLE_RUNNING; + Irq_Enable(); + + SCHED_STD_END; } /** @@ -162,97 +196,114 @@ StatusType StartScheduleTableAbs(ScheduleTableType sid, TickType val ){ * @param sid * @return */ +#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON ) StatusType StartScheduleTableSynchron(ScheduleTableType sid ){ - sched_table_t *s_p; + OsSchTblType *s_p; StatusType rv = E_OK; - DisableAllInterrupts(); + Irq_Disable(); SCHED_CHECK_ID(sid); - // OS387 + /** @req OS387 */ if( s_p->sync.syncStrategy != EXPLICIT ) { rv = E_OS_ID; goto err; } - // OS388 + /** @req OS388 */ if( s_p->state != SCHEDULETABLE_STOPPED ) { rv = E_OS_STATE; goto err; } - // OS389 + /** @req OS389 */ s_p->state = SCHEDULETABLE_WAITING; - EnableAllInterrupts(); + Irq_Enable(); SCHED_STD_END; } +#endif + - +/** @req OS006 */ +/* TODO: Implement StopScheduleTable */ StatusType StopScheduleTable(ScheduleTableType sid) { StatusType rv = E_OK; - sched_table_t *s_tbl; + OsSchTblType *s_tbl; + /** @req OS279 */ SCHED_CHECK_ID(sid); - s_tbl = Oil_GetSched(sid); - + s_tbl = Oil_GetSched(sid); + + /** @req OS280 */ + if(s_tbl->state == SCHEDULETABLE_STOPPED ) { + rv = E_OS_NOFUNC; + goto err; + } + + /** @req OS281 */ s_tbl->state = SCHEDULETABLE_STOPPED; SCHED_STD_END; } - + +/** @req OS191 */ StatusType NextScheduleTable( ScheduleTableType sid_curr, ScheduleTableType sid_next) { StatusType rv = E_OK; (void)sid_curr; (void)sid_next; - sched_table_t *s_curr; - sched_table_t *s_next; - + OsSchTblType *sFromPtr; + OsSchTblType *sToPtr; + + /** @req OS282 */ SCHED_CHECK_ID(sid_curr); SCHED_CHECK_ID(sid_next); - s_curr = Oil_GetSched(sid_curr); - s_next = Oil_GetSched(sid_curr); + sFromPtr = Oil_GetSched(sid_curr); + sToPtr = Oil_GetSched(sid_curr); - // OS330 - if( s_curr->counter != s_next->counter) { + /** @req OS330 */ + if( sFromPtr->counter != sToPtr->counter) { rv = E_OS_ID; goto err; } - - DisableAllInterrupts(); - - // OS283 - if( s_curr->state == SCHEDULETABLE_STOPPED || - s_curr->state == SCHEDULETABLE_NEXT || - s_next->state == SCHEDULETABLE_STOPPED || - s_next->state == SCHEDULETABLE_NEXT ) + /** @req OS283 */ + if( sFromPtr->state == SCHEDULETABLE_STOPPED || + sFromPtr->state == SCHEDULETABLE_NEXT ) { rv = E_OS_NOFUNC; goto err; } - // OS309 - if( s_next->state != SCHEDULETABLE_STOPPED ) { + /** @req OS309 */ + if( sToPtr->state != SCHEDULETABLE_STOPPED ) { rv = E_OS_STATE; goto err; - } - - // OS324 - if( s_curr->next != NULL ) { - // Stop the scheduletable that was to be next. - s_curr->next->state = SCHEDULETABLE_STOPPED; - } - - s_curr->next = s_next; - s_next->state = SCHEDULETABLE_NEXT; + } + + Irq_Disable(); + + /** @req OS453 */ + if( sFromPtr->state == SCHEDULETABLE_STOPPED ) { + sFromPtr->next->state = SCHEDULETABLE_STOPPED; + } else { + /** @req OS324 */ + if( sFromPtr->next != NULL ) { + // Stop the schedule-table that was to be next. + sFromPtr->next->state = SCHEDULETABLE_STOPPED; + } + + sFromPtr->next = sToPtr; + sToPtr->state = SCHEDULETABLE_NEXT; + sToPtr->expire_curr_index = 0; + } - EnableAllInterrupts(); + Irq_Enable(); SCHED_STD_END; } @@ -264,28 +315,30 @@ StatusType NextScheduleTable( ScheduleTableType sid_curr, ScheduleTableType sid_ * @param sid * @param globalTime * @return - */ + */ +#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON ) StatusType SyncScheduleTable( ScheduleTableType sid, GlobalTimeTickType globalTime ) { StatusType rv = E_OK; - sched_table_t *s_p = Oil_GetSched(sid); + OsSchTblType *s_p = Oil_GetSched(sid); SCHED_CHECK_ID(sid); + - // OS454 + /** @req OS454 */ if( s_p->sync.syncStrategy != EXPLICIT ) { rv = E_OS_ID; goto err; } - // OS455 + /** @req OS455 */ if( globalTime > s_p->duration ) { rv = E_OS_VALUE; goto err; } - DisableAllInterrupts(); + Irq_Disable(); - // OS456 + /** @req OS456 */ if( (s_p->state == SCHEDULETABLE_STOPPED) || (s_p->state == SCHEDULETABLE_NEXT) ) { rv = E_OS_STATE; @@ -314,32 +367,43 @@ StatusType SyncScheduleTable( ScheduleTableType sid, GlobalTimeTickType globalTi break; } - EnableAllInterrupts(); + Irq_Enable(); SCHED_STD_END; } +#endif + /** * * @param sid * @param status * @return - */ + */ + +/** @req OS359 */ +/** @req OS227 */ StatusType GetScheduleTableStatus( ScheduleTableType sid, ScheduleTableStatusRefType status ) { StatusType rv = E_OK; - sched_table_t *s_p; - (void)status; + OsSchTblType *s_p; + (void)status; + /** @req OS293 */ SCHED_CHECK_ID(sid); s_p = Oil_GetSched(sid); - DisableAllInterrupts(); - - switch(s_p->state) { - case SCHEDULETABLE_STOPPED: // OS289 - case SCHEDULETABLE_NEXT: // OS353 - case SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS: // OS290 - case SCHEDULETABLE_WAITING: // OS354 - case SCHEDULETABLE_RUNNING: // OS291 + Irq_Disable(); + + switch(s_p->state) { + /** @req OS289 */ + case SCHEDULETABLE_STOPPED: + /** @req OS353 */ + case SCHEDULETABLE_NEXT: + /** @req OS290 */ + case SCHEDULETABLE_RUNNING_AND_SYNCHRONOUS: + /** @req OS354 */ + case SCHEDULETABLE_WAITING: + /** @req OS291 */ + case SCHEDULETABLE_RUNNING: *status = s_p->state; break; default: @@ -347,7 +411,7 @@ StatusType GetScheduleTableStatus( ScheduleTableType sid, ScheduleTableStatusRef } - EnableAllInterrupts(); + Irq_Enable(); SCHED_STD_END; } @@ -357,30 +421,33 @@ StatusType GetScheduleTableStatus( ScheduleTableType sid, ScheduleTableStatusRef * * @param sid * @return - */ + */ +#if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON ) StatusType SetScheduleTableAsync( ScheduleTableType sid ) { StatusType rv = E_OK; - sched_table_t *s_p = Oil_GetSched(sid); + OsSchTblType *s_p = Oil_GetSched(sid); SCHED_CHECK_ID(sid); - // OS458 + /** @req OS458 */ if( s_p->sync.syncStrategy != EXPLICIT ) { rv = E_OS_ID; goto err; } - DisableAllInterrupts(); + Irq_Disable(); - // TODO: check OS362, OS323 + /** @req_todo OS362 */ + /** @req_todo OS323 */ - // OS300 + /** @req OS300 */ s_p->state = SCHEDULETABLE_RUNNING; - EnableAllInterrupts(); + Irq_Enable(); SCHED_STD_END; } +#endif /* *start e e e delta stop @@ -400,9 +467,9 @@ StatusType SetScheduleTableAsync( ScheduleTableType sid ) { * funcion is that I'm afraid of if I change the maxallowedvalue for the * counter I will miss to update the delta values */ -static void os_stbl_action_calc_delta( sched_table_t *stbl ) { - sched_action_t * first; - sched_action_t * second; +static void os_stbl_action_calc_delta( OsSchTblType *stbl ) { + OsScheduleTableActionType * first; + OsScheduleTableActionType * second; // ALIST_DECL_ITER(iter); int iter; @@ -421,8 +488,8 @@ static void os_stbl_action_calc_delta( sched_table_t *stbl ) { /** * */ -void os_stbl_init( void ) { - sched_table_t *s_p; +void Os_SchTblInit( void ) { + OsSchTblType *s_p; for( int i=0; i < Oil_GetSchedCnt();i++ ) { s_p = Oil_GetSched(i); os_stbl_action_calc_delta(s_p); @@ -432,59 +499,78 @@ void os_stbl_init( void ) { } /** + * Calculates expire value and changes state depending it's state. + * + * Note! + * We can't cheat with the final + initial expire-point, instead we + * must setup trigger after the final delay and set the "previous" + * table to SCHEDULETABLE_STOPPED and the new to SCHEDULETABLE_RUNNING. * - * @param stbl + * @param stbl Ptr to a Schedule Table. */ -void os_stbl_calc_expire( sched_table_t *stbl) { - - TickType old_delta; - - /* Any more actions in the action list?*/ - if( (stbl->expire_curr_index+1) >= SA_LIST_CNT(&stbl->action_list) ) { - - // TODO: final offset - if( stbl->next != NULL ) { - assert(stbl->state == SCHEDULETABLE_RUNNING); - } - - if( !stbl->repeating ) { - stbl->state = SCHEDULETABLE_STOPPED; - stbl->expire_curr_index = 0; - goto end; - } - } - - old_delta = SA_LIST_GET(&stbl->action_list,stbl->expire_curr_index)->delta; - stbl->expire_curr_index++; -// ALIST_INC(&stbl->action_list); - - stbl->expire_val = - os_calc_modulo( stbl->expire_val, - stbl->counter->alarm_base.maxallowedvalue, - old_delta); - +void Os_SchTblCalcExpire( OsSchTblType *stbl ) { -#if 0 - TickType old_delta; - if( ALIST_LAST(&stbl->action_list)) { - if( !stbl->repeating ) { - stbl->active = 0; - ALIST_RESET(&stbl->action_list); - goto end; - } - } - - old_delta = ALIST_GET_DATA(&stbl->action_list)->delta; - ALIST_INC(&stbl->action_list); - - stbl->expire_val = - os_calc_modulo( stbl->expire_val, - stbl->counter_id->alarm_base.maxallowedvalue, - old_delta); -// stbl->action_list[stbl->action_list_index]->delta); -#endif - -end: + TickType delta; + TickType initalOffset; + TickType finalOffset; + OsSchTblType *nextStblPtr; + + + if( (stbl->expire_curr_index) == SA_LIST_CNT(&stbl->action_list) ) { + /* We are at the last expiry point */ + finalOffset = Os_SchTblGetFinalOffset(stbl); + + stbl->expire_val = Os_CounterCalcModulo( + Os_CounterGetValue(stbl->counter), + Os_CounterGetMaxValue(stbl->counter), + finalOffset ); + + stbl->expire_curr_index++; + + } else if( (stbl->expire_curr_index) > SA_LIST_CNT(&stbl->action_list) ) { + + /** @req OS194 */ + if( (stbl->repeating == REPEATING) || (stbl->next != NULL) ) { + if( stbl->next != NULL ) { + /** @req OS284 */ + nextStblPtr = stbl->next; + /* NextScheduleTable() have been called */ + assert( nextStblPtr->state==SCHEDULETABLE_NEXT ); + + /* We don't care about REPEATING or SINGLE_SHOT here */ + initalOffset = Os_SchTblGetInitialOffset(nextStblPtr); + stbl->state = SCHEDULETABLE_STOPPED; + nextStblPtr->state = SCHEDULETABLE_RUNNING; + } else { + /* REPEATING */ + assert( stbl->repeating == REPEATING ); + initalOffset = Os_SchTblGetInitialOffset(stbl); + } + + stbl->expire_val = Os_CounterCalcModulo( + Os_CounterGetValue(stbl->counter), + Os_CounterGetMaxValue(stbl->counter), + initalOffset ); + + } else { + assert( stbl->repeating == SINGLE_SHOT ); + /** @req OS009 */ + stbl->state = SCHEDULETABLE_STOPPED; + stbl->expire_curr_index = 0; + } + } else { + + delta = SA_LIST_GET(&stbl->action_list,stbl->expire_curr_index)->delta; + + stbl->expire_val = Os_CounterCalcModulo( + Os_CounterGetValue(stbl->counter), + Os_CounterGetMaxValue(stbl->counter), + delta ); + + stbl->expire_curr_index++; + + } + return; } diff --git a/system/kernel/swap.c b/system/kernel/swap.c deleted file mode 100644 index 069edc40..00000000 --- a/system/kernel/swap.c +++ /dev/null @@ -1,147 +0,0 @@ -/* -------------------------------- Arctic Core ------------------------------ - * Arctic Core - the open source AUTOSAR platform http://arccore.com - * - * Copyright (C) 2009 ArcCore AB - * - * This source code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by the - * Free Software Foundation; See . - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - - -#include "types.h" -#include "pcb.h" -#include "arch.h" -#include "debug.h" -//#include "arch_offset.h" -#include "sys.h" -#include "kernel.h" -#include "assert.h" -#include "swap.h" -#include "task_i.h" -#include "hooks.h" -#include "internal.h" - - -#define USE_DEBUG -#include "Trace.h" - -// we come here from -// - WaitEvent() -// old_pcb -> WAITING -// new_pcb -> READY(RUNNING) -// - Schedule(), -// old_pcb -> READY -// new_pcb -> READY/RUNNING - -/* - * two strategies - * 1. When running -> - * - remove from ready queue - * - set state == ST_RUNNING - * - * 2. When running -> - * * leave in ready queue - * * set state == ST_RUNNING - * - ready queue and ST_READY not the same - * + No need to remove the running process from ready queue - */ - - -/** - * Swap context, from one pcb to another - */ -void os_swap_context(pcb_t *old_pcb, pcb_t *new_pcb ) { - - POSTTASKHOOK(); - - assert(new_pcb!=NULL); - - os_resource_release_internal(); - - if( !os_arch_stack_endmark_ok(old_pcb) ) { - ShutdownOS(E_OS_STACKFAULT); - } - -#if 0 - // Make a simple stack check for prio procs... - // See OS068, Autosar SWS - { - uint32_t stackp = (uint32_t)os_arch_get_stackptr(); - uint32_t smallc_size = os_arch_get_sc_size(); - - // enough size to place a small context on the stack - // top( low address ) + small context > current stackpointer - if( (uint32_t)(old_pcb->stack.top + smallc_size) > stackp ) { - ShutdownOS(E_OS_STACKFAULT); - } - } -#endif - -// os_arch_print_context("NEW:",new_pcb); - os_arch_swap_context(old_pcb,new_pcb); - - - { - pcb_t *t_pcb = os_get_curr_pcb(); -// dbg_printf("New pcb: %s\n",t_pcb->name); - os_pcb_make_running(t_pcb); - } - os_resource_get_internal(); - PRETASKHOOK(); -} - -pcb_t *OsFindTopPrioTask( void ) { - - -} - -/** - * Unconditional dispatch. - * Used by: - * ActivateTask() - * WaitEvent() - * - * - */ -void OsDispatch( void ) { - uint32_t flags; - pcb_t pcbPtr; - - assert(os_sys.int_nest_cnt == 0); - assert(os_sys.scheduler_lock == 0 ); - - Irq_Save(flags); - pcbPtr = os_find_top_prio_proc(); - if( ) - - - Irq_Restore(flags); -} - - -// We come here from -// - os_init - -/** - * Called when a task is to be run for the first time. - */ -void os_swap_context_to(pcb_t *old_pcb, pcb_t *new_pcb ) { - - - os_arch_swap_context_to(old_pcb,new_pcb); - /* TODO: When do we return here ?? */ -} - diff --git a/system/kernel/task.c b/system/kernel/task.c index b9a5ba36..09116654 100644 --- a/system/kernel/task.c +++ b/system/kernel/task.c @@ -13,16 +13,405 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - -#include "Os.h" -#include "pcb.h" -#include "sys.h" -#include "internal.h" -#include "hooks.h" #include -#include "swap.h" -#include "task_i.h" -#include "Ramlog.h" +#include "Os.h" +#include "internal.h" +#include "arc.h" +#include "arch.h" + +/** @req OS067 */ + +_Bool os_pcb_pid_valid( OsPcbType *restrict pcb ) { + return ( pcb->pid > Oil_GetTaskCnt() ) ? 0 : 1; +} +/** + * Start an extended task. + * Tasks done: + * - Grab the internal resource for the process + * - Set it running state. + * - Start to execute the process + * + */ +void Os_TaskStartExtended( void ) { + OsPcbType *pcb; + + PRETASKHOOK(); + + pcb = Os_TaskGetCurrent(); + Os_ResourceGetInternal(); + Os_TaskMakeRunning(pcb); + + os_arch_first_call(); + + /** @req OS070 */ + Os_ResourceCheckAndRelease(pcb); + + /** @req OS239 */ + Irq_Disable(); + if( Os_IrqAnyDisabled() ) { + Os_IrqClearAll(); + } + + /** @req OS069 */ + ERRORHOOK(E_OS_MISSINGEND); + + /** @req OS052 */ + TerminateTask(); +} + +/** + * Start an basic task. + * See extended task. + */ + +void Os_TaskStartBasic( void ) { + OsPcbType *pcb; + + PRETASKHOOK(); + + pcb = Os_TaskGetCurrent(); + Os_ResourceGetInternal(); + Os_TaskMakeRunning(pcb); + os_arch_first_call(); + + /** @req OS070 */ + Os_ResourceCheckAndRelease(pcb); + + /** @req OS239 */ + Irq_Disable(); + if( Os_IrqAnyDisabled() ) { + Os_IrqClearAll(); + } + + /** @req OS069 */ + ERRORHOOK(E_OS_MISSINGEND); + + /** @req OS052 */ + TerminateTask(); +} + + +static void Os_StackSetup( OsPcbType *pcbPtr ) { + uint8_t *bottom; + + /* Find bottom of the stack so that we can place the + * context there. + * + * stack bottom = high address. stack top = low address + */ + bottom = (uint8_t *)pcbPtr->stack.top + pcbPtr->stack.size; + pcbPtr->stack.curr = bottom; + // TODO: alignments here.. + // TODO :use function os_arch_get_call_size() ?? + + // Make some space for back-chain. + bottom -= 16; + // Set the current stack so that it points to the context + pcbPtr->stack.curr = bottom - Os_ArchGetScSize(); + + Os_StackSetEndmark(pcbPtr); +} + +/** + * Fill the stack with a predefined pattern + * + * @param pcbPtr Pointer to the pcb to fill with pattern + */ +static void Os_StackFill(OsPcbType *pcbPtr) { + uint8_t *p = pcbPtr->stack.curr; + + assert(pcbPtr->stack.curr > pcbPtr->stack.top); + + while (p > (uint8_t *) pcbPtr->stack.top) { + --p; + *p = STACK_PATTERN; + } +} + +#if 0 +/** + * + * @param pcbPtr + */ +static void Os_TaskSetEntry(OsPcbType *pcbPtr ) { + +} +#endif + + +/** + * Setup the context for a pcb. The context differs for different arch's + * so we call the arch dependent functions also. + * The context at setup is always a small context. + * + * @param pcb Ptr to the pcb to setup context for. + */ +void Os_ContextInit( OsPcbType *pcb ) { + + if( pcb->autostart ) { + Os_TaskMakeReady(pcb); + } else { + pcb->state = ST_SUSPENDED; + } + + Os_StackSetup(pcb); + Os_StackFill(pcb); + OsArch_SetTaskEntry(pcb); + + os_arch_setup_context(pcb); +} + +/** + * + * @param pcb + */ +void Os_ContextReInit( OsPcbType *pcbPtr ) { + Os_StackSetup(pcbPtr); + OsArch_SetTaskEntry(pcbPtr); + // TODO: This really need to be done + os_arch_setup_context(pcbPtr); +} + +/** + * Search for a specific task in the pcb list. + * + * @param tid The task id to search for + * @return Ptr to the found pcb or NULL + */ +OsPcbType *os_find_task( TaskType tid ) { + OsPcbType *i_pcb; + + /* TODO: Implement this as an array */ + TAILQ_FOREACH(i_pcb,& os_sys.pcb_head,pcb_list) { + if(i_pcb->pid == tid ) { + return i_pcb; + } + } + assert(0); + return NULL; +} + +/** + * Adds a pcb to the list of pcb's + * @param pcb + */ +TaskType Os_AddTask( OsPcbType *pcb ) { + long msr; + + Irq_Save(msr); // Save irq status and disable interrupts + + pcb->pid = os_sys.task_cnt; + // Add to list of PCB's + TAILQ_INSERT_TAIL(& os_sys.pcb_head,pcb,pcb_list); + os_sys.task_cnt++; + + Irq_Restore(msr); // Restore interrupts + return pcb->pid; +} + + +#define PRIO_ILLEGAL -100 +// TODO: we can't have O(n) search here.. hash on prio instead + +/** + * Find the top priority task. Even the running task is included. + * + * @return + */ + +OsPcbType *Os_TaskGetTop( void ){ + OsPcbType *i_pcb; + OsPcbType *top_prio_pcb = NULL; + OsPriorityType top_prio = PRIO_ILLEGAL; + + os_isr_printf(D_TASK,"os_find_top_prio_proc\n"); + + TAILQ_FOREACH(i_pcb,& os_sys.ready_head,ready_list) { + // all ready task are canidates + if( i_pcb->state & (ST_READY|ST_RUNNING)) { + if( top_prio != PRIO_ILLEGAL ) { + if( i_pcb->prio > top_prio ) { + top_prio = i_pcb->prio; + top_prio_pcb = i_pcb; + } + } else { + top_prio = i_pcb->prio; + top_prio_pcb = i_pcb; + } + } else { + assert(0); + } + } + + assert(top_prio_pcb!=NULL); + + os_isr_printf(D_TASK,"Found %s\n",top_prio_pcb->name); + + return top_prio_pcb; +} + + +#define USE_DEBUG +#include "Trace.h" + +// we come here from +// - WaitEvent() +// old_pcb -> WAITING +// new_pcb -> READY(RUNNING) +// - Schedule(), +// old_pcb -> READY +// new_pcb -> READY/RUNNING + +/* + * two strategies + * 1. When running -> + * - remove from ready queue + * - set state == ST_RUNNING + * + * 2. When running -> + * * leave in ready queue + * * set state == ST_RUNNING + * - ready queue and ST_READY not the same + * + No need to remove the running process from ready queue + */ + +OsPcbType *Os_FindTopPrioTask( void ) { + + + return NULL; +} + +/** + * Tries to Dispatch. + * + * Used by: + * ActivateTask() + * WaitEvent() + * TerminateTask() + * + * @param force Force a re-scheduling + * + */ +void Os_Dispatch( _Bool force ) { + OsPcbType *pcbPtr; + OsPcbType *currPcbPtr; + + assert(os_sys.int_nest_cnt == 0); + assert(os_sys.scheduler_lock == 0 ); + + pcbPtr = Os_TaskGetTop(); + currPcbPtr = Os_TaskGetCurrent(); + /* Swap if we found any process or are forced (multiple activations)*/ + if( pcbPtr != currPcbPtr || force ) { + /* Add us to the ready list */ + if( currPcbPtr->state & ST_RUNNING ) { + Os_TaskRunningToReady(currPcbPtr); + } + + /* + * Swap context + */ + /** @req OS052 */ + POSTTASKHOOK(); + assert(pcbPtr!=NULL); + + Os_ResourceReleaseInternal(); + +#if (OS_STACK_MONITORING == 1) + if( !Os_StackIsEndmarkOk(currPcbPtr) ) { +#if ( OS_SC1 == 1) || ( OS_SC2 == 1) + /** @req OS068 */ + ShutdownOS(E_OS_STACKFAULT); +#else +#error SC3 or SC4 not supported. Protection hook should be called here +#endif + } +#endif + +#if 0 + // Make a simple stack check for prio procs... + // See OS068, Autosar SWS + { + uint32_t stackp = (uint32_t)Os_ArchGetStackPtr(); + uint32_t smallc_size = Os_ArchGetScSize(); + + // enough size to place a small context on the stack + // top( low address ) + small context > current stackpointer + if( (uint32_t)(currPcbPtr->stack.top + smallc_size) > stackp ) { + ShutdownOS(E_OS_STACKFAULT); + } + } +#endif + + /* Cases: + * 1. Re-Activate the same basic task again -> Os_ArchSwapContextToW() + * 2. Swap out a terminated task -> Os_ArchSwapContextToW() + * 3. Normal swap -> Os_ArchSwapContext() + */ + + /* Force is ONLY used from TerminateTask() */ + if( force ) { + Os_ArchSwapContextToW(currPcbPtr ,pcbPtr, pcbPtr->stack.curr ); + } + + Os_ArchSwapContext(currPcbPtr,pcbPtr); + + pcbPtr = Os_TaskGetCurrent(); + Os_TaskMakeRunning(pcbPtr); + + Os_ResourceGetInternal(); + + PRETASKHOOK(); + + } else { + /* We haven't removed ourselves from the ready list? */ + assert(currPcbPtr->state != ST_WAITING); + /* We have terminated and found us in the ready list? */ + assert(currPcbPtr->state != ST_SUSPENDED); + } +} + +// We come here from +// - os_init + +/** + * Called when a task is to be run for the first time. + */ +void Os_TaskSwapContextTo(OsPcbType *old_pcb, OsPcbType *new_pcb ) { + + + Os_ArchSwapContextTo(old_pcb,new_pcb); + /* TODO: When do we return here ?? */ +} + + +void Os_Arc_GetStackInfo( TaskType task, StackInfoType *s) { + OsPcbType *pcb = os_get_pcb(task); + + s->curr = Os_ArchGetStackPtr(); + s->top = pcb->stack.top; + s->at_swap = pcb->stack.curr; + s->size = pcb->stack.size; + s->usage = (void *)Os_StackGetUsage(pcb); +} + + +#if 0 +OsPcbType *os_find_higher_priority_task( OsPriorityType prio ) { + OsPcbType *i_pcb; + OsPcbType *h_prio_pcb = NULL; + OsPriorityType t_prio = prio; + + TAILQ_FOREACH(i_pcb,& os_sys.ready_head,ready_list) { + if( i_pcb->prio > t_prio ) { + t_prio = i_pcb->prio; + h_prio_pcb = i_pcb; + } + } + return h_prio_pcb; +} +#endif + StatusType GetTaskState(TaskType TaskId, TaskStateRefType State) { state_t curr_state = os_pcb_get_state(os_get_pcb(TaskId)); @@ -46,6 +435,18 @@ StatusType GetTaskID( TaskRefType task_id ) { *task_id = os_sys.curr_pcb->pid; return E_OK; } + +ISRType GetISRID( void ) { + OsPcbType *pPtr; + + /** @req OS264 */ + if(os_sys.int_nest_cnt == 0 ) { + return INVALID_ISR; + } + + /** @req OS263 */ + return (ISRType)Os_TaskGetCurrent()->pid; +} /** * The task is transferred from the suspended state into @@ -62,70 +463,107 @@ StatusType GetTaskID( TaskRefType task_id ) { * When an extended task is transferred from suspended state * into ready state all its events are cleared. * + * Note! + * ActivateTask will not immediately change the state of the task + * in case of multiple activation requests. If the task is not + * suspended, the activation will only be recorded and performed later. + * * @param pid * @return */ StatusType ActivateTask( TaskType TaskID ) { long msr; - pcb_t *pcb = os_get_pcb(TaskID); + OsPcbType *pcb = os_get_pcb(TaskID); StatusType rv = E_OK; os_isr_printf(D_TASK,"ActivateTask %s\n",pcb->name); - Irq_Save(msr); - - // TODO: It doesn't say anything about if we do this - // on a waiting task! if( !os_pcb_pid_valid(pcb) ) { - ramlog_str("E_OS_ID\n"); - ramlog_str(pcb->name); - ramlog_hex(pcb->pid); rv = E_OS_ID; goto err; } -#if 0 - if( os_pcb_get_state(pcb) != ST_SUSPENDED ) { - ramlog_str("#E_OS_LIMIT\n"); - ramlog_str(pcb->name); - ramlog_hex(pcb->pid); - ramlog_str(" "); - ramlog_hex(pcb->state); - ramlog_str(" "); - rv = E_OS_LIMIT; - goto err; - - } else { -#endif - if( pcb->activations == pcb->activationLimit ) { - return E_OS_LIMIT; - } else { + /* @req OS093 ActivateTask */ + if( Os_IrqAnyDisabled() ) { + rv = E_OS_DISABLEDINT; + goto err; + } + + Irq_Save(msr); + + if( os_pcb_get_state(pcb) == ST_SUSPENDED ) { pcb->activations++; - if( os_pcb_get_state(pcb) == ST_READY ) { - /* We do nothing */ - } else { - /* TODO: This makes some things double.. cleanup is needed */ - os_pcb_make_virgin(pcb); - } - } - - os_pcb_make_ready(pcb); + if (pcb->proc_type == PROC_EXTENDED) { + /** @req OSEK ActivateTask Cleanup events + * OSEK,ActivateTask, When an extended task is transferred from suspended + * state into ready state all its events are cleared.*/ + pcb->ev_set = 0; + pcb->ev_wait = 0; + } + Os_TaskMakeReady(pcb); + } else { + + if( pcb->proc_type == PROC_EXTENDED ) { + /** @req OSEK Activate task. + * An extended task be activated once. See Chapter 4.3 in OSEK + */ + rv = E_OS_LIMIT; + goto err; + } + + /** @req OSEK_? Too many task activations */ + if( pcb->activations == pcb->activationLimit ) { + rv=E_OS_LIMIT; + goto err; + } else { + pcb->activations++; + } + } + Irq_Restore(msr); - - // Following chapter 4.6.1 in OSEK/VDX here it seems we should re-schedule. - if( (pcb->scheduling == FULL) && (os_sys.int_nest_cnt == 0) ) { - Schedule(); + + /* Preempt only if higher prio than us */ + if( (pcb->scheduling == FULL) && + (os_sys.int_nest_cnt == 0) ) + { + Os_Dispatch(0); } OS_STD_END_1(OSServiceId_ActivateTask,TaskID); } - -extern void os_pcb_make_virgin(pcb_t *pcb); + +/** + * This service causes the termination of the calling task. The + * calling task is transferred from the running state into the + * suspended state. + * + * An internal resource assigned to the calling task is automatically + * released. Other resources occupied by the task shall have been + * released before the call to TerminateTask. If a resource is still + * occupied in standard status the behaviour is undefined. + * + * If the call was successful, TerminateTask does not return to the + * call level and the status can not be evaluated. + * + * If the version with extended status is used, the service returns + * in case of error, and provides a status which can be evaluated + * in the application. + * + * If the service TerminateTask is called successfully, it enforces a + * rescheduling. + * + * [ Ending a task function without call to TerminateTask + * or ChainTask is strictly forbidden and may leave the system in an + * undefined state. ] + * + * [] is an OSEK requirement and is overridden by OS052 + * + * @return + */ StatusType TerminateTask( void ) { - pcb_t *curr_pcb = os_get_curr_pcb(); - pcb_t *new_pcb; + OsPcbType *curr_pcb = Os_TaskGetCurrent(); StatusType rv = E_OK; uint32_t flags; @@ -136,14 +574,33 @@ StatusType TerminateTask( void ) { goto err; } - Irq_Save(flags); - - os_pcb_make_suspended(curr_pcb); - - // Schedule any process - new_pcb = os_find_top_prio_proc(); - assert(new_pcb!=NULL); - os_swap_context(curr_pcb,new_pcb); + Irq_Save(flags); + + --curr_pcb->activations; + assert(curr_pcb->activations>=0); + + /*@req OSEK TerminateTask + * In case of tasks with multiple activation requests, + * terminating the current instance of the task automatically puts the next + * instance of the same task into the ready state + */ + if( curr_pcb->activations == 0 ) { + Os_TaskMakeSuspended(curr_pcb); + } else { + /* We need to add ourselves to the ready list again, + * with a startup context. */ + + + } + /* We're manipulating the current stack here. + * Os_ArchSwapContext(old,new) saves on current stack. + * 1. We add an argument to Os_ArchSwapContext() to set the stack. + * 2. We could call ActivateTask here... + */ + Os_ContextReInit(curr_pcb); + + /* Force the dispatcher to find something, even if its us */ + Os_Dispatch(1); Irq_Restore(flags); // It must find something here...otherwise something is very wrong.. @@ -189,8 +646,8 @@ StatusType ChainTask( TaskType TaskId ) { * */ StatusType Schedule( void ) { - pcb_t *pcb; - pcb_t *curr_pcb = get_curr_pcb(); +// OsPcbType *pcb; +// OsPcbType *curr_pcb = get_curr_pcb(); StatusType rv = E_OK; uint32_t flags; @@ -200,10 +657,16 @@ StatusType Schedule( void ) { * FULL - Assigned internal resource OR * No assigned internal resource. * */ + if( Os_TaskGetCurrent()->scheduling != NON ) { + return E_OK; + } + +#if 0 if( os_get_resource_int_p() == NULL ) { /* We do nothing */ return E_OK; } +#endif /* Check that we are not calling from interrupt context */ if( os_sys.int_nest_cnt != 0 ) { @@ -211,16 +674,8 @@ StatusType Schedule( void ) { goto err; } - Irq_Save(flags); - /* Try to find higher prio task that is ready, if none, continue */ - pcb = os_find_top_prio_proc(); - - /* Swap if we found any process */ - if( pcb != curr_pcb ) { - /* Add us to the ready list */ - os_pcb_running_to_ready(curr_pcb); - os_swap_context(curr_pcb,pcb); - } + Irq_Save(flags); + Os_Dispatch(0); Irq_Restore(flags); // Prevent label warning. Remove this when proper error handling is implemented. diff --git a/system/kernel/task_i.c b/system/kernel/task_i.c deleted file mode 100644 index 64a315d8..00000000 --- a/system/kernel/task_i.c +++ /dev/null @@ -1,227 +0,0 @@ -/* -------------------------------- Arctic Core ------------------------------ - * Arctic Core - the open source AUTOSAR platform http://arccore.com - * - * Copyright (C) 2009 ArcCore AB - * - * This source code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by the - * Free Software Foundation; See . - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - - -#include "Os.h" -#include "pcb.h" -#include "sys.h" -#include -//#include "arch_offset.h" -#include "hooks.h" -#include "task_i.h" -#include "arch.h" -#include "ext_config.h" -#include "assert.h" -#include "internal.h" - -_Bool os_pcb_pid_valid( pcb_t *restrict pcb ) { - return ( pcb->pid > Oil_GetTaskCnt() ) ? 0 : 1; -} -/** - * Start an extended task. - * Tasks done: - * - Grab the internal resource for the process - * - Set it running state. - * - Start to execute the process - * - */ -void os_proc_start_extended( void ) { - pcb_t *pcb; - - // TODO: Get internal resource - PRETASKHOOK(); - - pcb = os_get_curr_pcb(); - os_resource_get_internal(); - os_pcb_make_running(pcb); - - os_arch_first_call(); - - // If we have a extented process that that exits, we end up here - // See OS052,OS069, Autosar SWS - ERRORHOOK(E_OS_MISSINGEND); - - /* TODO: Terminate the task */ - //while(1); -} - -/** - * Start an basic task. - * See extended task. - */ - -void os_proc_start_basic( void ) { - pcb_t *pcb; - - // TODO: Get internal resource - PRETASKHOOK(); - - pcb = os_get_curr_pcb(); - os_resource_get_internal(); - os_pcb_make_running(pcb); - os_arch_first_call(); - - TerminateTask(); -// ERRORHOOK(E_OS_MISSINGEND); -} - -/** - * Setup the context for a pcb. The context differs for different arch's - * so we call the arch dependent functions also. - * The context at setup is always a small context. - * - * @param pcb Ptr to the pcb to setup context for. - */ -void os_setup_context( pcb_t *pcb ) { - uint8_t *bottom; - - /* Find bottom of the stack so that we can place the - * context there. - * - * stack bottom = high address. stack top = low address - */ - bottom = (uint8_t *)pcb->stack.top + pcb->stack.size; - pcb->stack.curr = bottom; - // TODO: aligments here.. - // TODO :use function os_arch_get_call_size() ?? - - // Make some space for back-chain. - bottom -= 16; - // Set the current stack so that it points to the context - pcb->stack.curr = bottom - os_arch_get_sc_size(); - - os_arch_setup_context(pcb); -} - -/** - * Search for a specific task in the pcb list. - * - * @param tid The task id to search for - * @return Ptr to the found pcb or NULL - */ -pcb_t *os_find_task( TaskType tid ) { - pcb_t *i_pcb; - - /* TODO: Implement this as an array */ - TAILQ_FOREACH(i_pcb,& os_sys.pcb_head,pcb_list) { - if(i_pcb->pid == tid ) { - return i_pcb; - } - } - assert(0); - return NULL; -} - -/** - * Adds a pcb to the list of pcb's - * @param pcb - */ -TaskType os_add_task( pcb_t *pcb ) { - long msr; - - Irq_Save(msr); // Save irq status and disable interrupts - - pcb->pid = os_sys.task_cnt; - // Add to list of PCB's - TAILQ_INSERT_TAIL(& os_sys.pcb_head,pcb,pcb_list); - os_sys.task_cnt++; - - Irq_Restore(msr); // Restore interrupts - return pcb->pid; -} - - -#define PRIO_ILLEGAL -100 -// TODO: we can't have O(n) search here.. hash on prio instead - -/** - * Find the top priority task. Even the running task is included. - * - * @return - */ - -pcb_t *os_find_top_prio_proc( void ){ - pcb_t *i_pcb; - pcb_t *top_prio_pcb = NULL; - prio_t top_prio = PRIO_ILLEGAL; - - os_isr_printf(D_TASK,"os_find_top_prio_proc\n"); - - TAILQ_FOREACH(i_pcb,& os_sys.ready_head,ready_list) { - // all ready task are canidates - if( i_pcb->state & (ST_READY|ST_RUNNING)) { - if( top_prio != PRIO_ILLEGAL ) { - if( i_pcb->prio > top_prio ) { - top_prio = i_pcb->prio; - top_prio_pcb = i_pcb; - } - } else { - top_prio = i_pcb->prio; - top_prio_pcb = i_pcb; - } - } else { - assert(0); - } - } - os_isr_printf(D_TASK,"Found %s\n",top_prio_pcb->name); - - return top_prio_pcb; -} - -/** - * Used at startup to initialize a pcb. Is sometimes - * used to restore the state of a basic process. - * - * @param pcb The pcb to make virgin - */ - -void os_pcb_make_virgin( pcb_t *pcb ) { - if( pcb->autostart ) { - os_pcb_make_ready(pcb); - } else { - pcb->state = ST_SUSPENDED; - } - - /* TODO: cleanup resource here ?? */ - pcb->ev_set = 0; - pcb->ev_wait = 0; - - os_setup_context(pcb); -} - -#if 0 -pcb_t *os_find_higher_priority_task( prio_t prio ) { - pcb_t *i_pcb; - pcb_t *h_prio_pcb = NULL; - prio_t t_prio = prio; - - TAILQ_FOREACH(i_pcb,& os_sys.ready_head,ready_list) { - if( i_pcb->prio > t_prio ) { - t_prio = i_pcb->prio; - h_prio_pcb = i_pcb; - } - } - return h_prio_pcb; -} -#endif - - diff --git a/system/kernel/testsystem/config/Os_Cfg.c b/system/kernel/testsystem/config/Os_Cfg.c index 78e41c06..5a29e0a4 100644 --- a/system/kernel/testsystem/config/Os_Cfg.c +++ b/system/kernel/testsystem/config/Os_Cfg.c @@ -91,18 +91,23 @@ OsTickType OsTickFreq = 1000; extern void dec_exception( void ); - -// atleast 1 -#define SERVICE_CNT 1 + +#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) +// atleast 1 +#define SERVICE_CNT 1 GEN_TRUSTEDFUNCTIONS_LIST +#endif //------------------------------------------------------------------- - + +#if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) GEN_APPLICATION_HEAD { GEN_APPLICATON(0,"application_1",true,NULL,NULL,NULL , 0,0,0,0,0,0 ) -}; +}; +#endif + //------------------------------------------------------------------- #define ALIGN_16(x) (((x)>>4)<<4) @@ -143,16 +148,16 @@ GEN_TASK_HEAD { GEN_ETASK(OsIdle,0,true/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0 ), /* extended */ - GEN_ETASK(etask_master,1,true/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0 ), + GEN_ETASK(etask_master,1,true/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, NON, 0), GEN_ETASK(etask_sup_l,2,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0 ), GEN_ETASK(etask_sup_m,3,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0 ), GEN_ETASK(etask_sup_h,4,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0 ), /* basic */ - GEN_BTASK(btask_sup_l,2,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0 ), - GEN_BTASK(btask_sup_m,3,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0 ), - GEN_BTASK(btask_sup_h,4,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0 ), + GEN_BTASK(btask_sup_l,2,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0, 1 ), + GEN_BTASK(btask_sup_m,3,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0, 1 ), + GEN_BTASK(btask_sup_h,4,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0, 1 ), GEN_ISR_2( TASK_ID_os_tick, "dec", OsTick, /*prio*/ 11, /*type*/ PROC_ISR2, INTC_VECTOR_EXCEPTION_DEC , NULL, APPLICATION_ID_application_1), #if 0 @@ -193,11 +198,12 @@ GEN_IRQ_PRIORITY_TABLE_HEAD {}; //------------------------------------------------------------------- // Generate as _data +#if 0 #ifdef ALARM_USE int MsgRx_1_data; int MsgTx_1_data; -message_obj_t message_list[] = { +OsMessageType message_list[] = { { .property = RECEIVE_UNQUEUED_INTERNAL, .data = &MsgRx_1_data, @@ -221,12 +227,13 @@ message_obj_t message_list[] = { MESSAGE_CLASS(rx1,int,,,); #endif +#endif /* typedef struct { message_type_t type; // RECEIVE_UNQUEUED_INTERNAL, RECEIVE_QUEUE_INTERNAL MessageType send_id; - message_notification_t *notification; + OsMessageNotificationType *notification; void *queue_data; uint32 queue_size; } message_rx_t; @@ -316,7 +323,7 @@ GEN_ALARM_HEAD { #if defined(SCHEDULETABLE_USE) -sched_action_t sched_expire_list_0[] = { +OsScheduleTableActionType sched_expire_list_0[] = { { .type = SCHEDULE_ACTION_ACTIVATETASK, .offset = 5, @@ -330,7 +337,7 @@ sched_action_t sched_expire_list_0[] = { }; -sched_action_t sched_expire_list_1[] = { +OsScheduleTableActionType sched_expire_list_1[] = { { .type = SCHEDULE_ACTION_ACTIVATETASK, .offset = 2, @@ -344,7 +351,7 @@ GEN_SCHEDULETABLE_HEAD { 0, // id "stable0", // name COUNTER_ID_soft_2, // counter - 1, // periodic + REPEATING, // periodic SCHEDULETABLE_DURATION_1, // duration 0, // app_mask ARRAY_SIZE(sched_expire_list_0), // action count @@ -358,7 +365,7 @@ GEN_SCHEDULETABLE_HEAD { 1, // id "stable1", // name COUNTER_ID_soft_2, // counter - 1, // periodic + REPEATING, // periodic SCHEDULETABLE_DURATION_2, // duration 0, // app_mask ARRAY_SIZE(sched_expire_list_1), // action count @@ -374,9 +381,11 @@ GEN_SCHEDULETABLE_HEAD { // --- HOOKS --- -struct os_conf_global_hooks_s os_conf_global_hooks = { - .StartupHook = StartupHook, - .ProtectionHook = ProtectionHook, +struct OsHooks os_conf_global_hooks = { + .StartupHook = StartupHook, +#if ( OS_SC2 == STD_ON ) || ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON ) + .ProtectionHook = ProtectionHook, +#endif .ShutdownHook = ShutdownHook, .ErrorHook = ErrorHook, .PreTaskHook = PreTaskHook, diff --git a/system/kernel/testsystem/config/Os_Cfg.h b/system/kernel/testsystem/config/Os_Cfg.h index 21ae81ad..7a3852a3 100644 --- a/system/kernel/testsystem/config/Os_Cfg.h +++ b/system/kernel/testsystem/config/Os_Cfg.h @@ -13,22 +13,11 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - -/* - * Os_Cfg.h - * - * Created on: 2008-dec-22 - * Author: mahi - */ + #ifndef OS_CFG_H_ #define OS_CFG_H_ + /* os_config.h */ diff --git a/system/kernel/testsystem/makefile b/system/kernel/testsystem/makefile index 6c00aa7c..ab199d7b 100644 --- a/system/kernel/testsystem/makefile +++ b/system/kernel/testsystem/makefile @@ -5,10 +5,17 @@ # APPLICATION obj-y += test_master.o -obj-y += test_sup_01.o -obj-y += test_sup_02.o -obj-y += test_sup_03.o -obj-y += test_sup_04.o +obj-y += test_01_task.o +obj-y += test_02_resource.o +obj-y += test_03_alarm.o +obj-y += test_04_stable.o +obj-y += test_05_const.o +obj-y += test_06_event.o + +#obj-y += test_sup_01.o +#obj-y += test_sup_02.o +#obj-y += test_sup_03.o +#obj-y += test_sup_04.o obj-y += test_framework.o obj-y += Os_Cfg.o @@ -31,7 +38,7 @@ CFG+=CONSOLE_WINIDEA # TODO: Fix this.... -vpath-$(BUILD_TREE) += $(ROOTDIR)/$(ARCH_PATH-y)/kernel +vpath-y += $(ROOTDIR)/$(ARCH_PATH-y)/kernel vpath-y += $(ROOTDIR)/$(ARCH_PATH-y)/drivers vpath-y += $(ROOTDIR)/boards/$(BOARDDIR) vpath-y += $(ROOTDIR)/boards/$(BOARDDIR)/config diff --git a/system/kernel/testsystem/os_test.h b/system/kernel/testsystem/os_test.h index 2b281315..41b58d1d 100644 --- a/system/kernel/testsystem/os_test.h +++ b/system/kernel/testsystem/os_test.h @@ -39,7 +39,11 @@ typedef void (*test_func_t)( void ); #define TEST_ASSERT(_cond) if(!(_cond)) { TEST_FAIL(#_cond); } extern int test_suite; -extern int test_nr; +extern int test_nr; + +#define TASK_ID_ILL 99 +#define RES_ID_ILL 99 +#define ALARM_ID_ILL 99 #if 1 #define SECTION_SUP diff --git a/system/kernel/testsystem/test_01_task.c b/system/kernel/testsystem/test_01_task.c new file mode 100644 index 00000000..169ad68b --- /dev/null +++ b/system/kernel/testsystem/test_01_task.c @@ -0,0 +1,203 @@ +/* -------------------------------- Arctic Core ------------------------------ + * Arctic Core - the open source AUTOSAR platform http://arccore.com + * + * Copyright (C) 2009 ArcCore AB + * + * This source code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * -------------------------------- Arctic Core ------------------------------*/ + +/* + * Tests tasks: + * + * OSEK + * - ActivateTask E_OS_ID, E_OS_LIMIT + * - TerminateTask E_OS_RESOURCE, E_OS_CALLEVEL + * - ChainTask E_OS_ID, E_OS_LIMIT, E_OS_RESOURCE, E_OS_CALLLEVEL + * - Schedule E_OS_CALLEVEL, E_OS_RESOURCE + * - GetTaskID + * - GetTaskState E_OS_ID + * + * + * Limitations: + * - No way to detect if in ISR1 or hooks + * - NON tasks are not tested. + * - ActivateTask() with own taskid? + */ + +#include "Os.h" +#include "os_test.h" +#include "arc.h" + +int btaskRunCnt = 0; + +void isr_l(void ) { + StatusType rv; + switch(test_nr) { + case 11: + rv = TerminateTask(); + TEST_ASSERT(rv=E_OS_CALLEVEL); + break; + case 12: + break; + case 13: + break; + default: + while(1); + } +} + +void etask_sup_l_01(void) { + _Bool done = 0; + StatusType rv; + + while (!done) { + switch (test_nr) { + case 1: + /*@req E_OS_ID ActivateTask */ + rv = ActivateTask(TASK_ID_ILL); + TEST_ASSERT(rv == E_OS_ID); + test_nr = 2; + break; + case 2: + /*@req E_OS_LIMIT ActivateTask + * Test the activation limit and check that activated task is run + * the activation limit times */ + + /* Activate higher prio task to do the test */ + rv = ActivateTask(TASK_ID_btask_sup_h); + TEST_ASSERT(rv=E_OK); + + /* Was it run activation times? */ + TEST_ASSERT(btaskRunCnt == Os_ArcTest_GetTaskActivationLimit(TASK_ID_btask_sup_m)); + test_nr = 10; + break; + case 10: + /*@req E_OS_RESOURCE TerminateTask + * Terminate a task that still holds resources + * */ + rv = ActivateTask(TASK_ID_btask_sup_h); + TEST_ASSERT(rv=E_OK); + break; + case 11: + /*@req E_OS_CALLEVEL TerminateTask */ + Os_ArcTest_SetIrqNestLevel(1); + isr_l(); + Os_ArcTest_SetIrqNestLevel(0); + test_nr=20; + break; + + case 20: + /*@req E_OS_ID ChainTask */ + rv = ChainTask(TASK_ID_ILL); + TEST_ASSERT(rv == E_OS_ID); + test_nr++; + case 21: + /*@req E_OS_LIMIT ChainTask */ + case 22: + /*@req E_OS_RESOURCE ChainTask */ + case 23: + /*@req E_OS_CALLLEVEL ChainTask */ + break; + + case 30: + /*@req E_OS_CALLEVEL Schedule */ + case 31: + /*@req E_OS_RESOURCE Schedule */ + break; + + case 100: + /*@req Scheduler test + * The first task(oldest) task of the same priority should be scheduled first + * E.g. From M task do ActivateTask() + */ + /* Change to higher prio */ + btaskRunCnt = 0; + rv = ActivateTask(TASK_ID_btask_sup_m); + /* We got back from M, btask_l is now ready in queue */ + TEST_ASSERT(btaskRunCnt==0); + /* Terminate ourselves, to be activated later */ + TerminateTask(); + break; + case 101: + TEST_ASSERT(btaskRunCnt==1); + break; + default: + while(1); + } + } +} + +void btask_sup_l_01( void ) { + switch(test_nr){ + case 100: + btaskRunCnt++; + /* Make it go up again */ + test_nr = 101; + ActivateTask(TASK_ID_etask_sup_l); + break; + default: + break; + } + +} + +void btask_sup_m_01( void ) { + int rv; + switch(test_nr){ + case 2: + btaskRunCnt++; + break; + case 10: + rv = GetResource(RES_ID_ext_prio_3); + TEST_ASSERT(rv=E_OK); + + rv = TerminateTask(); + TEST_ASSERT(rv==E_OS_RESOURCE); + + rv = ReleaseResource(RES_ID_ext_prio_3); + TerminateTask(); + break; + case 100: + /* We got here from etask_l, so it should be oldest */ + rv = ActivateTask(TASK_ID_btask_sup_l); + break; + default: + while(1); + } + +} + +void btask_sup_h_01(void) { + StatusType rv; + int limit; + + switch (test_nr) { + case 2: + /* Activate a basic task to many times */ + limit = Os_ArcTest_GetTaskActivationLimit(TASK_ID_btask_sup_m); + for (int i = 0; i < limit; i++) { + rv = ActivateTask(TASK_ID_btask_sup_m); + TEST_ASSERT(rv == E_OK); + } + rv = ActivateTask(TASK_ID_btask_sup_m); + TEST_ASSERT(rv == E_OS_LIMIT); + /* Let the us terminate and count the number of times the tasks + * was actually activated + * + * TODO:@req Since the etask and btask have the same priority, who gets scheduled? + * Oldest is scheduled first.. + * */ + break; + default: + while(1); + + } +} + diff --git a/system/kernel/testsystem/test_02_resource.c b/system/kernel/testsystem/test_02_resource.c new file mode 100644 index 00000000..51566029 --- /dev/null +++ b/system/kernel/testsystem/test_02_resource.c @@ -0,0 +1,32 @@ +/* -------------------------------- Arctic Core ------------------------------ + * Arctic Core - the open source AUTOSAR platform http://arccore.com + * + * Copyright (C) 2009 ArcCore AB + * + * This source code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * -------------------------------- Arctic Core ------------------------------*/ + +/* + * Tests: + * + * OSEK: + * - GetResource E_OS_ID, E_OS_ACCESS + * - ReleaseResource E_OS_ID, E_OS_ACCESS, E_OS_NOFUNC + * + * More tests here: + * - GetResource(RES_SCHEDULER) + * - Check the ceiling protocol + * - Linked resources + * - Nested allocation of the same resource is forbidden. + * + * + * Limitations: + * - Internal resources. + */ diff --git a/system/kernel/testsystem/test_03_alarm.c b/system/kernel/testsystem/test_03_alarm.c new file mode 100644 index 00000000..94389f3f --- /dev/null +++ b/system/kernel/testsystem/test_03_alarm.c @@ -0,0 +1,35 @@ +/* -------------------------------- Arctic Core ------------------------------ + * Arctic Core - the open source AUTOSAR platform http://arccore.com + * + * Copyright (C) 2009 ArcCore AB + * + * This source code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * -------------------------------- Arctic Core ------------------------------*/ + +/* + * Tests: + * + * OSEK + * - GetAlarmBase E_OS_ID + * - GetAlarm E_OS_ID, E_OS_NOFUNC + * - SetRelAlarm E_OS_ID, E_OS_STATE, E_OS_VALUE + * - SetAbsAlarm E_OS_ID, E_OS_STATE, E_OS_VALUE + * - CancelAlarm E_OS_ID, E_OS_NOFUNC + * + * Autosar + * - IncrementCounter E_OS_ID + * - GetCounterValue E_OS_ID + * - GetElapsedCounterValue E_OS_ID, E_OS_VALUE + * + * More tests here: + * + * Limitations: + */ + diff --git a/system/kernel/testsystem/test_04_stable.c b/system/kernel/testsystem/test_04_stable.c new file mode 100644 index 00000000..63b5fbe8 --- /dev/null +++ b/system/kernel/testsystem/test_04_stable.c @@ -0,0 +1,35 @@ +/* -------------------------------- Arctic Core ------------------------------ + * Arctic Core - the open source AUTOSAR platform http://arccore.com + * + * Copyright (C) 2009 ArcCore AB + * + * This source code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * -------------------------------- Arctic Core ------------------------------*/ + +/* + * From Autosar 3.1 + * + * Tests: + * - StartScheduleTableRel E_OS_ID, E_OS_VALUE, E_OS_STATE + * - StartScheduleTableAbs E_OS_ID, E_OS_VALUE, E_OS_STATE + * - StopScheduleTable E_OS_ID, E_OS_NO_FUNC + * - NextScheduleTable E_OS_ID, E_OS_NO_FUNC, E_OS_STATE + * - GetScheduleTableStatus E_OS_ID, + * + * Class 2 and 4 + * - StartScheduleTableSynchrone E_OS_ID, E_OS_STATE + * - SyncScheduleTable E_OS_ID, E_OS_VALUE, E_OS_STATE + * - SetScheduleTableAsync E_OS_ID, + * + * More tests here: + * + * Limitations: + */ + diff --git a/system/kernel/stack.c b/system/kernel/testsystem/test_05_const.c similarity index 66% rename from system/kernel/stack.c rename to system/kernel/testsystem/test_05_const.c index 82ce0792..7ddff737 100644 --- a/system/kernel/stack.c +++ b/system/kernel/testsystem/test_05_const.c @@ -1,43 +1,42 @@ -/* -------------------------------- Arctic Core ------------------------------ - * Arctic Core - the open source AUTOSAR platform http://arccore.com - * - * Copyright (C) 2009 ArcCore AB - * - * This source code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by the - * Free Software Foundation; See . - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - +/* -------------------------------- Arctic Core ------------------------------ + * Arctic Core - the open source AUTOSAR platform http://arccore.com + * + * Copyright (C) 2009 ArcCore AB + * + * This source code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * -------------------------------- Arctic Core ------------------------------*/ + /* - * stack.c + * Tests: + * + * OSEK constants + * - OSMAXALLOWEDVALUE_x + * - OSTICKSPERBASE_x + * - OSMINCYCLE_x + * - OSMAXALLOWEDVALUE + * - OSTICKSPERBASE + * - OSMINCYCLE + * - OSTICKDURATION + * + * - INVALID_TASK + * + * - OSDEFAULTAPPMODE * - * Created on: 2009-jan-25 - * Author: mahi + * - OSServiceId_xx + * - OSErrorGetServiceId + * - OSError_x1_x2 + * + * Autosar constants + * + * More tests here: + * + * Limitations: */ -#include "pcb.h" -#include "arch.h" -#include "Os.h" - -void Os_GetStackInfo( TaskType task, StackInfoType *s) { - - pcb_t *pcb = os_get_pcb(task); - - s->curr = os_arch_get_stackptr(); - s->top = pcb->stack.top; - s->at_swap = pcb->stack.curr; - s->size = pcb->stack.size; - s->usage = (void *)os_arch_get_stack_usage(pcb); -} diff --git a/system/kernel/pool.c b/system/kernel/testsystem/test_06_event.c similarity index 71% rename from system/kernel/pool.c rename to system/kernel/testsystem/test_06_event.c index 92cd5012..28bbe352 100644 --- a/system/kernel/pool.c +++ b/system/kernel/testsystem/test_06_event.c @@ -1,40 +1,29 @@ -/* -------------------------------- Arctic Core ------------------------------ - * Arctic Core - the open source AUTOSAR platform http://arccore.com - * - * Copyright (C) 2009 ArcCore AB - * - * This source code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by the - * Free Software Foundation; See . - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - +/* -------------------------------- Arctic Core ------------------------------ + * Arctic Core - the open source AUTOSAR platform http://arccore.com + * + * Copyright (C) 2009 ArcCore AB + * + * This source code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * -------------------------------- Arctic Core ------------------------------*/ -static uint8_tos_pool[20000]; +/* + * Tests: + * + * OSEK + * - SetEvent E_OS_ID, E_OS_ACCESS, E_OS_STATE + * - ClearEvent E_OS_ACCESS, E_OS_CALLEVEL + * - GetEvent E_OS_ID, E_OS_ACCESS, E_OS_STATE + * - WaitEvent E_OS_ACCESS, E_OS_RESOURCE, E_OS_CALLEVEL + * + * More tests here: + * + * Limitations: + */ -typedef struct { - void *free; -}os_memory_t; - -k_memory_tos_mem = { .free = NULL }; - -void *k_malloc( int size ) { - void *t; - if(os_mem.free != NULL ) { - t =os_mem.free; - (uint8)k_mem.free += size; - return t; - } - return NULL; -} diff --git a/system/kernel/testsystem/test_07_misc.c b/system/kernel/testsystem/test_07_misc.c new file mode 100644 index 00000000..2dbb8d2c --- /dev/null +++ b/system/kernel/testsystem/test_07_misc.c @@ -0,0 +1,104 @@ +/* -------------------------------- Arctic Core ------------------------------ + * Arctic Core - the open source AUTOSAR platform http://arccore.com + * + * Copyright (C) 2009 ArcCore AB + * + * This source code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * -------------------------------- Arctic Core ------------------------------*/ + +/* + * Tests: + * + * OSEK + * - DisableAllInterrupts + * - EnableAllInterrupts + * - SuspendAllInterrupts + * - ResumeAllInterrupts + * - SuspendOSInterrupts + * - ResumeOSInterrupts + * + * - GetActiveApplicationMode + * - StartOS + * - ShutdownOS + * + * + * Autosar + * + * Class 3 and 4 + * - GetApplicationID + * - GetISRID IVALID_ISR + * - CallTrustedFunction ... + * - CheckISRMemoryAccess ... + * - CheckTaskMemoryAccess + * - CheckObjectMemoryAccess + * - CheckObjectOwnership + * - TerminateApplication + * + * Autosar additional tests: + * + * Class 2,3,4 + * - ProtectionHook + * + * Class 2,4 + * - Timing Protection + * - Global Time + * + * Class 3,4 + * - Memory Protection + * - Os-Applications + * - Service Protection + * - Call trusted function + * + * Limitations: + */ + +void intTest( void ) { + + /* Just call them to its works */ + DisableAllInterrupts(); + EnableAllInterrupts(); + + SuspendAllInterrupts(); + ResumeAllInterrupts(); + + SuspendOSInterrupts(); + ResumeOSInterrupts(); + + /** @req OS092 */ + /* We should be able to call them and they should be ignored */ + EnableAllInterrupts(); + EnableAllInterrupts(); + + ResumeAllInterrupts(); + ResumeAllInterrupts(); + + ResumeOSInterrupts(); + ResumeOSInterrupts(); + + /* No nesting for DisableAllInterrupts() and EnableAllInterrupts */ + DisableAllInterrupts(); + /* No calls allowed here */ + EnableAllInterrupts(); + + /* Nesting allowed for these calls */ + SuspendAllInterrupts(); + SuspendAllInterrupts(); + SuspendOSInterrupts(); + ResumeOSInterrupts(); + ResumeAllInterrupts(); + ResumeAllInterrupts(); + + /* MORE MORE */ + +} + + + + diff --git a/system/kernel/testsystem/test_master.c b/system/kernel/testsystem/test_master.c index 4d9e9ad9..9e8a962e 100644 --- a/system/kernel/testsystem/test_master.c +++ b/system/kernel/testsystem/test_master.c @@ -13,16 +13,8 @@ * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - -#include "Os.h" #include +#include "Os.h" #include "os_test.h" #include "Mcu.h" #if defined(USE_GPT) @@ -44,7 +36,7 @@ extern void etask_sup_h_basic_02( void ); extern void btest_sup_m_##_nr(void);\ extern void btest_sup_h_##_nr(void); -DECLARE_BASIC(02); +// DECLARE_BASIC(02); typedef struct { uint32 nr; @@ -72,12 +64,11 @@ void etask_master( void ) { { test_nr = 1; dbg_printf("-----> Test Suite %02d\n",test_suite); - pid = test_activate_pid_list[test_case]; - ActivateTask(pid); - // All test tasks are higher prio than we.. so this triggers them.. - Schedule(); - // All tasks in the test are now terminated... - // Start new tests.. + pid = test_activate_pid_list[test_case]; + ActivateTask(pid); + /* We are lowest prio task in the system (apart from idle) so + * all tasks in the test are now terminated... + */ test_suite++; } @@ -87,19 +78,22 @@ void etask_master( void ) { } test_func_t etask_sup_matrix[][3] = { -/* 01*/ { etask_sup_l_01, etask_sup_m_01, etask_sup_h_01}, +/* 01*/ { etask_sup_l_01, NULL, NULL }, +#if 0 /* 02*/ { etask_sup_l_02, etask_sup_m_02, etask_sup_h_02}, /* 03*/ { etask_sup_l_03, etask_sup_m_03, NULL}, -/* 04*/ { etask_sup_l_04, etask_sup_m_04, NULL}, +/* 04*/ { etask_sup_l_04, etask_sup_m_04, NULL}, +#endif }; // __attribute__ ((section(".data_app_2"))); #define TEST_BASIC(nr) \ { btest_sup_l_##nr , btest_sup_m_##nr , btest_sup_h_## nr } test_func_t btask_sup_matrix[][3] = { -/* 01*/ { NULL, NULL, NULL}, - TEST_BASIC(02), +/* 01*/ { NULL, NULL, NULL}, #if 0 + TEST_BASIC(02), + #endif }; // __attribute__ ((section(".data_app_2"))); @@ -215,7 +209,7 @@ void PostTaskHook( void ) { // dbg_printf("## PostTaskHook, taskid=%d\n",task); { StackInfoType si; - Os_GetStackInfo(task,&si); + Os_Arc_GetStackInfo(task,&si); // dbg_printf("Stack usage %d%% (this=%08x, top=%08x, size=%08x,usage=%08x )\n",OS_STACK_USAGE(&si),si.curr, si.top,si.size,si.usage); } } diff --git a/system/kernel/testsystem/test_sup_01.c b/system/kernel/testsystem/test_sup_01.c index 9d23ac24..f88f8298 100644 --- a/system/kernel/testsystem/test_sup_01.c +++ b/system/kernel/testsystem/test_sup_01.c @@ -12,14 +12,6 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - /* * Tested: Tasks @@ -44,14 +36,57 @@ DeclareResource(RES_1); //static int test = 1; - + +#define TASK_ID_ILL 99 +#define RES_ID_ILL 99 +#define ALARM_ID_ILL 99 + +static void taskApiTests( void ) { + StatusType rv; + TaskStateType taskState; + EventMaskType eventMask; + AlarmBaseType alarmInfo; + TickType tick; + + /*@req E_OS_ID */ + rv = ActivateTask(TASK_ID_ILL); + TEST_ASSERT(rv==E_OS_ID ); + rv = ChainTask(TASK_ID_ILL); + TEST_ASSERT(rv==E_OS_ID ); + + rv = GetTaskState(TASK_ID_ILL,&taskState); + TEST_ASSERT(rv==E_OS_ID ); + + rv = GetResource(RES_ID_ILL); + TEST_ASSERT(rv==E_OS_ID ); + rv = ReleaseResource(RES_ID_ILL); + TEST_ASSERT(rv==E_OS_ID ); + + rv = SetEvent(TASK_ID_ILL,1); + TEST_ASSERT(rv==E_OS_ID ); + rv = GetEvent(TASK_ID_ILL,&eventMask); + TEST_ASSERT(rv==E_OS_ID ); + + rv = GetAlarmBase(ALARM_ID_ILL,&alarmInfo); + TEST_ASSERT(rv==E_OS_ID ); + rv = GetAlarm(ALARM_ID_ILL,&tick); + TEST_ASSERT(rv==E_OS_ID ); + rv = SetRelAlarm(ALARM_ID_ILL,1,2); + TEST_ASSERT(rv==E_OS_ID ); + rv = SetAbsAlarm(ALARM_ID_ILL,1,2); + TEST_ASSERT(rv==E_OS_ID ); + rv = CancelAlarm(ALARM_ID_ILL); + TEST_ASSERT(rv==E_OS_ID ); +} + void etask_sup_l_01( void ){ _Bool done = 0; while(!done) { switch( test_nr ) { - case 1: + case 1: + /*@req OSEK_TASK_1 */ ActivateTask(TASK_ID_etask_sup_m); /* Switch to higher prio */ Schedule(); @@ -59,11 +94,13 @@ void etask_sup_l_01( void ){ case 4: // From WaitEvent() in sup_m TEST_OK(); - ++test_nr; + ++test_nr; + ClearEvent(EVENT_1); // trigger sup_m to ready state(since it's waiting for the event) SetEvent(TASK_ID_etask_sup_m,EVENT_1); - // Let SUP_M take the event - Schedule(); + // Let SUP_M take the event +#warning Something is very wrong here... + WaitEvent(EVENT_1); break; case 7: // We get scheduled again from sup_m @@ -74,7 +111,7 @@ void etask_sup_l_01( void ){ case 100: SetEvent(TASK_ID_etask_sup_m,EVENT_1); // Let SUP_M finish... - Schedule(); + // Schedule(); // The test case is done! Kill ourselves TerminateTask(); // done = 1; @@ -115,7 +152,8 @@ void etask_sup_m_01( void ){ // No event waiting so this should trigger sup_l WaitEvent(EVENT_1); break; - case 5: + case 5: + SetEvent(TASK_ID_etask_sup_l,EVENT_1); TEST_OK(); ++test_nr; break; diff --git a/system/kernel/testsystem/test_sup_02.c b/system/kernel/testsystem/test_sup_02.c index 1cd82b89..d84c9d83 100644 --- a/system/kernel/testsystem/test_sup_02.c +++ b/system/kernel/testsystem/test_sup_02.c @@ -12,19 +12,13 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * -------------------------------- Arctic Core ------------------------------*/ - - - - - - - - /* * Tested: alarms and events - * * + * COUNTER_ID_soft_1 drives alarms: + * ALARM_ID_c_soft_1_setevent_etask_m + * ALARM_ID_c_soft_1_inc_counter_2 */ #include "Os.h" @@ -60,15 +54,12 @@ void etask_sup_l_02( void ) { } case 3: // Make cyclic alarm - SetRelAlarm(ALARM_ID_c_soft_1_setevent_etask_m, 2, 5); + SetRelAlarm(ALARM_ID_c_soft_1_setevent_etask_m, 2, 5); + // Let sup_m wait for the event. ActivateTask(TASK_ID_etask_sup_m); - Schedule(); - // Nothing should happen here - IncrementCounter(COUNTER_ID_soft_1); - // Trigger the event... + IncrementCounter(COUNTER_ID_soft_1); // 1 IncrementCounter(COUNTER_ID_soft_1); // 2 - // Should trigger - Schedule(); + // Should trigger trigger after here, since higher prio it should swap break; case 4: IncrementCounter(COUNTER_ID_soft_1); // 3 diff --git a/system/kernel/testsystem/test_sup_04.c b/system/kernel/testsystem/test_sup_04.c index 298d0e34..cb4d64f6 100644 --- a/system/kernel/testsystem/test_sup_04.c +++ b/system/kernel/testsystem/test_sup_04.c @@ -27,7 +27,7 @@ //#include #include #include "os_test.h" -#include "int_ctrl.h" +#include "irq.h" #if 0 void isr_l(void ) { @@ -38,7 +38,7 @@ void isr_l(void ) { case 5: test_nr++; /* Trigger higher prio interrupt */ - IntCtrl_GenerateSoftInt(EXTI1_IRQn); + Irq_GenerateSoftInt(EXTI1_IRQn); TEST_ASSERT(test_nr==8); break; default: @@ -54,7 +54,7 @@ void isr_m(void ) { case 6: test_nr++; /* Trigger higher prio interrupt */ - IntCtrl_GenerateSoftInt(EXTI2_IRQn); + Irq_GenerateSoftInt(EXTI2_IRQn); TEST_ASSERT(test_nr==7); test_nr++; break; diff --git a/system/kernel/testsystem/test_sup_05.c b/system/kernel/testsystem/test_sup_05.c index a8c7e580..67d2d1e6 100644 --- a/system/kernel/testsystem/test_sup_05.c +++ b/system/kernel/testsystem/test_sup_05.c @@ -27,7 +27,7 @@ //#include #include #include "os_test.h" -#include "int_ctrl.h" +#include "irq.h" #if 0 void isr_l(void ) { @@ -38,7 +38,7 @@ void isr_l(void ) { case 5: test_nr++; /* Trigger higher prio interrupt */ - IntCtrl_GenerateSoftInt(EXTI1_IRQn); + Irq_GenerateSoftInt(EXTI1_IRQn); TEST_ASSERT(test_nr==8); break; default: @@ -54,7 +54,7 @@ void isr_m(void ) { case 6: test_nr++; /* Trigger higher prio interrupt */ - IntCtrl_GenerateSoftInt(EXTI2_IRQn); + Irq_GenerateSoftInt(EXTI2_IRQn); TEST_ASSERT(test_nr==7); test_nr++; break; @@ -156,7 +156,7 @@ void etask_sup_m_04( void ) { * Example: Two tasks, main with prio 2 and slave with prio 1,activate 2. */ -void ActivationQuee(void) { +void ActivationQueue(void) { { StatusType rv; /* Queue up */ diff --git a/system/kernel/testsystem/test_sup_irq.c b/system/kernel/testsystem/test_sup_irq.c index 1f387b7f..69026a4a 100644 --- a/system/kernel/testsystem/test_sup_irq.c +++ b/system/kernel/testsystem/test_sup_irq.c @@ -22,7 +22,7 @@ //#include #include #include "os_test.h" -#include "int_ctrl.h" +#include "irq.h" void isr_l(void ) { switch(test_nr) { @@ -32,7 +32,7 @@ void isr_l(void ) { case 5: test_nr++; /* Trigger higher prio interrupt */ - IntCtrl_GenerateSoftInt(EXTI1_IRQn); + Irq_GenerateSoftInt(EXTI1_IRQn); TEST_ASSERT(test_nr==8); break; default: @@ -48,7 +48,7 @@ void isr_m(void ) { case 6: test_nr++; /* Trigger higher prio interrupt */ - IntCtrl_GenerateSoftInt(EXTI2_IRQn); + Irq_GenerateSoftInt(EXTI2_IRQn); TEST_ASSERT(test_nr==7); test_nr++; break; @@ -83,36 +83,36 @@ void etask_sup_l_04( void ) { switch(test_nr){ case 1: // test 01 =============================================== - isr1 = Os_CreateIsr(isr_l,6/*prio*/,"ISR_L"); - IntCtrl_AttachIsr2(isr1,NULL, EXTI0_IRQn); + isr1 = Os_Arc_CreateIsr(isr_l,6/*prio*/,"ISR_L"); + Irq_AttachIsr2(isr1,NULL, EXTI0_IRQn); - isr2 = Os_CreateIsr(isr_m,7/*prio*/,"ISR_M"); - IntCtrl_AttachIsr2(isr2,NULL, EXTI1_IRQn); + isr2 = Os_Arc_CreateIsr(isr_m,7/*prio*/,"ISR_M"); + Irq_AttachIsr2(isr2,NULL, EXTI1_IRQn); - isr3 = Os_CreateIsr(isr_h,8/*prio*/,"ISR_H"); - IntCtrl_AttachIsr2(isr3,NULL, EXTI2_IRQn); + isr3 = Os_Arc_CreateIsr(isr_h,8/*prio*/,"ISR_H"); + Irq_AttachIsr2(isr3,NULL, EXTI2_IRQn); TEST_OK(); test_nr++; break; case 2: // test 02 =============================================== - IntCtrl_GenerateSoftInt(EXTI0_IRQn); + Irq_GenerateSoftInt(EXTI0_IRQn); TEST_ASSERT(test_nr==3); break; case 3: // test 03 =============================================== - IntCtrl_GenerateSoftInt(EXTI1_IRQn); + Irq_GenerateSoftInt(EXTI1_IRQn); TEST_ASSERT(test_nr==4); break; case 4: // test 04 =============================================== - IntCtrl_GenerateSoftInt(EXTI2_IRQn); + Irq_GenerateSoftInt(EXTI2_IRQn); TEST_ASSERT(test_nr==5); break; case 5: // test 05 =============================================== - IntCtrl_GenerateSoftInt(EXTI2_IRQn); + Irq_GenerateSoftInt(EXTI2_IRQn); TEST_ASSERT(test_nr==5); break; case 100: diff --git a/system/kernel/trusted.c b/system/kernel/trusted.c index 856b297d..1a5e752c 100644 --- a/system/kernel/trusted.c +++ b/system/kernel/trusted.c @@ -15,7 +15,7 @@ - +#error Do not use. Its only supported in SC3 and SC4 @@ -26,16 +26,16 @@ #include "ext_config.h" -StatusType CallTrustedFunction( TrustedFunctionIndexType ix, - TrustedFunctionParameterRefType param ) +StatusType CallTrustedFunction( TrustedFunctionIndexType ix, + TrustedFunctionParameterRefType param ) { - /* INFO: Can't find anything in the autosar documentation about calling a + /* INFO: Can't find anything in the autosar documentation about calling a * trusted function directly from a trusted application(not calling - * CallTrustedFunction() at all). So this code checks if in user mode - * or not. - * - * In Linux you either call the function directly e.g "getpid()" when + * CallTrustedFunction() at all). So this code checks if in user mode + * or not. + * + * In Linux you either call the function directly e.g "getpid()" when * in priv. mode and through "syscall(SYS_getpid)" when in user mode. */ @@ -44,8 +44,8 @@ StatusType CallTrustedFunction( TrustedFunctionIndexType ix, if( ix > Oil_GetServiceCnt() ) { return E_OS_SERVICEID; } - + CallService(ix,param); - + return E_OK; } diff --git a/tools/t32/load.cmm b/tools/t32/load.cmm index 9eaaf639..29f6e57f 100644 --- a/tools/t32/load.cmm +++ b/tools/t32/load.cmm @@ -52,8 +52,10 @@ postload_CortexM3: r.s MSP 0x20005000 RETURN -postload_MPC5516: +postload_mpc5516: postload_MPC5554: +postload_MPC5554: +postload_mpc5633M: RETURN //------------------------------------------------------------- @@ -121,5 +123,6 @@ path: + diff --git a/tools/t32/start.cmm b/tools/t32/start.cmm index 83d1dd6b..dd6a3a5c 100644 --- a/tools/t32/start.cmm +++ b/tools/t32/start.cmm @@ -27,8 +27,8 @@ IF "&cfg_project_path_g"=="" &cpu="&cfg_cpu_g" -winpos 0% 70% 50% 30% -area +//winpos 0% 70% 50% 30% +//area sys.down @@ -122,5 +122,6 @@ enddo + -- 2.39.2