]> rtime.felk.cvut.cz Git - arc.git/blob - system/kernel/include/kernel.h
Again, changes to generator macro. GEN_RESOURCE, GEN_ETASK, GEN_BTASK have changed
[arc.git] / system / kernel / include / kernel.h
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
16 \r
17 #ifndef KERNEL_H_\r
18 #define KERNEL_H_\r
19 \r
20 #include <sys/queue.h>
21 #include "Os.h"
22 \r
23 #if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON )\r
24 typedef void ( * trusted_func_t)( TrustedFunctionIndexType , TrustedFunctionParameterRefType );\r
25 #endif
26
27
28 /* STD container : OsOs. OSEK properties
29  * Class: ALL
30  *
31  * OsScalabilityClass:                  0..1 SC1,SC2,SC3,SC4
32  * OsStackMonitoring:                   1    Stack monitoring of tasks/category 2
33  * OsStatus                     1    EXTENDED or STANDARD status
34  * OsUseGetServiceId                    1    We can use the  OSErrorGetServiceId() function
35  * OsUseParameterAccess                 1    We save the parameters in OSError_XX_YY()
36  * OsUseResScheduler                    1
37  * OsHooks[C]                   1
38  *
39  * From OSEK/VDX oil:
40  *
41  * OS ExampleOS {
42  *   STATUS = STANDARD;
43  *   STARTUPHOOK = TRUE;
44  *   ERRORHOOK = TRUE;
45  *   SHUTDOWNHOOK = TRUE;
46  *   PRETASKHOOK = FALSE;
47  *   POSTTASKHOOK = FALSE;
48  *   USEGETSERVICEID = FALSE;
49  *   USEPARAMETERACCESS = FALSE;
50  *   USERESSCHEDULER = TRUE;
51  * };
52  *
53  * OS_SC1 | OS_SC2 | OS_SC3 | OS_SC4
54  * OS_STACK_MONITORING
55  * OS_STATUS_EXTENDED  / OS_STATUS_STANDARD
56  * OS_USE_GET_SERVICE_ID
57  * OS_USE_PARAMETER_ACCESS
58  * OS_RES_SCHEDULER
59  * */
60
61 /**
62  * STD container: OsResource
63  * OsResourceProperty:                          1    INTERNAL, LINKED, STANDARD
64  * OsResourceAccessingApplication:  0..*
65  * OsResourceLinkedResourceRef:     0..1
66  */
67 \r
68 typedef enum {\r
69         /* External resource */\r
70         RESOURCE_TYPE_STANDARD,//!< RESOURCE_TYPE_STANDARD\r
71         /* ?? */\r
72         RESOURCE_TYPE_LINKED,  //!< RESOURCE_TYPE_LINKED\r
73         /* Internal resource */
74         RESOURCE_TYPE_INTERNAL //!< RESOURCE_TYPE_INTERNAL\r
75 } OsResourcePropertyType;\r
76 \r
77 /*-----------------------------------------------------------------*/\r
78 typedef struct OsResource {\r
79         char id[16];\r
80         // The running number, starting at RES_SCHEDULER=0\r
81         int nr;\r
82         // The calculated ceiling prio\r
83         uint32 ceiling_priority;\r
84         // Stored prio of the owner oi the resource\r
85         uint32 old_task_prio;\r
86 \r
87         // What application may access this resource. A resource may only be\r
88         // accessed by one application
89 #if ( OS_SC3 == STD_ON ) || ( OS_SC4 == STD_ON )\r
90         uint32 application_owner_id;
91 #endif\r
92         // What tasks may access this resource. A resource may be be shared\r
93         // several tasks.\r
94 //      uint32 task_mask;\r
95         // Owner of the resource...\r
96         TaskType owner;\r
97 \r
98         OsResourcePropertyType type;\r
99         // used only if type is RESOURCE_TYPE_LINKED\r
100         ResourceType    linked_resource;\r
101
102         /* List of resources for each task. */
103         TAILQ_ENTRY(OsResource) listEntry;\r
104 \r
105 } OsResourceType;\r
106 \r
107 typedef enum {\r
108         LOCK_TYPE_RESOURCE,\r
109         LOCK_TYPE_INTERRUPT,\r
110 } OsLocktypeType;\r
111 \r
112 typedef struct OsLockingtime {\r
113         OsLocktypeType type;\r
114         union {\r
115                 struct {\r
116                         ResourceType id;\r
117                         uint64 time;\r
118                 } resource;\r
119 \r
120                 struct {\r
121                         uint64 all;\r
122                         uint64 os;\r
123                 } interrupt;\r
124         } u;\r
125 } OsLockingtimeType;\r
126 \r
127 typedef struct OsTimingProtection {\r
128         // ROM, worst case execution budget in ns\r
129         uint64  execution_budget;\r
130         // ROM, the frame in ns that timelimit may execute in.\r
131         uint64 timeframe;\r
132         // ROM, time in ns that the task/isr may with a timeframe.\r
133         uint64 timelimit;\r
134         // ROM, resource/interrupt locktimes\r
135         OsLockingtimeType *lockingtime;\r
136 } OsTimingProtectionType;\r
137 \r
138
139 #include "counter_i.h"
140 #include "alarm_i.h"
141 #include "sched_table_i.h"
142 #include "application.h"
143 #include "pcb.h"
144 #include "sys.h"
145 \r
146 /*-----------------------------------------------------------------*/\r
147 \r
148 \r
149 /*-----------------------------------------------------------------*/\r
150 /*\r
151  * debug settings for os_debug_mask\r
152  *\r
153  */\r
154 \r
155 #define OS_DBG_MASTER_PRINT             (1<<0)\r
156 #define OS_DBG_ISR_MASTER_PRINT (1<<1)\r
157 #define OS_DBG_STDOUT                           (1<<2)\r
158 #define OS_DBG_ISR_STDOUT                       (1<<3)\r
159 \r
160 // Enable print dbg_XXXX (not dbg_isr_XXX though)\r
161 #define D_MASTER_PRINT                          (1<<0)\r
162 // Enable print for all dbg_isr_XXX\r
163 #define D_ISR_MASTER_PRINT                      (1<<1)\r
164 // print to STDOUT. If not set it prints to ramlog\r
165 #define D_STDOUT                                        (1<<2)\r
166 #define D_RAMLOG                                        0\r
167 // print to STDOUT, If not set print to ramlog\r
168 #define D_ISR_STDOUT                            (1<<3)\r
169 #define D_ISR_RAMLOG                            0\r
170 \r
171 #define D_TASK                                          (1<<13)\r
172 #define D_ALARM                                 (1<<14)\r
173 \r
174 #define OS_DBG_TASK                             (1<<13)\r
175 #define OS_DBG_ALARM                            (1<<14)\r
176
177 #endif /* KERNEL_H_ */\r