Mercurial > flash_v2
annotate packages/kernel/current/include/memvar.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_MEMVAR_HXX |
| 2 #define CYGONCE_KERNEL_MEMVAR_HXX | |
| 3 | |
| 4 //========================================================================== | |
| 5 // | |
| 2 | 6 // memvar.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 Memvar class interface | |
| 41 // Description: Inline class for constructing a variable block allocator | |
| 42 // Usage: #include <cyg/kernel/memvar.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/mvarimpl.hxx> // implementation of a variable mem pool | |
| 59 | |
| 60 class Cyg_Mempool_Variable { | |
| 61 private: | |
| 62 #ifdef CYGIMP_MEM_USE_MEMPOOLT_PLAIN | |
| 63 Cyg_Mempoolt<Cyg_Mempool_Variable_Implementation> mypool; | |
| 64 #else | |
| 65 Cyg_Mempolt2<Cyg_Mempool_Variable_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 variable 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. Alignment is the alignment of allocated blocks. | |
| 77 Cyg_Mempool_Variable( | |
| 78 cyg_uint8 * /* base */, | |
| 79 cyg_int32 /* size */); | |
| 80 | |
| 81 // Destructor | |
| 82 ~Cyg_Mempool_Variable(); | |
| 83 | |
| 84 // get some memory; wait if none available | |
| 85 cyg_uint8 * | |
| 86 alloc(cyg_int32 /* size */); | |
| 87 | |
| 88 #ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 89 // get some memory with a timeout | |
| 90 cyg_uint8 * | |
| 91 alloc(cyg_int32 /* size */, cyg_tick_count /* delay_timeout */ ); | |
| 92 #endif | |
| 93 | |
| 94 // get some memory, return NULL if none available | |
| 95 cyg_uint8 * | |
| 96 try_alloc(cyg_int32 /* size */ ); | |
| 97 | |
| 98 // free the memory back to the pool | |
| 99 cyg_bool | |
| 100 free( cyg_uint8 * /* ptr */, cyg_int32 /* size */ ); | |
| 101 | |
| 102 // is anyone waiting for memory? | |
| 103 cyg_bool | |
| 104 waiting( void ); | |
| 105 | |
| 106 // read the fixed allocation size (-1 indicates variable) | |
| 107 cyg_int32 | |
| 108 get_blocksize( void ); | |
| 109 | |
| 110 // these two are obvious and generic | |
| 111 cyg_int32 | |
| 112 get_totalmem( void ); | |
| 113 | |
| 114 cyg_int32 | |
| 115 get_freemem( void ); | |
| 116 | |
| 117 // get information about the construction parameters for external | |
| 118 // freeing after the destruction of the holding object | |
| 119 // also finds largest free block | |
| 120 void | |
| 121 get_arena( cyg_uint8 * & /* base */, cyg_int32 & /* size */, | |
| 122 CYG_ADDRWORD & /* maxfree */ ); | |
| 123 | |
| 124 // Return the size of the memory allocation (previously returned | |
| 125 // by alloc() or try_alloc() ) at ptr. Returns -1 if not found | |
| 126 cyg_int32 | |
| 127 get_allocation_size( cyg_uint8 * /* ptr */ ); | |
| 128 }; | |
| 129 | |
| 130 #endif // ifndef CYGONCE_KERNEL_MEMVAR_HXX | |
| 131 // EOF memvar.hxx |
