diff --git a/Makefile b/Makefile index a27f836..95ce54f 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ GNU ?= $(PREFIX)/$(ARCH)/bin/$(ARCH) # Source files SOURCES_ASM := arch/$(ARCH)/boot.s -SOURCES_C := driver/video/vga.c kernel/brados.c lib/string.c +SOURCES_C := arch/$(ARCH)/multiboot.c driver/video/vga.c kernel/brados.c kernel/printk.c lib/string.c # Object files OBJS := $(patsubst %.s,%.o,$(SOURCES_ASM)) diff --git a/arch/arm-none-eabi/multiboot.c b/arch/arm-none-eabi/multiboot.c new file mode 100644 index 0000000..ce0a430 --- /dev/null +++ b/arch/arm-none-eabi/multiboot.c @@ -0,0 +1,13 @@ +#include + +#include + +uint32_t multiboot_getAddress() +{ + return 0; +} + +uint32_t multiboot_getMagic() +{ + return 0; +} diff --git a/arch/i586-elf/boot.s b/arch/i586-elf/boot.s index 9dd64ac..c667fd1 100644 --- a/arch/i586-elf/boot.s +++ b/arch/i586-elf/boot.s @@ -27,6 +27,9 @@ _start: # Setup the stack movl $stack_top, %esp + # Push the multiboot information onto the stack + push %ebx + push %eax # Call the main kernel function call brados_main diff --git a/arch/i586-elf/multiboot.c b/arch/i586-elf/multiboot.c new file mode 100644 index 0000000..bb5c489 --- /dev/null +++ b/arch/i586-elf/multiboot.c @@ -0,0 +1,23 @@ +#include + +#include + +uint32_t multiboot_getAddress() +{ + uint32_t address = 0; + __asm__( + "movl %%ebx, %0;" + :"=r"(address) + ); + return address; +} + +uint32_t multiboot_getMagic() +{ + uint32_t magic = 0; + __asm__( + "movl %%eax, %0;" + :"=r"(magic) + ); + return magic; +} diff --git a/driver/video/vga.c b/driver/video/vga.c index ff335ae..4f26589 100644 --- a/driver/video/vga.c +++ b/driver/video/vga.c @@ -82,6 +82,26 @@ void term_setColor(struct vgastate *state, uint8_t color) state->term_color = color; } +// Test various VGA functionality +void term_test(struct vgastate *term) +{ + // Test line wrapping + term_writeStr(term, "Welcome to the desert of the real. I thought what I'd do was I'd pretend I was one of those deaf mutes.\n\n"); + + // Test colors + term_setColor(term, make_color(VGA_COLOR_BLACK, VGA_COLOR_WHITE)); + term_writeStr(term, "This text should be inverse.\n"); + term_setColor(term, make_color(VGA_COLOR_LIGHT_BLUE, VGA_COLOR_GREEN)); + term_writeStr(term, "This text should be colorful.\n\n"); + + // Test scrolling + term_setColor(term, make_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK)); + for (size_t i = 0; i < 20; i++) { + term_writeStr(term, "Printing some lines.\n"); + for (volatile size_t j = 0; j < 100000000; j++); + } +} + // Write a string to a VGA term void term_writeStr(struct vgastate *state, const char *data) { diff --git a/include/brados/printk.h b/include/brados/printk.h new file mode 100644 index 0000000..78ad554 --- /dev/null +++ b/include/brados/printk.h @@ -0,0 +1,8 @@ +#ifndef __brados_printk_h__ +#define __brados_printk_h__ + +#include