aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/x86_64/scripts/kernel.ld20
-rw-r--r--arch/x86_64/src/boot/boot.s16
-rw-r--r--arch/x86_64/src/kernel/main.cpp35
3 files changed, 44 insertions, 27 deletions
diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld
index c3eea9c..cc07896 100644
--- a/arch/x86_64/scripts/kernel.ld
+++ b/arch/x86_64/scripts/kernel.ld
@@ -48,17 +48,17 @@ SECTIONS
*(.boot_text)
} :boot_text
- .boot_data ALIGN(4K) : AT(ADDR (.boot_data))
- {
- *(.boot_data)
- } :boot_data
-
.boot_bss ALIGN(4K) : AT(ADDR (.boot_bss))
{
*(.boot_bss)
*(.boot_stack)
}
+ .boot_data ALIGN(4K) : AT(ADDR (.boot_data))
+ {
+ *(.boot_data)
+ } :boot_data
+
/***************************************************************************
* Now it is time to load the 64-bit kernel code. We
* make sure to align the loaded data onto a page boundary.
@@ -112,17 +112,17 @@ SECTIONS
KEEP(*crtend.o(.dtors))
}
- .data ALIGN(4K) : AT (ADDR (.data))
- {
- *(.data*)
- }
-
.bss ALIGN(4K) : AT (ADDR (.bss))
{
*(COMMON)
*(.bss*)
}
+ .data ALIGN(4K) : AT (ADDR (.data))
+ {
+ *(.data*)
+ }
+
/***************************************************************************
* In accordance with the symbol definitions at the start, we generate some
* symbols to mark the end of our loaded image.
diff --git a/arch/x86_64/src/boot/boot.s b/arch/x86_64/src/boot/boot.s
index c1b3203..8d27ea1 100644
--- a/arch/x86_64/src/boot/boot.s
+++ b/arch/x86_64/src/boot/boot.s
@@ -7,6 +7,16 @@
* Uninitialized data for the bootstrapping process.
*/
.section .boot_bss, "aw", @nobits
+
+/**
+ * Reserve some space for the Multiboot 2 information pointer.
+ */
+.global multiboot_information_pointer
+multiboot_information_pointer: .skip 4
+
+/**
+ * Align page maps to 4 KiB or the assembler code, will cause crashes when attempting to enable paging.
+ */
.align 4096
/**
@@ -31,12 +41,6 @@ page_map_level_3: .skip 512 * 8
page_map_level_2: .skip 512 * 8
/**
- * Reserve some space for the Multiboot 2 information pointer.
- */
-.global multiboot_information_pointer
-multiboot_information_pointer: .skip 4
-
-/**
* Stack space for the bootstrapping process.
*
* Note: We are going to reserve 1 MiB for now. If/when the kernel requires
diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp
index dd0a1d8..7463fc4 100644
--- a/arch/x86_64/src/kernel/main.cpp
+++ b/arch/x86_64/src/kernel/main.cpp
@@ -8,14 +8,19 @@
namespace teachos::arch::kernel
{
- auto main() -> void
+ auto stack_overflow_test(int count) -> int
{
- video::vga::text::clear();
- video::vga::text::cursor(false);
- video::vga::text::write("TeachOS is starting up...", video::vga::text::common_attributes::green_on_black);
-
- memory::initialize_memory_management();
+ int test[5000] = {};
+ if (test[0] == 0xFFFF)
+ {
+ return count;
+ }
+ count = stack_overflow_test(count);
+ return count++;
+ }
+ auto heap_test() -> void
+ {
memory::heap::bump_allocator heap_allocator{memory::heap::HEAP_START,
memory::heap::HEAP_START + memory::heap::HEAP_SIZE};
auto test = heap_allocator.allocate(1024);
@@ -28,14 +33,22 @@ namespace teachos::arch::kernel
test5.kernel_end = 3000;
auto test6 = test4.kernel_end;
auto test7 = test5.kernel_end;
- if (test6 && test7)
+ auto test8 = memory::multiboot::read_multiboot2();
+ if (test6 && test7 && test8.kernel_end)
{
video::vga::text::write("Kernel remapping successfull", video::vga::text::common_attributes::green_on_black);
}
+ }
+
+ auto main() -> void
+ {
+ video::vga::text::clear();
+ video::vga::text::cursor(false);
+ video::vga::text::write("TeachOS is starting up...", video::vga::text::common_attributes::green_on_black);
+
+ memory::initialize_memory_management();
- // TODO: Why is identity mapping multiboot2 information structure with new kernel not required and
- // allocator.allocate_frame still works?
- // TODO: Fix unmapping old level 4 page table and turn it into guard page, use Stack Probes for stack allocation if
- // possible.
+ // stack_overflow_test(0);
+ // heap_test();
}
} // namespace teachos::arch::kernel