Mercurial > ecos
annotate packages/kernel/current/include/kapi.h @ 8:ece80412419a ecos-sw-1999-05-21
Merge from eCos master repository on 1999-05-21-22:05:54-BST
| author | jlarmour |
|---|---|
| date | Fri, 21 May 1999 15:09:30 +0000 |
| parents | 443894e2e912 |
| children | d3fbcdfa1b2f |
| rev | line source |
|---|---|
| 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 | |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
147 /* It may be necessary to arrange for the victim to run for it to disappear */ |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
148 cyg_bool_t cyg_thread_delete(cyg_handle_t thread); /* false if NOT deleted */ |
| 0 | 149 |
| 150 void cyg_thread_suspend(cyg_handle_t thread); | |
| 151 | |
| 152 void cyg_thread_resume(cyg_handle_t thread); | |
| 153 | |
| 154 void cyg_thread_kill(cyg_handle_t thread); | |
| 155 | |
| 2 | 156 void cyg_thread_release(cyg_handle_t thread); |
| 0 | 157 |
| 158 void cyg_thread_yield(void); | |
| 159 | |
| 160 cyg_handle_t cyg_thread_self(void); | |
| 161 | |
| 162 | |
| 163 /* Priority manipulation */ | |
| 164 | |
| 165 void cyg_thread_set_priority(cyg_handle_t thread, cyg_priority_t priority ); | |
| 166 | |
| 167 cyg_priority_t cyg_thread_get_priority(cyg_handle_t thread); | |
| 168 | |
| 169 /* Deadline scheduling control (optional) */ | |
| 170 | |
| 171 void cyg_thread_deadline_wait( | |
| 172 cyg_tick_count_t start_time, /* abs earliest start time */ | |
| 173 cyg_tick_count_t run_time, /* worst case execution time */ | |
| 174 cyg_tick_count_t deadline /* absolute deadline */ | |
| 175 ); | |
| 176 | |
| 177 void cyg_thread_delay(cyg_tick_count_t delay); | |
| 178 | |
| 179 /*---------------------------------------------------------------------------*/ | |
| 2 | 180 /* Per-thread Data */ |
| 181 | |
| 182 #ifdef CYGVAR_KERNEL_THREADS_DATA | |
| 183 | |
| 184 cyg_ucount32 cyg_thread_new_data_index(void); | |
| 185 | |
| 186 void cyg_thread_free_data_index(cyg_ucount32 index); | |
| 187 | |
| 188 CYG_ADDRWORD cyg_thread_get_data(cyg_ucount32 index); | |
| 189 | |
| 190 CYG_ADDRWORD *cyg_thread_get_data_ptr(cyg_ucount32 index); | |
| 191 | |
| 192 void cyg_thread_set_data(cyg_ucount32 index, CYG_ADDRWORD data); | |
| 193 | |
| 194 #endif | |
| 195 | |
| 196 /*---------------------------------------------------------------------------*/ | |
| 0 | 197 /* Exception handling. */ |
| 198 | |
| 199 /* Replace current exception handler, this may apply to either the */ | |
| 200 /* current thread, or to a global exception handler. The exception */ | |
| 201 /* number may be ignored, or used to specify a particular handler. */ | |
| 202 | |
| 203 void cyg_exception_set_handler( | |
| 204 cyg_code_t exception_number, | |
| 205 cyg_exception_handler_t *new_handler, | |
| 206 cyg_addrword_t new_data, | |
| 207 cyg_exception_handler_t **old_handler, | |
| 208 cyg_addrword_t *old_data | |
| 209 ); | |
| 210 | |
| 211 /* Clear exception hander to default value */ | |
| 212 void cyg_exception_clear_handler( | |
| 213 cyg_code_t exception_number | |
| 214 ); | |
| 215 | |
| 216 /* Invoke exception handler */ | |
| 217 void cyg_exception_call_handler( | |
| 218 cyg_handle_t thread, | |
| 219 cyg_code_t exception_number, | |
| 2 | 220 cyg_addrword_t exception_info |
| 0 | 221 ); |
| 222 | |
| 223 | |
| 224 /*---------------------------------------------------------------------------*/ | |
| 225 /* Interrupt handling */ | |
| 226 typedef void cyg_VSR_t(void); | |
| 227 typedef cyg_uint32 cyg_ISR_t(cyg_vector_t vector, cyg_addrword_t data); | |
| 228 typedef void cyg_DSR_t( | |
| 229 cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data); | |
| 230 | |
| 231 | |
| 232 enum cyg_ISR_results | |
| 233 { | |
| 234 CYG_ISR_HANDLED = 1, /* Interrupt was handled */ | |
| 235 CYG_ISR_CALL_DSR = 2 /* Schedule DSR */ | |
| 236 }; | |
| 237 | |
| 238 void cyg_interrupt_create( | |
| 239 cyg_vector_t vector, /* Vector to attach to */ | |
| 240 cyg_priority_t priority, /* Queue priority */ | |
| 2 | 241 cyg_addrword_t data, /* Data pointer */ |
| 0 | 242 cyg_ISR_t *isr, /* Interrupt Service Routine */ |
| 243 cyg_DSR_t *dsr, /* Deferred Service Routine */ | |
| 244 cyg_handle_t *handle, /* returned handle */ | |
| 245 cyg_interrupt *intr /* put interrupt here */ | |
| 246 ); | |
| 247 | |
| 248 void cyg_interrupt_delete( cyg_handle_t interrupt ); | |
| 249 | |
| 250 void cyg_interrupt_attach( cyg_handle_t interrupt ); | |
| 251 | |
| 252 void cyg_interrupt_detach( cyg_handle_t interrupt ); | |
| 253 | |
| 254 /* VSR manipulation */ | |
| 255 | |
| 256 void cyg_interrupt_get_vsr( | |
| 257 cyg_vector_t vector, /* vector to get */ | |
| 258 cyg_VSR_t **vsr /* vsr got */ | |
| 259 ); | |
| 260 | |
| 261 void cyg_interrupt_set_vsr( | |
| 262 cyg_vector_t vector, /* vector to set */ | |
| 263 cyg_VSR_t *vsr /* vsr to set */ | |
| 264 ); | |
| 265 | |
| 266 /* CPU level interrupt mask */ | |
| 267 void cyg_interrupt_disable(void); | |
| 268 | |
| 269 void cyg_interrupt_enable(void); | |
| 270 | |
| 271 /* Interrupt controller access */ | |
| 272 void cyg_interrupt_mask(cyg_vector_t vector); | |
| 273 | |
| 274 void cyg_interrupt_unmask(cyg_vector_t vector); | |
| 275 | |
| 276 void cyg_interrupt_acknowledge(cyg_vector_t vector); | |
| 277 | |
| 278 void cyg_interrupt_configure( | |
| 279 cyg_vector_t vector, /* vector to configure */ | |
| 280 cyg_bool_t level, /* level or edge triggered */ | |
| 281 cyg_bool_t up /* rising/faling edge, high/low level*/ | |
| 282 ); | |
| 283 | |
| 284 /*---------------------------------------------------------------------------*/ | |
| 285 /* Counters, Clocks and Alarms */ | |
| 286 | |
| 287 void cyg_counter_create( | |
| 288 cyg_handle_t *handle, /* returned counter handle */ | |
| 289 cyg_counter *counter /* put counter here */ | |
| 290 ); | |
| 291 | |
| 292 void cyg_counter_delete(cyg_handle_t counter); | |
| 293 | |
| 294 /* Return current value of counter */ | |
| 295 cyg_tick_count_t cyg_counter_current_value(cyg_handle_t counter); | |
| 296 | |
| 297 /* Set new current value */ | |
| 298 void cyg_counter_set_value( | |
| 299 cyg_handle_t counter, | |
| 300 cyg_tick_count_t new_value | |
| 301 ); | |
| 302 | |
| 303 /* Advance counter by one tick */ | |
| 304 void cyg_counter_tick(cyg_handle_t counter); | |
| 305 | |
| 306 | |
| 307 typedef struct | |
| 308 { | |
| 309 cyg_uint32 dividend; | |
| 310 cyg_uint32 divisor; | |
| 311 } cyg_resolution_t; | |
| 312 | |
| 313 /* Create a clock object */ | |
| 314 void cyg_clock_create( | |
| 315 cyg_resolution_t resolution, /* Initial resolution */ | |
| 316 cyg_handle_t *handle, /* Returned clock handle */ | |
| 317 cyg_clock *clock /* put clock here */ | |
| 318 ); | |
| 319 | |
| 320 void cyg_clock_delete(cyg_handle_t clock); | |
| 321 | |
| 322 /* convert a clock handle to a counter handle so we can use the */ | |
| 323 /* counter API on it. */ | |
| 324 void cyg_clock_to_counter( | |
| 325 cyg_handle_t clock, | |
| 326 cyg_handle_t *counter | |
| 327 ); | |
| 328 | |
| 329 void cyg_clock_set_resolution( | |
| 330 cyg_handle_t clock, | |
| 331 cyg_resolution_t resolution /* New resolution */ | |
| 332 ); | |
| 333 | |
| 334 cyg_resolution_t cyg_clock_get_resolution(cyg_handle_t clock); | |
| 335 | |
| 336 /* handle of real time clock */ | |
| 337 cyg_handle_t cyg_real_time_clock(void); | |
| 338 | |
| 339 /* returns value of real time clock's counter. | |
| 340 This is the same as: | |
| 341 (cyg_clock_to_counter(cyg_real_time_clock(), &h), | |
| 342 cyg_counter_current_value(h)) */ | |
| 343 cyg_tick_count_t cyg_current_time(void); | |
| 344 | |
| 345 /* Alarm handler function */ | |
| 346 typedef void cyg_alarm_t(cyg_handle_t alarm, cyg_addrword_t data); | |
| 347 | |
| 348 void cyg_alarm_create( | |
| 349 cyg_handle_t counter, /* Attached to this counter */ | |
| 350 cyg_alarm_t *alarmfn, /* Call-back function */ | |
| 2 | 351 cyg_addrword_t data, /* Call-back data */ |
| 0 | 352 cyg_handle_t *handle, /* Returned alarm object */ |
| 353 cyg_alarm *alarm /* put alarm here */ | |
| 354 ); | |
| 355 | |
| 356 /* Disable alarm, detach from counter and invalidate handles */ | |
| 357 void cyg_alarm_delete( cyg_handle_t alarm); | |
| 358 | |
| 359 void cyg_alarm_initialize( | |
| 360 cyg_handle_t alarm, | |
| 361 cyg_tick_count_t trigger, /* Absolute trigger time */ | |
| 362 cyg_tick_count_t interval /* Relative retrigger interval */ | |
| 363 ); | |
| 364 | |
| 365 void cyg_alarm_enable( cyg_handle_t alarm ); | |
| 366 | |
| 367 void cyg_alarm_disable( cyg_handle_t alarm ); | |
| 368 | |
| 369 /*---------------------------------------------------------------------------*/ | |
| 370 /* Mail boxes */ | |
| 371 void cyg_mbox_create( | |
| 372 cyg_handle_t *handle, | |
| 373 cyg_mbox *mbox | |
| 374 ); | |
| 375 | |
| 376 void cyg_mbox_delete(cyg_handle_t mbox); | |
| 377 | |
| 378 void *cyg_mbox_get(cyg_handle_t mbox); | |
| 379 | |
| 380 #ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 381 void *cyg_mbox_timed_get( | |
| 382 cyg_handle_t mbox, | |
| 383 cyg_tick_count_t abstime | |
| 384 ); | |
| 385 #endif | |
| 386 | |
| 387 void *cyg_mbox_tryget(cyg_handle_t mbox); | |
| 388 | |
| 389 void *cyg_mbox_peek_item(cyg_handle_t mbox); | |
| 390 | |
| 391 #ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT | |
| 392 cyg_bool_t cyg_mbox_put(cyg_handle_t mbox, void *item); | |
| 393 #ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 394 cyg_bool_t cyg_mbox_timed_put( | |
| 395 cyg_handle_t mbox, | |
| 396 void *item, | |
| 397 cyg_tick_count_t abstime | |
| 398 ); | |
| 399 #endif | |
| 400 #endif | |
| 401 | |
| 402 cyg_bool_t cyg_mbox_tryput(cyg_handle_t mbox, void *item); | |
| 403 | |
| 404 cyg_count32 cyg_mbox_peek(cyg_handle_t mbox); | |
| 405 | |
| 406 cyg_bool_t cyg_mbox_waiting_to_get(cyg_handle_t mbox); | |
| 407 | |
| 408 cyg_bool_t cyg_mbox_waiting_to_put(cyg_handle_t mbox); | |
| 409 | |
| 410 | |
| 411 /*-----------------------------------------------------------------------*/ | |
| 412 /* Memory pools */ | |
| 413 | |
| 414 /* There are two sorts of memory pools. A variable size memory pool | |
| 415 is for allocating blocks of any size. A fixed size memory pool, has | |
| 416 the block size specified when the pool is created, and only provides | |
| 417 blocks of that size. */ | |
| 418 | |
| 419 /* Create a variable size memory pool */ | |
| 420 void cyg_mempool_var_create( | |
| 421 void *base, /* base of memory to use for pool */ | |
| 422 cyg_int32 size, /* size of memory in bytes */ | |
| 423 cyg_handle_t *handle, /* returned handle of memory pool */ | |
| 424 cyg_mempool_var *var /* space to put pool structure in */ | |
| 425 ); | |
| 426 | |
| 427 /* Delete variable size memory pool */ | |
| 428 void cyg_mempool_var_delete(cyg_handle_t varpool); | |
| 429 | |
| 430 /* Allocates a block of length size. This waits if the memory is not | |
| 431 currently available. */ | |
| 432 void *cyg_mempool_var_alloc(cyg_handle_t varpool, cyg_int32 size); | |
| 433 | |
| 434 /* Allocates a block of length size. This waits until abstime, | |
| 435 if the memory is not already available. NULL is returned if | |
| 436 no memory is available. */ | |
| 437 void *cyg_mempool_var_timed_alloc( | |
| 438 cyg_handle_t varpool, | |
| 439 cyg_int32 size, | |
| 440 cyg_tick_count_t abstime); | |
| 441 | |
| 442 /* Allocates a block of length size. NULL is returned if no memory is | |
| 443 available. */ | |
| 444 void *cyg_mempool_var_try_alloc( | |
| 445 cyg_handle_t varpool, | |
| 446 cyg_int32 size); | |
| 447 | |
| 448 /* Frees memory back into variable size pool. */ | |
| 449 void cyg_mempool_var_free(cyg_handle_t varpool, void *p); | |
| 450 | |
| 451 /* Returns true if there are any threads waiting for memory in the | |
| 452 given memory pool. */ | |
| 453 cyg_bool_t cyg_mempool_var_waiting(cyg_handle_t varpool); | |
| 454 | |
| 455 typedef struct { | |
| 456 cyg_int32 totalmem; | |
| 457 cyg_int32 freemem; | |
| 458 void *base; | |
| 459 cyg_int32 size; | |
| 460 cyg_int32 blocksize; | |
| 461 cyg_int32 maxfree; // The largest free block | |
| 462 } cyg_mempool_info; | |
| 463 | |
| 464 /* Puts information about a variable memory pool into the structure | |
| 465 provided. */ | |
| 466 void cyg_mempool_var_get_info(cyg_handle_t varpool, cyg_mempool_info *info); | |
| 467 | |
| 468 /* Create a fixed size memory pool */ | |
| 469 void cyg_mempool_fix_create( | |
| 470 void *base, // base of memory to use for pool | |
| 471 cyg_int32 size, // size of memory in byte | |
| 472 cyg_int32 blocksize, // size of allocation in bytes | |
| 473 cyg_handle_t *handle, // handle of memory pool | |
| 474 cyg_mempool_fix *fix // space to put pool structure in | |
| 475 ); | |
| 476 | |
| 477 /* Delete fixed size memory pool */ | |
| 478 void cyg_mempool_fix_delete(cyg_handle_t fixpool); | |
| 479 | |
| 480 /* Allocates a block. This waits if the memory is not | |
| 481 currently available. */ | |
| 482 void *cyg_mempool_fix_alloc(cyg_handle_t fixpool); | |
| 483 | |
| 484 /* Allocates a block. This waits until abstime, if the memory | |
| 485 is not already available. NULL is returned if no memory is | |
| 486 available. */ | |
| 487 void *cyg_mempool_fix_timed_alloc( | |
| 488 cyg_handle_t fixpool, | |
| 489 cyg_tick_count_t abstime); | |
| 490 | |
| 491 /* Allocates a block. NULL is returned if no memory is available. */ | |
| 492 void *cyg_mempool_fix_try_alloc(cyg_handle_t fixpool); | |
| 493 | |
| 494 /* Frees memory back into fixed size pool. */ | |
| 495 void cyg_mempool_fix_free(cyg_handle_t fixpool, void *p); | |
| 496 | |
| 497 /* Returns true if there are any threads waiting for memory in the | |
| 498 given memory pool. */ | |
| 499 cyg_bool_t cyg_mempool_fix_waiting(cyg_handle_t fixpool); | |
| 500 | |
| 501 /* Puts information about a variable memory pool into the structure | |
| 502 provided. */ | |
| 503 void cyg_mempool_fix_get_info(cyg_handle_t fixpool, cyg_mempool_info *info); | |
| 504 | |
| 505 /*---------------------------------------------------------------------------*/ | |
| 506 /* Semaphores */ | |
| 507 | |
| 508 void cyg_semaphore_init( | |
| 509 cyg_sem_t *sem, /* Semaphore to init */ | |
| 2 | 510 cyg_count32 val /* Initial semaphore value */ |
| 0 | 511 ); |
| 512 | |
| 513 void cyg_semaphore_destroy( cyg_sem_t *sem ); | |
| 514 | |
| 515 void cyg_semaphore_wait( cyg_sem_t *sem ); | |
| 516 | |
| 517 #ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 518 cyg_bool_t cyg_semaphore_timed_wait( | |
| 519 cyg_sem_t *sem, | |
| 520 cyg_tick_count_t abstime | |
| 521 ); | |
| 522 #endif | |
| 523 | |
| 524 cyg_bool_t cyg_semaphore_trywait( cyg_sem_t *sem ); | |
| 525 | |
| 526 void cyg_semaphore_post( cyg_sem_t *sem ); | |
| 527 | |
| 2 | 528 void cyg_semaphore_peek( cyg_sem_t *sem, cyg_count32 *val ); |
| 0 | 529 |
| 530 /*---------------------------------------------------------------------------*/ | |
| 531 /* Flags */ | |
| 532 | |
| 533 typedef cyg_uint32 cyg_flag_value_t; | |
| 534 typedef cyg_uint8 cyg_flag_mode_t; | |
| 535 #define CYG_FLAG_WAITMODE_AND ((cyg_flag_mode_t)0) /* all bits must be set */ | |
| 536 #define CYG_FLAG_WAITMODE_OR ((cyg_flag_mode_t)2) /* any bit must be set */ | |
| 537 #define CYG_FLAG_WAITMODE_CLR ((cyg_flag_mode_t)1) /* clear when satisfied */ | |
| 538 | |
| 539 void cyg_flag_init( | |
| 540 cyg_flag_t *flag /* Flag to init */ | |
| 541 ); | |
| 542 | |
| 543 void cyg_flag_destroy( cyg_flag_t *flag ); | |
| 544 | |
| 545 /* bitwise-or in the bits in value; awaken any waiting tasks whose | |
| 546 condition is now satisfied */ | |
| 547 void cyg_flag_setbits( cyg_flag_t *flag, cyg_flag_value_t value); | |
| 548 | |
| 549 /* bitwise-and with the the bits in value; this clears the bits which | |
| 550 are not set in value. No waiting task can be awoken. */ | |
| 551 void cyg_flag_maskbits( cyg_flag_t *flag, cyg_flag_value_t value); | |
| 552 | |
| 553 /* wait for the flag value to match the pattern, according to the mode. | |
| 554 If mode includes CLR, set the flag value to zero when | |
| 555 our pattern is matched. The return value is that which matched | |
| 556 the request, or zero for an error/timeout return. | |
| 557 Value must not itself be zero. */ | |
| 558 cyg_flag_value_t cyg_flag_wait( cyg_flag_t *flag, | |
| 559 cyg_flag_value_t pattern, | |
| 560 cyg_flag_mode_t mode ); | |
| 561 | |
| 562 #ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 563 cyg_flag_value_t cyg_flag_timed_wait( cyg_flag_t *flag, | |
| 564 cyg_flag_value_t pattern, | |
| 565 cyg_flag_mode_t mode, | |
| 566 cyg_tick_count_t abstime ); | |
| 567 | |
| 568 #endif | |
| 569 | |
| 570 cyg_flag_value_t cyg_flag_poll( cyg_flag_t *flag, | |
| 571 cyg_flag_value_t pattern, | |
| 572 cyg_flag_mode_t mode ); | |
| 573 | |
| 574 cyg_flag_value_t cyg_flag_peek( cyg_flag_t *flag ); | |
| 575 | |
| 576 cyg_bool_t cyg_flag_waiting( cyg_flag_t *flag ); | |
| 577 | |
| 578 /*---------------------------------------------------------------------------*/ | |
| 579 /* Mutex */ | |
| 580 | |
| 581 void cyg_mutex_init( | |
| 582 cyg_mutex_t *mutex /* Mutex to init */ | |
| 583 ); | |
| 584 | |
| 585 void cyg_mutex_destroy( cyg_mutex_t *mutex ); | |
| 586 | |
| 2 | 587 cyg_bool_t cyg_mutex_lock( cyg_mutex_t *mutex ); |
| 0 | 588 |
| 589 cyg_bool_t cyg_mutex_trylock( cyg_mutex_t *mutex ); | |
| 590 | |
| 591 void cyg_mutex_unlock( cyg_mutex_t *mutex ); | |
| 592 | |
| 2 | 593 void cyg_mutex_release( cyg_mutex_t *mutex ); |
| 594 | |
| 0 | 595 /*---------------------------------------------------------------------------*/ |
| 596 /* Condition Variables */ | |
| 597 | |
| 598 void cyg_cond_init( | |
| 599 cyg_cond_t *cond, /* condition variable to init */ | |
| 600 cyg_mutex_t *mutex /* associated mutex */ | |
| 601 ); | |
| 602 | |
| 603 void cyg_cond_destroy( cyg_cond_t *cond ); | |
| 604 | |
| 605 void cyg_cond_wait( cyg_cond_t *cond ); | |
| 606 | |
| 607 void cyg_cond_signal( cyg_cond_t *cond ); | |
| 608 | |
| 609 void cyg_cond_broadcast( cyg_cond_t *cond ); | |
| 610 | |
| 611 #ifdef CYGMFN_KERNEL_SYNCH_CONDVAR_TIMED_WAIT | |
| 612 cyg_bool_t cyg_cond_timed_wait( | |
| 613 cyg_cond_t *cond, | |
| 614 cyg_tick_count_t abstime | |
| 615 ); | |
| 616 #endif | |
| 617 | |
| 618 | |
| 619 #ifdef __cplusplus | |
| 620 } | |
| 621 #endif | |
| 622 | |
| 623 #include <cyg/kernel/kapidata.h> | |
| 624 | |
| 625 /*---------------------------------------------------------------------------*/ | |
| 626 /* EOF kapi.h */ | |
| 627 #endif /* CYGFUN_KERNEL_API_C */ | |
| 628 #endif /* CYGONCE_KERNEL_KAPI_H */ |
