From 4130562b1555cabe441efe9420cebe12e7ed8d39 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sat, 13 Jan 2024 16:43:49 -0500 Subject: application loading --- applications/init/main.cpp | 24 ++++++++++++++++++++++++ applications/link.ld | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 applications/init/main.cpp create mode 100644 applications/link.ld (limited to 'applications') diff --git a/applications/init/main.cpp b/applications/init/main.cpp new file mode 100644 index 0000000..7aa2a38 --- /dev/null +++ b/applications/init/main.cpp @@ -0,0 +1,24 @@ +#include + +using mercury::syscall::encoded_color; +using mercury::syscall::color; + +encoded_color *fb; +uint32_t fb_width; +uint32_t fb_height; +uint32_t fb_pitch; + +int main(int, char **) { + mercury::syscall::get_framebuffer(fb, fb_width, fb_height, fb_pitch); + for (uint32_t y = 0; y < fb_height; ++y) + for (uint32_t x = 0; x < fb_width; ++x) { + color c = { + .r = 0, + .g = (uint8_t)(y * 255 / fb_height), + .b = (uint8_t)(x * 255 / fb_width) + }; + fb[y * fb_pitch + x] = mercury::syscall::encode_color(c); + } + mercury::syscall::draw_framebuffer(); + return 0; +} diff --git a/applications/link.ld b/applications/link.ld new file mode 100644 index 0000000..eaba220 --- /dev/null +++ b/applications/link.ld @@ -0,0 +1,38 @@ +OUTPUT_FORMAT(elf64-x86-64) +OUTPUT_ARCH(i386:x86-64) + +ENTRY(_entry) + +PHDRS { + rx PT_LOAD FLAGS(5); + ro PT_LOAD FLAGS(4); + rw PT_LOAD FLAGS(6); +} + +SECTIONS { + + /* see also ../documentation/memory.txt */ + . = 0x200000; + + .text : { + *(.text .text.*) + } : rx + + . = ALIGN(0x200000); + + .rodata : { + *(.rodata .rodata.*) + } : ro + + . = ALIGN(0x200000); + + .data : { + *(.data .data.*) + } : rw + + .bss : { + *(.bss .bss.*) + *(COMMON) + } : rw + +} -- cgit v1.2.3