Mercurial > flash_v2
annotate packages/kernel/current/include/mvarimpl.hxx @ 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 | bf00f99aec69 |
| children |
| rev | line source |
|---|---|
| 0 | 1 #ifndef CYGONCE_KERNEL_MVARIMPL_HXX |
| 2 #define CYGONCE_KERNEL_MVARIMPL_HXX | |
| 3 | |
| 4 //========================================================================== | |
| 5 // | |
| 2 | 6 // mvarimpl.hxx |
| 0 | 7 // |
| 2 | 8 // Memory pool with variable 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): dsm |
| 38 // Contributors: dsm | |
| 39 // Date: 1998-05-21 | |
| 40 // Purpose: Define Mvarimpl class interface | |
| 41 // Description: Inline class for constructing a variable block allocator | |
| 42 // Usage: #include <cyg/kernel/mvarimpl.hxx> | |
| 43 // | |
| 0 | 44 // |
| 45 //####DESCRIPTIONEND#### | |
| 46 // | |
| 47 //========================================================================== | |
| 48 | |
| 49 #include <cyg/kernel/ktypes.h> | |
| 50 #include <cyg/kernel/thread.hxx> | |
| 51 | |
| 52 class Cyg_Mempool_Variable_Implementation { | |
| 53 private: | |
| 54 // these constructors are explicitly disallowed | |
| 55 Cyg_Mempool_Variable_Implementation() {}; | |
| 56 // Cyg_Mempool_Variable_Implementation( Cyg_Mempool_Variable_Implementation &ref ) | |
| 57 // {}; | |
| 58 Cyg_Mempool_Variable_Implementation & | |
| 59 operator=( Cyg_Mempool_Variable_Implementation &ref ) | |
| 60 { return ref; }; | |
| 61 | |
| 62 private: | |
| 63 struct memdq { | |
| 64 struct memdq *prev, *next; | |
| 65 cyg_int32 size; | |
| 66 }; | |
| 67 | |
| 68 struct memdq head; | |
| 69 cyg_uint8 *obase; | |
| 70 cyg_int32 osize; | |
| 71 cyg_int32 oalign; | |
| 72 cyg_uint8 *bottom; | |
| 73 cyg_uint8 *top; | |
| 74 cyg_int32 alignment; | |
| 75 cyg_int32 freemem; | |
| 76 | |
| 77 // round up size passed to alloc/free to a size that will be used | |
| 78 // for allocation | |
| 79 cyg_int32 | |
| 80 roundup(cyg_int32 size); | |
| 81 | |
| 82 public: | |
| 83 // THIS is the public API of memory pools generally that can have the | |
| 84 // kernel oriented thread-safe package layer atop. | |
| 85 | |
| 86 // Constructor: gives the base and size of the arena in which memory is | |
| 87 // to be carved out. | |
| 88 Cyg_Mempool_Variable_Implementation( | |
| 89 cyg_uint8 * /* base */, | |
| 90 cyg_int32 /* size */, | |
| 91 CYG_ADDRWORD /* alignment */); | |
| 92 | |
| 93 // Destructor | |
| 94 ~Cyg_Mempool_Variable_Implementation(); | |
| 95 | |
| 96 // get size bytes of memory | |
| 97 inline cyg_uint8 * | |
| 98 alloc( cyg_int32 /* size */ ); | |
| 99 | |
| 100 // free size bytes of memory back to the pool | |
| 101 inline cyg_bool | |
| 102 free( cyg_uint8 * /* ptr */, | |
| 103 cyg_int32 /* size */ ); | |
| 104 | |
| 105 // returns -1 as not variable size | |
| 106 inline cyg_int32 | |
| 107 get_blocksize( void ) { return -1; } | |
| 108 | |
| 109 // these two are obvious and generic | |
| 110 inline cyg_int32 | |
| 111 get_totalmem( void ) { return top-bottom; } | |
| 112 | |
| 113 inline cyg_int32 | |
| 114 get_freemem( void ) { return freemem; } | |
| 115 | |
| 116 // get information about the construction parameters for external | |
| 117 // freeing after the destruction of the holding object | |
| 118 inline void | |
| 119 get_arena( cyg_uint8 * & /* base */, | |
| 120 cyg_int32 & /* size */, | |
| 121 CYG_ADDRWORD & /* maxfree */ ); | |
| 122 | |
| 123 // Return the size of the memory allocation (previously returned | |
| 124 // by alloc() or try_alloc() ) at ptr. Returns -1 if not found | |
| 125 inline cyg_int32 | |
| 126 get_allocation_size( cyg_uint8 * /* ptr */ ); | |
| 127 | |
| 128 }; | |
| 129 | |
| 130 // ------------------------------------------------------------------------- | |
| 131 #endif // ifndef CYGONCE_KERNEL_MVARIMPL_HXX | |
| 132 // EOF mvarimpl.hxx |
