comparison packages/kernel/current/include/mvarimpl.hxx @ 0:3111d98ba7b3 ecos-v1_1-release

Initial commit of eCos version 1.1
author jlarmour
date Tue, 11 May 1999 11:16:07 +0000
parents
children 443894e2e912
comparison
equal deleted inserted replaced
-1:000000000000 0:3111d98ba7b3
1 #ifndef CYGONCE_KERNEL_MVARIMPL_HXX
2 #define CYGONCE_KERNEL_MVARIMPL_HXX
3
4 //==========================================================================
5 //
6 // mvarimpl.hxx
7 //
8 // Memory pool with variable block class declarations
9 //
10 //==========================================================================
11 //####COPYRIGHTBEGIN####
12 //
13 // -------------------------------------------
14 // The contents of this file are subject to the Cygnus eCos Public License
15 // Version 1.0 (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://sourceware.cygnus.com/ecos
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 Cygnus Operating System, released
25 // September 30, 1998.
26 //
27 // The Initial Developer of the Original Code is Cygnus. Portions created
28 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved.
29 // -------------------------------------------
30 //
31 //####COPYRIGHTEND####
32 //==========================================================================
33 //#####DESCRIPTIONBEGIN####
34 //
35 // Author(s): dsm
36 // Contributors: dsm
37 // Date: 1998-05-21
38 // Purpose: Define Mvarimpl class interface
39 // Description: Inline class for constructing a variable block allocator
40 // Usage: #include <cyg/kernel/mvarimpl.hxx>
41 //
42 //
43 //####DESCRIPTIONEND####
44 //
45 //==========================================================================
46
47 #include <cyg/kernel/ktypes.h>
48 #include <cyg/kernel/thread.hxx>
49
50 class Cyg_Mempool_Variable_Implementation {
51 private:
52 // these constructors are explicitly disallowed
53 Cyg_Mempool_Variable_Implementation() {};
54 // Cyg_Mempool_Variable_Implementation( Cyg_Mempool_Variable_Implementation &ref )
55 // {};
56 Cyg_Mempool_Variable_Implementation &
57 operator=( Cyg_Mempool_Variable_Implementation &ref )
58 { return ref; };
59
60 private:
61 struct memdq {
62 struct memdq *prev, *next;
63 cyg_int32 size;
64 };
65
66 struct memdq head;
67 cyg_uint8 *obase;
68 cyg_int32 osize;
69 cyg_int32 oalign;
70 cyg_uint8 *bottom;
71 cyg_uint8 *top;
72 cyg_int32 alignment;
73 cyg_int32 freemem;
74
75 // round up size passed to alloc/free to a size that will be used
76 // for allocation
77 cyg_int32
78 roundup(cyg_int32 size);
79
80 public:
81 // THIS is the public API of memory pools generally that can have the
82 // kernel oriented thread-safe package layer atop.
83
84 // Constructor: gives the base and size of the arena in which memory is
85 // to be carved out.
86 Cyg_Mempool_Variable_Implementation(
87 cyg_uint8 * /* base */,
88 cyg_int32 /* size */,
89 CYG_ADDRWORD /* alignment */);
90
91 // Destructor
92 ~Cyg_Mempool_Variable_Implementation();
93
94 // get size bytes of memory
95 inline cyg_uint8 *
96 alloc( cyg_int32 /* size */ );
97
98 // free size bytes of memory back to the pool
99 inline cyg_bool
100 free( cyg_uint8 * /* ptr */,
101 cyg_int32 /* size */ );
102
103 // returns -1 as not variable size
104 inline cyg_int32
105 get_blocksize( void ) { return -1; }
106
107 // these two are obvious and generic
108 inline cyg_int32
109 get_totalmem( void ) { return top-bottom; }
110
111 inline cyg_int32
112 get_freemem( void ) { return freemem; }
113
114 // get information about the construction parameters for external
115 // freeing after the destruction of the holding object
116 inline void
117 get_arena( cyg_uint8 * & /* base */,
118 cyg_int32 & /* size */,
119 CYG_ADDRWORD & /* maxfree */ );
120
121 // Return the size of the memory allocation (previously returned
122 // by alloc() or try_alloc() ) at ptr. Returns -1 if not found
123 inline cyg_int32
124 get_allocation_size( cyg_uint8 * /* ptr */ );
125
126 };
127
128 // -------------------------------------------------------------------------
129 #endif // ifndef CYGONCE_KERNEL_MVARIMPL_HXX
130 // EOF mvarimpl.hxx