X-Git-Url: https://git.saurik.com/apple/boot.git/blobdiff_plain/14c7c974991c850bfa0348affbd4bee3223205ee..57c72a9a9f2a263d364c2df1178760bd057c390f:/i386/boot2/boot2.s diff --git a/i386/boot2/boot2.s b/i386/boot2/boot2.s index ec16572..f8b70b4 100644 --- a/i386/boot2/boot2.s +++ b/i386/boot2/boot2.s @@ -42,9 +42,13 @@ #define data32 .byte 0x66 #define retf .byte 0xcb - .file "boot2.s" + .data + +EXPORT(_chainbootdev) .byte 0x80 +EXPORT(_chainbootflag) .byte 0x00 + .text # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -75,12 +79,17 @@ LABEL(boot2) data32 call __real_to_prot # Enter protected mode. + fninit # FPU init + # We are now in 32-bit protected mode. # Transfer execution to C by calling boot(). pushl %edx # bootdev call _boot + testb $0xff, _chainbootflag + jnz start_chain_boot # Jump to a foreign booter + call __prot_to_real # Back to real mode. data32 @@ -96,3 +105,22 @@ LABEL(boot2) retf # Hardcode a far return +start_chain_boot: + xorl %edx, %edx + movb _chainbootdev, %dl # Setup DL with the BIOS device number + + call __prot_to_real # Back to real mode. + + data32 + call __switch_stack # Restore original stack + + pop %es # Restore original ES and DS + pop %ds + popl %edi # Restore all general purpose registers + popl %esi # except EAX. + popl %ebp + popl %ebx + popl %ecx + + data32 + ljmp $0, $0x7c00 # Jump to boot code already in memory