]> rtime.felk.cvut.cz Git - arc.git/blob - system/kernel/include/kernel.h
abbbfccf3ac40e74bc2119b2383a70e4a5bdac3b
[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 \r
62 typedef enum {\r
63         /* External resource */\r
64         RESOURCE_TYPE_STANDARD,\r
65         /* ?? */\r
66         RESOURCE_TYPE_LINKED,\r
67         /* Internal resource */
68         RESOURCE_TYPE_INTERNAL\r
69 } OsResourceTypeType;\r
70 \r
71 typedef struct  {
72 \r
73         OsResourceTypeType type;\r
74         /* used only if type is RESOURCE_TYPE_LINKED */\r
75         ResourceType    linked_resource;\r
76 } OsResourcePropertyType;\r
77 \r
78 /*-----------------------------------------------------------------*/\r
79 typedef struct OsResource {\r
80         char id[16];\r
81         // The running number, starting at RES_SCHEDULER=0\r
82         int nr;\r
83         // The calculated ceiling prio\r
84         uint32 ceiling_priority;\r
85         // Stored prio of the owner oi the resource\r
86         uint32 old_task_prio;\r
87 \r
88         // What application may access this resource. A resource may only be\r
89         // accessed by one application\r
90         uint32 application_owner_id;\r
91         // What tasks may access this resource. A resource may be be shared\r
92         // several tasks.\r
93         uint32 task_mask;\r
94         // Owner of the resource...\r
95         TaskType owner;\r
96 \r
97         OsResourceTypeType type;\r
98         // used only if type is RESOURCE_TYPE_LINKED\r
99         ResourceType    linked_resource;\r
100
101         /* List of resources for each task. */
102         TAILQ_ENTRY(OsResource) listEntry;\r
103 \r
104 } OsResourceType;\r
105 \r
106 typedef enum {\r
107         LOCK_TYPE_RESOURCE,\r
108         LOCK_TYPE_INTERRUPT,\r
109 } OsLocktypeType;\r
110 \r
111 typedef struct OsLockingtime {\r
112         OsLocktypeType type;\r
113         union {\r
114                 struct {\r
115                         ResourceType id;\r
116                         uint64 time;\r
117                 } resource;\r
118 \r
119                 struct {\r
120                         uint64 all;\r
121                         uint64 os;\r
122                 } interrupt;\r
123         } u;\r
124 } OsLockingtimeType;\r
125 \r
126 typedef struct OsTimingProtection {\r
127         // ROM, worst case execution budget in ns\r
128         uint64  execution_budget;\r
129         // ROM, the frame in ns that timelimit may execute in.\r
130         uint64 timeframe;\r
131         // ROM, time in ns that the task/isr may with a timeframe.\r
132         uint64 timelimit;\r
133         // ROM, resource/interrupt locktimes\r
134         OsLockingtimeType *lockingtime;\r
135 } OsTimingProtectionType;\r
136 \r
137
138 #include "counter_i.h"
139 #include "alarm_i.h"
140 #include "sched_table_i.h"
141 #include "application.h"
142 #include "pcb.h"
143 #include "sys.h"
144 \r
145 /*-----------------------------------------------------------------*/\r
146 \r
147 \r
148 /*-----------------------------------------------------------------*/\r
149 /*\r
150  * debug settings for os_debug_mask\r
151  *\r
152  */\r
153 \r
154 #define OS_DBG_MASTER_PRINT             (1<<0)\r
155 #define OS_DBG_ISR_MASTER_PRINT (1<<1)\r
156 #define OS_DBG_STDOUT                           (1<<2)\r
157 #define OS_DBG_ISR_STDOUT                       (1<<3)\r
158 \r
159 // Enable print dbg_XXXX (not dbg_isr_XXX though)\r
160 #define D_MASTER_PRINT                          (1<<0)\r
161 // Enable print for all dbg_isr_XXX\r
162 #define D_ISR_MASTER_PRINT                      (1<<1)\r
163 // print to STDOUT. If not set it prints to ramlog\r
164 #define D_STDOUT                                        (1<<2)\r
165 #define D_RAMLOG                                        0\r
166 // print to STDOUT, If not set print to ramlog\r
167 #define D_ISR_STDOUT                            (1<<3)\r
168 #define D_ISR_RAMLOG                            0\r
169 \r
170 #define D_TASK                                          (1<<13)\r
171 #define D_ALARM                                 (1<<14)\r
172 \r
173 #define OS_DBG_TASK                             (1<<13)\r
174 #define OS_DBG_ALARM                            (1<<14)\r
175
176 #endif /* KERNEL_H_ */\r