Hello,
I have a need to access 32 bit address space from within a 16 bit option ROM I’m writing. As a test I added code to load the gdt as required to set up 32 bit protected mode but I’ve encountered a problem. Below are my code and gdt structures.
My issue is that when the ljmp is executed the model reboots (this is running on seabios under Qemu). I suspect a GP violation but can’t seem to put my finger on it. I tried defining an idt containing a handler that hangs (i.e. jmp .) but was never successful
in seeing that work.
Does anyone have ideas for why this won’t work? Could the Qemu environment restrict this?
Thanks.
Bob
--------------------------------------------
go_to_32bit_protected_mode:
cli
cld
lgdtw %cs:opRom_gdt_32
movl %cr0, %eax
orl $1, %eax
movl %eax, %cr0
ljmp $MODE32_CS_SEL, $pmode
.code32
pmode:
movl $MODE32_DS_SEL, %eax
movl $16, %eax
movw %ax, %ds
movw %ax, %es
movw %ax, %ss
movw %ax, %fs
movw %ax, %gs
sti
ret
// 32 bit protected mode GDT descriptors
opRom_gdt_32_descs_start:
.quad 0x0
.quad 0x00CF9B000000FFFF
.quad 0x00CF93000000FFFF
.quad 0x00CFFA000000FFFF
.quad 0x00CFF2000000FFFF
opRom_gdt_32_descs_end:
opRom_gdt_32:
.word (opRom_gdt_32_descs_end - opRom_gdt_32_descs_start) - 1
.long opRom_gdt_32_descs_start
Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer:
This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.