]> rtime.felk.cvut.cz Git - arc.git/blob - arch/arm/arm_cm3/kernel/arch.c
c7d465c3986a758e3ff5652067eab122df1e2c08
[arc.git] / arch / arm / arm_cm3 / kernel / arch.c
1 /* -------------------------------- Arctic Core ------------------------------
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com
3  *
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
5  *
6  * This source code is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 as published by the
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * for more details.
14  * -------------------------------- Arctic Core ------------------------------*/
15
16
17
18
19
20
21
22
23 \r
24 //#include "arch_offset.h"\r
25 #include "pcb.h"\r
26 #include "sys.h"\r
27 #include <stdlib.h>\r
28 #include "task_i.h"\r
29 #include "stack.h"\r
30 #include "arch_offset.h"\r
31 #include "stm32f10x.h"\r
32 #include "core_cm3.h"\r
33 \r
34 /**\r
35  * Function make sure that we switch to supervisor mode(rfi) before\r
36  * we call a task for the first time.\r
37  */\r
38 \r
39 void os_arch_first_call( void )\r
40 {\r
41         // TODO: make switch here... for now just call func.\r
42         os_sys.curr_pcb->entry();\r
43 }\r
44 \r
45 void *os_arch_get_stackptr( void ) {\r
46 \r
47         return __get_MSP();\r
48 }\r
49 \r
50 unsigned int os_arch_get_sc_size( void ) {\r
51         return SC_SIZE;\r
52 }\r
53
54 \r
55 void os_arch_setup_context( pcb_t *pcb ) {\r
56         // TODO: Add lots of things here, see ppc55xx\r
57         uint32_t *context = (uint32_t *)pcb->stack.curr;\r
58         context[C_CONTEXT_OFFS/4] = SC_PATTERN;\r
59 \r
60         /* Set LR to start function */\r
61         if( pcb->proc_type == PROC_EXTENDED ) {\r
62                 context[VGPR_LR_OFF/4] = (uint32_t)os_proc_start_extended;\r
63         } else if( pcb->proc_type == PROC_BASIC ) {\r
64                 context[VGPR_LR_OFF/4] = (uint32_t)os_proc_start_basic;\r
65         }\r
66 // os_arch_setup_context_asm(pcb->stack.curr,NULL);\r
67 }\r
68 \r
69 void os_arch_init( void ) {\r
70         // nothing to do here, yet :)\r
71 }\r