]> rtime.felk.cvut.cz Git - arc.git/blob - system/kernel/asm_offset.c
Again, loads of refactoring and removing and adding files.
[arc.git] / system / kernel / asm_offset.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 \r
16 /* A steal in an idea from\r
17  * http://blogs.sun.com/nickstephen/entry/some_assembly_required_-_down\r
18  * According to blog original BSD license..\r
19  *\r
20  * Generate assembler from this file( -S option for GNU ).\r
21  * extract the "#defines" with some tool e.g. "sed -n '/#define/p' <asm_file>"\r
22  */\r
23 \r
24 #include <stddef.h>\r
25 #include "internal.h"
26 \r
27 #define DECLARE(sym,val) \\r
28         __asm("#define\t" #sym "\t%0" : : "n" ((val)))\r
29 \r
30 void  asm_foo(void) {\r
31         DECLARE(PCB_STACK_CURR_P,       offsetof(OsPcbType, stack));\r
32         DECLARE(PCB_ENTRY_P,            offsetof(OsPcbType, entry));\r
33         DECLARE(SYS_CURR_PCB_P,         offsetof(sys_t, curr_pcb));\r
34         DECLARE(SYS_INT_NEST_CNT, offsetof(sys_t, int_nest_cnt));\r
35         DECLARE(SYS_INT_STACK, offsetof(sys_t, int_stack));\r
36 }\r
37 \r
38 \r
39 \r