]> rtime.felk.cvut.cz Git - arc.git/blob - arch/hc1x/hcs12d/kernel/arch.c
0252a9e8a228b52e6800554800193ce733ad6c4d
[arc.git] / arch / hc1x / hcs12d / kernel / arch.c
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\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
9  *\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
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 #include "internal.h"\r
17 #include "context.h"\r
18 \r
19 /**\r
20  * Function make sure that we switch to supervisor mode(rfi) before\r
21  * we call a task for the first time.\r
22  */\r
23 \r
24 void Os_ArchFirstCall( void )\r
25 {\r
26         // TODO: make switch here... for now just call func.\r
27         Irq_Enable();\r
28         os_sys.curr_pcb->entry();\r
29 }\r
30 \r
31 void *Os_ArchGetStackPtr( void ) {\r
32 \r
33 //      return (void *)__get_MSP();\r
34 }\r
35 \r
36 unsigned int Os_ArchGetScSize( void ) {\r
37         return CONTEXT_SIZE_W;\r
38 }\r
39 \r
40 \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
45 \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
51 //      }\r
52 //      Os_StackSetEndmark(pcb);\r
53 // Os_ArchSetupContext_asm(pcb->stack.curr,NULL);\r
54 }\r
55 \r
56 /**\r
57  *\r
58  * @param pcbPtr\r
59  */\r
60 \r
61 void Os_ArchSetTaskEntry(OsPcbType *pcbPtr ) {\r
62         uint8_t *context_bytes = (uint8_t *)pcbPtr->stack.curr;\r
63         uint16_t temp;\r
64 \r
65         /* Set Return to start function */\r
66 \r
67         context_bytes[8] = OS_KERNEL_CODE_PPAGE;\r
68 \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
77         }\r
78 }\r
79 \r
80 \r
81 void Os_ArchInit( void ) {\r
82         // nothing to do here, yet :)\r
83 }\r