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