From 53801b9baed096e57b40df6147d9ff0f3da0c737 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sat, 16 May 2020 13:25:46 -0400 Subject: Hello world --- src/kernel/link.ld | 15 +++++++++++++++ src/kernel/main.c | 7 +++++++ src/kernel/vga.c | 14 ++++++++++++++ src/kernel/vga.h | 3 +++ 4 files changed, 39 insertions(+) create mode 100644 src/kernel/link.ld create mode 100644 src/kernel/main.c create mode 100644 src/kernel/vga.c create mode 100644 src/kernel/vga.h (limited to 'src/kernel') diff --git a/src/kernel/link.ld b/src/kernel/link.ld new file mode 100644 index 0000000..1fcff40 --- /dev/null +++ b/src/kernel/link.ld @@ -0,0 +1,15 @@ +OUTPUT_FORMAT(binary) +OUTPUT_ARCH(i386) + +SECTIONS { + . = 0x00030000; + .entry : { + */main.o(.text) + } + .bin : { + *(.text) + *(.rodata) + *(.data) + *(.bss) + } +} \ No newline at end of file diff --git a/src/kernel/main.c b/src/kernel/main.c new file mode 100644 index 0000000..1a8b2f4 --- /dev/null +++ b/src/kernel/main.c @@ -0,0 +1,7 @@ +#include +#include "vga.h" + +void main() { + while (1) + vga_printsz("Hello! "); +} \ No newline at end of file diff --git a/src/kernel/vga.c b/src/kernel/vga.c new file mode 100644 index 0000000..d0170c0 --- /dev/null +++ b/src/kernel/vga.c @@ -0,0 +1,14 @@ +#include + +#define VGA_START (uint16_t *)0x000b8000 +#define VGA_END (VGA_START + 80 * 25) +uint16_t *cursor = VGA_START; +uint16_t color = 0x1f00; + +void vga_printsz(uint8_t *sz) { + while (*sz) { + *(cursor++) = color | *(sz++); + if (cursor == VGA_END) + cursor = VGA_START; + } +} \ No newline at end of file diff --git a/src/kernel/vga.h b/src/kernel/vga.h new file mode 100644 index 0000000..47ac1fb --- /dev/null +++ b/src/kernel/vga.h @@ -0,0 +1,3 @@ +#include + +void vga_printsz(uint8_t *sz); \ No newline at end of file -- cgit v1.2.3