From: Joshua Wise Date: Wed, 10 Sep 2008 22:23:05 +0000 (-0400) Subject: Also add realmode warm booter X-Git-Url: http://git.joshuawise.com/netwatch.git/commitdiff_plain/c4a165640f8cbf4844426c8cea87246db3953467?hp=-c Also add realmode warm booter --- c4a165640f8cbf4844426c8cea87246db3953467 diff --git a/grubload/Makefile b/grubload/Makefile index 971fb5c..c850bb3 100644 --- a/grubload/Makefile +++ b/grubload/Makefile @@ -1,4 +1,4 @@ -OBJS=multiboot_c.o multiboot_asm.o console.o minilib.o +OBJS=multiboot_c.o multiboot_asm.o console.o minilib.o realmode.o CC=gcc CFLAGS=-nostdlib -I../include -I. -fno-builtin -nostdinc @@ -6,3 +6,9 @@ all: multiboot multiboot: $(OBJS) ld -o multiboot $(OBJS) -Ttext=0x100000 + +realmode.bin: realmode.asm + nasm -o realmode.bin realmode.asm + +realmode.o: realmode.bin + objcopy -I binary -B i386 -O elf32-i386 realmode.bin realmode.o diff --git a/grubload/multiboot_c.c b/grubload/multiboot_c.c index c87b675..25522e2 100644 --- a/grubload/multiboot_c.c +++ b/grubload/multiboot_c.c @@ -1,5 +1,8 @@ #include "console.h" +extern char _binary_realmode_bin_start[]; +extern int _binary_realmode_bin_size; + struct mb_info { unsigned long flags; @@ -23,6 +26,8 @@ void c_start(unsigned int magic, struct mb_info *wee) unsigned short *grubptr = 0x7CFE; int i; + void (*realmode)() = 0x4000; + puts("Magic is: "); puthex(magic); puts("\nMultiboot header is: "); @@ -41,6 +46,8 @@ void c_start(unsigned int magic, struct mb_info *wee) puts(" Size: "); puthex(wee->mods[i].mod_end - wee->mods[i].mod_start); puts("\n"); puts(" Name: "); puts(wee->mods[i].mod_string); puts("\n"); } - while (1) - ; + + puts("Now returning to real mode.\n"); + memcpy(0x4000, _binary_realmode_bin_start, (int)&_binary_realmode_bin_size); + realmode(); }