diff --git a/Makescript b/Makescript new file mode 100644 index 0000000..e85ac06 --- /dev/null +++ b/Makescript @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +INCLUDE="-Isys/drv/vga/include -Isys/include" +CFLAGS="-g -m32 -ffreestanding -Wall -Wextra -pedantic -nostdlib $INCLUDE" +ASFLAGS="-felf32" +LDFLAGS="-m elf_i386" + +cc $CFLAGS -c sys/drv/vga/video.c -o obj/vga.o +cc $CFLAGS -c sys/sysinit.c -o obj/sysinit.o +nasm $ASFLAGS boot/boot.s -o obj/boot.o +ld $LDFLAGS -T boot/link.ld -o omos obj/boot.o obj/vga.o obj/sysinit.o diff --git a/boot/Makefile b/boot/Makefile new file mode 100644 index 0000000..2e284ff --- /dev/null +++ b/boot/Makefile @@ -0,0 +1,5 @@ +AS=nasm +FLAGS=-felf32 + +boot.o: + $(AS) $(FLAGS) boot.s -o boot.o diff --git a/boot/boot.s b/boot/boot.s index b9f1494..c776932 100644 --- a/boot/boot.s +++ b/boot/boot.s @@ -1,15 +1,12 @@ ; only support mb1 -align equ 1 << 0 -info equ 1 << 1 -flags equ align | info -magic equ 0x1BADB002 -chksum equ - (magic + flags) + +bits 32 section .multiboot align 4 - dd magic - dd flags - dd chksum + dd 0x1badb002 + dd 0x00 + dd - (0x1badb002 + 0x00) global _start extern sysinit diff --git a/link.ld b/link.ld new file mode 100644 index 0000000..2bb394a --- /dev/null +++ b/link.ld @@ -0,0 +1,9 @@ +OUTPUT_FORMAT(elf32-i386) +ENTRY(_start) +SECTIONS +{ + . = 0x100000; + .text : {*(.text)} + .data : {*(.data)} + .bss : {*(.bss)} +} diff --git a/omos b/omos new file mode 100755 index 0000000..e18b757 Binary files /dev/null and b/omos differ diff --git a/sys/Makefile b/sys/Makefile index b87ea45..b974734 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -1,4 +1,5 @@ include sys/drv/vga/Makefile + CC=cc FLAGS=-Wall -c -g -Wextra -ffreestanding -m32 -nostdlib SRCS=$(wildcard sys/*.c) diff --git a/sys/drv/vga/include/video.h b/sys/drv/vga/include/video.h index 1c3ff3f..b9ec86a 100644 --- a/sys/drv/vga/include/video.h +++ b/sys/drv/vga/include/video.h @@ -8,6 +8,6 @@ s8 *vga_vidmem = (s8 *)0xb8000; void vga_write(s8 *, s8); -void vga_clearscreen(); +void vga_clearscreen(void); #endif diff --git a/sys/drv/vga/video.c b/sys/drv/vga/video.c index 1ace1b4..d8b607a 100644 --- a/sys/drv/vga/video.c +++ b/sys/drv/vga/video.c @@ -15,7 +15,9 @@ vga_write(s8 *sequence, s8 flags) } } -void vga_clearscreen() { +void +vga_clearscreen(void) +{ for (int i = 0; i <= SIZE; i++) { vga_vidmem[i] = 0; } diff --git a/sys/sysinit.c b/sys/sysinit.c index af45b09..9d57aa0 100644 --- a/sys/sysinit.c +++ b/sys/sysinit.c @@ -1,4 +1,6 @@ void -sysinit() { - write("Om Smart.", 0x0F, 10); +sysinit(void) +{ + vga_clearscreen(); + vga_write("Om Smart.", 0x0F); }