1 /* -------------------------------- Arctic Core ------------------------------
\r
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
\r
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
\r
6 * This source code is free software; you can redistribute it and/or modify it
\r
7 * under the terms of the GNU General Public License version 2 as published by the
\r
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
\r
10 * This program is distributed in the hope that it will be useful, but
\r
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
\r
14 * -------------------------------- Arctic Core ------------------------------*/
\r
16 #include "internal.h"
\r
17 #include "context.h"
\r
20 * Function make sure that we switch to supervisor mode(rfi) before
\r
21 * we call a task for the first time.
\r
24 void Os_ArchFirstCall( void )
\r
26 // TODO: make switch here... for now just call func.
\r
28 os_sys.curr_pcb->entry();
\r
31 void *Os_ArchGetStackPtr( void ) {
\r
33 // return (void *)__get_MSP();
\r
36 unsigned int Os_ArchGetScSize( void ) {
\r
37 return CONTEXT_SIZE_W;
\r
41 void Os_ArchSetupContext( OsPcbType *pcb ) {
\r
42 // TODO: Add lots of things here, see ppc55xx
\r
43 // uint16_t *context = (uint16_t *)pcb->stack.curr;
\r
44 // context[C_CONTEXT_OFF/4] = SC_PATTERN;
\r
46 /* Set LR to start function */
\r
47 // if( pcb->proc_type == PROC_EXTENDED ) {
\r
48 // context[VGPR_LR_OFF/4] = (uint16_t)Os_TaskStartExtended;
\r
49 // } else if( pcb->proc_type == PROC_BASIC ) {
\r
50 // context[VGPR_LR_OFF/4] = (uint16_t)Os_TaskStartBasic;
\r
52 // Os_StackSetEndmark(pcb);
\r
53 // Os_ArchSetupContext_asm(pcb->stack.curr,NULL);
\r
61 void Os_ArchSetTaskEntry(OsPcbType *pcbPtr ) {
\r
62 uint8_t *context_bytes = (uint8_t *)pcbPtr->stack.curr;
\r
65 /* Set Return to start function */
\r
67 context_bytes[8] = OS_KERNEL_CODE_PPAGE;
\r
69 if( pcbPtr->proc_type == PROC_EXTENDED ) {
\r
70 temp = (uint16_t)Os_TaskStartExtended;
\r
71 context_bytes[HIGH_BYTE_RETURN_ADRESS] = temp >> 8;
\r
72 context_bytes[LOW_BYTE_RETURN_ADRESS] = temp & 0xFF;
\r
73 } else if( pcbPtr->proc_type == PROC_BASIC ) {
\r
74 temp = (uint16_t)Os_TaskStartBasic;
\r
75 context_bytes[HIGH_BYTE_RETURN_ADRESS] = temp >> 8;
\r
76 context_bytes[LOW_BYTE_RETURN_ADRESS] = temp & 0xFF;
\r
81 void Os_ArchInit( void ) {
\r
82 // nothing to do here, yet :)
\r