aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--boot/grub.cfg2
-rw-r--r--src/boot.s25
-rw-r--r--src/kernel.c10
4 files changed, 31 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 769f738..e587fec 100644
--- a/Makefile
+++ b/Makefile
@@ -2,9 +2,10 @@ CC = i386-elf-gcc
AS = i386-elf-as
CFLAGS = -std=gnu99 -ffreestanding -O2 -Wall -Wextra
-SRCS = src/kernel.c
OBJS = src/boot.o src/kernel.o
+.PHONY: all clean iso-files
+
all: FrenchToastOS-bios.iso FrenchToastOS-efi.iso
src/boot.o: src/boot.s
@@ -21,7 +22,6 @@ iso-files: FrenchToastOS.bin
cp FrenchToastOS.bin isodir/boot/
cp boot/grub.cfg isodir/boot/grub/
-
FrenchToastOS-bios.iso: iso-files
grub-mkrescue /usr/lib/grub/i386-pc -o FrenchToastOS-bios.iso isodir
diff --git a/boot/grub.cfg b/boot/grub.cfg
index 05aa62e..8a730f9 100644
--- a/boot/grub.cfg
+++ b/boot/grub.cfg
@@ -2,5 +2,7 @@
# This software is licensed under the ARPL. See LICENSE for details.
menuentry "FrenchToastOS" {
+ set gfxmode=1024x768x32
+ insmod multiboot
multiboot /boot/FrenchToastOS.bin
}
diff --git a/src/boot.s b/src/boot.s
index 053752a..caad675 100644
--- a/src/boot.s
+++ b/src/boot.s
@@ -2,17 +2,33 @@
This software is licensed under the ARPL. See LICENSE for details. */
/* Multiboot header dark magic, do not touch */
-.set ALIGN, 1<<0
-.set MEMINFO, 1<<1
-.set FLAGS, ALIGN | MEMINFO
-.set MAGIC, 0x1BADB002
+.set ALIGN, 1<<0
+.set MEMINFO, 1<<1
+.set VIDMODE, 1<<2
+.set FLAGS, ALIGN | MEMINFO | VIDMODE
+.set MAGIC, 0x1BADB002
.set CHECKSUM, -(MAGIC + FLAGS)
+/* ask grub for framebuffer
+ if this breaks the OS i might crash out */
+.set WIDTH, 1024
+.set HEIGHT, 768
+.set DEPTH, 32
+
.section .multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
+.long 0 /* header_addr (unused) */
+.long 0 /* load_addr (unused) */
+.long 0 /* load_end_addr (unused) */
+.long 0 /* bss_end_addr (unused) */
+.long 0 /* entry_addr (unused) */
+.long 0 /* mode_type: 0 = linear framebuffer */
+.long WIDTH /* width */
+.long HEIGHT /* height */
+.long DEPTH /* depth */
/* Multiboot does not define the esp/stack, create the stack ourselves */
.section bss
@@ -43,6 +59,7 @@ _start:
ABI says we need 16-byte alignment here, we aligned that before and pushed a multiple of 16 bits (zero) so we fine
but i will realign for good measure anyway */
.align 16
+ push %ebx
call kernel_main
/* if nothing left then just infinite loop */
diff --git a/src/kernel.c b/src/kernel.c
index ae50def..9697a83 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -5,14 +5,14 @@ This software is licensed under the ARPL. See LICENSE for details. */
#include <stddef.h>
#include <stdint.h>
-/* Check if the compiler thinks you are targeting the wrong operating system. */
+/* check if compiler thinks we are targeting incorrect OS. */
#if defined(__linux__)
-#error "you are not using a cross-compiler, this is bad. use an elf cross-compiler for ix86 targets, for example, i686-elf-gcc"
+#error "you are not using a cross-compiler, this is bad. use an elf cross-compiler for ix86 targets, for example, i386-elf-gcc"
#endif
-/* This operating system will only work for the 32-bit ix86 targets. */
+/* OS only works on 32bit ix86 */
#if !defined(__i386__)
-#error "this operating system needs to be compiled with a ix86-elf compiler"
+#error "this operating system is only supported on ix86 targets. use an elf cross-compiler for ix86 targets, for example, i386-elf-gcc"
#endif
/* Hardware text mode color constants. */
@@ -123,6 +123,8 @@ void kernel_main(void)
terminal_writestring("loading FrenchToastOS...\n");
terminal_writestring("developed by Arslaan Pathan");
+ /* if there is nothing else to do, halt, or the computer commit die */
+ /* our boot.s code does this already, but better to be safe than f**ked */
while (1) {
__asm__ __volatile__ ("hlt");
}