From 998fe3d26de4735bdbe43842ba2450174c4d5ee9 Mon Sep 17 00:00:00 2001 From: Jarkko Toivanen Date: Fri, 23 Jun 2023 22:53:43 +0300 Subject: [PATCH 1/3] Getting memory information --- src/kernel.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/kernel.c b/src/kernel.c index c71309b..115a290 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -59,6 +59,14 @@ void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) { serial_write_string("\n BPos:"); serial_write_string(itoa(mbootinfo->framebuffer_blue_field_position, 10)); + serial_write_string("\nMemory: "); + serial_write_string("\n lower: "); + serial_write_string(uitoa(mbootinfo->mem_lower, 10)); + serial_write_string(" k"); + serial_write_string("\n upper: "); + serial_write_string(uitoa(mbootinfo->mem_upper/1024, 10)); + serial_write_string(" M"); + initfb(mbootinfo->framebuffer_addr, mbootinfo->framebuffer_width, mbootinfo->framebuffer_height, mbootinfo->framebuffer_bpp, mbootinfo->framebuffer_pitch, mbootinfo->framebuffer_red_field_position, mbootinfo->framebuffer_green_field_position, mbootinfo->framebuffer_blue_field_position); int x, y, i; unsigned char c = 0; From b2c4091216acabeba777747a90c9153b8bec6209 Mon Sep 17 00:00:00 2001 From: Jarkko Toivanen Date: Fri, 23 Jun 2023 22:54:05 +0300 Subject: [PATCH 2/3] Fixing multiboot section to be a section --- src/start32.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/start32.asm b/src/start32.asm index 5344b47..4293474 100644 --- a/src/start32.asm +++ b/src/start32.asm @@ -9,7 +9,7 @@ MULTIBOOT_HEADER_MAGIC equ 0x1BADB002 MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN or MULTIBOOT_MEMORY_INFO or MULTIBOOT_VIDEO_REQUEST MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) -.multiboot: align 4 +section '.multiboot' align 4 dd MULTIBOOT_HEADER_MAGIC dd MULTIBOOT_HEADER_FLAGS dd MULTIBOOT_CHECKSUM From 5badddbadad80268929d63718751aa5615da6fb0 Mon Sep 17 00:00:00 2001 From: Jarkko Toivanen Date: Fri, 23 Jun 2023 22:54:46 +0300 Subject: [PATCH 3/3] Using framebuffer info for putpixel loop instead of hardcoded values (never expect Multiboot to give you what you want!) --- src/kernel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kernel.c b/src/kernel.c index 115a290..60d6c3a 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -71,8 +71,8 @@ void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) { int x, y, i; unsigned char c = 0; for(;;) { - for(y=0;y<768;y++) { - for(x=0;x<1024;x++) { + for(y=0; y < mbootinfo->framebuffer_height; y++) { + for(x=0; x < mbootinfo->framebuffer_width; x++) { putpixel(x, y, c, c, c, 0xff); } }