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