4 ms·
As another alternative, bootstrap your OS using EFI. You get to boot directly in 32-bit or 64-bit mode, as with multiboot, and you get a handful of OS-like fac
by JoshTriplett 12y ago
As another alternative, bootstrap your OS using EFI. You get to boot directly in 32-bit or 64-bit mode, as with multiboot, and you get a handful of OS-like facilities to bootstrap yourself with, such as files, input, output, graphics, and even networking. (You'll want to replace those with your own facilities eventually, but until then you can focus on more interesting problems.)
- exDM69 12y agoExcellent point, back when I was writing my project, EFI wasn't a viable alternative. Do you know how is the tooling with EFI these days? Can you boot EFI-bootable images using QEMU or Bochs? How about debugging, etc?
- JoshTriplett 12y agoKVM/QEMU with the OVMF BIOS image provides a full emulation environment for testing and debugging. You can build EFI binaries using entirely Open Source tools. Also try BITS (biosbits.org) for experimentation with either BIOS, ACPI, and EFI; it's a port of Python to run in GRUB2. (I'm one of the upstream authors.)
- voltagex_ 12y agoHave you got any good references for OS dev under (U)EFI? The specs from the Tianocore project are fairly verbose.
- JoshTriplett 12y agoI don't know of any tutorial-style material, but for references, I use both the official specs from uefi.org and the wiki on the Phoenix site (for instance, http://wiki.phoenix.com/wiki/index.php/EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL http://wiki.phoenix.com/wiki/index.php/EFI_SIMPLE_TEXT_INPUT... ).
- pgeorgi 12y agobut you don't get to decide whether to use 32bit or 64bit mode, your firmware does for you.
- exDM69 12y agoFirmware? No, the OS will have to explicitly choose the mode the CPU operates in. The PC, under "normal" legacy BIOS, always boots to 16 bit mode (like in OP). From there on, you manually have to change the processor operating mode to 32 bits (protected mode) or 64 bits (long mode), by setting some privileged registers and doing a jump to 32/64 bit code. In the case of UEFI, it may be possible to explicitly ask for a certain operating mode at boot, but I am not familiar with that (yet).
- JoshTriplett 12y ago> In the case of UEFI, it may be possible to explicitly ask for a certain operating mode at boot, but I am not familiar with that (yet). That was the point of the comment you replied to. Normally, EFI either runs in 32-bit or 64-bit, and only loads and runs binaries for that mode.
- JoshTriplett 12y agoTrue, the portion of your OS that actually uses EFI services must work in both 32-bit and 64-bit mode, so you'll have to write it portably. That's somewhat easier since you don't need to write any assembly; you can write in any high-level language with an FFI to C. However, you can run a 64-bit OS with 32-bit EFI or vice versa; you just have to switch modes yourself. And you can defer that until later in the development of your OS.
- pgeorgi 12y agoOnce you switch modes, you better stick to Runtime Services, so networking etc is out. But yes, for the beginning all that might not matter too much and you can get by running your "OS" as BDS application and incrementally migrate away from that.