]> rtime.felk.cvut.cz Git - arc.git/blob - include/hc1x/Cpu.h
Updated examples for HCS12
[arc.git] / include / hc1x / Cpu.h
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 #ifndef CPU_H_\r
17 #define CPU_H_\r
18 \r
19 #include "Std_Types.h"\r
20 typedef uint32_t imask_t;\r
21 \r
22 #define Irq_Disable()           asm volatile (" sei");\r
23 #define Irq_Enable()            asm volatile (" cli");\r
24 \r
25 #define Irq_SuspendAll()        Irq_Disable()\r
26 #define Irq_ResumeAll()         Irq_Enable()\r
27 \r
28 #define Irq_SuspendOs()         Irq_Disable()\r
29 #define Irq_ResumeOs()          Irq_Enable()\r
30 \r
31 #define Irq_Save(flags)    flags = _Irq_Disable_save()\r
32 #define Irq_Restore(flags) _Irq_Disable_restore(flags)\r
33 \r
34 /*-----------------------------------------------------------------*/\r
35 \r
36 static inline unsigned long _Irq_Disable_save(void)\r
37 {\r
38    unsigned long result;\r
39    asm volatile ("tfr CCR, %0" : "=r" (result) : );\r
40    Irq_Disable();\r
41    return result;\r
42 }\r
43 \r
44 /*-----------------------------------------------------------------*/\r
45 \r
46 static inline void _Irq_Disable_restore(unsigned long flags)\r
47 {\r
48    asm volatile ("tfr %0, CCR" : : "r" (flags) );\r
49 }\r
50 \r
51 #define ilog2(x) __builtin_ffs(x)\r
52 #endif /* CPU_H_ */\r