about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYour Name <you@example.com>2020-06-25 04:20:39 +0200
committerYour Name <you@example.com>2020-06-25 04:20:39 +0200
commit14ad232afad456d867488f5fceb5c23f54486e9d (patch)
tree28a511adeda143a8cf977e7efa36a79e7ca9361c
parentShell: better signal handling (diff)
downloadpOS-14ad232afad456d867488f5fceb5c23f54486e9d.tar.gz
pOS-14ad232afad456d867488f5fceb5c23f54486e9d.tar.bz2
pOS-14ad232afad456d867488f5fceb5c23f54486e9d.zip
Base: added skeleton for a physical memory manager
Added skeleton files to prepare to implement a pmm
-rw-r--r--src/pOS/arch/x86/kernel/physm.cpp21
-rw-r--r--src/pOS/arch/x86/libc/stdio/getc.cpp1
-rw-r--r--src/pOS/arch/x86/libc/stdlib/memory.cpp11
-rw-r--r--src/pOS/include/kernel/kernel.h3
-rw-r--r--src/pOS/include/kernel/physm.h14
-rw-r--r--src/pOS/include/libc/stdio.h1
-rw-r--r--src/pOS/include/libc/stdlib.h4
-rw-r--r--src/pOS/include/libc/string.h6
-rw-r--r--src/pOS/kernel/kernel.cpp2
9 files changed, 61 insertions, 2 deletions
diff --git a/src/pOS/arch/x86/kernel/physm.cpp b/src/pOS/arch/x86/kernel/physm.cpp
new file mode 100644
index 0000000..b3e1705
--- /dev/null
+++ b/src/pOS/arch/x86/kernel/physm.cpp
@@ -0,0 +1,21 @@
+#include <kernel/physm.h>
+
+int PhysM::init(void)
+{
+
+    return 0;
+}
+
+void* PhysM::malloc(size_t size)
+{
+    if(!size)
+        return NULL;
+
+    return NULL;
+}
+
+void PhysM::free(void* ptr)
+{
+    if(!ptr)
+        return;
+}
diff --git a/src/pOS/arch/x86/libc/stdio/getc.cpp b/src/pOS/arch/x86/libc/stdio/getc.cpp
index e0d1b09..3f0f85e 100644
--- a/src/pOS/arch/x86/libc/stdio/getc.cpp
+++ b/src/pOS/arch/x86/libc/stdio/getc.cpp
@@ -1,5 +1,4 @@
 #include <stdio.h>
-#include "../../kernel/drivers/keyboard/include/kbbuf.h"
 
 char getc(void)
 {
diff --git a/src/pOS/arch/x86/libc/stdlib/memory.cpp b/src/pOS/arch/x86/libc/stdlib/memory.cpp
new file mode 100644
index 0000000..fec9ef8
--- /dev/null
+++ b/src/pOS/arch/x86/libc/stdlib/memory.cpp
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+
+void *malloc(size_t size)
+{
+    return PhysM::malloc(size);
+}
+
+void free(void* ptr)
+{
+    return PhysM::free(ptr);
+}
diff --git a/src/pOS/include/kernel/kernel.h b/src/pOS/include/kernel/kernel.h
index 2c22263..68ca24f 100644
--- a/src/pOS/include/kernel/kernel.h
+++ b/src/pOS/include/kernel/kernel.h
@@ -6,12 +6,13 @@
 #include <math.h>
 #include <assert.h>
 
-#include <kernel/shell/shell.h>
 #include <kernel/time.h>
 #include <kernel/timer.h>
 #include <kernel/debug.h>
 #include <kernel/drivers.h>
 #include <kernel/acpi.h>
+#include <kernel/physm.h>
+#include <kernel/shell/shell.h>
 #include <kernel/interrupts/gdt.h>
 #include <kernel/interrupts/idt.h>
 #include <kernel/interrupts/isrs.h>
diff --git a/src/pOS/include/kernel/physm.h b/src/pOS/include/kernel/physm.h
new file mode 100644
index 0000000..a7b3292
--- /dev/null
+++ b/src/pOS/include/kernel/physm.h
@@ -0,0 +1,14 @@
+#ifndef _PHYSM_H_
+#define _PHYSM_H_
+
+#include <stddef.h>
+
+class PhysM
+{
+public:
+    static int init(void);
+    static void *malloc(size_t size);
+    static void free(void* ptr);
+};
+
+#endif
diff --git a/src/pOS/include/libc/stdio.h b/src/pOS/include/libc/stdio.h
index fa3a35e..a2fbf49 100644
--- a/src/pOS/include/libc/stdio.h
+++ b/src/pOS/include/libc/stdio.h
@@ -6,6 +6,7 @@
 #include <kernel/tty.h>
 #include <printf_internal.h>
 #include <kernel/serial.h>
+#include "../../arch/x86/kernel/drivers/keyboard/include/kbbuf.h"
 
 #define EOF (-1)
 
diff --git a/src/pOS/include/libc/stdlib.h b/src/pOS/include/libc/stdlib.h
index d7e174e..86ba7a6 100644
--- a/src/pOS/include/libc/stdlib.h
+++ b/src/pOS/include/libc/stdlib.h
@@ -4,6 +4,10 @@
 #include <stddef.h>
 #include <stdbool.h>
 #include <assert.h>
+#include <kernel/physm.h>
+
+void *malloc(size_t size);
+void free(void* ptr);
 
 int itoa(int i, char* buf, size_t len);
 int atoi(const char* str);
diff --git a/src/pOS/include/libc/string.h b/src/pOS/include/libc/string.h
index 66f93ed..5b37a33 100644
--- a/src/pOS/include/libc/string.h
+++ b/src/pOS/include/libc/string.h
@@ -11,5 +11,11 @@ int memcmp(const void* ptr1, const void* ptr2, size_t size);
 char* strncpy(char* dst, const char* src, size_t len);
 char* strncat(char *dest, const char *src, size_t len);
 int strncmp(const char* str1, const char* str2, size_t len);
+char* strtok(char* str, const char* delim);
+
+constexpr unsigned int str2int(const char* str, int h = 0)
+{
+    return !str[h] ? 5381 : (str2int(str, h+1) * 33) ^ str[h];
+}
 
 #endif
diff --git a/src/pOS/kernel/kernel.cpp b/src/pOS/kernel/kernel.cpp
index 742c205..2170124 100644
--- a/src/pOS/kernel/kernel.cpp
+++ b/src/pOS/kernel/kernel.cpp
@@ -13,6 +13,8 @@ extern "C" int kmain(void)
     IDT::init();
     ISRS::install();
 
+    PhysM::init();
+
     Drivers::load_drivers();
 
     /*asm volatile("mov %eax, 0x100  \t\n"