3 ms·
Real mode is "bad" because it emulates a crappy processor from 1976 with a weird 16 bit segmented model in which a segment address is multiplied by 16 and added
by kazinator 1y ago
Real mode is "bad" because it emulates a crappy processor from 1976 with a weird 16 bit segmented model in which a segment address is multiplied by 16 and added to the offset address, leading to 4096 ways of expressing the same pointer.
A real mode that provides a sane 32 or 64 bit address space, with the MMU disabled, would be totally cool.
- userbinator 1y agoBIOSes since the 386 traditionally switched to https://en.wikipedia.org/wiki/Unreal_mode https://en.wikipedia.org/wiki/Unreal_mode early in their init sequence.
- JdeBP 1y agoOther way around. The processors came up in unreal mode, and it is only comparatively recently that the firmwares have had the possibility of not needing to do the whole "compatibility support" thing and just going straight from unreal mode to protected mode, without passing through real mode.
- userbinator 1y agoNo, unreal mode was not the state at reset, at least as far as I know (my knowledge of the details ends around the time of the 3rd-generation i7.) Disassembling from the reset vector of any reset BIOS can confirm/deny whether that's still the case; notably, InsydeH2O BIOS enters unreal mode in around a dozen instructions from the reset vector.
- JdeBP 1y agoYes, it is; as I explained back in 2018. It's documented in the IA manuals, and indeed in the AMD manuals. The segment descriptors start off in unreal mode, which is changed at the first far jump that loads CS. TianoCore does a near jump after a couple of NOPs, because there's a whole 64KiB of space for unreal mode code to do the setup for entering the SEC phase, and it does a modicum of setup in unreal mode finding the boot firmware volume and indeed the SEC phase code. u-boot does not take as much advantage of the available space, changing directly from unreal mode to flat model 32-bit protected mode within a few instructions of the initial near jump. * https://news.ycombinator.com/item?id=18166292 https://news.ycombinator.com/item?id=18166292 * https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/SecCore/Ia32/ResetVec.nasmb#L70 https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Sec... * https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/ResetVector/Vtf0/ReadMe.txt https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Res... * https://github.com/u-boot/u-boot/blob/master/arch/x86/cpu/start16.S#L47 https://github.com/u-boot/u-boot/blob/master/arch/x86/cpu/st...