There are many GRUB-experts on this forum, maybe one of you know the answer.
My boot loader is capable of booting many different ways (from ROM, disk, cdrom, as Linux kernel, etc.) All works fine, except when I boot it with recent GRUB2 versions.
Because my loader is quite complex, I've narrowed the problem down to a simple VESA call and 512 bytes of code. I've attached the source and the outputs. The problem is, when this code is booted through GRUB using Multiboot, and it switches back to real mode to continue where the other boot paths start, then some of the BIOS routines go crazy. I think the code sets up everything for real mode correctly (segments, GDT, IVT etc.). I wonder what could be missing.
Code: Select all
USE32
multiboot_start:
cli
cld
lgdt [GDT_value]
mov ax, DATA_BOOT
mov ds, ax
mov es, ax
jmp CODE_BOOT:.real ;load 16 bit mode segment into cs
USE16
.real: mov eax, CR0
and eax, 07FFFFFFEh ;switching back to real mode
mov CR0, eax
xor ax, ax
mov ds, ax ;load segment registers DS and CS
jmp 0:@f
@@: lidt [idt16] ;restore IDT as newer GRUBs mess it up
;fallthrough realmode_start
realmode_start:
I've provided a Makefile for testing ("make all" will compile the code and create the required images):
Code: Select all
make bochsrom
make bochsbios
make bochsgrub
make qemurom
make qemubios
make qemugrub
Cheers,
bzt
ps: the attachment is a targz, but phpbb does not allow the extension tgz.