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