diff --git a/include/lib/list.h b/include/lib/list.h
index a3eb619..95042a4 100644
--- a/include/lib/list.h
+++ b/include/lib/list.h
@@ -47,7 +47,6 @@ struct ListHead_t
struct ListNode_t
{
- void *data;
ListHead_t *head;
ListNode_t *prev;
ListNode_t *next;
@@ -71,22 +70,6 @@ static inline ListHead_t
return head;
}
-// Create a node
-//
-static inline ListNode_t
-*ExCreateNode(void *data)
-{
- ListNode_t *node = malloc(sizeof(ListNode_t));
-
- if (node == NULL) return NULL;
-
- node->data = data;
- node->head = NULL;
- node->prev = node->next = NULL;
-
- return node;
-}
-
//
// Prepend node at beginning of list
//
@@ -228,16 +211,6 @@ leave:
return head;
}
-//
-// Free a node
-//
-static inline void
-ExDestroyNode(ListNode_t *node)
-{
- assert(node);
- free(node);
-}
-
//
// Free a list head
//
@@ -248,11 +221,6 @@ ExDestroyListHead(ListHead_t *head)
free(head);
}
-//
-// Access a node's data
-//
-#define ExGetNodeData(node, type) ((type)(node)->data)
-
//------------------------------------------//
#ifdef __cplusplus
diff --git a/include/mm/malloc.h b/include/mm/malloc.h
new file mode 100644
index 0000000..44531ad
--- /dev/null
+++ b/include/mm/malloc.h
@@ -0,0 +1,102 @@
+//----------------------------------------------------------------------------//
+// GNU GPL OS/K //
+// //
+// Desc: Memory allocation functions //
+// //
+// //
+// Copyright © 2018-2019 The OS/K Team //
+// //
+// This file is part of OS/K. //
+// //
+// OS/K is free software: you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation, either version 3 of the License, or //
+// any later version. //
+// //
+// OS/K is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY//without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details. //
+// //
+// You should have received a copy of the GNU General Public License //
+// along with OS/K. If not, see . //
+//----------------------------------------------------------------------------//
+
+#ifndef _KERNEL_H
+#include
+#endif
+
+#ifndef _LIB_LIST_H
+#include
+#endif
+
+#ifndef _MM_MALLOC_H
+#define _MM_MALLOC_H
+
+#ifndef PAGESIZE
+#define PAGESIZE 4096
+#endif
+
+typedef struct Cache_t Cache_t;
+typedef struct Pool_t Pool_t;
+
+// Operation on objects
+typedef void (*ObjCtor_t)(Cache_t *cache,
+ Pool_t *pool,
+ void *obj);
+//
+// A cache containing many pools
+//
+struct Cache_t
+{
+ // Synchronization
+ Spinlock_t lock;
+
+ // Cache name
+ char name[64];
+
+ // Size of each object
+ size_t objsize;
+
+ // Number of objects allocated
+ size_t objused;
+
+ // Number of available objects including unused
+ size_t objtotal;
+
+ // Number of objects per pool
+ size_t objperpool;
+
+ // Object constructor
+ ObjOper_t *ctor;
+
+ // Object destructor
+ ObjOper_t *dtor;
+
+ // Object pools without any allocated object
+ ListHead_t *freepools;
+
+ // Object pools containing some allocated objects
+ ListHead_t *usedpools;
+
+ // Objects pools containing no unallocated object
+ ListHead_t *fullpools;
+};
+
+//
+// A pool of allocable objects
+// Takes a fixed amount of pages
+//
+struct Pool_t
+{
+
+};
+
+//
+// Allocates memory from the kernel heap
+//
+void *kmalloc(size_t req, uint flags);
+void *kmemalign(size_t req, uint align, uint flags);
+
+#endif
+