Mercurial > ecos
comparison packages/services/memalloc/common/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 | |
| children | e0c0827131d1 |
comparison
equal
deleted
inserted
replaced
| 114:5ad2b71d525e | 115:6ed91473a1cd |
|---|---|
| 1 #ifndef CYGONCE_MEMALLOC_KAPI_H | |
| 2 #define CYGONCE_MEMALLOC_KAPI_H | |
| 3 | |
| 4 /*========================================================================== | |
| 5 // | |
| 6 // kapi.h | |
| 7 // | |
| 8 // Memory allocator portion of kernel C API | |
| 9 // | |
| 10 //========================================================================== | |
| 11 //####COPYRIGHTBEGIN#### | |
| 12 // | |
| 13 // ------------------------------------------- | |
| 14 // The contents of this file are subject to the Red Hat eCos Public License | |
| 15 // Version 1.1 (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://www.redhat.com/ | |
| 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 Configurable Operating System, | |
| 25 // released September 30, 1998. | |
| 26 // | |
| 27 // The Initial Developer of the Original Code is Red Hat. | |
| 28 // Portions created by Red Hat are | |
| 29 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 30 // All Rights Reserved. | |
| 31 // ------------------------------------------- | |
| 32 // | |
| 33 //####COPYRIGHTEND#### | |
| 34 //========================================================================== | |
| 35 //#####DESCRIPTIONBEGIN#### | |
| 36 // | |
| 37 // Author(s): jlarmour | |
| 38 // Contributors: | |
| 39 // Date: 2000-06-12 | |
| 40 // Purpose: Memory allocator portion of kernel C API | |
| 41 // Description: This is intentionally only to be included from | |
| 42 // <cyg/kernel/kapi.h> | |
| 43 // Usage: This file should not be used directly - instead it should | |
| 44 // be used via <cyg/kernel/kapi.h> | |
| 45 // | |
| 46 // | |
| 47 //####DESCRIPTIONEND#### | |
| 48 // | |
| 49 //========================================================================*/ | |
| 50 | |
| 51 /* CONFIGURATION */ | |
| 52 | |
| 53 #include <pkgconf/memalloc.h> | |
| 54 | |
| 55 /* TYPE DEFINITIONS */ | |
| 56 | |
| 57 struct cyg_mempool_var; | |
| 58 typedef struct cyg_mempool_var cyg_mempool_var; | |
| 59 | |
| 60 struct cyg_mempool_fix; | |
| 61 typedef struct cyg_mempool_fix cyg_mempool_fix; | |
| 62 | |
| 63 /*-----------------------------------------------------------------------*/ | |
| 64 /* Memory pools */ | |
| 65 | |
| 66 /* There are two sorts of memory pools. A variable size memory pool | |
| 67 is for allocating blocks of any size. A fixed size memory pool, has | |
| 68 the block size specified when the pool is created, and only provides | |
| 69 blocks of that size. */ | |
| 70 | |
| 71 /* Create a variable size memory pool */ | |
| 72 void cyg_mempool_var_create( | |
| 73 void *base, /* base of memory to use for pool */ | |
| 74 cyg_int32 size, /* size of memory in bytes */ | |
| 75 cyg_handle_t *handle, /* returned handle of memory pool */ | |
| 76 cyg_mempool_var *var /* space to put pool structure in */ | |
| 77 ); | |
| 78 | |
| 79 /* Delete variable size memory pool */ | |
| 80 void cyg_mempool_var_delete(cyg_handle_t varpool); | |
| 81 | |
| 82 #ifdef CYGSEM_MEMALLOC_ALLOCATOR_VARIABLE_THREADAWARE | |
| 83 | |
| 84 /* Allocates a block of length size. This waits if the memory is not | |
| 85 currently available. */ | |
| 86 void *cyg_mempool_var_alloc(cyg_handle_t varpool, cyg_int32 size); | |
| 87 | |
| 88 # ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 89 | |
| 90 /* Allocates a block of length size. This waits until abstime, | |
| 91 if the memory is not already available. NULL is returned if | |
| 92 no memory is available. */ | |
| 93 void *cyg_mempool_var_timed_alloc( | |
| 94 cyg_handle_t varpool, | |
| 95 cyg_int32 size, | |
| 96 cyg_tick_count_t abstime); | |
| 97 | |
| 98 # endif | |
| 99 #endif | |
| 100 | |
| 101 /* Allocates a block of length size. NULL is returned if no memory is | |
| 102 available. */ | |
| 103 void *cyg_mempool_var_try_alloc( | |
| 104 cyg_handle_t varpool, | |
| 105 cyg_int32 size); | |
| 106 | |
| 107 /* Frees memory back into variable size pool. */ | |
| 108 void cyg_mempool_var_free(cyg_handle_t varpool, void *p); | |
| 109 | |
| 110 /* Returns true if there are any threads waiting for memory in the | |
| 111 given memory pool. */ | |
| 112 cyg_bool_t cyg_mempool_var_waiting(cyg_handle_t varpool); | |
| 113 | |
| 114 typedef struct { | |
| 115 cyg_int32 totalmem; | |
| 116 cyg_int32 freemem; | |
| 117 void *base; | |
| 118 cyg_int32 size; | |
| 119 cyg_int32 blocksize; | |
| 120 cyg_int32 maxfree; // The largest free block | |
| 121 } cyg_mempool_info; | |
| 122 | |
| 123 /* Puts information about a variable memory pool into the structure | |
| 124 provided. */ | |
| 125 void cyg_mempool_var_get_info(cyg_handle_t varpool, cyg_mempool_info *info); | |
| 126 | |
| 127 /* Create a fixed size memory pool */ | |
| 128 void cyg_mempool_fix_create( | |
| 129 void *base, // base of memory to use for pool | |
| 130 cyg_int32 size, // size of memory in byte | |
| 131 cyg_int32 blocksize, // size of allocation in bytes | |
| 132 cyg_handle_t *handle, // handle of memory pool | |
| 133 cyg_mempool_fix *fix // space to put pool structure in | |
| 134 ); | |
| 135 | |
| 136 /* Delete fixed size memory pool */ | |
| 137 void cyg_mempool_fix_delete(cyg_handle_t fixpool); | |
| 138 | |
| 139 #ifdef CYGSEM_MEMALLOC_ALLOCATOR_FIXED_THREADAWARE | |
| 140 /* Allocates a block. This waits if the memory is not | |
| 141 currently available. */ | |
| 142 void *cyg_mempool_fix_alloc(cyg_handle_t fixpool); | |
| 143 | |
| 144 # ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 145 | |
| 146 /* Allocates a block. This waits until abstime, if the memory | |
| 147 is not already available. NULL is returned if no memory is | |
| 148 available. */ | |
| 149 void *cyg_mempool_fix_timed_alloc( | |
| 150 cyg_handle_t fixpool, | |
| 151 cyg_tick_count_t abstime); | |
| 152 | |
| 153 # endif | |
| 154 #endif | |
| 155 | |
| 156 /* Allocates a block. NULL is returned if no memory is available. */ | |
| 157 void *cyg_mempool_fix_try_alloc(cyg_handle_t fixpool); | |
| 158 | |
| 159 /* Frees memory back into fixed size pool. */ | |
| 160 void cyg_mempool_fix_free(cyg_handle_t fixpool, void *p); | |
| 161 | |
| 162 /* Returns true if there are any threads waiting for memory in the | |
| 163 given memory pool. */ | |
| 164 cyg_bool_t cyg_mempool_fix_waiting(cyg_handle_t fixpool); | |
| 165 | |
| 166 /* Puts information about a variable memory pool into the structure | |
| 167 provided. */ | |
| 168 void cyg_mempool_fix_get_info(cyg_handle_t fixpool, cyg_mempool_info *info); | |
| 169 | |
| 170 | |
| 171 | |
| 172 #endif /* ifndef CYGONCE_MEMALLOC_KAPI_H */ | |
| 173 /* EOF kapi.h */ |
