Readit News logoReadit News
Posted by u/UnmappedStack a year ago
Show HN: My from-scratch OS kernel that runs DOOMgithub.com/UnmappedStack/...
Hi there! I've been on-and-off working on TacOS for a few months, which follows some UNIX-derived concepts (exec/fork, unix-style VFS, etc) and is now able to run a port of Doom, with a fairly small amount of modifications, using my from-scratch libc. The performance is actually decent compared to what I expected. Very interested to hear your thoughts. Thank you!
planck_tonne · a year ago
Hi, congratulations! You must be feeling proud. Nice choice of proof of concept (DOOM).

Sorry to disappoint you but all I have are some noob questions.

What would be the steps to run this on a laptop? I take it that after building it there would be a process similar to, say, setting up dual-boot in a Windows PC? (Whoa I'm asking a stranger on the Internet how to run dangerous software on my computer...)

If one wanted to undertake such a project, do you have any recommendations of textbooks or other reading material? I had some OS & related courses in university (I'm EE, so computer-adjacent), but they were all very abstract / high level / conceptually-focused. I'd love something more concrete. It doesn't have to be x64.

UnmappedStack · a year ago
Not disappointed at all to answer! Running it on my laptop was literally just formatting a USB with the ISO and booting from the USB.

I would recommend checking out https://osdev.wiki to start out if you want to write a kernel, as well as reading relevant specifications (such as Intel Developer Manual and the specs for any drivers you write). I don't really know much about non-x86 kernel dev but most of the concepts are the same as far as I know, just different technical implementations. There's a link to a discord server on the project's readme, there are some very smart people in there who I'm sure would be more than happy to help you out.

khaledh · a year ago
I wrote a kernel as well (not complete yet), and I documented all the steps I'm taking. A lot of people found it useful: https://0xc0ffee.netlify.app/osdev
the_hoffa · a year ago
Ok, but can your tacos run DOOM??

I kid I kid ;) That's a commendable effort and nice job! Question though: was it an effort to make TacOS using DOOM as a "standard" or was it an effort to make an OS dedicated to running DOOM run from scratch?

And I don't ask from any place but actual curiosity. I made an absolute bare-bones-cant-do-anything-but-boot type OS way back "in the day" (like almost 30 years ago, ack!!!) just for my own education/fun, but the idea of having a dedicated OS that can basically only run DOOM, yet be ported to anything would just make the "can it run DOOM" meme so much more ironic and fun!

Nice stuff! Keep it up!!

UnmappedStack · a year ago
Well, it can do a little more than run Doom, that's just the latest milestone as to what was ported last. It wasn't a huge effort, maybe took a week or so to get Doom itself running including adding libc requirements for Doom, but what came before that was a fair bit more groundwork. I used DoomGeneric, which is basically a fork of Doom which is made to be very portable. I hope I answered your question, I might have misunderstood.
andrewmcwatters · a year ago
From-scratch kernel straight to DOOM is some top-tier hacker cred stuff. You must be very happy with it running on real hardware. Very cool.
UnmappedStack · a year ago
Yes, quite happy with real hardware. The kernel isn't exactly straight to Doom, it boots into a shell which you can just run Doom from, but yeah lol.
xhrpost · a year ago
Slight tangent but I've wondered about something similar to this, has there been much initiative to make games that directly boot on modern PC hardware? So not load a full OS but just go directly to the game. Similar to older generation gaming consoles. It should be possible, granted if you want to stay simple, things like wifi, bt, GPU would be hard to utilize without modern drivers, but a keyboard and mouse should be fairly doable as they seem to have some sort of default BIOS access? (probably wrong terms there but hopefully my point is understandable)
dmwilcox · a year ago
I don't know if it's been much used but it is known and works. I was doing this early on in my x86-16 assembler experiments but ended up using DOS as a program launcher for an easier emulator to use than qemu (dosbox-staging).

The big limits if you don't want to get into disk IO, is 512 bytes or less since you're basically running your program as a master boot record. To get more you'll need to load some LBAs from disk which yes there is an interrupt for and osdev has even better stuff.

Other than that, the difference between a .com file (usual limit 64kb single segment) and an MBR style bootable program is pretty minimal

tamat · a year ago
Great work, I would love to have the skills to do something like this, but I can see you had to read lots of specifications to achieve this and thats my weakest point.

One silly question you may know: Imagine you wanted to use GPU acceleration, even in the smallest form. How hard would it be to build a driver for the GPU? Do you think there is good documentation about it?

UnmappedStack · a year ago
Umm that's probably the extreme end of OSDev which I likely wouldn't be able to do, at least not for a driver you can buy. Qemu's emulated GPU is documented decently and could be possible, but things like nvidia GPUs are badly documented (and until recently, the docs were fully closed source) - even Linux has issues with this (and I actually see a few other hobby OS devs who just use Linux's GPU drivers in the end). There aren't a lot of things I've marked as near impossible but writing a genuinely decent GPU driver for a common GPU isn't really something I imagine I'll ever be able to do sadly.
noone_youknow · a year ago
The docs for intel’s integrated offerings seem pretty good, I’m planning to do a driver for those on my toy OS. Anything else is hit and miss in terms of availability of information unfortunately.
tamat · a year ago
thanks for your response. Thats what I heard but I was wishing things to change...

I was also thinking about integrated GPUs like the one in a RPi or other SoCs

OSDeveloper · a year ago
Hey unmapped (I am ThatOSDeveloper on GitHub and discord it's my display name) I never knew you got doom running on it, pretty cool, but I have a few questions, is it the original doom, is it on disk or an initramfs and do you use freedom or the shareware doom wad with the engine you use?
kleiba · a year ago
It's doomgeneric, as can be seen in the article, with a fairly small amount of modifications, as can be seen at the top of this page.
UnmappedStack · a year ago
Hi, I use DoomGeneric which is a portable fork of Doom. It's on a TempFS loaded from an initrd. I use doom1.wad.
worldsavior · a year ago
Very cool, but why choose an unsafe language when today there exists low-level memory-safe languages? We all know already that most of security bugs are memory related.

I get that this is an hobby project, but still why not deprecate unsafe languages where there are much better alternatives?

UnmappedStack · a year ago
Mostly just because C is a lot simpler, and in kernel dev, simplicity is everything. I've used rust for other projects but I feel like in kernel dev I would much rather use a simple and readable language than a safe language.
waschl · a year ago
Welcome to the club! Did almost the same and really enjoyed the serenity of doing something which never will end up in a product

https://jakobbr.eu/2024/08/19/writing-my-own-x86_64-operatin...

UnmappedStack · a year ago
Very nice!i