]> rtime.felk.cvut.cz Git - arc.git/blob - include/irq.h
EcuM: More SchM,Gpt stuff
[arc.git] / include / irq.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 \r
17 #ifndef IRQ_H_\r
18 #define IRQ_H_\r
19 \r
20 #include <stdint.h>\r
21 #include "Os.h"\r
22 #include "irq_types.h"\r
23 #include "bit.h"\r
24 \r
25 typedef void ( * func_t)(void);\r
26 \r
27 \r
28 \r
29 #if (OS_SC2==STD_ON) || (OS_SC4==STD_ON)\r
30 #define HAVE_SC2_SC4(_value) _value\r
31 #else\r
32 #define HAVE_SC2_SC4(_value)\r
33 #endif\r
34 \r
35 #define IRQ_NAME(_vector)               IrqVector_ ## _vector\r
36 \r
37 #define IRQ_DECL_ISR2_TIMING_PROT(      \\r
38                                 _name, \\r
39                                 _max_all_interrupt_lock_time, \\r
40                                 _exeution_budget, \\r
41                                 _os_interrupt_lock_budget, \\r
42                                 _time_frame, \\r
43                                 _resource_lock_list )\r
44 \r
45 \r
46 #define IRQ_DECL_ISR1(_name, _vector, _core, _prio, _entry  ) \\r
47                 const OsIsrConstType Irq_VectorConst_ ## _vector = {    \\r
48                 .name = _name,                                          \\r
49                 .vector = (_vector),                            \\r
50                 .core = (_core),                                        \\r
51                 .prio = (_prio),                                        \\r
52                 .entry = (_entry),                                      \\r
53                 .type = ISR_TYPE_1,                                     \\r
54         }\r
55 \r
56 \r
57 #define IRQ_DECL_ISR2(_name,_vector, _core, _prio, _entry, _resource_mask, _timing_prot) \\r
58                 const OsIsrConstType Irq_VectorConst_ ## _vector = {    \\r
59                 .name = _name,                                          \\r
60                 .vector = (_vector),                            \\r
61                 .core = (_core),                                        \\r
62                 .prio = (_prio),                                        \\r
63                 .entry = (_entry),                                      \\r
64                 .type = ISR_TYPE_2,                                     \\r
65                 .resourceMask = (_resource_mask),       \\r
66                 .timingProtPtr = (_timing_prot)     \\r
67         }\r
68 \r
69 \r
70 #define IRQ_ATTACH(_vector)     Irq_Attach(&Irq_VectorConst_ ## _vector)\r
71 \r
72 /* Example:\r
73  * IRQ_DECL_ISR2_RESOURCE(res2, RES_ID_2, 500000U );                    // Max 50us\r
74  * IRQ_DECL_ISR2_TIMING_PROT(timing,0,0,0,0,res2);\r
75  * IRQ_DECL_ISR2("MyIsr",10,10,MyIsr,HAVE_SC2_SC4(RES_ID_1),HAVE_SC2_SC4(timing));\r
76  *\r
77  */\r
78 \r
79 // typedef _Bool IsrType;\r
80 \r
81 /**\r
82  * Init the interrupt controller\r
83  */\r
84 void Irq_Init( void );\r
85 \r
86 \r
87 #if defined(CFG_HC1X)\r
88 /**\r
89  *\r
90  * @param stack Ptr to the current stack.\r
91  * @param irq_nr The nr. of the interrupt being handled.\r
92  *\r
93  * The stack holds C, NVGPR, VGPR and the EXC frame.\r
94  *\r
95  */\r
96 void *Irq_Entry( uint8_t irq_nr, void *stack );\r
97 \r
98 #else\r
99 /**\r
100  *\r
101  * @param stack_p Ptr to the current stack.\r
102  *\r
103  * The stack holds C, NVGPR, VGPR and the EXC frame.\r
104  *\r
105  */\r
106 void *Irq_Entry( void *stack_p );\r
107 #endif\r
108 \r
109 struct OsIsrConst;\r
110 /**\r
111  * Generates a soft interrupt\r
112  * @param vector\r
113  */\r
114 void Irq_GenerateSoftInt( IrqType vector );\r
115 /**\r
116  * Get the current priority from the interrupt controller.\r
117  * @param cpu\r
118  * @return\r
119  */\r
120 uint8_t Irq_GetCurrentPriority( Cpu_t cpu);\r
121 \r
122 /**\r
123  * Set the priority in the interrupt controller for vector\r
124  */\r
125 void Irq_SetPriority( Cpu_t cpu,  IrqType vector, uint8_t prio );\r
126 \r
127 void Irq_EnableVector( int16_t vector, int priority, int core );\r
128 \r
129 #ifndef Irq_EOI\r
130 void Irq_EOI( void );\r
131 #endif\r
132 \r
133 #endif /* IRQ_H_ */\r