]> rtime.felk.cvut.cz Git - arc.git/blob - include/isr.h
Updated installation of ISRs in mpc55xx drivers
[arc.git] / include / isr.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 ISR_H_\r
17 #define ISR_H_\r
18 \r
19 /*\r
20  * INCLUDE "RULES"\r
21  *  Since this types and methods defined here are used by the drivers, they should\r
22  *  include it. E.g. #include "isr.h"\r
23  *\r
24  *  This file is also used internally by the kernel\r
25  *\r
26  *\r
27  *  irq_types.h ( Vector enums )\r
28  *  irq.h       ( Interface )\r
29  *\r
30  *  Problem:\r
31  *    Os_Cfg.h needs types from isr.h\r
32  *\r
33  */\r
34 \r
35 /* ----------------------------[includes]------------------------------------*/\r
36 /* ----------------------------[define]--------------------------------------*/\r
37 \r
38 #define ISR_TYPE_1                      0\r
39 #define ISR_TYPE_2                      1\r
40 \r
41 /* ----------------------------[macro]---------------------------------------*/\r
42 #define ISR_DECLARE_ISR2( _name, _entry, _unique, _vector, _priority, _app )        \\r
43           const OsIsrConstType _entry ## _unique = { \\r
44                         .vector =          _vector,       \\r
45                         .type =             ISR_TYPE_2,   \\r
46                         .priority =        _priority,     \\r
47                         .entry =           _entry,        \\r
48                         .name =            _name,         \\r
49                         .resourceMask =     0,            \\r
50                         .timingProtPtr =    NULL,         \\r
51                         .appOwner =        _app,          \\r
52                   }\r
53 \r
54 #define _ISR_INSTALL_ISR2( _name, _entry, _unique, _vector, _priority, _app )        \\r
55         do {                                         \\r
56           const OsIsrConstType _entry ## _unique = { \\r
57                         .vector =          _vector,       \\r
58                         .type =             ISR_TYPE_2,   \\r
59                         .priority =        _priority,     \\r
60                         .entry =           _entry,        \\r
61                         .name =            _name,         \\r
62                         .resourceMask =     0,            \\r
63                         .timingProtPtr =    NULL,         \\r
64                         .appOwner =        _app,          \\r
65                   };                                  \\r
66           Os_IsrAdd( & _entry ## _unique);        \\r
67         } while(0)\r
68 \r
69 #define ISR_INSTALL_ISR2( _name, _entry, _vector, _priority, _app )        \\r
70                 _ISR_INSTALL_ISR2( _name, _entry, __LINE__, _vector, _priority, _app )\r
71 \r
72 \r
73 /* ----------------------------[typedef]-------------------------------------*/\r
74 \r
75 \r
76 \r
77 /* STD container : OsIsrResourceLock\r
78  * Class: 2 and 4\r
79  *\r
80  * OsIsrResourceLockBudget      1    Float in seconds (MAXRESOURCELOCKINGTIME)\r
81  * OsIsrResourceLockResourceRef 1    Ref to OsResource\r
82  * */\r
83 \r
84 typedef struct OsIsrResourceLock {\r
85         uint32_t lockBudget;\r
86         uint32_t lockResourceRef;       /* Wrong type */\r
87 } OsIsrResourceLockType;\r
88 \r
89 \r
90 /* STD container : OsIsrTimingProtection\r
91  * Class: 2 and 4\r
92  *\r
93  * OsIsrAllInterruptLockBudget  0..1 float\r
94  * OsIsrExecutionBudget                 0..1 float\r
95  * OsIsrOsInterruptLockBudget   0..1 float\r
96  * OsIsrTimeFrame                               0..1 float\r
97  * OsIsrResourceLock[C]                 0..*\r
98  * */\r
99 \r
100 typedef struct OsIsrTimingProtection {\r
101         uint32_t allInterruptLockBudget;\r
102         uint32_t executionBudget;\r
103         uint32_t osInterruptLockBudget;\r
104         uint32_t timeFrame;\r
105         uint32_t resourceLock;          /* Wrong type */\r
106 } OsIsrTimingProtectionType;\r
107 \r
108 typedef struct {\r
109         void            *curr;  /* Current stack ptr( at swap time ) */\r
110         void            *top;   /* Top of the stack( low address )   */\r
111         uint32          size;   /* The size of the stack             */\r
112 } OsIsrStackType;\r
113 \r
114 \r
115 /* STD container : OsIsr\r
116  * Class: ALL\r
117  *\r
118  * OsIsrCategory:                               1    CATEGORY_1 or CATEGORY_2\r
119  * OsIsrResourceRef:                    0..* Reference to OsResources\r
120  * OsIsrTimingProtection[C]     0..1\r
121  * */\r
122 \r
123 typedef struct {\r
124         const char              *name;\r
125         uint8_t                 core;\r
126         int16_t                 vector;\r
127         int16_t                 type;\r
128         int16_t                 priority;\r
129         void                    (*entry)();\r
130         uint32_t                appOwner;\r
131         /* Mapped against OsIsrResourceRef */\r
132         uint32_t                resourceMask;\r
133 #if (  OS_USE_ISR_TIMING_PROT == STD_ON )\r
134         /* Mapped against OsIsrTimingProtection[C] */\r
135         OsIsrTimingProtectionType *timingProtPtr;\r
136 #else\r
137         void *timingProtPtr;\r
138 #endif\r
139 } OsIsrConstType;\r
140 \r
141 /*\r
142  *\r
143  */\r
144 typedef struct {\r
145         ISRType id;\r
146         OsIsrStackType          stack;\r
147         int                                     state;\r
148         const OsIsrConstType *constPtr;\r
149 } OsIsrVarType;\r
150 \r
151 \r
152 /* ----------------------------[functions]-----------------------------------*/\r
153 \r
154 void Os_IsrInit( void );\r
155 ISRType Os_IsrAdd( const OsIsrConstType * restrict isrPtr );\r
156 const OsIsrConstType * Os_IsrGet( int16_t vector);\r
157 void Os_IsrGetStackInfo( OsIsrStackType *stack );\r
158 \r
159 #endif /*ISR_H_*/\r