]> rtime.felk.cvut.cz Git - arc.git/blob - system/kernel/include/arch.h
Again, loads of refactoring and removing and adding files.
[arc.git] / system / kernel / include / arch.h
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 /*\r
17  * Porting interface. Should really be called port.h or something.\r
18 \r
19  * The routines below + interrupt handing in Mcu_IntXX.c, should\r
20  * be all that needs to be implemented for a new port.
21  */\r
22 \r
23 #ifndef ARCH_H_\r
24 #define ARCH_H_\r
25
26 #define STACK_PATTERN   0x42
27
28
29
30 /**
31  * Swap context with a context. The difference between this
32  * function and Os_ArchSwapContext is that the later use
33  * the current stack. This one uses stack from context.
34  *
35  * @param old     always NULL
36  * @param new     Ptr to pcb.
37  * @param context Ptr to context
38  * @return
39  */
40 void Os_ArchSwapContextToW(void *old,void *new, void *context );
41 \r
42 /**\r
43  * Swap context.\r
44  * Sets the current pcb\r
45  *\r
46  * @param old - old ptr to pcb\r
47  * @return
48  */\r
49 void Os_ArchSwapContext(void *old,void *new);\r
50 \r
51 /**\r
52  * Swap context for the first time for a task\r
53  *\r
54  * The only way to call this function right now is to:\r
55  *   Os_TaskSwapContextTo(NULL,<pcb>);\r
56  */\r
57 void Os_ArchSwapContextTo(void *old,void *new);\r
58 \r
59 /**\r
60  * Setup a pcb before use.\r
61  *\r
62  * This function should setup:\r
63  * - context marker( SC_PATTERN, LC_PATTERN )\r
64  * - Arch specific register setup\r
65  * - Check that the stack is suffient for the arch\r
66  * - More...\r
67  *\r
68  * @param pcb Ptr to pcb
69  */\r
70 void os_arch_setup_context( OsPcbType *pcb );\r
71 \r
72 /**\r
73  * Get current stack pointer\r
74  *\r
75  * @return current stack pointer
76  */\r
77 void *Os_ArchGetStackPtr( void );\r
78 \r
79 /**\r
80  * Initialize the hardware.\r
81  * This could be initialization of:\r
82  * - interrupt controller\r
83  * - timers\r
84  */\r
85 void os_arch_init( void );\r
86 \r
87 /**\r
88  * Function that is used when task entry is called for the\r
89  * first time. For ports that don't support user mode it\r
90  * should just call entry entry() function of the current task.\r
91  *\r
92  * When user mode is supported a switch to user mode must be done\r
93  * in some way. A trap maybe?\r
94  */\r
95 void os_arch_first_call( void );\r
96 \r
97 \r
98 /**\r
99  * Get the small context size\r
100  *\r
101  * @return The small context size in bytes
102  */\r
103 unsigned int Os_ArchGetScSize( void );\r
104
105 void OsArch_SetTaskEntry(OsPcbType *pcbPtr );
106
107 #if 0\r
108 \r
109 void *os_arch_get_stack_usage( OsPcbType * );\r
110 \r
111 _Bool os_arch_stack_endmark_ok( OsPcbType *);
112 #endif
113
114 \r
115 \r
116 #endif /*ARCH_H_*/\r