]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/kernel/v2_0/include/kapi.h
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / kernel / v2_0 / include / kapi.h
1 #ifndef CYGONCE_KERNEL_KAPI_H
2 #define CYGONCE_KERNEL_KAPI_H
3
4 /*==========================================================================
5 //
6 //      kapi.h
7 //
8 //      Native API for Kernel
9 //
10 //==========================================================================
11 //####ECOSGPLCOPYRIGHTBEGIN####
12 // -------------------------------------------
13 // This file is part of eCos, the Embedded Configurable Operating System.
14 // Copyright (C) 2002 Bart Veer
15 // Copyright (C) 2002 Nick Garnett
16 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
17 //
18 // eCos is free software; you can redistribute it and/or modify it under
19 // the terms of the GNU General Public License as published by the Free
20 // Software Foundation; either version 2 or (at your option) any later version.
21 //
22 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
23 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25 // for more details.
26 //
27 // You should have received a copy of the GNU General Public License along
28 // with eCos; if not, write to the Free Software Foundation, Inc.,
29 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
30 //
31 // As a special exception, if other files instantiate templates or use macros
32 // or inline functions from this file, or you compile this file and link it
33 // with other works to produce a work based on this file, this file does not
34 // by itself cause the resulting work to be covered by the GNU General Public
35 // License. However the source code for this file must still be made available
36 // in accordance with section (3) of the GNU General Public License.
37 //
38 // This exception does not invalidate any other reasons why a work based on
39 // this file might be covered by the GNU General Public License.
40 //
41 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
42 // at http://sources.redhat.com/ecos/ecos-license/
43 // -------------------------------------------
44 //####ECOSGPLCOPYRIGHTEND####
45 //==========================================================================
46 //#####DESCRIPTIONBEGIN####
47 //
48 // Author(s):   nickg, dsm
49 // Contributors:        nickg
50 // Date:        1998-03-02
51 // Purpose:     Native API for Kernel
52 // Description: This file describes the native API for using the kernel.
53 //              It is essentially a set of C wrappers for the C++ class
54 //              member functions.
55 // Usage:       #include <cyg/kernel/kapi.h>
56 //
57 //####DESCRIPTIONEND####
58 //
59 //========================================================================*/
60
61 #include <pkgconf/system.h>
62 #include <pkgconf/kernel.h>
63
64 #ifdef CYGFUN_KERNEL_API_C
65 #include <cyg/infra/cyg_type.h>
66
67 /*---------------------------------------------------------------------------*/
68
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72
73 /*---------------------------------------------------------------------------*/
74 /* The following are derived types, they may have different                  */
75 /* definitions from these depending on configuration.                        */
76
77 typedef CYG_ADDRWORD   cyg_addrword_t;      /* May hold pointer or word      */
78 typedef cyg_addrword_t cyg_handle_t;        /* Object handle                 */
79 typedef cyg_uint32     cyg_priority_t;      /* type for priorities           */
80 typedef cyg_int32      cyg_code_t;          /* type for various codes        */
81 typedef cyg_uint32     cyg_vector_t;        /* Interrupt vector id           */
82 typedef cyg_uint32     cyg_cpu_t;           /* CPU id type                   */
83
84 typedef cyg_uint64 cyg_tick_count_t;
85
86 typedef int cyg_bool_t;
87
88 /* Exception handler function definition                                     */
89 typedef void cyg_exception_handler_t(
90     cyg_addrword_t data,
91     cyg_code_t   exception_number,
92     cyg_addrword_t info
93 );
94
95 /*---------------------------------------------------------------------------*/
96 struct cyg_thread;
97 typedef struct cyg_thread cyg_thread;
98
99 struct cyg_interrupt;
100 typedef struct cyg_interrupt cyg_interrupt;
101
102 struct cyg_counter;
103 typedef struct cyg_counter cyg_counter;
104
105 struct cyg_clock;
106 typedef struct cyg_clock cyg_clock;
107
108 struct cyg_alarm;
109 typedef struct cyg_alarm cyg_alarm;
110
111 struct cyg_mbox;
112 typedef struct cyg_mbox cyg_mbox;
113
114 struct cyg_sem_t;
115 typedef struct cyg_sem_t cyg_sem_t;
116
117 struct cyg_flag_t;
118 typedef struct cyg_flag_t cyg_flag_t;
119
120 struct cyg_mutex_t;
121 typedef struct cyg_mutex_t cyg_mutex_t;
122
123 struct cyg_cond_t;
124 typedef struct cyg_cond_t cyg_cond_t;
125
126 struct cyg_spinlock_t;
127 typedef struct cyg_spinlock_t cyg_spinlock_t;
128
129 /*---------------------------------------------------------------------------*/
130 /* Scheduler operations */
131
132 /* Starts scheduler with created threads.  Never returns. */
133 void cyg_scheduler_start(void) __THROW CYGBLD_ATTRIB_NORET;
134
135 /* Lock and unlock the scheduler. When the scheduler is   */
136 /* locked thread preemption is disabled.                  */
137 void cyg_scheduler_lock(void) __THROW;
138
139 void cyg_scheduler_unlock(void) __THROW;
140
141 /* Just like 'cyg_scheduler_lock()', but never take the lock higher than 1  */
142 /* Thus this call is safe even if the scheduler is already locked and a     */
143 /* subsequent call to 'cyg_scheduler_unlock()' will completely unlock.      */
144 void cyg_scheduler_safe_lock(void) __THROW;
145     
146 /* Read the scheduler lock value. */
147 cyg_ucount32 cyg_scheduler_read_lock(void) __THROW;
148
149 /*---------------------------------------------------------------------------*/
150 /* Thread operations */
151
152 typedef void cyg_thread_entry_t(cyg_addrword_t);
153
154 void cyg_thread_create(
155     cyg_addrword_t      sched_info,             /* scheduling info (eg pri)  */
156     cyg_thread_entry_t  *entry,                 /* entry point function      */
157     cyg_addrword_t      entry_data,             /* entry data                */
158     char                *name,                  /* optional thread name      */
159     void                *stack_base,            /* stack base, NULL = alloc  */
160     cyg_ucount32        stack_size,             /* stack size, 0 = default   */
161     cyg_handle_t        *handle,                /* returned thread handle    */
162     cyg_thread          *thread                 /* put thread here           */
163 ) __THROW;
164     
165 void cyg_thread_exit(void) __THROW;
166
167 /* It may be necessary to arrange for the victim to run for it to disappear */
168 cyg_bool_t cyg_thread_delete(cyg_handle_t thread) __THROW; /* false if NOT deleted */
169
170 void cyg_thread_suspend(cyg_handle_t thread) __THROW;
171
172 void cyg_thread_resume(cyg_handle_t thread) __THROW;
173
174 void cyg_thread_kill(cyg_handle_t thread) __THROW;
175
176 void cyg_thread_release(cyg_handle_t thread) __THROW;    
177     
178 void cyg_thread_yield(void) __THROW;
179
180 cyg_handle_t cyg_thread_self(void) __THROW;
181
182 cyg_handle_t cyg_thread_idle_thread(void) __THROW;
183
184 /* Priority manipulation */
185
186 void cyg_thread_set_priority(cyg_handle_t thread, cyg_priority_t priority ) __THROW;
187
188 cyg_priority_t cyg_thread_get_priority(cyg_handle_t thread) __THROW;              
189 cyg_priority_t cyg_thread_get_current_priority(cyg_handle_t thread) __THROW; 
190
191 /* Deadline scheduling control (optional) */
192
193 void cyg_thread_deadline_wait( 
194     cyg_tick_count_t    start_time,             /* abs earliest start time   */
195     cyg_tick_count_t    run_time,               /* worst case execution time */
196     cyg_tick_count_t    deadline                /* absolute deadline         */
197 ) __THROW; 
198
199 void cyg_thread_delay(cyg_tick_count_t delay) __THROW;
200
201 /* Stack information */
202 cyg_addrword_t cyg_thread_get_stack_base(cyg_handle_t thread) __THROW;
203
204 cyg_uint32 cyg_thread_get_stack_size(cyg_handle_t thread) __THROW;
205
206 #ifdef CYGFUN_KERNEL_THREADS_STACK_MEASUREMENT
207 cyg_uint32 cyg_thread_measure_stack_usage(cyg_handle_t thread) __THROW;
208 #endif
209
210 /*---------------------------------------------------------------------------*/
211 /* Thread enumeration and information                                        */
212     
213 typedef struct
214 {
215     cyg_handle_t        handle;
216     cyg_uint16          id;
217     cyg_uint32          state;
218     char                *name;
219     cyg_priority_t      set_pri;
220     cyg_priority_t      cur_pri;
221     cyg_addrword_t      stack_base;
222     cyg_uint32          stack_size;
223     cyg_uint32          stack_used;
224 } cyg_thread_info;
225     
226 cyg_bool_t cyg_thread_get_next( cyg_handle_t *thread, cyg_uint16 *id ) __THROW;
227
228 cyg_bool_t cyg_thread_get_info( cyg_handle_t thread,
229                                 cyg_uint16 id,
230                                 cyg_thread_info *info ) __THROW;
231
232 cyg_uint16 cyg_thread_get_id( cyg_handle_t thread ) __THROW;
233
234 cyg_handle_t cyg_thread_find( cyg_uint16 id ) __THROW;
235     
236 /*---------------------------------------------------------------------------*/
237 /* Per-thread Data                                                           */
238
239 #ifdef CYGVAR_KERNEL_THREADS_DATA
240
241 cyg_ucount32 cyg_thread_new_data_index(void) __THROW;
242
243 void cyg_thread_free_data_index(cyg_ucount32 index) __THROW;
244
245 CYG_ADDRWORD cyg_thread_get_data(cyg_ucount32 index) __THROW;
246
247 CYG_ADDRWORD *cyg_thread_get_data_ptr(cyg_ucount32 index) __THROW;
248
249 void cyg_thread_set_data(cyg_ucount32 index, CYG_ADDRWORD data) __THROW;
250
251 #endif
252     
253 /*---------------------------------------------------------------------------*/
254 /* Thread destructors                                                        */
255
256 #ifdef CYGPKG_KERNEL_THREADS_DESTRUCTORS
257
258 typedef void (*cyg_thread_destructor_fn)(cyg_addrword_t);
259
260 cyg_bool_t cyg_thread_add_destructor( cyg_thread_destructor_fn fn,
261                                       cyg_addrword_t data ) __THROW;
262 cyg_bool_t cyg_thread_rem_destructor( cyg_thread_destructor_fn fn,
263                                       cyg_addrword_t data ) __THROW;
264 #endif
265     
266 /*---------------------------------------------------------------------------*/
267 /* Exception handling.                                                       */
268
269 /* Replace current exception handler, this may apply to either the           */
270 /* current thread, or to a global exception handler. The exception           */
271 /* number may be ignored, or used to specify a particular handler.           */
272
273 void cyg_exception_set_handler(
274     cyg_code_t                  exception_number,
275     cyg_exception_handler_t     *new_handler,
276     cyg_addrword_t                new_data,
277     cyg_exception_handler_t     **old_handler,
278     cyg_addrword_t                *old_data
279 ) __THROW;
280
281 /* Clear exception hander to default value                                   */
282 void cyg_exception_clear_handler(
283     cyg_code_t                  exception_number
284 ) __THROW;
285     
286 /* Invoke exception handler                                                  */
287 void cyg_exception_call_handler(
288     cyg_handle_t                thread,
289     cyg_code_t                  exception_number,
290     cyg_addrword_t              exception_info
291 ) __THROW;
292
293
294 /*---------------------------------------------------------------------------*/
295 /* Interrupt handling                                                        */
296 typedef void            cyg_VSR_t(void);
297 typedef cyg_uint32      cyg_ISR_t(cyg_vector_t vector, cyg_addrword_t data);
298 typedef void            cyg_DSR_t( cyg_vector_t vector,
299                                    cyg_ucount32 count,
300                                    cyg_addrword_t data);
301
302
303 enum cyg_ISR_results
304 {
305     CYG_ISR_HANDLED  = 1,               /* Interrupt was handled             */
306     CYG_ISR_CALL_DSR = 2                /* Schedule DSR                      */
307 };
308
309 void cyg_interrupt_create(
310     cyg_vector_t        vector,         /* Vector to attach to               */
311     cyg_priority_t      priority,       /* Queue priority                    */
312     cyg_addrword_t      data,           /* Data pointer                      */
313     cyg_ISR_t           *isr,           /* Interrupt Service Routine         */
314     cyg_DSR_t           *dsr,           /* Deferred Service Routine          */
315     cyg_handle_t        *handle,        /* returned handle                   */
316     cyg_interrupt       *intr           /* put interrupt here                */
317 ) __THROW;
318
319 void cyg_interrupt_delete( cyg_handle_t interrupt ) __THROW;
320
321 void cyg_interrupt_attach( cyg_handle_t interrupt ) __THROW;
322
323 void cyg_interrupt_detach( cyg_handle_t interrupt ) __THROW;
324     
325 /* VSR manipulation */
326
327 void cyg_interrupt_get_vsr(
328     cyg_vector_t        vector,         /* vector to get                     */
329     cyg_VSR_t           **vsr           /* vsr got                           */
330 ) __THROW;
331
332 void cyg_interrupt_set_vsr(
333     cyg_vector_t        vector,         /* vector to set                     */
334     cyg_VSR_t           *vsr            /* vsr to set                        */
335 ) __THROW;
336
337 /* CPU level interrupt mask                                                  */
338 void cyg_interrupt_disable(void) __THROW;
339
340 void cyg_interrupt_enable(void) __THROW;
341
342 /* Interrupt controller access                                               */
343 void cyg_interrupt_mask(cyg_vector_t vector) __THROW;
344 void cyg_interrupt_mask_intunsafe(cyg_vector_t vector) __THROW;
345
346 void cyg_interrupt_unmask(cyg_vector_t vector) __THROW;
347 void cyg_interrupt_unmask_intunsafe(cyg_vector_t vector) __THROW;
348
349 void cyg_interrupt_acknowledge(cyg_vector_t vector) __THROW;
350
351 void cyg_interrupt_configure(
352     cyg_vector_t        vector,         /* vector to configure               */
353     cyg_bool_t          level,          /* level or edge triggered           */
354     cyg_bool_t          up              /* rising/faling edge, high/low level*/
355 ) __THROW;
356
357 void cyg_interrupt_set_cpu(
358     cyg_vector_t        vector,         /* vector to control                 */
359     cyg_cpu_t           cpu             /* CPU to set                        */
360 ) __THROW;
361
362 cyg_cpu_t cyg_interrupt_get_cpu(
363     cyg_vector_t        vector          /* vector to control                 */
364 ) __THROW;
365     
366 /*---------------------------------------------------------------------------*/
367 /* Counters, Clocks and Alarms                                               */
368
369 void cyg_counter_create(
370     cyg_handle_t        *handle,        /* returned counter handle           */
371     cyg_counter         *counter        /* put counter here                  */
372 ) __THROW;
373
374 void cyg_counter_delete(cyg_handle_t counter) __THROW;
375
376 /* Return current value of counter                                           */
377 cyg_tick_count_t cyg_counter_current_value(cyg_handle_t counter) __THROW;
378
379 /* Set new current value                                                     */
380 void cyg_counter_set_value(
381     cyg_handle_t        counter,
382     cyg_tick_count_t new_value
383 ) __THROW;
384
385 /* Advance counter by one tick                                               */
386 void cyg_counter_tick(cyg_handle_t counter) __THROW;
387
388 /* Advance counter by multiple ticks                                         */
389 void cyg_counter_multi_tick(cyg_handle_t counter, cyg_tick_count_t _ticks) __THROW;
390
391
392 #define CYG_RESOLUTION_T_MEMBERS  \
393     cyg_uint32  dividend;         \
394     cyg_uint32  divisor;
395
396 typedef struct 
397 {
398     CYG_RESOLUTION_T_MEMBERS
399 } cyg_resolution_t;
400
401 /* Create a clock object                */
402 void cyg_clock_create(
403     cyg_resolution_t    resolution,     /* Initial resolution                */
404     cyg_handle_t        *handle,        /* Returned clock handle             */
405     cyg_clock           *clock          /* put clock here                    */    
406 ) __THROW;
407
408 void cyg_clock_delete(cyg_handle_t clock) __THROW;
409
410 /* convert a clock handle to a counter handle so we can use the              */
411 /* counter API on it.                                                        */
412 void cyg_clock_to_counter(
413     cyg_handle_t        clock,
414     cyg_handle_t        *counter
415 ) __THROW;
416
417 void cyg_clock_set_resolution(
418     cyg_handle_t        clock,
419     cyg_resolution_t    resolution      /* New resolution                    */
420 ) __THROW;
421
422 cyg_resolution_t cyg_clock_get_resolution(cyg_handle_t clock) __THROW;
423
424 /* handle of real time clock                                                 */
425 cyg_handle_t cyg_real_time_clock(void) __THROW;
426
427 /* returns value of real time clock's counter.
428    This is the same as:
429    (cyg_clock_to_counter(cyg_real_time_clock(), &h),
430     cyg_counter_current_value(h))                                            */
431 cyg_tick_count_t cyg_current_time(void) __THROW;
432
433 /* Alarm handler function                                                    */
434 typedef void cyg_alarm_t(cyg_handle_t alarm, cyg_addrword_t data);
435
436 void cyg_alarm_create(
437     cyg_handle_t        counter,        /* Attached to this counter          */
438     cyg_alarm_t         *alarmfn,       /* Call-back function                */
439     cyg_addrword_t      data,           /* Call-back data                    */
440     cyg_handle_t        *handle,        /* Returned alarm object             */
441     cyg_alarm           *alarm          /* put alarm here                    */    
442 ) __THROW;
443
444 /* Disable alarm, detach from counter and invalidate handles                 */
445 void cyg_alarm_delete( cyg_handle_t alarm) __THROW;
446
447 void cyg_alarm_initialize(
448     cyg_handle_t        alarm,
449     cyg_tick_count_t    trigger,        /* Absolute trigger time             */
450     cyg_tick_count_t    interval        /* Relative retrigger interval       */
451 ) __THROW;
452
453 void cyg_alarm_get_times(
454     cyg_handle_t        alarm,
455     cyg_tick_count_t    *trigger,       /* Next trigger time                 */
456     cyg_tick_count_t    *interval       /* Current interval                  */
457 ) __THROW;
458
459 void cyg_alarm_enable( cyg_handle_t alarm ) __THROW;
460
461 void cyg_alarm_disable( cyg_handle_t alarm ) __THROW;
462
463 /*---------------------------------------------------------------------------*/
464 /* Mail boxes                                                                */
465 void cyg_mbox_create(
466     cyg_handle_t        *handle,
467     cyg_mbox            *mbox
468 ) __THROW;
469
470 void cyg_mbox_delete(cyg_handle_t mbox) __THROW;
471
472 void *cyg_mbox_get(cyg_handle_t mbox) __THROW;
473
474 #ifdef CYGFUN_KERNEL_THREADS_TIMER
475 void *cyg_mbox_timed_get(
476     cyg_handle_t mbox,
477     cyg_tick_count_t abstime
478     ) __THROW;
479 #endif
480
481 void *cyg_mbox_tryget(cyg_handle_t mbox) __THROW;
482
483 void *cyg_mbox_peek_item(cyg_handle_t mbox) __THROW;
484
485 #ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT
486 cyg_bool_t cyg_mbox_put(cyg_handle_t mbox, void *item) __THROW;
487 #ifdef CYGFUN_KERNEL_THREADS_TIMER
488 cyg_bool_t cyg_mbox_timed_put(
489     cyg_handle_t mbox,
490     void *item,
491     cyg_tick_count_t abstime
492     ) __THROW;
493 #endif
494 #endif
495
496 cyg_bool_t cyg_mbox_tryput(cyg_handle_t mbox, void *item) __THROW;
497
498 cyg_count32 cyg_mbox_peek(cyg_handle_t mbox) __THROW;
499
500 cyg_bool_t cyg_mbox_waiting_to_get(cyg_handle_t mbox) __THROW;
501
502 cyg_bool_t cyg_mbox_waiting_to_put(cyg_handle_t mbox) __THROW;
503
504
505 /*-----------------------------------------------------------------------*/
506 /* Memory pools                                                          */
507
508 /* These definitions are found in the "memalloc" package as this is      */
509 /* where the implementation lives.                                       */
510
511 #ifdef CYGPKG_MEMALLOC
512 # include <cyg/memalloc/kapi.h>
513 #endif
514
515 /*---------------------------------------------------------------------------*/
516 /* Semaphores                                                                */
517
518 void      cyg_semaphore_init(
519     cyg_sem_t           *sem,            /* Semaphore to init                */
520     cyg_count32         val              /* Initial semaphore value          */
521 ) __THROW;
522
523 void cyg_semaphore_destroy( cyg_sem_t *sem ) __THROW;
524
525 cyg_bool_t cyg_semaphore_wait( cyg_sem_t *sem ) __THROW;
526
527 #ifdef CYGFUN_KERNEL_THREADS_TIMER
528 cyg_bool_t cyg_semaphore_timed_wait(
529     cyg_sem_t          *sem,
530     cyg_tick_count_t   abstime
531     ) __THROW;
532 #endif
533
534 cyg_bool_t cyg_semaphore_trywait( cyg_sem_t *sem ) __THROW;
535
536 void cyg_semaphore_post( cyg_sem_t *sem ) __THROW;
537
538 void cyg_semaphore_peek( cyg_sem_t *sem, cyg_count32 *val ) __THROW;
539
540 /*---------------------------------------------------------------------------*/
541 /* Flags                                                                     */
542
543 typedef cyg_uint32 cyg_flag_value_t;
544 typedef cyg_uint8  cyg_flag_mode_t;
545 #define CYG_FLAG_WAITMODE_AND ((cyg_flag_mode_t)0) /* all bits must be set */
546 #define CYG_FLAG_WAITMODE_OR  ((cyg_flag_mode_t)2) /* any bit must be set  */
547 #define CYG_FLAG_WAITMODE_CLR ((cyg_flag_mode_t)1) /* clear when satisfied */
548
549 void cyg_flag_init(
550     cyg_flag_t        *flag             /* Flag to init                      */
551 ) __THROW;
552
553 void cyg_flag_destroy( cyg_flag_t *flag ) __THROW;
554
555 /* bitwise-or in the bits in value; awaken any waiting tasks whose
556    condition is now satisfied */
557 void cyg_flag_setbits( cyg_flag_t *flag, cyg_flag_value_t value) __THROW;
558
559 /* bitwise-and with the the bits in value; this clears the bits which
560    are not set in value.  No waiting task can be awoken. */
561 void cyg_flag_maskbits( cyg_flag_t *flag, cyg_flag_value_t value) __THROW;
562
563 /* wait for the flag value to match the pattern, according to the mode.
564    If mode includes CLR, set the flag value to zero when
565    our pattern is matched.  The return value is that which matched
566    the request, or zero for an error/timeout return.
567    Value must not itself be zero. */
568 cyg_flag_value_t cyg_flag_wait( cyg_flag_t        *flag,
569                                 cyg_flag_value_t   pattern, 
570                                 cyg_flag_mode_t    mode ) __THROW;
571
572 #ifdef CYGFUN_KERNEL_THREADS_TIMER
573 cyg_flag_value_t cyg_flag_timed_wait( cyg_flag_t        *flag,
574                                       cyg_flag_value_t   pattern, 
575                                       cyg_flag_mode_t    mode,
576                                       cyg_tick_count_t   abstime ) __THROW;
577
578 #endif
579
580 cyg_flag_value_t cyg_flag_poll( cyg_flag_t         *flag,
581                                 cyg_flag_value_t    pattern, 
582                                 cyg_flag_mode_t     mode ) __THROW;
583
584 cyg_flag_value_t cyg_flag_peek( cyg_flag_t *flag ) __THROW;
585
586 cyg_bool_t cyg_flag_waiting( cyg_flag_t *flag ) __THROW;
587
588 /*---------------------------------------------------------------------------*/
589 /* Mutex                                                                     */
590
591 #ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC
592 enum cyg_mutex_protocol
593 {
594   CYG_MUTEX_NONE = 0,                   // no inversion protocol
595   CYG_MUTEX_INHERIT,                    // priority inheritance protocol
596   CYG_MUTEX_CEILING                     // priority ceiling protocol
597 };
598 #endif
599
600 void cyg_mutex_init(
601     cyg_mutex_t        *mutex          /* Mutex to init                      */
602 ) __THROW;
603
604 void cyg_mutex_destroy( cyg_mutex_t *mutex ) __THROW;
605
606 cyg_bool_t cyg_mutex_lock( cyg_mutex_t *mutex ) __THROW;
607
608 cyg_bool_t cyg_mutex_trylock( cyg_mutex_t *mutex ) __THROW;
609
610 void cyg_mutex_unlock( cyg_mutex_t *mutex ) __THROW;
611
612 void cyg_mutex_release( cyg_mutex_t *mutex ) __THROW;
613
614 #ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_CEILING
615 void cyg_mutex_set_ceiling( cyg_mutex_t *mutex, cyg_priority_t priority ) __THROW;
616 #endif
617
618 #ifdef CYGSEM_KERNEL_SYNCH_MUTEX_PRIORITY_INVERSION_PROTOCOL_DYNAMIC
619 void cyg_mutex_set_protocol ( cyg_mutex_t *mutex, enum cyg_mutex_protocol protocol ) __THROW;
620 #endif
621
622 /*---------------------------------------------------------------------------*/
623 /* Condition Variables                                                       */
624
625 void cyg_cond_init(
626     cyg_cond_t          *cond,          /* condition variable to init        */
627     cyg_mutex_t         *mutex          /* associated mutex                  */
628 ) __THROW;
629
630 void cyg_cond_destroy( cyg_cond_t *cond ) __THROW;
631
632 cyg_bool_t cyg_cond_wait( cyg_cond_t *cond ) __THROW;
633
634 void cyg_cond_signal( cyg_cond_t *cond ) __THROW;
635
636 void cyg_cond_broadcast( cyg_cond_t *cond ) __THROW;
637
638 #ifdef CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT
639 cyg_bool_t cyg_cond_timed_wait(
640     cyg_cond_t        *cond,
641     cyg_tick_count_t  abstime
642     ) __THROW;
643 #endif
644
645 /*---------------------------------------------------------------------------*/
646 /* Spinlocks                                                                 */
647
648 void cyg_spinlock_init(
649     cyg_spinlock_t      *lock,          /* spinlock to initialize            */
650     cyg_bool_t          locked          /* init locked or unlocked           */
651 ) __THROW;
652
653 void cyg_spinlock_destroy( cyg_spinlock_t *lock ) __THROW;
654
655 void cyg_spinlock_spin( cyg_spinlock_t *lock ) __THROW;
656
657 void cyg_spinlock_clear( cyg_spinlock_t *lock ) __THROW;
658
659 cyg_bool_t cyg_spinlock_try( cyg_spinlock_t *lock ) __THROW;
660
661 cyg_bool_t cyg_spinlock_test( cyg_spinlock_t *lock ) __THROW;
662
663 void cyg_spinlock_spin_intsave( cyg_spinlock_t *lock,
664                                 cyg_addrword_t *istate ) __THROW;
665
666 void cyg_spinlock_clear_intsave( cyg_spinlock_t *lock,
667                                  cyg_addrword_t istate ) __THROW;
668
669 /*---------------------------------------------------------------------------*/
670 #ifdef __cplusplus
671 }
672 #endif
673
674 /*---------------------------------------------------------------------------*/
675
676 #include <cyg/kernel/kapidata.h>
677
678 /*---------------------------------------------------------------------------*/
679 /* EOF kapi.h                                                                */
680 #endif /* CYGFUN_KERNEL_API_C   */
681 #endif /* CYGONCE_KERNEL_KAPI_H */