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