Mercurial > ecos
annotate packages/kernel/current/include/mfiximpl.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_MFIXIMPL_HXX |
| 2 #define CYGONCE_KERNEL_MFIXIMPL_HXX | |
| 3 | |
| 4 //========================================================================== | |
| 5 // | |
| 2 | 6 // mfiximpl.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 Mfiximpl class interface | |
| 41 // Description: Inline class for constructing a fixed block allocator | |
| 42 // Usage: #include <cyg/kernel/mfiximpl.hxx> | |
| 43 // | |
| 0 | 44 // |
| 45 //####DESCRIPTIONEND#### | |
| 46 // | |
| 47 //========================================================================== | |
| 48 | |
| 49 #include <cyg/kernel/ktypes.h> | |
| 50 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 51 #include <cyg/kernel/thread.hxx> | |
| 52 | |
| 53 class Cyg_Mempool_Fixed_Implementation { | |
| 54 private: | |
| 55 // these constructors are explicitly disallowed | |
| 56 Cyg_Mempool_Fixed_Implementation() {}; | |
| 57 // Cyg_Mempool_Fixed_Implementation( Cyg_Mempool_Fixed_Implementation &ref ) | |
| 58 // {}; | |
| 59 Cyg_Mempool_Fixed_Implementation & | |
| 60 operator=( Cyg_Mempool_Fixed_Implementation &ref ) | |
| 61 { return ref; }; | |
| 62 | |
| 63 private: | |
| 64 cyg_uint32 *bitmap; | |
| 65 cyg_int32 maptop; | |
| 66 cyg_uint8 *mempool; | |
| 67 cyg_int32 numblocks; | |
| 68 cyg_int32 freeblocks; | |
| 69 cyg_int32 blocksize; | |
| 70 cyg_int32 firstfree; | |
| 71 cyg_uint8 *top; | |
| 72 | |
| 73 public: | |
| 74 // THIS is the public API of memory pools generally that can have the | |
| 75 // kernel oriented thread-safe package layer atop. | |
| 76 // | |
| 77 // The kernel package is a template whose type parameter is one of | |
| 78 // these. That is the reason there are superfluous parameters here and | |
| 79 // more genereralization than might be expected in a fixed block | |
| 80 // allocator. | |
| 81 | |
| 82 // Constructor: gives the base and size of the arena in which memory is | |
| 83 // to be carved out, note that management structures are taken from the | |
| 84 // same arena. The alloc_unit may be any other param in general; it | |
| 85 // comes through from the outer constructor unchanged. | |
| 86 Cyg_Mempool_Fixed_Implementation( | |
| 87 cyg_uint8 *base, | |
| 88 cyg_int32 size, | |
| 89 CYG_ADDRWORD alloc_unit ); | |
| 90 | |
| 91 // Destructor | |
| 92 ~Cyg_Mempool_Fixed_Implementation(); | |
| 93 | |
| 94 // get some memory; size is ignored in a fixed block allocator | |
| 95 inline cyg_uint8 *alloc( cyg_int32 size ); | |
| 96 | |
| 97 // free the memory back to the pool; size ignored here | |
| 98 inline cyg_bool free( cyg_uint8 *p, cyg_int32 size ); | |
| 99 | |
| 100 // if applicable: return -1 if not fixed size | |
| 101 inline cyg_int32 get_blocksize() { return blocksize; } | |
| 102 | |
| 103 // these two are obvious and generic | |
| 104 inline cyg_int32 get_totalmem() { return blocksize * numblocks; } | |
| 105 inline cyg_int32 get_freemem() { return blocksize * freeblocks; } | |
| 106 | |
| 107 // get information about the construction parameters for external | |
| 108 // freeing after the destruction of the holding object | |
| 109 inline void get_arena( cyg_uint8 * &base, cyg_int32 &size, CYG_ADDRWORD &alloc ) | |
| 110 { | |
| 111 base = (cyg_uint8 *)bitmap; | |
| 112 size = top - base; | |
| 113 alloc = blocksize; | |
| 114 } | |
| 115 | |
| 116 }; | |
| 117 | |
| 118 // ------------------------------------------------------------------------- | |
| 119 #endif // ifndef CYGONCE_KERNEL_MFIXIMPL_HXX | |
| 120 // EOF mfiximpl.hxx |
