|
0
|
1 #ifndef CYGONCE_KERNEL_KAPIDATA_H |
|
|
2 #define CYGONCE_KERNEL_KAPIDATA_H |
|
|
3 |
|
|
4 /*============================================================================= |
|
|
5 // |
|
|
6 // kapidata.h |
|
|
7 // |
|
|
8 // Native API data structures |
|
|
9 // |
|
|
10 //========================================================================== |
|
|
11 //####COPYRIGHTBEGIN#### |
|
|
12 // |
|
|
13 // ------------------------------------------- |
|
|
14 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
15 // Version 1.0 (the "License"); you may not use this file except in |
|
|
16 // compliance with the License. You may obtain a copy of the License at |
|
|
17 // http://sourceware.cygnus.com/ecos |
|
|
18 // |
|
|
19 // Software distributed under the License is distributed on an "AS IS" |
|
|
20 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
21 // License for the specific language governing rights and limitations under |
|
|
22 // the License. |
|
|
23 // |
|
|
24 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
25 // September 30, 1998. |
|
|
26 // |
|
|
27 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
28 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. |
|
|
29 // ------------------------------------------- |
|
|
30 // |
|
|
31 //####COPYRIGHTEND#### |
|
|
32 //========================================================================== |
|
|
33 //#####DESCRIPTIONBEGIN#### |
|
|
34 // |
|
|
35 // Author(s): nickg |
|
|
36 // Contributors: nickg |
|
|
37 // Date: 1998-03-13 |
|
|
38 // Purpose: Native API data structures |
|
|
39 // Description: This file defines the structures used in the native API. The |
|
|
40 // sizes of these structures are dependent on the system |
|
|
41 // configuration and must be kept in step with their real |
|
|
42 // counterparts in the C++ headers. |
|
|
43 // Usage: included by kapi.h |
|
|
44 // |
|
|
45 //####DESCRIPTIONEND#### |
|
|
46 // |
|
|
47 //==========================================================================*/ |
|
|
48 |
|
|
49 #include <pkgconf/kernel.h> |
|
|
50 |
|
|
51 #include <cyg/infra/cyg_type.h> |
|
|
52 #include <cyg/hal/hal_intr.h> // exception defines |
|
|
53 |
|
|
54 /*---------------------------------------------------------------------------*/ |
|
|
55 |
|
|
56 #ifdef __cplusplus |
|
|
57 extern "C" { |
|
|
58 #endif |
|
|
59 |
|
|
60 /*---------------------------------------------------------------------------*/ |
|
|
61 |
|
|
62 #ifndef CYGNUM_KERNEL_SCHED_BITMAP_SIZE |
|
|
63 #if defined(CYGSEM_KERNEL_SCHED_MLQUEUE) |
|
|
64 #define CYGNUM_KERNEL_SCHED_BITMAP_SIZE 32 |
|
|
65 #elif defined(CYGSEM_KERNEL_SCHED_BITMAP) |
|
|
66 #define CYGNUM_KERNEL_SCHED_BITMAP_SIZE 32 |
|
|
67 #endif |
|
|
68 #endif |
|
|
69 |
|
|
70 #if CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 8 |
|
|
71 typedef cyg_ucount8 cyg_sched_bitmap; |
|
|
72 #elif CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 16 |
|
|
73 typedef cyg_ucount16 cyg_sched_bitmap; |
|
|
74 #elif CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 32 |
|
|
75 typedef cyg_ucount32 cyg_sched_bitmap; |
|
|
76 #elif CYGNUM_KERNEL_SCHED_BITMAP_SIZE <= 64 |
|
|
77 typedef cyg_ucount64 cyg_sched_bitmap; |
|
|
78 #else |
|
|
79 #error Bitmaps greater than 64 bits not currently allowed |
|
|
80 #endif |
|
|
81 |
|
|
82 typedef struct |
|
|
83 { |
|
|
84 #if defined(CYGSEM_KERNEL_SCHED_BITMAP) |
|
|
85 |
|
|
86 cyg_sched_bitmap map; |
|
|
87 |
|
|
88 #elif defined(CYGSEM_KERNEL_SCHED_MLQUEUE) |
|
|
89 |
|
|
90 cyg_thread *queue; |
|
|
91 |
|
|
92 #elif defined(CYGSEM_KERNEL_SCHED_LOTTERY) |
|
|
93 |
|
|
94 cyg_thread *queue; |
|
|
95 |
|
|
96 #else |
|
|
97 |
|
|
98 #error Undefined scheduler type |
|
|
99 |
|
|
100 #endif |
|
|
101 } cyg_threadqueue; |
|
|
102 |
|
|
103 /*---------------------------------------------------------------------------*/ |
|
|
104 |
|
|
105 struct cyg_interrupt |
|
|
106 { |
|
|
107 cyg_vector_t vector; |
|
|
108 cyg_priority_t priority; |
|
|
109 cyg_ISR_t *isr; |
|
|
110 cyg_DSR_t *dsr; |
|
|
111 CYG_ADDRWORD data; |
|
|
112 |
|
|
113 #ifdef CYGIMP_KERNEL_INTERRUPTS_DSRS_LIST |
|
|
114 cyg_ucount32 dsr_count; |
|
|
115 cyg_interrupt *next_dsr; |
|
|
116 #endif |
|
|
117 #ifdef CYGIMP_KERNEL_INTERRUPTS_CHAIN |
|
|
118 cyg_interrupt *next; |
|
|
119 #endif |
|
|
120 }; |
|
|
121 |
|
|
122 |
|
|
123 /*---------------------------------------------------------------------------*/ |
|
|
124 |
|
|
125 struct cyg_counter |
|
|
126 { |
|
|
127 #if defined(CYGIMP_KERNEL_COUNTERS_SINGLE_LIST) |
|
|
128 cyg_alarm *alarm_list; |
|
|
129 #elif defined(CYGIMP_KERNEL_COUNTERS_MULTI_LIST) |
|
|
130 cyg_alarm *alarm_list[CYGNUM_KERNEL_COUNTERS_MULTI_LIST_SIZE]; |
|
|
131 #endif |
|
|
132 cyg_tick_count_t counter; |
|
|
133 cyg_uint32 increment; |
|
|
134 }; |
|
|
135 |
|
|
136 /*---------------------------------------------------------------------------*/ |
|
|
137 |
|
|
138 struct cyg_clock |
|
|
139 { |
|
|
140 cyg_counter counter; |
|
|
141 cyg_resolution_t resolution; |
|
|
142 }; |
|
|
143 |
|
|
144 /*---------------------------------------------------------------------------*/ |
|
|
145 |
|
|
146 struct cyg_alarm |
|
|
147 { |
|
|
148 #if defined(CYGIMP_KERNEL_COUNTERS_SINGLE_LIST) || defined(CYGIMP_KERNEL_COUNTERS_MULTI_LIST) |
|
|
149 cyg_alarm *next; |
|
|
150 #endif |
|
|
151 cyg_counter *counter; |
|
|
152 cyg_alarm_t *alarm; |
|
|
153 CYG_ADDRWORD data; |
|
|
154 cyg_tick_count_t trigger; |
|
|
155 cyg_tick_count_t interval; |
|
|
156 cyg_bool enabled; |
|
|
157 }; |
|
|
158 |
|
|
159 /*---------------------------------------------------------------------------*/ |
|
|
160 /* Exception controller */ |
|
|
161 |
|
|
162 #ifdef CYGPKG_KERNEL_EXCEPTIONS |
|
|
163 typedef struct |
|
|
164 { |
|
|
165 #ifdef CYGSEM_KERNEL_EXCEPTIONS_DECODE |
|
|
166 cyg_exception_handler_t *exception_handler[CYG_EXCEPTION_COUNT]; |
|
|
167 |
|
|
168 CYG_ADDRWORD exception_data[CYG_EXCEPTION_COUNT]; |
|
|
169 #else |
|
|
170 cyg_exception_handler_t *exception_handler; // Handler function |
|
|
171 |
|
|
172 CYG_ADDRWORD exception_data; // Handler data |
|
|
173 #endif |
|
|
174 |
|
|
175 } cyg_exception_control; |
|
|
176 |
|
|
177 #endif |
|
|
178 |
|
|
179 /*---------------------------------------------------------------------------*/ |
|
|
180 /* Thread structure */ |
|
|
181 |
|
|
182 typedef struct |
|
|
183 { |
|
|
184 CYG_ADDRESS stack_base; /* pointer to base of stack area */ |
|
|
185 cyg_uint32 stack_size; /* size of stack area in bytes */ |
|
|
186 #ifdef CYGFUN_KERNEL_THREADS_STACK_LIMIT |
|
|
187 CYG_ADDRESS stack_limit; /* movable stack limit */ |
|
|
188 #endif |
|
|
189 CYG_ADDRESS stack_ptr; /* pointer to saved state on stack */ |
|
|
190 CYG_ADDRWORD entry_point; /* main entry point (code pointer!) */ |
|
|
191 CYG_ADDRWORD entry_data; /* entry point argument */ |
|
|
192 #ifdef CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT |
|
|
193 void *saved_context; // If non-zero, this points at a more |
|
|
194 // interesting context than stack_ptr. |
|
|
195 #endif |
|
|
196 |
|
|
197 } cyg_hardwarethread; |
|
|
198 |
|
|
199 typedef struct |
|
|
200 { |
|
|
201 #if defined(CYGSEM_KERNEL_SCHED_BITMAP) |
|
|
202 |
|
|
203 cyg_priority_t priority; /* current thread priority */ |
|
|
204 |
|
|
205 #elif defined(CYGSEM_KERNEL_SCHED_MLQUEUE) |
|
|
206 |
|
|
207 cyg_thread *next; |
|
|
208 cyg_thread *prev; |
|
|
209 |
|
|
210 cyg_priority_t priority; /* current thread priority */ |
|
|
211 |
|
|
212 #elif defined(CYGSEM_KERNEL_SCHED_LOTTERY) |
|
|
213 |
|
|
214 cyg_thread *next; |
|
|
215 cyg_thread *prev; |
|
|
216 |
|
|
217 cyg_priority_t priority; /* current thread priority */ |
|
|
218 |
|
|
219 cyg_priority_t compensation_tickets; /* sleep compensation */ |
|
|
220 |
|
|
221 #else |
|
|
222 |
|
|
223 #error Undefined scheduler type |
|
|
224 |
|
|
225 #endif |
|
|
226 |
|
|
227 cyg_threadqueue *queue; |
|
|
228 |
|
|
229 #ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE |
|
|
230 cyg_count32 mutex_count; |
|
|
231 #ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INHERITANCE_SIMPLE |
|
|
232 cyg_priority_t original_priority; |
|
|
233 cyg_bool priority_inherited; |
|
|
234 #endif |
|
|
235 #endif |
|
|
236 |
|
|
237 } cyg_schedthread; |
|
|
238 |
|
|
239 typedef struct |
|
|
240 { |
|
|
241 cyg_alarm alarm; |
|
|
242 cyg_thread *thread; |
|
|
243 } cyg_threadtimer; |
|
|
244 |
|
|
245 |
|
|
246 typedef int cyg_reason_t; /* cyg_reason is originally an enum */ |
|
|
247 |
|
|
248 struct cyg_thread |
|
|
249 { |
|
|
250 cyg_hardwarethread hwthread; |
|
|
251 cyg_schedthread schedthread; |
|
|
252 |
|
|
253 cyg_uint32 state; |
|
|
254 cyg_ucount32 suspend_count; |
|
|
255 cyg_ucount32 wakeup_count; |
|
|
256 CYG_ADDRWORD wait_info; |
|
|
257 cyg_uint16 unique_id; |
|
|
258 |
|
|
259 |
|
|
260 #if defined(CYGPKG_KERNEL_EXCEPTIONS) && !defined(CYGSEM_KERNEL_EXCEPTIONS_GLOBAL) |
|
|
261 |
|
|
262 cyg_exception_control exception_control; |
|
|
263 |
|
|
264 #endif |
|
|
265 |
|
|
266 #ifdef CYGFUN_KERNEL_THREADS_TIMER |
|
|
267 cyg_threadtimer timer; |
|
|
268 #endif |
|
|
269 |
|
|
270 cyg_reason_t sleep_reason; |
|
|
271 cyg_reason_t wake_reason; |
|
|
272 |
|
|
273 #ifdef CYGVAR_KERNEL_THREADS_DATA |
|
|
274 |
|
|
275 CYG_ADDRWORD thread_data[CYGNUM_KERNEL_THREADS_DATA_MAX]; |
|
|
276 |
|
|
277 #endif |
|
|
278 |
|
|
279 #ifdef CYGVAR_KERNEL_THREADS_NAME |
|
|
280 |
|
|
281 char *name; |
|
|
282 |
|
|
283 #endif |
|
|
284 |
|
|
285 #ifdef CYGVAR_KERNEL_THREADS_LIST |
|
|
286 |
|
|
287 cyg_thread *list_next; |
|
|
288 |
|
|
289 #endif |
|
|
290 |
|
|
291 }; |
|
|
292 |
|
|
293 /*---------------------------------------------------------------------------*/ |
|
|
294 |
|
|
295 struct cyg_mbox |
|
|
296 { |
|
|
297 cyg_count32 base; /* index of first used slot */ |
|
|
298 cyg_count32 count; /* count of used slots */ |
|
|
299 cyg_threadqueue get_threadq; /* Queue of waiting threads */ |
|
|
300 #ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT |
|
|
301 cyg_threadqueue put_threadq; /* Queue of waiting threads */ |
|
|
302 #endif |
|
|
303 void * itemqueue[ CYGNUM_KERNEL_SYNCH_MBOX_QUEUE_SIZE ]; |
|
|
304 }; |
|
|
305 |
|
|
306 /*---------------------------------------------------------------------------*/ |
|
|
307 |
|
|
308 struct cyg_sem_t |
|
|
309 { |
|
|
310 cyg_count32 count; /* The semaphore count */ |
|
|
311 cyg_threadqueue queue; /* Queue of waiting threads */ |
|
|
312 }; |
|
|
313 |
|
|
314 /*---------------------------------------------------------------------------*/ |
|
|
315 |
|
|
316 struct cyg_flag_t |
|
|
317 { |
|
|
318 cyg_flag_value_t value; /* The flag value */ |
|
|
319 cyg_threadqueue queue; /* Queue of waiting threads */ |
|
|
320 }; |
|
|
321 |
|
|
322 /*---------------------------------------------------------------------------*/ |
|
|
323 |
|
|
324 struct cyg_mutex_t |
|
|
325 { |
|
|
326 cyg_bool locked; /* true if locked */ |
|
|
327 cyg_thread *owner; /* Current locking thread */ |
|
|
328 cyg_threadqueue queue; /* Queue of waiting threads */ |
|
|
329 |
|
|
330 }; |
|
|
331 |
|
|
332 /*---------------------------------------------------------------------------*/ |
|
|
333 |
|
|
334 struct cyg_cond_t |
|
|
335 { |
|
|
336 cyg_mutex_t *mutex; /* Associated mutex */ |
|
|
337 cyg_threadqueue queue; /* Queue of waiting threads */ |
|
|
338 }; |
|
|
339 |
|
|
340 /*---------------------------------------------------------------------------*/ |
|
|
341 |
|
|
342 /* This corresponds to the extra fields provided by the mempoolt template |
|
|
343 not the actual size of the template in any given instance. */ |
|
|
344 typedef struct cyg_mempoolt { |
|
|
345 cyg_threadqueue queue; |
|
|
346 } cyg_mempoolt; |
|
|
347 |
|
|
348 |
|
|
349 struct cyg_mempool_var_memdq { |
|
|
350 struct cyg_mempool_var_memdq *prev, *next; |
|
|
351 cyg_int32 size; |
|
|
352 }; |
|
|
353 |
|
|
354 struct cyg_mempool_var { |
|
|
355 struct cyg_mempool_var_memdq head; |
|
|
356 cyg_uint8 *obase; |
|
|
357 cyg_int32 osize; |
|
|
358 cyg_int32 oalign; |
|
|
359 cyg_uint8 *bottom; |
|
|
360 cyg_uint8 *top; |
|
|
361 cyg_int32 alignment; |
|
|
362 cyg_int32 freemem; |
|
|
363 cyg_mempoolt mempoolt; |
|
|
364 }; |
|
|
365 |
|
|
366 struct cyg_mempool_fix { |
|
|
367 cyg_uint32 *bitmap; |
|
|
368 cyg_int32 maptop; |
|
|
369 cyg_uint8 *mempool; |
|
|
370 cyg_int32 numblocks; |
|
|
371 cyg_int32 freeblocks; |
|
|
372 cyg_int32 blocksize; |
|
|
373 cyg_int32 firstfree; |
|
|
374 cyg_uint8 *top; |
|
|
375 cyg_mempoolt mempoolt; |
|
|
376 }; |
|
|
377 |
|
|
378 /*------------------------------------------------------------------------*/ |
|
|
379 |
|
|
380 #ifdef __cplusplus |
|
|
381 } |
|
|
382 #endif |
|
|
383 |
|
|
384 /*---------------------------------------------------------------------------*/ |
|
|
385 /* EOF kapidata.h */ |
|
|
386 #endif /* CYGONCE_KERNEL_KAPIDATA_H */ |