draw pixels to screen to verify framebuffer access and multiboot info

This commit is contained in:
Josh Holtrop 2020-10-18 13:25:26 -04:00
parent 8f9881889b
commit 06644a02f9
2 changed files with 23 additions and 5 deletions

View File

@ -1,7 +1,8 @@
/* Declare constants for the multiboot header. */ /* Declare constants for the multiboot header. */
.set ALIGN, 1<<0 /* align loaded modules on page boundaries */ .set ALIGN, 1<<0 /* align loaded modules on page boundaries */
.set MEMINFO, 1<<1 /* provide memory map */ .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 MAGIC, 0x1BADB002 /* 'magic number' lets bootloader find the header */
.set CHECKSUM, -(MAGIC + FLAGS) /* checksum of above, to prove we are multiboot */ .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 MAGIC
.long FLAGS .long FLAGS
.long CHECKSUM .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 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 C++ features such as global constructors and exceptions will require
runtime support to work as well. runtime support to work as well.
*/ */
/* /*
Enter the high-level kernel. The ABI requires the stack is 16-byte Enter the high-level kernel. The ABI requires the stack is 16-byte
aligned at the time of the call instruction (which afterwards pushes 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 stack since (pushed 0 bytes so far), so the alignment has thus been
preserved and the call is well defined. preserved and the call is well defined.
*/ */
push $0
push $0
push $0
push %ebx
call kernel_main call kernel_main
/* /*

View File

@ -1,9 +1,13 @@
#include <stdint.h> #include <stdint.h>
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);
} }
} }