comparison packages/kernel/current/include/kapi.h @ 115:6ed91473a1cd ecos-sw-2000-08-21

Merge from eCos master repository on 2000-08-21-22:40:54-BST
author jlarmour
date Fri, 25 Aug 2000 17:32:38 +0000
parents 5a0cc6c243a9
children d397fc472bcf
comparison
equal deleted inserted replaced
114:5ad2b71d525e 115:6ed91473a1cd
96 typedef struct cyg_alarm cyg_alarm; 96 typedef struct cyg_alarm cyg_alarm;
97 97
98 struct cyg_mbox; 98 struct cyg_mbox;
99 typedef struct cyg_mbox cyg_mbox; 99 typedef struct cyg_mbox cyg_mbox;
100 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; 101 struct cyg_sem_t;
108 typedef struct cyg_sem_t cyg_sem_t; 102 typedef struct cyg_sem_t cyg_sem_t;
109 103
110 struct cyg_flag_t; 104 struct cyg_flag_t;
111 typedef struct cyg_flag_t cyg_flag_t; 105 typedef struct cyg_flag_t cyg_flag_t;
426 420
427 421
428 /*-----------------------------------------------------------------------*/ 422 /*-----------------------------------------------------------------------*/
429 /* Memory pools */ 423 /* Memory pools */
430 424
431 /* There are two sorts of memory pools. A variable size memory pool 425 /* These definitions are found in the "memalloc" package as this is */
432 is for allocating blocks of any size. A fixed size memory pool, has 426 /* where the implementation lives. */
433 the block size specified when the pool is created, and only provides 427
434 blocks of that size. */ 428 #include <cyg/memalloc/kapi.h>
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 429
522 /*---------------------------------------------------------------------------*/ 430 /*---------------------------------------------------------------------------*/
523 /* Semaphores */ 431 /* Semaphores */
524 432
525 void cyg_semaphore_init( 433 void cyg_semaphore_init(
527 cyg_count32 val /* Initial semaphore value */ 435 cyg_count32 val /* Initial semaphore value */
528 ); 436 );
529 437
530 void cyg_semaphore_destroy( cyg_sem_t *sem ); 438 void cyg_semaphore_destroy( cyg_sem_t *sem );
531 439
532 void cyg_semaphore_wait( cyg_sem_t *sem ); 440 cyg_bool_t cyg_semaphore_wait( cyg_sem_t *sem );
533 441
534 #ifdef CYGFUN_KERNEL_THREADS_TIMER 442 #ifdef CYGFUN_KERNEL_THREADS_TIMER
535 cyg_bool_t cyg_semaphore_timed_wait( 443 cyg_bool_t cyg_semaphore_timed_wait(
536 cyg_sem_t *sem, 444 cyg_sem_t *sem,
537 cyg_tick_count_t abstime 445 cyg_tick_count_t abstime
617 cyg_mutex_t *mutex /* associated mutex */ 525 cyg_mutex_t *mutex /* associated mutex */
618 ); 526 );
619 527
620 void cyg_cond_destroy( cyg_cond_t *cond ); 528 void cyg_cond_destroy( cyg_cond_t *cond );
621 529
622 void cyg_cond_wait( cyg_cond_t *cond ); 530 cyg_bool_t cyg_cond_wait( cyg_cond_t *cond );
623 531
624 void cyg_cond_signal( cyg_cond_t *cond ); 532 void cyg_cond_signal( cyg_cond_t *cond );
625 533
626 void cyg_cond_broadcast( cyg_cond_t *cond ); 534 void cyg_cond_broadcast( cyg_cond_t *cond );
627 535