-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
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
#include "console.h"
+extern char _binary_realmode_bin_start[];
+extern int _binary_realmode_bin_size;
+
struct mb_info
{
unsigned long flags;
unsigned short *grubptr = 0x7CFE;
int i;
+ void (*realmode)() = 0x4000;
+
puts("Magic is: ");
puthex(magic);
puts("\nMultiboot header is: ");
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();
}