From 06644a02f94379a316ed5e0a6dd0f5d640fa6b96 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 18 Oct 2020 13:25:26 -0400 Subject: [PATCH] draw pixels to screen to verify framebuffer access and multiboot info --- src/boot.S | 18 ++++++++++++++++-- src/kernel_main.c | 10 +++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/boot.S b/src/boot.S index 33072fe..06bfd9e 100644 --- a/src/boot.S +++ b/src/boot.S @@ -1,7 +1,8 @@ /* Declare constants for the multiboot header. */ .set ALIGN, 1<<0 /* align loaded modules on page boundaries */ .set MEMINFO, 1<<1 /* provide memory map */ -.set FLAGS, ALIGN | MEMINFO /* this is the Multiboot 'flag' field */ +.set VID, 1<<2 +.set FLAGS, ALIGN | MEMINFO | VID /* this is the Multiboot 'flag' field */ .set MAGIC, 0x1BADB002 /* 'magic number' lets bootloader find the header */ .set CHECKSUM, -(MAGIC + FLAGS) /* checksum of above, to prove we are multiboot */ @@ -17,6 +18,15 @@ forced to be within the first 8 KiB of the kernel file. .long MAGIC .long FLAGS .long CHECKSUM +.long 0 +.long 0 +.long 0 +.long 0 +.long 0 +.long 0 +.long 0 +.long 0 +.long 0 /* The multiboot standard does not define the value of the stack pointer register @@ -75,7 +85,7 @@ _start: C++ features such as global constructors and exceptions will require runtime support to work as well. */ - + /* Enter the high-level kernel. The ABI requires the stack is 16-byte aligned at the time of the call instruction (which afterwards pushes @@ -84,6 +94,10 @@ _start: stack since (pushed 0 bytes so far), so the alignment has thus been preserved and the call is well defined. */ + push $0 + push $0 + push $0 + push %ebx call kernel_main /* diff --git a/src/kernel_main.c b/src/kernel_main.c index 1a22fb2..fd5cae8 100644 --- a/src/kernel_main.c +++ b/src/kernel_main.c @@ -1,9 +1,13 @@ #include -void kernel_main(void) +void kernel_main(uint32_t mbinfo) { - for (;;) + volatile uint32_t * mbi = (volatile uint32_t *)mbinfo; + volatile uint32_t * fb = (volatile uint32_t *)mbi[88 / 4]; + uint32_t c = 0u; + for (uint32_t i = 0u; i < 800u * 600u; i++) { - (*(volatile uint16_t *)0xB8000)++; + c++; + fb[i] = (c << 28u) | 0x00669900u | ((c << 4u) & 0xFFu); } }