From: Joshua Wise Date: Wed, 10 Sep 2008 22:24:10 +0000 (-0400) Subject: Merge ELF loader. X-Git-Url: http://git.joshuawise.com/netwatch.git/commitdiff_plain/86c89e89a88d25e85956b258005b52e0f2686b89?ds=sidebyside;hp=-c Merge ELF loader. --- 86c89e89a88d25e85956b258005b52e0f2686b89 diff --combined grubload/Makefile index c850bb3,041f09c..f0f9742 --- a/grubload/Makefile +++ b/grubload/Makefile @@@ -1,4 -1,4 +1,4 @@@ - OBJS=multiboot_c.o multiboot_asm.o console.o minilib.o realmode.o -OBJS=multiboot_c.o multiboot_asm.o console.o minilib.o loader.o ++OBJS=multiboot_c.o multiboot_asm.o console.o minilib.o realmode.o loader.o CC=gcc CFLAGS=-nostdlib -I../include -I. -fno-builtin -nostdinc @@@ -6,9 -6,3 +6,9 @@@ all: multiboo 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 --combined grubload/multiboot_c.c index 25522e2,f871687..03e2143 --- a/grubload/multiboot_c.c +++ b/grubload/multiboot_c.c @@@ -1,8 -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; @@@ -26,8 -23,6 +26,8 @@@ void c_start(unsigned int magic, struc unsigned short *grubptr = 0x7CFE; int i; + void (*realmode)() = 0x4000; + puts("Magic is: "); puthex(magic); puts("\nMultiboot header is: "); @@@ -38,7 -33,8 +38,8 @@@ puts("Grubptr is: "); puthex(*grubptr); puts("\n"); - + + for (i = 0; i < wee->mod_cnt; i++) { puts("Module:\n"); @@@ -47,7 -43,15 +48,15 @@@ puts(" Name: "); puts(wee->mods[i].mod_string); puts("\n"); } + if ((wee->mod_cnt != 1) || (strcmp(wee->mods[0].mod_string, "aseg.elf"))) + { + puts("Expected 1 module called aseg.elf.\n"); + while(1) asm("hlt"); + } + + load_elf(wee->mods[0].mod_start, wee->mods[0].mod_end - wee->mods[0].mod_start); + - - while (1) - ; + puts("Now returning to real mode.\n"); + memcpy(0x4000, _binary_realmode_bin_start, (int)&_binary_realmode_bin_size); - realmode(); ++ realmode(); // goodbye! }