TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to write a simple operating system

247 pointsby motxiloover 14 years ago

8 comments

a-prioriover 14 years ago
While it's cool and all to write your own bootloader, this means you have to deal with a lot of the really ugly bits of x86/PC architecture... like the A20 gate, for example (if you don't know what that is, count yourself lucky).<p>Instead, I suggest using GRUB to boot your kernel image. It leaves you in 32-bit mode and a relatively sane state. It's not hard to write a loader file (in assembly) which contains the multiboot header and an entry point. Presumably you'll want to set up a basic C runtime environment and call your C "main" function.<p><a href="http://wiki.osdev.org/Bare_bones" rel="nofollow">http://wiki.osdev.org/Bare_bones</a>
评论 #2100895 未加载
评论 #2103258 未加载
steveklabnikover 14 years ago
I also have a bare bones OS project up on GitHub:<p><a href="https://github.com/xomboverlord/xomb-bare-bones" rel="nofollow">https://github.com/xomboverlord/xomb-bare-bones</a><p>It's a bit of a niche inside a niche: it explains how to set things up to write an OS in D. This was extracted from the OS that my friends and I started a while ago, that's now two of theirs' PhD research:<p><a href="https://github.com/xomboverlord/xomb" rel="nofollow">https://github.com/xomboverlord/xomb</a>
senkoover 14 years ago
If you're into building custom OS' but not interested in doing the lowest level bits (bootloader, fiddling page table bits, worrying about the processor details, etc), using a pre-existing microkernel and building whatever you want on top of it can be interesting.<p>I used my diploma thesis as an excuse to build a toy OS on top of a L4 (L4Ka::Pistachio) microkernel. It provides the basics, incl. IPC and VM building blocks, and a straightforward C/C++ API, and you can do the rest (there's also a number of things built on top of it that you could mix'n'match - i just implemented most of my userspace stuff because that was what I was interested in).<p>Some links (haven't been in touch for a few years, I don't know how up to date they are):<p>L4Ka project: <a href="http://os.ibds.kit.edu/1953.php" rel="nofollow">http://os.ibds.kit.edu/1953.php</a> OKL3 (successor to Pistachio, as far as I can tell): <a href="http://wiki.ok-labs.com/" rel="nofollow">http://wiki.ok-labs.com/</a> Iguana, a set of components to be (re)used on top of L4: <a href="http://www.ertos.nicta.com.au/software/kenge/iguana-project/latest//" rel="nofollow">http://www.ertos.nicta.com.au/software/kenge/iguana-project/...</a> Misc L4 resources: <a href="http://www.l4hq.org/projects/os/" rel="nofollow">http://www.l4hq.org/projects/os/</a><p>If anyone's interested, I could try to find my old code and put it on GitHub (it's a combination of MIT and GPL licenced things).
评论 #2103372 未加载
Sapientover 14 years ago
I found this invaluable when writing my own small OS.<p><a href="http://www.jamesmolloy.co.uk/tutorial_html/index.html" rel="nofollow">http://www.jamesmolloy.co.uk/tutorial_html/index.html</a><p>He includes a lot of details, and seems to try to do things "The Right Way" as much as possible. (Not that I am a good person to judge that)
评论 #2103960 未加载
alexwestholmover 14 years ago
The project seems to be dead these days, but if you're interested in writing OSes, take a look at the Flux OSKit:<p><a href="http://www.cs.utah.edu/flux/oskit/" rel="nofollow">http://www.cs.utah.edu/flux/oskit/</a><p>OSKit aims to be a set of libraries that dramatically lower the barrier to entry on OS development.
Ruskyover 14 years ago
There is no reason to write your own x86 bootloader- it's just an exercise in abstracting away the most brain-dead ISA on the planet.<p>What you should do instead is write the kernel and just load it with GRUB. It allows you to immediately jump into the interesting stuff that makes your kernel unique, makes it easy to test on real hardware without getting a second machine, and makes it possible to dual-boot with it if/when you get that far.<p>I haven't tried this, but it might be fun to write a kernel for some other system- some ARM device, maybe. Any kind of bootloader would be infinitely less encumbered with x86's layer upon layer of compatibility stuff.
coderdudeover 14 years ago
This is where floppy disks come in handy. Burning an ISO to a CD for each round of testing is a pain and wasteful. When I dabbled into this years ago I was lucky enough to still have a floppy drive.
评论 #2102420 未加载
paulgerhardtover 14 years ago
Or another for AMD64: <a href="http://code.jeffkent.net/trac/shiny_moose/browser/trunk/kernel" rel="nofollow">http://code.jeffkent.net/trac/shiny_moose/browser/trunk/kern...</a>