[SeaBIOS] Entering protected mode (and back) in option ROM

Bob Moore Robert.Moore at hgst.com
Tue Mar 1 00:05:44 CET 2016


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?





        lgdtw %cs:opRom_gdt_32

        movl %cr0, %eax
        orl $1, %eax
        movl %eax, %cr0

        ljmp $MODE32_CS_SEL, $pmode

        movl $MODE32_DS_SEL, %eax
        movl $16, %eax
        movw %ax, %ds
        movw %ax, %es
        movw %ax, %ss
        movw %ax, %fs
        movw %ax, %gs


// 32 bit protected mode GDT descriptors
.quad 0x0
.quad 0x00CF9B000000FFFF
.quad 0x00CF93000000FFFF
.quad 0x00CFFA000000FFFF
.quad 0x00CFF2000000FFFF

.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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.seabios.org/pipermail/seabios/attachments/20160229/e4d946be/attachment.html>

More information about the SeaBIOS mailing list