aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-02-07 18:06:51 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2021-02-07 18:06:51 +0200
commit2c8cfb327ab8aff0deb44c826fe659bf0062fe59 (patch)
tree4282d611641cbf85431464707efcf686ea08681e
parentRewrite makefile (diff)
downloadkernel.cpp-2c8cfb327ab8aff0deb44c826fe659bf0062fe59.tar.xz
Rename kernel/ to src/
-rw-r--r--.gitignore2
-rw-r--r--kernel/makefile2
-rw-r--r--makefile4
-rw-r--r--src/boot.s (renamed from kernel/boot.s)0
-rw-r--r--src/kernel.cc26
-rw-r--r--src/kernel/dump_multiboot.cc (renamed from kernel/kernel.cc)21
-rw-r--r--src/makefile5
-rw-r--r--src/vga.cc (renamed from kernel/vga.cc)0
-rw-r--r--src/vga.h (renamed from kernel/vga.h)0
9 files changed, 35 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore
index ae3d99d..94e1555 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
glitch.elf
glitch.iso
-obj/
+build/
isodir/
diff --git a/kernel/makefile b/kernel/makefile
deleted file mode 100644
index 23e3683..0000000
--- a/kernel/makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-AS_OBJ += kernel/boot.o
-CXX_OBJ += kernel/kernel.o kernel/vga.o
diff --git a/makefile b/makefile
index 6dd59d7..0235442 100644
--- a/makefile
+++ b/makefile
@@ -4,9 +4,9 @@
# != execute a shell script on the right-hand side and assign its result to the left-hand side
include toolchain.makefile
-OBJ_DIR := obj
+OBJ_DIR := build
-include kernel/makefile
+include src/makefile
include libk/makefile
AS_OBJ := $(addprefix $(OBJ_DIR)/, $(AS_OBJ))
CXX_OBJ := $(addprefix $(OBJ_DIR)/, $(CXX_OBJ))
diff --git a/kernel/boot.s b/src/boot.s
index bb446d8..bb446d8 100644
--- a/kernel/boot.s
+++ b/src/boot.s
diff --git a/src/kernel.cc b/src/kernel.cc
new file mode 100644
index 0000000..c083364
--- /dev/null
+++ b/src/kernel.cc
@@ -0,0 +1,26 @@
+/* Check if the compiler thinks you are targeting the wrong operating system. */
+#if defined(__linux__)
+#error "You are not using a cross-compiler"
+#endif
+
+/* This tutorial will only work for the 32-bit ix86 targets. */
+#if !defined(__i386__)
+#error "This tutorial needs to be compiled with a ix86-elf compiler"
+#endif
+
+#include <stdlib.h>
+#include <types.h>
+#include "vga.h"
+
+extern "C" void dump_multiboot(uint32_t mb_magic, uint32_t mb_addr);
+
+extern "C" void kernel_main(uint32_t mb_magic, uint32_t mb_addr) {
+ VGA terminal;
+ Console::set(&terminal);
+
+ printk("Hello, kernel World!\n");
+
+ dump_multiboot(mb_magic, mb_addr);
+
+ abort();
+}
diff --git a/kernel/kernel.cc b/src/kernel/dump_multiboot.cc
index 9ea5c95..60b4b91 100644
--- a/kernel/kernel.cc
+++ b/src/kernel/dump_multiboot.cc
@@ -1,24 +1,7 @@
-/* Check if the compiler thinks you are targeting the wrong operating system. */
-#if defined(__linux__)
-#error "You are not using a cross-compiler"
-#endif
-
-/* This tutorial will only work for the 32-bit ix86 targets. */
-#if !defined(__i386__)
-#error "This tutorial needs to be compiled with a ix86-elf compiler"
-#endif
-
#include <multiboot2.h>
#include <stdlib.h>
-#include <types.h>
-#include "vga.h"
-
-extern "C" void kernel_main(uint32_t mb_magic, uint32_t mb_addr) {
- VGA terminal;
- Console::set(&terminal);
-
- printk("Hello, kernel World!\n");
+extern "C" void dump_multiboot(uint32_t mb_magic, uint32_t mb_addr) {
printk("multiboot magic: ", uhex{mb_magic}, mb_magic == MULTIBOOT2_BOOTLOADER_MAGIC ? " valid" : " invalid", '\n');
printk("multiboot addr: ", uhex{mb_addr}, !(mb_addr & 7) ? " is aligned" : " is not aligned", '\n');
@@ -70,6 +53,4 @@ extern "C" void kernel_main(uint32_t mb_magic, uint32_t mb_addr) {
tag = (struct multiboot_tag*)((multiboot_uint8_t*)tag + ((tag->size + 7) & ~7));
printk("Total mbi size ", (unsigned)tag - mb_addr, '\n');
-
- abort();
}
diff --git a/src/makefile b/src/makefile
new file mode 100644
index 0000000..86c8877
--- /dev/null
+++ b/src/makefile
@@ -0,0 +1,5 @@
+AS_OBJ += src/boot.o
+
+CXX_OBJ += src/kernel.o \
+ src/kernel/dump_multiboot.o \
+ src/vga.o
diff --git a/kernel/vga.cc b/src/vga.cc
index 83d0060..83d0060 100644
--- a/kernel/vga.cc
+++ b/src/vga.cc
diff --git a/kernel/vga.h b/src/vga.h
index 3052dbc..3052dbc 100644
--- a/kernel/vga.h
+++ b/src/vga.h