Mercurial > ecos
annotate packages/kernel/current/include/memfixed.hxx @ 66:bf00f99aec69 ecos-sw-2000-02-02
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
| author | jlarmour |
|---|---|
| date | Wed, 02 Feb 2000 19:57:02 +0000 |
| parents | c38311975d4f |
| children |
| rev | line source |
|---|---|
| 0 | 1 #ifndef CYGONCE_KERNEL_MEMFIXED_HXX |
| 2 #define CYGONCE_KERNEL_MEMFIXED_HXX | |
| 3 | |
| 4 //========================================================================== | |
| 5 // | |
| 2 | 6 // memfixed.hxx |
| 0 | 7 // |
| 2 | 8 // Memory pool with fixed block class declarations |
| 0 | 9 // |
| 10 //========================================================================== | |
| 11 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
12 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
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:
2
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:
2
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:
2
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:
2
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:
2
diff
changeset
|
22 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
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:
2
diff
changeset
|
25 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
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:
2
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:
2
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:
2
diff
changeset
|
30 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
31 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
32 // |
| 0 | 33 //####COPYRIGHTEND#### |
| 34 //========================================================================== | |
| 35 //#####DESCRIPTIONBEGIN#### | |
| 36 // | |
| 2 | 37 // Author(s): hmt |
| 38 // Contributors: hmt | |
| 39 // Date: 1998-03-23 | |
| 40 // Purpose: Define Memfixed class interface | |
| 41 // Description: Inline class for constructing a fixed block allocator | |
| 42 // Usage: #include <cyg/kernel/memfixed.hxx> | |
| 43 // | |
| 0 | 44 // |
| 45 //####DESCRIPTIONEND#### | |
| 46 // | |
| 47 //========================================================================== | |
| 48 | |
| 49 #include <cyg/kernel/ktypes.h> // kernel types | |
| 50 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 51 | |
| 52 #ifdef CYGIMP_MEM_USE_MEMPOOLT_PLAIN | |
| 53 #include <cyg/kernel/mempoolt.hxx> // kernel safe mempool template | |
| 54 #else | |
| 55 #include <cyg/kernel/mempolt2.hxx> // kernel safe mempool template | |
| 56 #endif | |
| 57 | |
| 58 #include <cyg/kernel/mfiximpl.hxx> // implementation of a fixed mem pool | |
| 59 | |
| 60 class Cyg_Mempool_Fixed { | |
| 61 private: | |
| 62 #ifdef CYGIMP_MEM_USE_MEMPOOLT_PLAIN | |
| 63 Cyg_Mempoolt<Cyg_Mempool_Fixed_Implementation> mypool; | |
| 64 #else | |
| 65 Cyg_Mempolt2<Cyg_Mempool_Fixed_Implementation> mypool; | |
| 66 #endif | |
| 67 | |
| 68 public: | |
| 69 // this API makes concrete a class which implements a thread-safe | |
| 70 // kernel-savvy memory pool which manages fixed size blocks. | |
| 71 | |
| 72 CYGDBG_DEFINE_CHECK_THIS | |
| 73 | |
| 74 // Constructor: gives the base and size of the arena in which memory is | |
| 75 // to be carved out, note that management structures are taken from the | |
| 76 // same arena. Alloc_unit is the blocksize allocated. | |
| 77 Cyg_Mempool_Fixed( | |
| 78 cyg_uint8 *base, | |
| 79 cyg_int32 size, | |
| 80 CYG_ADDRWORD alloc_unit ); | |
| 81 | |
| 82 // Destructor | |
| 83 ~Cyg_Mempool_Fixed(); | |
| 84 | |
| 85 // get some memory; wait if none available | |
| 86 cyg_uint8 *alloc(); | |
| 87 | |
| 88 #ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 89 // get some memory with a timeout | |
| 90 cyg_uint8 *alloc(cyg_tick_count delay_timeout ); | |
| 91 #endif | |
| 92 | |
| 93 // get some memory, return NULL if none available | |
| 94 cyg_uint8 *try_alloc(); | |
| 95 | |
| 96 // free the memory back to the pool | |
| 97 cyg_bool free( cyg_uint8 *p); | |
| 98 | |
| 99 // is anyone waiting for memory? | |
| 100 cyg_bool waiting(); | |
| 101 | |
| 102 // read the fixed allocation size | |
| 103 cyg_int32 get_blocksize(); | |
| 104 | |
| 105 // these two are obvious and generic | |
| 106 cyg_int32 get_totalmem(); | |
| 107 cyg_int32 get_freemem(); | |
| 108 | |
| 109 // get information about the construction parameters for external | |
| 110 // freeing after the destruction of the holding object | |
| 111 void | |
| 112 get_arena( cyg_uint8 * &base, cyg_int32 &size, CYG_ADDRWORD &alloc ); | |
| 113 | |
| 114 // Return the size of the memory allocation (previously returned | |
| 115 // by alloc() or try_alloc() ) at ptr. Returns -1 if not found | |
| 116 cyg_int32 | |
| 117 get_allocation_size( cyg_uint8 * /* ptr */ ); | |
| 118 }; | |
| 119 | |
| 120 #endif // ifndef CYGONCE_KERNEL_MEMFIXED_HXX | |
| 121 // EOF memfixed.hxx |
