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