]> rtime.felk.cvut.cz Git - arc.git/blob - system/kernel/asm_offset.c
Cleanup of makefiles. Cleanup of merge.
[arc.git] / system / kernel / asm_offset.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 /* 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"\r
26 \r
27 #if defined(__GNUC__)\r
28 #define DECLARE(sym,val) \\r
29         __asm("#define\t" #sym "\t%0" : : "n" ((val)))\r
30 \r
31 void  asm_foo(void) {\r
32 #elif defined(__CWCC__)\r
33 #define DECLARE(_var,_offset) \\r
34     __declspec(section ".apa") char _var[100+ (_offset)]\r
35 #pragma section ".apa" ".apa"\r
36 #endif\r
37 DECLARE(PCB_STACK_CURR_P,       offsetof(OsTaskVarType, stack));\r
38         DECLARE(PCB_CONST_P,            offsetof(OsTaskVarType, constPtr));\r
39 //      DECLARE(PCB_ENTRY_P,            offsetof(OsTaskVarType, entry));\r
40         DECLARE(SYS_CURR_PCB_P,         offsetof(Os_SysType, currTaskPtr));\r
41         DECLARE(SYS_INT_NEST_CNT, offsetof(Os_SysType, intNestCnt));\r
42         DECLARE(SYS_INT_STACK, offsetof(Os_SysType, intStack));\r
43 #if defined(__GNUC__)\r
44 }\r
45 #endif\r
46 \r