From 8f00324b30aa80fc66b89a41b7baa71cd72ccd84 Mon Sep 17 00:00:00 2001 From: josh Date: Wed, 25 Jul 2007 03:00:58 +0000 Subject: [PATCH] bootable with small multiboot kernel git-svn-id: svn://anubis/hos/trunk@5 5b3e749e-e535-0410-8002-a9bb6afbdfca --- Makefile | 9 +++++++-- iso/boot/grub/menu.lst | 6 ++++++ kernel/Makefile | 8 ++++++-- kernel/boot.asm | 27 +++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 iso/boot/grub/menu.lst create mode 100644 kernel/boot.asm diff --git a/Makefile b/Makefile index cb3342f..764a134 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,9 @@ HOS = hos MKISOFS = genisoimage ISO = $(HOS).iso +QEMU = qemu-system-x86_64 -.PHONY: kernel iso clean +.PHONY: kernel iso clean qemu # default target: build the kernel and ISO image all: kernel iso @@ -14,9 +15,13 @@ kernel: # build the ISO image iso: kernel + cp kernel/$(HOS) iso/boot $(MKISOFS) -R -b boot/grub/stage2_eltorito -no-emul-boot \ -boot-load-size 4 -boot-info-table -o $(ISO) iso clean: make -C kernel clean - -rm -f $(ISO) + -rm -f $(ISO) iso/boot/$(HOS) + +qemu: + $(QEMU) -cdrom $(ISO) -boot d -m 384 -localtime diff --git a/iso/boot/grub/menu.lst b/iso/boot/grub/menu.lst new file mode 100644 index 0000000..447f187 --- /dev/null +++ b/iso/boot/grub/menu.lst @@ -0,0 +1,6 @@ + +timeout 10 +default 0 + +title HOS +kernel /boot/hos diff --git a/kernel/Makefile b/kernel/Makefile index ebbed51..745f3b3 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,8 +1,12 @@ +KERNEL = hos +TARGET = elf32-i386 + .PHONY: clean all: - @echo Nothing yet + nasm -f elf -o boot.o boot.asm + ld --oformat $(TARGET) -o $(KERNEL) boot.o clean: - @echo Nothing yet + -rm -f *~ $(KERNEL) *.o diff --git a/kernel/boot.asm b/kernel/boot.asm new file mode 100644 index 0000000..d616cd9 --- /dev/null +++ b/kernel/boot.asm @@ -0,0 +1,27 @@ + +%define MULTIBOOT_HEADER_MAGIC 0x1BADB002 +%define MULTIBOOT_HEADER_FLAGS 0x3 + +[global start] +[global _start] +start: +_start: + jmp multiboot_entry + align 4 + +multiboot_header: + ; magic + dd MULTIBOOT_HEADER_MAGIC + ; flags + dd MULTIBOOT_HEADER_FLAGS + ; checksum + dd -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) + +multiboot_entry: + mov byte [0xB8000+160*10+2*2], 'J' + mov byte [0xB8001+160*10+2*2+1], 0x07 + +looplbl: + hlt + jmp looplbl +