summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2010-05-20 19:16:30 -0500
committerPatrick Williams <iawillia@us.ibm.com>2010-05-20 19:16:30 -0500
commitd9d7e6c7247aaf5d2721d08a365e9c51ec18c870 (patch)
tree16f882f7d77eb293ac0417b43bb5680ee149efbd /src/include
parentd5a43e2fa43f8178aaa7ca67a9615d3ab4e68dbb (diff)
downloadtalos-hostboot-d9d7e6c7247aaf5d2721d08a365e9c51ec18c870.tar.gz
talos-hostboot-d9d7e6c7247aaf5d2721d08a365e9c51ec18c870.zip
Create page manager.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/kernel/pagemgr.H42
-rw-r--r--src/include/stddef.h12
-rw-r--r--src/include/stdint.h2
3 files changed, 56 insertions, 0 deletions
diff --git a/src/include/kernel/pagemgr.H b/src/include/kernel/pagemgr.H
new file mode 100644
index 000000000..1d7193b22
--- /dev/null
+++ b/src/include/kernel/pagemgr.H
@@ -0,0 +1,42 @@
+#ifndef __KERNEL_PAGEMGR_H
+#define __KERNEL_PAGEMGR_H
+
+#include <stdint.h>
+
+/** @class PageManager
+ * @brief Manages the allocation of memory pages.
+ */
+
+class PageManager
+{
+ public:
+ static void* allocatePage(size_t n = 1);
+ static void freePage(void*, size_t n = 1);
+
+ enum
+ {
+ PAGESIZE = 4096,
+ MEMLEN = 8 * 1024 * 1024,
+
+ BUCKETS = 16,
+ };
+
+ protected:
+ PageManager();
+ ~PageManager() {};
+
+ private:
+ void* _allocatePage(size_t);
+ void _freePage(void*, size_t);
+
+ struct page_t
+ {
+ page_t* next_page;
+ };
+ page_t* first_page[BUCKETS];
+
+ page_t* pop_bucket(size_t);
+ void push_bucket(page_t*, size_t);
+};
+
+#endif
diff --git a/src/include/stddef.h b/src/include/stddef.h
new file mode 100644
index 000000000..10c28e361
--- /dev/null
+++ b/src/include/stddef.h
@@ -0,0 +1,12 @@
+#ifndef __STDDEF_H
+#define __STDDEF_H
+
+#ifndef NULL
+#ifdef __cplusplus
+#define NULL 0
+#else
+#define NULL ((void*)0)
+#endif
+#endif
+
+#endif
diff --git a/src/include/stdint.h b/src/include/stdint.h
index f5a30a9f5..1b7328d80 100644
--- a/src/include/stdint.h
+++ b/src/include/stdint.h
@@ -1,6 +1,8 @@
#ifndef __STDINT_H
#define __STDINT_H
+#include <stddef.h>
+
typedef char int8_t;
typedef short int int16_t;
typedef int int32_t;
OpenPOWER on IntegriCloud