8

What I'm wanting to do is somehow run BIOS-only OSes on computers that do not support BIOS booting or CSM. Does there exist an efi application that I can chainload that can act as some kind of emulator for legacy BIOS?

For my purposes, using a VM defeats the point. I'm looking for as close to bare-metal as possible.

12
  • 4
    A company that writes UEFI firmware might be able to write one with a Legacy mode(aka CFM). You might need to fit a chip, this website mentions something about a chip replacement biosmaster.co.uk
    – barlop
    Jun 12, 2023 at 4:08
  • 1
    @barlop For my purposes, replacing a chip is out of the question. My question as written is about the general idea of software emulation of BIOS calls that can run on a UEFI-only motherboard. However my specific use case is installing old OSes (like windows xp, dos, windows 3.1, etc) on newer hardware. I didn't include that detail because I feel that would attract "Use DOSBox" and "Use a VM" as answers, which is not in the spirit of what I'm looking for.
    – Daffy
    Jun 12, 2023 at 4:22
  • 3
    I think this is a lot more complex than one would assume, looking at gitlab.com/tkchia/biefircate/-/blob/main/NOTES.asciidoc here. Found via reboot.pro/index.php?showtopic=22488 . There was also BAMBIOS but never heard of it again after initial drop..
    – Raf
    Jun 13, 2023 at 13:35
  • 2
    Looks like it exists for Win 7: github.com/manatails/uefiseven although the last commit is 2 years old. You could analyze that and see to make it work for other OSes
    – 1NN
    Jun 14, 2023 at 8:06
  • 1
    And it looks like someone figured it out for Win XP too: betaarchive.com/forum/… So the easier approach looks like going OS by OS, rather than to emulate BIOS. It's easier to google, too .. I found this googling for "windows xp on uefi"
    – 1NN
    Jun 14, 2023 at 8:27

2 Answers 2

12

A "BIOS emulator" would mostly be a full BIOS implementation, minus the motherboard-specific hardware initialization code. The one that's typically used in such situations is SeaBIOS, which is used e.g. on machines that use Coreboot firmware (dual-booting Chromebooks and such) in a very similar way as you're asking for UEFI.

SeaBIOS also seems to be available as an UEFI firmware package (i.e. it can be the CSM embedded in your firmware), though apparently not as a standalone .efi executable.

4
  • 1
    I think much lesser can be done. I couldn't crack how due to insufficient understanding of UEFI syscalls. You should be able to relocate your emulator above 15MB (memory between 1MB-15MB must be contiguous--but you can use a sparse map above), relocate yourself there, set up a new memory mapping that uses F0000-FFFFF as a 16 bit to 64 bit trampoline and implement bios services in terms of UEFI services. It's open to debate whether or not it's faster to switch between 16 and 64 bit code in the trampoline or just emulate all 16 bit instructions.
    – Joshua
    Jun 12, 2023 at 18:57
  • @Joshua do you think it would be possible to implement all BIOS interrupt calls, which is pretty bare metal stuff, in a complete hardware agnostic way using only high level UEFI interfaces?
    – xenoson
    Jun 19, 2023 at 14:01
  • @xenoson: Assuming no floppy disk device, the only things you would have to implement directly are 14h and 1Ah. 15h function 89h can't be done, but it's so rarely used that it was broken (as in returns to the wrong address) for years before somebody noticed. Note that you can get away with saying "no printer here", "no joystick here", and "no lightpen here".
    – Joshua
    Jun 19, 2023 at 14:31
  • Correction: "broken for years" -> "broken in dosbox for years"
    – Joshua
    Jun 19, 2023 at 21:50
2

I am not sure, but I believe GRUB or REFIND (Or it's Mac-compatible fork ReFIT) can boot mbr, but it is really a function of the BIOS to load the legacy MBR/CSM (compatibility support mode). Your best bet is to install these tools and try to see if they will work on your hardware.

Edit: after doing some digging, the answer is likely no: https://www.freebasic.net/forum/viewtopic.php?t=27466 https://mail.coreboot.org/hyperkitty/list/[email protected]/thread/GNX7DJC7BF6JUSKFZVGSZEWWZG2FUPDR/

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .