summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordzwdz2021-07-31 14:36:56 +0200
committerdzwdz2021-07-31 14:36:56 +0200
commit95e33f7f9362aadd9c6169b41437ca478aa3be14 (patch)
tree29a740559f707455a5b570f0c1f05360e1c6500f /src
parent9fa85569ba6785576af675d6cb74323bbc937050 (diff)
kmalloc() and kfree() stubs
Diffstat (limited to 'src')
-rw-r--r--src/kernel/mem.c10
-rw-r--r--src/kernel/mem.h3
-rw-r--r--src/kernel/proc.c4
3 files changed, 15 insertions, 2 deletions
diff --git a/src/kernel/mem.c b/src/kernel/mem.c
index 5684bb7..19a10a9 100644
--- a/src/kernel/mem.c
+++ b/src/kernel/mem.c
@@ -25,3 +25,13 @@ void *page_alloc(size_t pages) {
void page_free(void *first, size_t pages) {
// not implemented
}
+
+
+void *kmalloc(size_t len) {
+ // extremely inefficient, but this is only temporary anyways
+ return page_alloc(len / PAGE_SIZE + 1);
+}
+
+void kfree(void *ptr) {
+ // unimplemented
+}
diff --git a/src/kernel/mem.h b/src/kernel/mem.h
index f608bb8..b17ba30 100644
--- a/src/kernel/mem.h
+++ b/src/kernel/mem.h
@@ -9,3 +9,6 @@ void *page_alloc(size_t pages);
// frees `pages` consecutive pages starting from *first
void page_free(void *first, size_t pages);
+
+void *kmalloc(size_t len);
+void kfree(void *ptr);
diff --git a/src/kernel/proc.c b/src/kernel/proc.c
index 8a80754..b705324 100644
--- a/src/kernel/proc.c
+++ b/src/kernel/proc.c
@@ -8,7 +8,7 @@ struct process *process_first;
struct process *process_current;
struct process *process_seed() {
- struct process *proc = page_alloc(1); // TODO kmalloc
+ struct process *proc = kmalloc(sizeof(struct process));
proc->pages = pagedir_new();
proc->state = PS_RUNNING;
proc->next = NULL;
@@ -30,7 +30,7 @@ struct process *process_seed() {
}
struct process *process_clone(struct process *orig) {
- struct process *clone = page_alloc(1);
+ struct process *clone = kmalloc(sizeof(struct process));
memcpy(clone, orig, sizeof(struct process));
clone->pages = pagedir_copy(orig->pages);
orig->next = clone;