aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/arch/x86_64
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/arch/x86_64')
-rw-r--r--kernel/arch/x86_64/limine.cpp6
-rw-r--r--kernel/arch/x86_64/limine.h2
-rw-r--r--kernel/arch/x86_64/linker.ld78
3 files changed, 83 insertions, 3 deletions
diff --git a/kernel/arch/x86_64/limine.cpp b/kernel/arch/x86_64/limine.cpp
index 84f8642..8c67c52 100644
--- a/kernel/arch/x86_64/limine.cpp
+++ b/kernel/arch/x86_64/limine.cpp
@@ -1,4 +1,3 @@
-#include <cstddef>
#include <stdint.h>
#include <stddef.h>
#include "limine.h"
@@ -37,6 +36,7 @@ void hcf() {
extern void (*__init_array[])();
extern void (*__init_array_end[])();
+extern "C" void kernel_main();
extern "C" void _start() {
if (!LIMINE_BASE_REVISION_SUPPORTED) {
@@ -58,11 +58,13 @@ extern "C" void _start() {
limine_framebuffer *framebuffer = framebuffer_request.response->framebuffers[0];
// Note: we assume the framebuffer model is RGB with 32-bit pixels.
- for (std::size_t i = 0; i < 100; i++) {
+ for (size_t i = 0; i < 100; i++) {
volatile uint32_t *fb_ptr = static_cast<volatile uint32_t *>(framebuffer->address);
fb_ptr[i * (framebuffer->pitch / 4) + i] = 0xffffff;
}
+
+
// We're done, just hang...
hcf();
} \ No newline at end of file
diff --git a/kernel/arch/x86_64/limine.h b/kernel/arch/x86_64/limine.h
index 0e7e87a..b4afb43 100644
--- a/kernel/arch/x86_64/limine.h
+++ b/kernel/arch/x86_64/limine.h
@@ -584,4 +584,4 @@ struct limine_dtb_request {
}
#endif
-#endif \ No newline at end of file
+#endif
diff --git a/kernel/arch/x86_64/linker.ld b/kernel/arch/x86_64/linker.ld
new file mode 100644
index 0000000..5724ecf
--- /dev/null
+++ b/kernel/arch/x86_64/linker.ld
@@ -0,0 +1,78 @@
+OUTPUT_FORMAT(elf64-x86-64)
+OUTPUT_ARCH(i386:x86-64)
+
+/* Excecution entry point symbol */
+ENTRY(_start)
+
+PHDRS
+{
+ requests PT_LOAD FLAGS((1 << 1) | (1 << 2)); /* Write + Read */
+ text PT_LOAD FLAGS((1 << 0) | (1 << 2)); /* Execute + Read */
+ rodata PT_LOAD FLAGS((1 << 2)); /* Read only */
+ data PT_LOAD FLAGS((1 << 1) | (1 << 2)); /* Write + Read */
+ dynamic PT_DYNAMIC FLAGS((1 << 1) | (1 << 2)); /* Dynamic PHDR for relocations */
+}
+
+SECTIONS
+{
+ /* Places kernel in the top 2GiB of the address space */
+ . = 0xffffffff80000000;
+
+ /* Used to get the beginning and end address of the kernel */
+ __kernel_begin = .;
+
+ .requests : {
+ KEEP(*(.requests_start_marker))
+ KEEP(*(.requests))
+ KEEP(*(.requests_end_marker))
+ } :requests
+
+ . += CONSTANT(MAXPAGESIZE);
+
+ /* code. multiboot header comes first */
+ .text : {
+ *(.text .text.*)
+ } :text
+
+ . += CONSTANT(MAXPAGESIZE);
+
+ /* read only data */
+ .rodata : {
+ *(. .rodata.*)
+ } :rodata
+
+ /* init array symbols used to get start and end address of the array */
+ .init_array : {
+ __init_array = .;
+ *(.init_array .init_array.*)
+ __init_array_end = .;
+ } :rodata
+
+ . += CONSTANT(MAXPAGESIZE);
+
+ /* read write data (initialized) */
+ .data : {
+ *(.data .data.*)
+ } :data
+
+ /* Dynamic section for relocations, both in its own PHDR and inside data PHDR */
+ .dynamic : {
+ *(.dynamic)
+ } :data :dynamic
+
+ . += CONSTANT(MAXPAGESIZE);
+
+ /* read write data (uninitialized) and stack */
+ .bss : {
+ *(.bss .bss.*)
+ *(COMMON)
+ } :data
+
+ /* Discard .note.* and .eh_frame since they may cause issues on some hosts */
+ /DISCARD/ : {
+ *(.eh_frame)
+ *(.note .note.*)
+ }
+
+ __kernel_end = .;
+} \ No newline at end of file