summaryrefslogtreecommitdiff
path: root/sys/kern/mm/kalloc.c
diff options
context:
space:
mode:
authorstefan <stefan@s00.xyz>2023-04-19 20:50:10 -0400
committerstefan <stefan@s00.xyz>2023-04-19 20:50:10 -0400
commit83e17e29456ec9b6d45f4d9f2634eb280c6f414f (patch)
tree004a9b2a7cd3f0c7bb4224b59204680bd5d79681 /sys/kern/mm/kalloc.c
parentaf1ce4b2e637ceb418ea72d51c49a3eee276a938 (diff)
downloadsv-83e17e29456ec9b6d45f4d9f2634eb280c6f414f.tar.gz
ticket locks
Diffstat (limited to 'sys/kern/mm/kalloc.c')
-rw-r--r--sys/kern/mm/kalloc.c66
1 files changed, 0 insertions, 66 deletions
diff --git a/sys/kern/mm/kalloc.c b/sys/kern/mm/kalloc.c
deleted file mode 100644
index bfd4f3f..0000000
--- a/sys/kern/mm/kalloc.c
+++ /dev/null
@@ -1,66 +0,0 @@
-#include <stddef.h>
-#include <stdint.h>
-#include <string.h>
-#include <printf.h>
-#include <mm/kalloc.h>
-
-extern uint64_t HEAP_START;
-
-typedef struct freenode {
- struct freenode *next;
-} freenode_t;
-
-freenode_t *head = NULL;
-
-void *
-kalloc(void)
-{
- freenode_t *p = head;
-
- if (p == NULL)
- return NULL;
-
- head = p->next;
- return p;
-}
-
-void *
-kzalloc(void)
-{
- freenode_t *p = kalloc();
- memset(p, 0, PAGE_SIZE);
- return p;
-}
-
-void
-kfree(void *p)
-{
- if (p == NULL)
- return;
-
- freenode_t *tmp = head;
- head = p;
- head->next = tmp;
-}
-
-void
-kalloc_init(void)
-{
- freenode_t *p = (freenode_t*)HEAP_START;
- for (;(unsigned long)p + PAGE_SIZE <= (HEAP_START + 0x100000); p += PAGE_SIZE) {
- kfree(p);
- }
-}
-
-void
-walkfree(void)
-{
- freenode_t *node = head;
- int nfree = 0;
- while (node) {
- printf("freenode at %p\n", node);
- node = node->next;
- nfree++;
- }
- printf("found and printed %d free pages!\n", nfree);
-}