\r
#if defined(USE_DEBUG)\r
{\r
- uint32 extal = Mcu_Global.config->McuClockSettingConfig[Mcu_Global.clockSetting].McuClockReferencePoint;\r
+ uint32 extal = Mcu_Global.config->McuClockSettingConfig[Mcu_Global.clockSetting].McuClockReferencePointFrequency;\r
uint32 f_sys;\r
\r
f_sys = CALC_SYSTEM_CLOCK( extal,\r
// TODO: This of course wrong....\r
uint32_t f_sys = 72000000UL;\r
#if 0\r
- uint32 extal = Mcu_Global.config->McuClockSettingConfig[Mcu_Global.clockSetting].McuClockReferencePoint;\r
+ uint32 extal = Mcu_Global.config->McuClockSettingConfig[Mcu_Global.clockSetting].McuClockReferencePointFrequency;\r
\r
f_sys = CALC_SYSTEM_CLOCK(extal,emfd,eprediv,erfd);\r
#endif\r
* we call a task for the first time.\r
*/\r
\r
-void os_arch_first_call( void )\r
+void Os_ArchFirstCall( void )\r
{\r
// TODO: make switch here... for now just call func.
Irq_Enable();\r
}\r
\r
-void os_arch_setup_context( OsPcbType *pcb ) {\r
+void Os_ArchSetupContext( OsPcbType *pcb ) {\r
// TODO: Add lots of things here, see ppc55xx\r
uint32_t *context = (uint32_t *)pcb->stack.curr;\r
context[C_CONTEXT_OFFS/4] = SC_PATTERN;\r
context[VGPR_LR_OFF/4] = (uint32_t)Os_TaskStartBasic;\r
}
os_arch_stack_set_endmark(pcb);\r
-// os_arch_setup_context_asm(pcb->stack.curr,NULL);\r
+// Os_ArchSetupContext_asm(pcb->stack.curr,NULL);\r
}\r
\r
-void os_arch_init( void ) {\r
+void Os_ArchInit( void ) {\r
// nothing to do here, yet :)\r
}\r
-/* -------------------------------- Arctic Core ------------------------------
- * Arctic Core - the open source AUTOSAR platform http://arccore.com
- *
- * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
- *
- * 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 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
- *
- * 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 "internal.h"
-#include "context.h"
+/* -------------------------------- Arctic Core ------------------------------\r
+ * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
+ *\r
+ * Copyright (C) 2009 ArcCore AB <contact@arccore.com>\r
+ *\r
+ * This source code is free software; you can redistribute it and/or modify it\r
+ * under the terms of the GNU General Public License version 2 as published by the\r
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
+ *\r
+ * This program is distributed in the hope that it will be useful, but\r
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\r
+ * for more details.\r
+ * -------------------------------- Arctic Core ------------------------------*/\r
+\r
+#include "internal.h"\r
+#include "context.h"\r
\r
/**\r
* Function make sure that we switch to supervisor mode(rfi) before\r
* we call a task for the first time.\r
*/\r
\r
-void os_arch_first_call( void )\r
+void Os_ArchFirstCall( void )\r
{\r
- // TODO: make switch here... for now just call func.
+ // TODO: make switch here... for now just call func.\r
Irq_Enable();\r
os_sys.curr_pcb->entry();\r
}\r
unsigned int Os_ArchGetScSize( void ) {\r
return SC_SIZE;\r
}\r
-
\r
-void os_arch_setup_context( OsPcbType *pcb ) {\r
+\r
+void Os_ArchSetupContext( OsPcbType *pcb ) {\r
// TODO: Add lots of things here, see ppc55xx\r
uint32_t *context = (uint32_t *)pcb->stack.curr;\r
context[C_CONTEXT_OFF/4] = SC_PATTERN;\r
context[VGPR_LR_OFF/4] = (uint32_t)Os_TaskStartExtended;\r
} else if( pcb->proc_type == PROC_BASIC ) {\r
context[VGPR_LR_OFF/4] = (uint32_t)Os_TaskStartBasic;\r
- }
+ }\r
Os_StackSetEndmark(pcb);\r
-// os_arch_setup_context_asm(pcb->stack.curr,NULL);\r
+// Os_ArchSetupContext_asm(pcb->stack.curr,NULL);\r
+}\r
+\r
+/**\r
+ *\r
+ * @param pcbPtr\r
+ */\r
+\r
+void OsArch_SetTaskEntry(OsPcbType *pcbPtr ) {\r
+ uint32_t *context = (uint32_t *)pcbPtr->stack.curr;\r
+\r
+ context[C_CONTEXT_OFF/4] = SC_PATTERN;\r
+\r
+ /* Set LR to start function */\r
+ if( pcbPtr->proc_type == PROC_EXTENDED ) {\r
+ context[C_LR_OFF/4] = (uint32_t)Os_TaskStartExtended;\r
+ } else if( pcbPtr->proc_type == PROC_BASIC ) {\r
+ context[C_LR_OFF/4] = (uint32_t)Os_TaskStartBasic;\r
+ }\r
}\r
-
-/**
- *
- * @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;
- }
-}
-
\r
-void os_arch_init( void ) {\r
+\r
+void Os_ArchInit( void ) {\r
// nothing to do here, yet :)\r
}\r
\r
#if defined(USE_DEBUG)\r
{\r
- uint32 extal = Mcu_Global.config->McuClockSettingConfig[Mcu_Global.clockSetting].McuClockReferencePoint;\r
+ uint32 extal = Mcu_Global.config->McuClockSettingConfig[Mcu_Global.clockSetting].McuClockReferencePointFrequency;\r
uint32 f_sys;\r
\r
f_sys = CALC_SYSTEM_CLOCK( extal,\r
* Function make sure that we switch to supervisor mode(rfi) before\r
* we call a task for the first time.\r
*/\r
-void os_arch_first_call( void )\r
+void Os_ArchFirstCall( void )\r
{\r
#if USE_MM_USER_MODE\r
\r
*\r
*/\r
\r
-void os_arch_setup_context( OsPcbType *pcb ) {\r
+void Os_ArchSetupContext( OsPcbType *pcb ) {\r
uint32_t msr;\r
- // Note! stack.curr already points to where to save the context\r
-\r
- // Check that the stack size is enough\r
- #define STACK_SIZE_MIN (SC_SIZE + 16*2 )
-
-#if 0\r
- if( pcb->stack.size < (STACK_SIZE_MIN) ) {\r
- os_arch_stack_to_small(pcb, STACK_SIZE_MIN);\r
- }\r
-#endif
-
\r
msr = MSR_EE;\r
\r
}\r
\r
\r
-void os_arch_init( void ) {\r
+void Os_ArchInit( void ) {\r
#if defined(CFG_SPE)\r
uint32_t msr = get_msr();\r
msr |= MSR_SPE;\r
.global Os_ArchSwapContextToW\r
.global Os_ArchSwapContextTo\r
.global Os_ArchSwapContext\r
+.global Os_ArchSetSpAndCall\r
.section .text\r
\r
+Os_ArchSetSpAndCall:\r
+ mr r1,r3\r
+ mtlr r4\r
+ blr\r
+\r
Os_ArchSwapContextToW:\r
mr r1,r5\r
b Os_ArchSwapContextTo\r
\r
.text :\r
{\r
- *(.text .text.* .init .fini* .eini* .gnu.linkonce* .gnu.warning)\r
+ *(.text .text.* .init .fini* .eini* .gnu.linkonce* .gnu.warning);\r
+ PROVIDE( btask_sup_matrix = .);\r
+ SORT(*)(.test_btask);\r
+ PROVIDE( etask_sup_matrix = .);\r
+ SORT(*)(.test_etask);\r
} > flash\r
\r
.fls_rom : {\r
Mcu_ClockSettingConfigType Mcu_ClockSettingConfigData[] =\r
{\r
{\r
- .McuClockReferencePoint = 8000000UL,\r
+ .McuClockReferencePointFrequency = 8000000UL,\r
.Pll1 = 1,\r
.Pll2 = 104,\r
.Pll3 = 5,\r
},\r
{\r
- .McuClockReferencePoint = 16000000UL,\r
+ .McuClockReferencePointFrequency = 16000000UL,\r
.Pll1 = 3,\r
.Pll2 = 83,\r
.Pll3 = 5,\r
Mcu_ClockSettingConfigType Mcu_ClockSettingConfigData[] =\r
{\r
{\r
- .McuClockReferencePoint = 8000000UL,\r
+ .McuClockReferencePointFrequency = 8000000UL,\r
.Pll1 = 1,\r
.Pll2 = 104,\r
.Pll3 = 5,\r
},\r
{\r
- .McuClockReferencePoint = 16000000UL,\r
+ .McuClockReferencePointFrequency = 16000000UL,\r
.Pll1 = 3,\r
.Pll2 = 83,\r
.Pll3 = 5,\r
Mcu_ClockSettingConfigType Mcu_ClockSettingConfigData[] =\r
{\r
{\r
- .McuClockReferencePoint = 8000000UL,\r
+ .McuClockReferencePointFrequency = 8000000UL,\r
.Pll1 = 1,\r
.Pll2 = 104,\r
.Pll3 = 5,\r
},\r
{\r
- .McuClockReferencePoint = 16000000UL,\r
+ .McuClockReferencePointFrequency = 16000000UL,\r
.Pll1 = 3,\r
.Pll2 = 83,\r
.Pll3 = 5,\r
Mcu_ClockSettingConfigType Mcu_ClockSettingConfigData[] =\r
{\r
{\r
- .McuClockReferencePoint = 16000000UL,\r
+ .McuClockReferencePointFrequency = 16000000UL,\r
.Pll1 = 2,\r
.Pll2 = 11,\r
.Pll3 = 0,\r
Mcu_ClockSettingConfigType Mcu_ClockSettingConfigData[] =\r
{\r
{\r
- .McuClockReferencePoint = 8000000UL,\r
+ .McuClockReferencePointFrequency = 8000000UL,\r
.Pll1 = 1,\r
.Pll2 = 104,\r
.Pll3 = 5,\r
},\r
{\r
- .McuClockReferencePoint = 40000000UL,\r
+ .McuClockReferencePointFrequency = 40000000UL,\r
.Pll1 = 3,\r
.Pll2 = 83,\r
.Pll3 = 5,\r
#ifndef MCU_H_\r
#define MCU_H_\r
-
-#define MCU_SW_MAJOR_VERSION 2
-#define MCU_SW_MINOR_VERSION 0
-#define MCU_SW_PATCH_VERSION 0
\r
#include "Cpu.h"\r
#include "irq_types.h"
void Mcu_SetMode( const Mcu_ModeType McuMode );\r
\r
#if ( MCU_VERSION_INFO_API == STD_ON )\r
-#define MCU_SW_MAJOR_VERSION 1\r
-#define MCU_SW_MINOR_VERSION 0\r
+#define MCU_SW_MAJOR_VERSION 2\r
+#define MCU_SW_MINOR_VERSION 0\r
#define MCU_SW_PATCH_VERSION 0\r
#define MCU_AR_MAJOR_VERSION 2\r
#define MCU_AR_MINOR_VERSION 2\r
#define STACK_PATTERN 0x42
-
+#if 0
/**
* Swap context with a context. The difference between this
* function and Os_ArchSwapContext is that the later use
* @param context Ptr to context
* @return
*/
+
void Os_ArchSwapContextToW(void *old,void *new, void *context );
+#endif
+
+
+/**
+ * Set the stack pointer to sp and call function f.
+ *
+ * @param sp Pointer to the stack
+ * @param f Pointer to the function to call.
+ *
+ */
+void Os_ArchSetSpAndCall(void *sp, void (*f)(void) );
\r
/**\r
* Swap context.\r
*\r
* @param pcb Ptr to pcb
*/\r
-void os_arch_setup_context( OsPcbType *pcb );\r
+void Os_ArchSetupContext( OsPcbType *pcb );\r
\r
/**\r
* Get current stack pointer\r
* - interrupt controller\r
* - timers\r
*/\r
-void os_arch_init( void );\r
+void Os_ArchInit( void );\r
\r
/**\r
* Function that is used when task entry is called for the\r
* When user mode is supported a switch to user mode must be done\r
* in some way. A trap maybe?\r
*/\r
-void os_arch_first_call( void );\r
+void Os_ArchFirstCall( void );\r
\r
\r
/**\r
/* Clear sys */
memset(&os_sys,0,sizeof(sys_t));
- os_arch_init();
+ Os_ArchInit();
// Assign pcb list and init ready queue
os_sys.pcb_list = pcb_list;
Os_ResourceGetInternal();
Os_TaskMakeRunning(pcb);
- os_arch_first_call();
+ Os_ArchFirstCall();
/** @req OS070 */
Os_ResourceCheckAndRelease(pcb);
Os_IrqClearAll();
}
+#warning Dont I have to check this at terminate task also?
+
/** @req OS069 */
ERRORHOOK(E_OS_MISSINGEND);
pcb = Os_TaskGetCurrent();
Os_ResourceGetInternal();
Os_TaskMakeRunning(pcb);
- os_arch_first_call();
+ Os_ArchFirstCall();
/** @req OS070 */
Os_ResourceCheckAndRelease(pcb);
Os_StackFill(pcb);
OsArch_SetTaskEntry(pcb);
- os_arch_setup_context(pcb);
+ Os_ArchSetupContext(pcb);
}
/**
*/
void Os_ContextReInit( OsPcbType *pcbPtr ) {
Os_StackSetup(pcbPtr);
- OsArch_SetTaskEntry(pcbPtr);
- // TODO: This really need to be done
- os_arch_setup_context(pcbPtr);
}
/**
pcbPtr = Os_TaskGetTop();
currPcbPtr = Os_TaskGetCurrent();
/* Swap if we found any process or are forced (multiple activations)*/
- if( pcbPtr != currPcbPtr || force ) {
+ if( pcbPtr != currPcbPtr ) {
/* Add us to the ready list */
if( currPcbPtr->state & ST_RUNNING ) {
Os_TaskRunningToReady(currPcbPtr);
* 3. Normal swap -> Os_ArchSwapContext()
*/
+#if 0
/* Force is ONLY used from TerminateTask() */
if( force ) {
- Os_ArchSwapContextToW(currPcbPtr ,pcbPtr, pcbPtr->stack.curr );
+ Os_StackSetup(pcbPtr);
+ OsArch_SetTaskEntry(pcbPtr);
+ // TODO: This really need to be done
+ Os_ArchSetupContext(pcbPtr);
+ // Os_ArchSetSpAndCall(pcbPtr->stack.curr,Os_TaskStartBasic);
}
+#endif
Os_ArchSwapContext(currPcbPtr,pcbPtr);
PRETASKHOOK();
} else {
+ Os_StackSetup(pcbPtr);
+ Os_ArchSetSpAndCall(pcbPtr->stack.curr,Os_TaskStartBasic);
+#if 0
/* 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);
+#endif
}
}
* state into ready state all its events are cleared.*/
pcb->ev_set = 0;
pcb->ev_wait = 0;
+ } else {
+ Os_StackSetup(pcb);
+ OsArch_SetTaskEntry(pcb);
+ Os_ArchSetupContext(pcb);
}
Os_TaskMakeReady(pcb);
} else {
/* Preempt only if higher prio than us */\r
if( (pcb->scheduling == FULL) &&
- (os_sys.int_nest_cnt == 0) )
+ (os_sys.int_nest_cnt == 0) && (pcb->prio > Os_TaskGetCurrent()->prio) )
{\r
Os_Dispatch(0);\r
}\r
Irq_Save(flags);
--curr_pcb->activations;
- assert(curr_pcb->activations>=0);
+// assert(curr_pcb->activations>=0);
/*@req OSEK TerminateTask
* In case of tasks with multiple activation requests,
} 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);
+
+// Os_ContextReInit(curr_pcb);
/* Force the dispatcher to find something, even if its us */
Os_Dispatch(1);
}\r
}\r
\r
+__attribute__ ((section (".test_btask"))) const test_func_t btask_sup_matrix_01[3] = { btask_sup_l_01, btask_sup_m_01, btask_sup_h_01 };\r
+__attribute__ ((section (".test_etask"))) const test_func_t etask_sup_matrix_01[3] = { etask_sup_l_01, NULL, NULL };\r
+\r
while(1);\r
\r
}\r
-\r
+
+#if 0\r
test_func_t etask_sup_matrix[][3] = {\r
/* 01*/ { etask_sup_l_01, NULL, NULL },
#if 0\r
\r
#define TEST_BASIC(nr) \\r
{ btest_sup_l_##nr , btest_sup_m_##nr , btest_sup_h_## nr }\r
+
\r
test_func_t btask_sup_matrix[][3] = {\r
-/* 01*/ { NULL, NULL, NULL},
+// /* 01*/ { NULL, NULL, NULL},
+ TEST_BASIC(01),
#if 0\r
TEST_BASIC(02),\r
\r
#endif\r
}; // __attribute__ ((section(".data_app_2")));\r
-\r
+
+#else
+extern test_func_t etask_sup_matrix[][3];
+extern test_func_t btask_sup_matrix[][3];\r
+#endif
\r
//--------------------------------------------------------------------\r
//--------------------------------------------------------------------\r