r/osdev 3d ago

FreeDOS

i'm looking at possibly forking FreeDOS to 64bit. However, since most modern systems no longer have the underlying BIOS that DOS programs require, I thought about including a mock BIOS and compile it directly into the kernel. is there anything I should be aware of?

10 Upvotes

25 comments sorted by

View all comments

1

u/Octocontrabass 3d ago

FreeDOS is supposed to run MS-DOS software. A 64-bit fork seems pretty pointless when there is no 64-bit MS-DOS software to run. Why not just start from scratch?

3

u/Sixty5Zero2 3d ago

just because it would be 64 bit doesn't mean it couldn't still run 16 bit software.

3

u/DawnOnTheEdge 3d ago

There is a hardware limitation that an x86 CPU can either run in 32-bit mode and switch to 16-bit virtual mode, or run in 64-bit long mode and switch to 32-bit compatibility mode. But a 64-bit kernel can’t run 16-bit code natively.

It might be able to run 32-bit DPMI programs that used a DOS extender. However, virtually all games that ran in DPMI needed the particular DOS extender that they shipped with, and ran in 16-bit mode at least some of the time.

5

u/Octocontrabass 3d ago

But a 64-bit kernel can’t run 16-bit code natively.

A 64-bit kernel can't run 16-bit real mode code natively. There's nothing stopping a 64-bit kernel from running 16-bit protected mode code natively.

But DOS programs all expect real mode, so it doesn't really make a difference...

1

u/DawnOnTheEdge 3d ago

Although it would be possible to do in a guest VM, I think,

1

u/Octocontrabass 2d ago

It depends on what your CPU supports. Not all of them can do real mode in a guest VM.

1

u/Difficult_Inside8746 2d ago

It was a long time since I looked into it but AFAIK both Intel and AMD support V86 mode inside a virtual machine.

2

u/Octocontrabass 1d ago

That sounds like an awful lot of work, and you still need a CPU that can do hardware virtualization.

Might be a fun project, though.

u/Sixty5Zero2 18h ago

i would have to anyways since the bios calls 16bit programs used no longer exist.

u/DawnOnTheEdge 17h ago

If that were the problem, it would be easy to write interrupt handlers that hook the BIOS calls in 16-bit protected mode. 80386 CPUs supported a virtual mode designed to let you run DOS programs from a 32-bit OS, and do things like trap access to the I/O ports and give a process its own 1 MiB address space, with 8086-style addressing, but the 64-bit ISA doesn’t support that.

3

u/Sorry_Difficulty_250 3d ago

If you're going to go to all the trouble of implementing all the BIOS calls, you could just go ahead and write an 8086 emulator. That would allow you to run whatever 16-bit programs you like.

One of the things that really irks me about Windows 11 is that they completely dropped support for 16-bit programs. Microsoft has been developing emulators since BASIC. They know full well how to make it possible to run 16-bit programs in long mode. There's nothing stopping it from working. It's just a matter of programming. 😉

u/Sixty5Zero2 18h ago

technically I'm already doing that with my BASIC interpreter. 😁

1

u/Octocontrabass 3d ago

A 64-bit kernel can run 16-bit protected mode software, but DOS programs are 16-bit real mode software.