|
0
|
1 #ifndef CYGONCE_KERNEL_KAPI_H |
|
|
2 #define CYGONCE_KERNEL_KAPI_H |
|
|
3 |
|
|
4 /*========================================================================== |
|
|
5 // |
|
2
|
6 // kapi.h |
|
0
|
7 // |
|
2
|
8 // Native API for Kernel |
|
0
|
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 |
|
2
|
28 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
0
|
29 // ------------------------------------------- |
|
|
30 // |
|
|
31 //####COPYRIGHTEND#### |
|
|
32 //========================================================================== |
|
|
33 //#####DESCRIPTIONBEGIN#### |
|
|
34 // |
|
2
|
35 // Author(s): nickg, dsm |
|
|
36 // Contributors: nickg |
|
|
37 // Date: 1998-03-02 |
|
|
38 // Purpose: Native API for Kernel |
|
|
39 // Description: This file describes the native API for using the kernel. |
|
0
|
40 // It is essentially a set of C wrappers for the C++ class |
|
|
41 // member functions. |
|
2
|
42 // Usage: #include <cyg/kernel/kapi.h> |
|
0
|
43 // |
|
|
44 //####DESCRIPTIONEND#### |
|
|
45 // |
|
|
46 //========================================================================*/ |
|
|
47 |
|
|
48 #include <pkgconf/kernel.h> |
|
|
49 |
|
|
50 #ifdef CYGFUN_KERNEL_API_C |
|
|
51 #include <cyg/infra/cyg_type.h> |
|
|
52 |
|
|
53 /*---------------------------------------------------------------------------*/ |
|
|
54 |
|
|
55 #ifdef __cplusplus |
|
|
56 extern "C" { |
|
|
57 #endif |
|
|
58 |
|
|
59 /*---------------------------------------------------------------------------*/ |
|
|
60 /* The following are derived types, they may have different */ |
|
|
61 /* definitions from these depending on configuration. */ |
|
|
62 |
|
2
|
63 typedef CYG_ADDRWORD cyg_addrword_t; /* May hold pointer or word */ |
|
|
64 typedef cyg_addrword_t cyg_handle_t; /* Object handle */ |
|
|
65 typedef cyg_uint32 cyg_priority_t; /* type for priorities */ |
|
|
66 typedef cyg_int32 cyg_code_t; /* type for various codes */ |
|
|
67 typedef cyg_uint32 cyg_vector_t; /* Interrupt vector id */ |
|
0
|
68 |
|
2
|
69 typedef cyg_uint64 cyg_tick_count_t; |
|
0
|
70 |
|
|
71 typedef int cyg_bool_t; |
|
|
72 |
|
|
73 /* Exception handler function definition */ |
|
|
74 typedef void cyg_exception_handler_t( |
|
|
75 cyg_addrword_t data, |
|
|
76 cyg_code_t exception_number, |
|
|
77 cyg_addrword_t info |
|
|
78 ); |
|
|
79 |
|
|
80 /*---------------------------------------------------------------------------*/ |
|
|
81 struct cyg_thread; |
|
|
82 typedef struct cyg_thread cyg_thread; |
|
|
83 |
|
|
84 struct cyg_interrupt; |
|
|
85 typedef struct cyg_interrupt cyg_interrupt; |
|
|
86 |
|
|
87 struct cyg_counter; |
|
|
88 typedef struct cyg_counter cyg_counter; |
|
|
89 |
|
|
90 struct cyg_clock; |
|
|
91 typedef struct cyg_clock cyg_clock; |
|
|
92 |
|
|
93 struct cyg_alarm; |
|
|
94 typedef struct cyg_alarm cyg_alarm; |
|
|
95 |
|
|
96 struct cyg_mbox; |
|
|
97 typedef struct cyg_mbox cyg_mbox; |
|
|
98 |
|
|
99 struct cyg_mempool_var; |
|
|
100 typedef struct cyg_mempool_var cyg_mempool_var; |
|
|
101 |
|
|
102 struct cyg_mempool_fix; |
|
|
103 typedef struct cyg_mempool_fix cyg_mempool_fix; |
|
|
104 |
|
|
105 struct cyg_sem_t; |
|
|
106 typedef struct cyg_sem_t cyg_sem_t; |
|
|
107 |
|
|
108 struct cyg_flag_t; |
|
|
109 typedef struct cyg_flag_t cyg_flag_t; |
|
|
110 |
|
|
111 struct cyg_mutex_t; |
|
|
112 typedef struct cyg_mutex_t cyg_mutex_t; |
|
|
113 |
|
|
114 struct cyg_cond_t; |
|
|
115 typedef struct cyg_cond_t cyg_cond_t; |
|
|
116 |
|
|
117 /*---------------------------------------------------------------------------*/ |
|
|
118 /* Scheduler operations */ |
|
|
119 |
|
|
120 /* Starts scheduler with created threads. Never returns. */ |
|
|
121 void cyg_scheduler_start(void) __attribute__ ((noreturn)); |
|
|
122 |
|
|
123 /* Lock and unlock the scheduler. When the scheduler is */ |
|
|
124 /* locked thread preemption is disabled. */ |
|
|
125 void cyg_scheduler_lock(void); |
|
|
126 |
|
|
127 void cyg_scheduler_unlock(void); |
|
|
128 |
|
|
129 /*---------------------------------------------------------------------------*/ |
|
|
130 /* Thread operations */ |
|
|
131 |
|
|
132 typedef void cyg_thread_entry_t(cyg_addrword_t); |
|
|
133 |
|
|
134 void cyg_thread_create( |
|
2
|
135 cyg_addrword_t sched_info, /* scheduling info (eg pri) */ |
|
0
|
136 cyg_thread_entry_t *entry, /* entry point function */ |
|
2
|
137 cyg_addrword_t entry_data, /* entry data */ |
|
0
|
138 char *name, /* optional thread name */ |
|
|
139 void *stack_base, /* stack base, NULL = alloc */ |
|
|
140 cyg_ucount32 stack_size, /* stack size, 0 = default */ |
|
|
141 cyg_handle_t *handle, /* returned thread handle */ |
|
|
142 cyg_thread *thread /* put thread here */ |
|
|
143 ); |
|
|
144 |
|
|
145 void cyg_thread_exit(void); |
|
|
146 |
|
2
|
147 void cyg_thread_delete(cyg_handle_t thread); |
|
0
|
148 |
|
|
149 void cyg_thread_suspend(cyg_handle_t thread); |
|
|
150 |
|
|
151 void cyg_thread_resume(cyg_handle_t thread); |
|
|
152 |
|
|
153 void cyg_thread_kill(cyg_handle_t thread); |
|
|
154 |
|
2
|
155 void cyg_thread_release(cyg_handle_t thread); |
|
0
|
156 |
|
|
157 void cyg_thread_yield(void); |
|
|
158 |
|
|
159 cyg_handle_t cyg_thread_self(void); |
|
|
160 |
|
|
161 |
|
|
162 /* Priority manipulation */ |
|
|
163 |
|
|
164 void cyg_thread_set_priority(cyg_handle_t thread, cyg_priority_t priority ); |
|
|
165 |
|
|
166 cyg_priority_t cyg_thread_get_priority(cyg_handle_t thread); |
|
|
167 |
|
|
168 /* Deadline scheduling control (optional) */ |
|
|
169 |
|
|
170 void cyg_thread_deadline_wait( |
|
|
171 cyg_tick_count_t start_time, /* abs earliest start time */ |
|
|
172 cyg_tick_count_t run_time, /* worst case execution time */ |
|
|
173 cyg_tick_count_t deadline /* absolute deadline */ |
|
|
174 ); |
|
|
175 |
|
|
176 void cyg_thread_delay(cyg_tick_count_t delay); |
|
|
177 |
|
|
178 /*---------------------------------------------------------------------------*/ |
|
2
|
179 /* Per-thread Data */ |
|
|
180 |
|
|
181 #ifdef CYGVAR_KERNEL_THREADS_DATA |
|
|
182 |
|
|
183 cyg_ucount32 cyg_thread_new_data_index(void); |
|
|
184 |
|
|
185 void cyg_thread_free_data_index(cyg_ucount32 index); |
|
|
186 |
|
|
187 CYG_ADDRWORD cyg_thread_get_data(cyg_ucount32 index); |
|
|
188 |
|
|
189 CYG_ADDRWORD *cyg_thread_get_data_ptr(cyg_ucount32 index); |
|
|
190 |
|
|
191 void cyg_thread_set_data(cyg_ucount32 index, CYG_ADDRWORD data); |
|
|
192 |
|
|
193 #endif |
|
|
194 |
|
|
195 /*---------------------------------------------------------------------------*/ |
|
0
|
196 /* Exception handling. */ |
|
|
197 |
|
|
198 /* Replace current exception handler, this may apply to either the */ |
|
|
199 /* current thread, or to a global exception handler. The exception */ |
|
|
200 /* number may be ignored, or used to specify a particular handler. */ |
|
|
201 |
|
|
202 void cyg_exception_set_handler( |
|
|
203 cyg_code_t exception_number, |
|
|
204 cyg_exception_handler_t *new_handler, |
|
|
205 cyg_addrword_t new_data, |
|
|
206 cyg_exception_handler_t **old_handler, |
|
|
207 cyg_addrword_t *old_data |
|
|
208 ); |
|
|
209 |
|
|
210 /* Clear exception hander to default value */ |
|
|
211 void cyg_exception_clear_handler( |
|
|
212 cyg_code_t exception_number |
|
|
213 ); |
|
|
214 |
|
|
215 /* Invoke exception handler */ |
|
|
216 void cyg_exception_call_handler( |
|
|
217 cyg_handle_t thread, |
|
|
218 cyg_code_t exception_number, |
|
2
|
219 cyg_addrword_t exception_info |
|
0
|
220 ); |
|
|
221 |
|
|
222 |
|
|
223 /*---------------------------------------------------------------------------*/ |
|
|
224 /* Interrupt handling */ |
|
|
225 typedef void cyg_VSR_t(void); |
|
|
226 typedef cyg_uint32 cyg_ISR_t(cyg_vector_t vector, cyg_addrword_t data); |
|
|
227 typedef void cyg_DSR_t( |
|
|
228 cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data); |
|
|
229 |
|
|
230 |
|
|
231 enum cyg_ISR_results |
|
|
232 { |
|
|
233 CYG_ISR_HANDLED = 1, /* Interrupt was handled */ |
|
|
234 CYG_ISR_CALL_DSR = 2 /* Schedule DSR */ |
|
|
235 }; |
|
|
236 |
|
|
237 void cyg_interrupt_create( |
|
|
238 cyg_vector_t vector, /* Vector to attach to */ |
|
|
239 cyg_priority_t priority, /* Queue priority */ |
|
2
|
240 cyg_addrword_t data, /* Data pointer */ |
|
0
|
241 cyg_ISR_t *isr, /* Interrupt Service Routine */ |
|
|
242 cyg_DSR_t *dsr, /* Deferred Service Routine */ |
|
|
243 cyg_handle_t *handle, /* returned handle */ |
|
|
244 cyg_interrupt *intr /* put interrupt here */ |
|
|
245 ); |
|
|
246 |
|
|
247 void cyg_interrupt_delete( cyg_handle_t interrupt ); |
|
|
248 |
|
|
249 void cyg_interrupt_attach( cyg_handle_t interrupt ); |
|
|
250 |
|
|
251 void cyg_interrupt_detach( cyg_handle_t interrupt ); |
|
|
252 |
|
|
253 /* VSR manipulation */ |
|
|
254 |
|
|
255 void cyg_interrupt_get_vsr( |
|
|
256 cyg_vector_t vector, /* vector to get */ |
|
|
257 cyg_VSR_t **vsr /* vsr got */ |
|
|
258 ); |
|
|
259 |
|
|
260 void cyg_interrupt_set_vsr( |
|
|
261 cyg_vector_t vector, /* vector to set */ |
|
|
262 cyg_VSR_t *vsr /* vsr to set */ |
|
|
263 ); |
|
|
264 |
|
|
265 /* CPU level interrupt mask */ |
|
|
266 void cyg_interrupt_disable(void); |
|
|
267 |
|
|
268 void cyg_interrupt_enable(void); |
|
|
269 |
|
|
270 /* Interrupt controller access */ |
|
|
271 void cyg_interrupt_mask(cyg_vector_t vector); |
|
|
272 |
|
|
273 void cyg_interrupt_unmask(cyg_vector_t vector); |
|
|
274 |
|
|
275 void cyg_interrupt_acknowledge(cyg_vector_t vector); |
|
|
276 |
|
|
277 void cyg_interrupt_configure( |
|
|
278 cyg_vector_t vector, /* vector to configure */ |
|
|
279 cyg_bool_t level, /* level or edge triggered */ |
|
|
280 cyg_bool_t up /* rising/faling edge, high/low level*/ |
|
|
281 ); |
|
|
282 |
|
|
283 /*---------------------------------------------------------------------------*/ |
|
|
284 /* Counters, Clocks and Alarms */ |
|
|
285 |
|
|
286 void cyg_counter_create( |
|
|
287 cyg_handle_t *handle, /* returned counter handle */ |
|
|
288 cyg_counter *counter /* put counter here */ |
|
|
289 ); |
|
|
290 |
|
|
291 void cyg_counter_delete(cyg_handle_t counter); |
|
|
292 |
|
|
293 /* Return current value of counter */ |
|
|
294 cyg_tick_count_t cyg_counter_current_value(cyg_handle_t counter); |
|
|
295 |
|
|
296 /* Set new current value */ |
|
|
297 void cyg_counter_set_value( |
|
|
298 cyg_handle_t counter, |
|
|
299 cyg_tick_count_t new_value |
|
|
300 ); |
|
|
301 |
|
|
302 /* Advance counter by one tick */ |
|
|
303 void cyg_counter_tick(cyg_handle_t counter); |
|
|
304 |
|
|
305 |
|
|
306 typedef struct |
|
|
307 { |
|
|
308 cyg_uint32 dividend; |
|
|
309 cyg_uint32 divisor; |
|
|
310 } cyg_resolution_t; |
|
|
311 |
|
|
312 /* Create a clock object */ |
|
|
313 void cyg_clock_create( |
|
|
314 cyg_resolution_t resolution, /* Initial resolution */ |
|
|
315 cyg_handle_t *handle, /* Returned clock handle */ |
|
|
316 cyg_clock *clock /* put clock here */ |
|
|
317 ); |
|
|
318 |
|
|
319 void cyg_clock_delete(cyg_handle_t clock); |
|
|
320 |
|
|
321 /* convert a clock handle to a counter handle so we can use the */ |
|
|
322 /* counter API on it. */ |
|
|
323 void cyg_clock_to_counter( |
|
|
324 cyg_handle_t clock, |
|
|
325 cyg_handle_t *counter |
|
|
326 ); |
|
|
327 |
|
|
328 void cyg_clock_set_resolution( |
|
|
329 cyg_handle_t clock, |
|
|
330 cyg_resolution_t resolution /* New resolution */ |
|
|
331 ); |
|
|
332 |
|
|
333 cyg_resolution_t cyg_clock_get_resolution(cyg_handle_t clock); |
|
|
334 |
|
|
335 /* handle of real time clock */ |
|
|
336 cyg_handle_t cyg_real_time_clock(void); |
|
|
337 |
|
|
338 /* returns value of real time clock's counter. |
|
|
339 This is the same as: |
|
|
340 (cyg_clock_to_counter(cyg_real_time_clock(), &h), |
|
|
341 cyg_counter_current_value(h)) */ |
|
|
342 cyg_tick_count_t cyg_current_time(void); |
|
|
343 |
|
|
344 /* Alarm handler function */ |
|
|
345 typedef void cyg_alarm_t(cyg_handle_t alarm, cyg_addrword_t data); |
|
|
346 |
|
|
347 void cyg_alarm_create( |
|
|
348 cyg_handle_t counter, /* Attached to this counter */ |
|
|
349 cyg_alarm_t *alarmfn, /* Call-back function */ |
|
2
|
350 cyg_addrword_t data, /* Call-back data */ |
|
0
|
351 cyg_handle_t *handle, /* Returned alarm object */ |
|
|
352 cyg_alarm *alarm /* put alarm here */ |
|
|
353 ); |
|
|
354 |
|
|
355 /* Disable alarm, detach from counter and invalidate handles */ |
|
|
356 void cyg_alarm_delete( cyg_handle_t alarm); |
|
|
357 |
|
|
358 void cyg_alarm_initialize( |
|
|
359 cyg_handle_t alarm, |
|
|
360 cyg_tick_count_t trigger, /* Absolute trigger time */ |
|
|
361 cyg_tick_count_t interval /* Relative retrigger interval */ |
|
|
362 ); |
|
|
363 |
|
|
364 void cyg_alarm_enable( cyg_handle_t alarm ); |
|
|
365 |
|
|
366 void cyg_alarm_disable( cyg_handle_t alarm ); |
|
|
367 |
|
|
368 /*---------------------------------------------------------------------------*/ |
|
|
369 /* Mail boxes */ |
|
|
370 void cyg_mbox_create( |
|
|
371 cyg_handle_t *handle, |
|
|
372 cyg_mbox *mbox |
|
|
373 ); |
|
|
374 |
|
|
375 void cyg_mbox_delete(cyg_handle_t mbox); |
|
|
376 |
|
|
377 void *cyg_mbox_get(cyg_handle_t mbox); |
|
|
378 |
|
|
379 #ifdef CYGFUN_KERNEL_THREADS_TIMER |
|
|
380 void *cyg_mbox_timed_get( |
|
|
381 cyg_handle_t mbox, |
|
|
382 cyg_tick_count_t abstime |
|
|
383 ); |
|
|
384 #endif |
|
|
385 |
|
|
386 void *cyg_mbox_tryget(cyg_handle_t mbox); |
|
|
387 |
|
|
388 void *cyg_mbox_peek_item(cyg_handle_t mbox); |
|
|
389 |
|
|
390 #ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT |
|
|
391 cyg_bool_t cyg_mbox_put(cyg_handle_t mbox, void *item); |
|
|
392 #ifdef CYGFUN_KERNEL_THREADS_TIMER |
|
|
393 cyg_bool_t cyg_mbox_timed_put( |
|
|
394 cyg_handle_t mbox, |
|
|
395 void *item, |
|
|
396 cyg_tick_count_t abstime |
|
|
397 ); |
|
|
398 #endif |
|
|
399 #endif |
|
|
400 |
|
|
401 cyg_bool_t cyg_mbox_tryput(cyg_handle_t mbox, void *item); |
|
|
402 |
|
|
403 cyg_count32 cyg_mbox_peek(cyg_handle_t mbox); |
|
|
404 |
|
|
405 cyg_bool_t cyg_mbox_waiting_to_get(cyg_handle_t mbox); |
|
|
406 |
|
|
407 cyg_bool_t cyg_mbox_waiting_to_put(cyg_handle_t mbox); |
|
|
408 |
|
|
409 |
|
|
410 /*-----------------------------------------------------------------------*/ |
|
|
411 /* Memory pools */ |
|
|
412 |
|
|
413 /* There are two sorts of memory pools. A variable size memory pool |
|
|
414 is for allocating blocks of any size. A fixed size memory pool, has |
|
|
415 the block size specified when the pool is created, and only provides |
|
|
416 blocks of that size. */ |
|
|
417 |
|
|
418 /* Create a variable size memory pool */ |
|
|
419 void cyg_mempool_var_create( |
|
|
420 void *base, /* base of memory to use for pool */ |
|
|
421 cyg_int32 size, /* size of memory in bytes */ |
|
|
422 cyg_handle_t *handle, /* returned handle of memory pool */ |
|
|
423 cyg_mempool_var *var /* space to put pool structure in */ |
|
|
424 ); |
|
|
425 |
|
|
426 /* Delete variable size memory pool */ |
|
|
427 void cyg_mempool_var_delete(cyg_handle_t varpool); |
|
|
428 |
|
|
429 /* Allocates a block of length size. This waits if the memory is not |
|
|
430 currently available. */ |
|
|
431 void *cyg_mempool_var_alloc(cyg_handle_t varpool, cyg_int32 size); |
|
|
432 |
|
|
433 /* Allocates a block of length size. This waits until abstime, |
|
|
434 if the memory is not already available. NULL is returned if |
|
|
435 no memory is available. */ |
|
|
436 void *cyg_mempool_var_timed_alloc( |
|
|
437 cyg_handle_t varpool, |
|
|
438 cyg_int32 size, |
|
|
439 cyg_tick_count_t abstime); |
|
|
440 |
|
|
441 /* Allocates a block of length size. NULL is returned if no memory is |
|
|
442 available. */ |
|
|
443 void *cyg_mempool_var_try_alloc( |
|
|
444 cyg_handle_t varpool, |
|
|
445 cyg_int32 size); |
|
|
446 |
|
|
447 /* Frees memory back into variable size pool. */ |
|
|
448 void cyg_mempool_var_free(cyg_handle_t varpool, void *p); |
|
|
449 |
|
|
450 /* Returns true if there are any threads waiting for memory in the |
|
|
451 given memory pool. */ |
|
|
452 cyg_bool_t cyg_mempool_var_waiting(cyg_handle_t varpool); |
|
|
453 |
|
|
454 typedef struct { |
|
|
455 cyg_int32 totalmem; |
|
|
456 cyg_int32 freemem; |
|
|
457 void *base; |
|
|
458 cyg_int32 size; |
|
|
459 cyg_int32 blocksize; |
|
|
460 cyg_int32 maxfree; // The largest free block |
|
|
461 } cyg_mempool_info; |
|
|
462 |
|
|
463 /* Puts information about a variable memory pool into the structure |
|
|
464 provided. */ |
|
|
465 void cyg_mempool_var_get_info(cyg_handle_t varpool, cyg_mempool_info *info); |
|
|
466 |
|
|
467 /* Create a fixed size memory pool */ |
|
|
468 void cyg_mempool_fix_create( |
|
|
469 void *base, // base of memory to use for pool |
|
|
470 cyg_int32 size, // size of memory in byte |
|
|
471 cyg_int32 blocksize, // size of allocation in bytes |
|
|
472 cyg_handle_t *handle, // handle of memory pool |
|
|
473 cyg_mempool_fix *fix // space to put pool structure in |
|
|
474 ); |
|
|
475 |
|
|
476 /* Delete fixed size memory pool */ |
|
|
477 void cyg_mempool_fix_delete(cyg_handle_t fixpool); |
|
|
478 |
|
|
479 /* Allocates a block. This waits if the memory is not |
|
|
480 currently available. */ |
|
|
481 void *cyg_mempool_fix_alloc(cyg_handle_t fixpool); |
|
|
482 |
|
|
483 /* Allocates a block. This waits until abstime, if the memory |
|
|
484 is not already available. NULL is returned if no memory is |
|
|
485 available. */ |
|
|
486 void *cyg_mempool_fix_timed_alloc( |
|
|
487 cyg_handle_t fixpool, |
|
|
488 cyg_tick_count_t abstime); |
|
|
489 |
|
|
490 /* Allocates a block. NULL is returned if no memory is available. */ |
|
|
491 void *cyg_mempool_fix_try_alloc(cyg_handle_t fixpool); |
|
|
492 |
|
|
493 /* Frees memory back into fixed size pool. */ |
|
|
494 void cyg_mempool_fix_free(cyg_handle_t fixpool, void *p); |
|
|
495 |
|
|
496 /* Returns true if there are any threads waiting for memory in the |
|
|
497 given memory pool. */ |
|
|
498 cyg_bool_t cyg_mempool_fix_waiting(cyg_handle_t fixpool); |
|
|
499 |
|
|
500 /* Puts information about a variable memory pool into the structure |
|
|
501 provided. */ |
|
|
502 void cyg_mempool_fix_get_info(cyg_handle_t fixpool, cyg_mempool_info *info); |
|
|
503 |
|
|
504 /*---------------------------------------------------------------------------*/ |
|
|
505 /* Semaphores */ |
|
|
506 |
|
|
507 void cyg_semaphore_init( |
|
|
508 cyg_sem_t *sem, /* Semaphore to init */ |
|
2
|
509 cyg_count32 val /* Initial semaphore value */ |
|
0
|
510 ); |
|
|
511 |
|
|
512 void cyg_semaphore_destroy( cyg_sem_t *sem ); |
|
|
513 |
|
|
514 void cyg_semaphore_wait( cyg_sem_t *sem ); |
|
|
515 |
|
|
516 #ifdef CYGFUN_KERNEL_THREADS_TIMER |
|
|
517 cyg_bool_t cyg_semaphore_timed_wait( |
|
|
518 cyg_sem_t *sem, |
|
|
519 cyg_tick_count_t abstime |
|
|
520 ); |
|
|
521 #endif |
|
|
522 |
|
|
523 cyg_bool_t cyg_semaphore_trywait( cyg_sem_t *sem ); |
|
|
524 |
|
|
525 void cyg_semaphore_post( cyg_sem_t *sem ); |
|
|
526 |
|
2
|
527 void cyg_semaphore_peek( cyg_sem_t *sem, cyg_count32 *val ); |
|
0
|
528 |
|
|
529 /*---------------------------------------------------------------------------*/ |
|
|
530 /* Flags */ |
|
|
531 |
|
|
532 typedef cyg_uint32 cyg_flag_value_t; |
|
|
533 typedef cyg_uint8 cyg_flag_mode_t; |
|
|
534 #define CYG_FLAG_WAITMODE_AND ((cyg_flag_mode_t)0) /* all bits must be set */ |
|
|
535 #define CYG_FLAG_WAITMODE_OR ((cyg_flag_mode_t)2) /* any bit must be set */ |
|
|
536 #define CYG_FLAG_WAITMODE_CLR ((cyg_flag_mode_t)1) /* clear when satisfied */ |
|
|
537 |
|
|
538 void cyg_flag_init( |
|
|
539 cyg_flag_t *flag /* Flag to init */ |
|
|
540 ); |
|
|
541 |
|
|
542 void cyg_flag_destroy( cyg_flag_t *flag ); |
|
|
543 |
|
|
544 /* bitwise-or in the bits in value; awaken any waiting tasks whose |
|
|
545 condition is now satisfied */ |
|
|
546 void cyg_flag_setbits( cyg_flag_t *flag, cyg_flag_value_t value); |
|
|
547 |
|
|
548 /* bitwise-and with the the bits in value; this clears the bits which |
|
|
549 are not set in value. No waiting task can be awoken. */ |
|
|
550 void cyg_flag_maskbits( cyg_flag_t *flag, cyg_flag_value_t value); |
|
|
551 |
|
|
552 /* wait for the flag value to match the pattern, according to the mode. |
|
|
553 If mode includes CLR, set the flag value to zero when |
|
|
554 our pattern is matched. The return value is that which matched |
|
|
555 the request, or zero for an error/timeout return. |
|
|
556 Value must not itself be zero. */ |
|
|
557 cyg_flag_value_t cyg_flag_wait( cyg_flag_t *flag, |
|
|
558 cyg_flag_value_t pattern, |
|
|
559 cyg_flag_mode_t mode ); |
|
|
560 |
|
|
561 #ifdef CYGFUN_KERNEL_THREADS_TIMER |
|
|
562 cyg_flag_value_t cyg_flag_timed_wait( cyg_flag_t *flag, |
|
|
563 cyg_flag_value_t pattern, |
|
|
564 cyg_flag_mode_t mode, |
|
|
565 cyg_tick_count_t abstime ); |
|
|
566 |
|
|
567 #endif |
|
|
568 |
|
|
569 cyg_flag_value_t cyg_flag_poll( cyg_flag_t *flag, |
|
|
570 cyg_flag_value_t pattern, |
|
|
571 cyg_flag_mode_t mode ); |
|
|
572 |
|
|
573 cyg_flag_value_t cyg_flag_peek( cyg_flag_t *flag ); |
|
|
574 |
|
|
575 cyg_bool_t cyg_flag_waiting( cyg_flag_t *flag ); |
|
|
576 |
|
|
577 /*---------------------------------------------------------------------------*/ |
|
|
578 /* Mutex */ |
|
|
579 |
|
|
580 void cyg_mutex_init( |
|
|
581 cyg_mutex_t *mutex /* Mutex to init */ |
|
|
582 ); |
|
|
583 |
|
|
584 void cyg_mutex_destroy( cyg_mutex_t *mutex ); |
|
|
585 |
|
2
|
586 cyg_bool_t cyg_mutex_lock( cyg_mutex_t *mutex ); |
|
0
|
587 |
|
|
588 cyg_bool_t cyg_mutex_trylock( cyg_mutex_t *mutex ); |
|
|
589 |
|
|
590 void cyg_mutex_unlock( cyg_mutex_t *mutex ); |
|
|
591 |
|
2
|
592 void cyg_mutex_release( cyg_mutex_t *mutex ); |
|
|
593 |
|
0
|
594 /*---------------------------------------------------------------------------*/ |
|
|
595 /* Condition Variables */ |
|
|
596 |
|
|
597 void cyg_cond_init( |
|
|
598 cyg_cond_t *cond, /* condition variable to init */ |
|
|
599 cyg_mutex_t *mutex /* associated mutex */ |
|
|
600 ); |
|
|
601 |
|
|
602 void cyg_cond_destroy( cyg_cond_t *cond ); |
|
|
603 |
|
|
604 void cyg_cond_wait( cyg_cond_t *cond ); |
|
|
605 |
|
|
606 void cyg_cond_signal( cyg_cond_t *cond ); |
|
|
607 |
|
|
608 void cyg_cond_broadcast( cyg_cond_t *cond ); |
|
|
609 |
|
|
610 #ifdef CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT |
|
|
611 cyg_bool_t cyg_cond_timed_wait( |
|
|
612 cyg_cond_t *cond, |
|
|
613 cyg_tick_count_t abstime |
|
|
614 ); |
|
|
615 #endif |
|
|
616 |
|
|
617 |
|
|
618 #ifdef __cplusplus |
|
|
619 } |
|
|
620 #endif |
|
|
621 |
|
|
622 #include <cyg/kernel/kapidata.h> |
|
|
623 |
|
|
624 /*---------------------------------------------------------------------------*/ |
|
|
625 /* EOF kapi.h */ |
|
|
626 #endif /* CYGFUN_KERNEL_API_C */ |
|
|
627 #endif /* CYGONCE_KERNEL_KAPI_H */ |