diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2010-05-21 13:09:21 -0500 |
---|---|---|
committer | Patrick Williams <iawillia@us.ibm.com> | 2010-05-21 13:09:21 -0500 |
commit | 8781b20afef41280e351d087bc05f6626e95cbda (patch) | |
tree | 1ca25664d5dc160962cecbff6ced916215c0edab /src/include/kernel | |
parent | 344e6d7bf3870202ff9206f389057e2c8a1e7345 (diff) | |
download | talos-hostboot-8781b20afef41280e351d087bc05f6626e95cbda.tar.gz talos-hostboot-8781b20afef41280e351d087bc05f6626e95cbda.zip |
Add heap manager for allocations up to 2040 bytes
Diffstat (limited to 'src/include/kernel')
-rw-r--r-- | src/include/kernel/heapmgr.H | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/include/kernel/heapmgr.H b/src/include/kernel/heapmgr.H new file mode 100644 index 000000000..41a3e2cf5 --- /dev/null +++ b/src/include/kernel/heapmgr.H @@ -0,0 +1,39 @@ +#ifndef __KERNEL_HEAPMGR_H +#define __KERNEL_HEAPMGR_H + +#include <stdint.h> +#include <util/lockfree/stack.H> + +class HeapManager +{ + public: + static void* allocate(size_t n); + static void free(void *); + + enum + { + BUCKETS = 8, + }; + + protected: + HeapManager() {}; + ~HeapManager() {}; + + private: + void* _allocate(size_t); + void _free(void*); + + struct chunk_t + { + size_t len; + chunk_t* next; + }; + Util::Lockfree::Stack<chunk_t> first_chunk[BUCKETS]; + + chunk_t* pop_bucket(size_t); + void push_bucket(chunk_t*, size_t); + + void newPage(); +}; + +#endif |