18 ms·
Rustboot: a 32 bit kernel written in Rust
- shardling 14y ago>It paints the screen bright red and then hangs. Well, it's a start, I guess. :) (The project is literally only half an hour old.)
- steveklabnik 14y ago> (The project is literally only half an hour old.) That's one of the funny things about starting your own operating system; it's not some sort of herculean task. Especially once you've done it once or twice. While you're right that this isn't particularly feature-rich at this point, it does get the annoying bits out of the way. It's a starting point that anyone doing this task would have to do, and do in the same way. It's also a proof of concept that this kind of thing does actually work; see the other thread on zero.rs where people were speculating if this is possible. Now we know.
- Ecio78 14y agoJust add some weird error lines and you have a Red Screen Of Death (RSOD)[1], certainly a good beginning :) [1] http://en.wikipedia.org/wiki/Red_Screen_of_Death http://en.wikipedia.org/wiki/Red_Screen_of_Death
- dysoco 14y agoSounds better than Vista!
- zerr 14y agoNot necessary. Most hobby OS projects stop at that stage (including mine, many many years ago...).
- jmgrosen 14y agoI saw zero.rs and said, "Hey, I know! I'm going to make a kernel!" Then after showering... came back and saw this. Well, in any case, great work! (Perhaps I'll use yours as a starting point.) EDIT: One question. When I try to compile it, rustc gives me these errors: error: no item found for `modulo` error: no item found for `durable` error: aborting due to 2 previous errors If I had to guess, it would be due to the fact that I'm trying to compile it on OS X but have i386-intel-linux set as the target, but your screenshot shows (at least it being emulated) on OS X. Did you have to build a special cross compiler version of rustc?
- FrozenCow 14y agoI had the same problem (I'm on ArchLinux). I fixed it as follows: https://github.com/FrozenCow/rustboot/commit/ec46219d50f44031a29e366f365a3b81e6a50533 https://github.com/FrozenCow/rustboot/commit/ec46219d50f4403... No idea whether this is actually correct, but it does run in qemu. It doesn't however boot on my laptop from a USB drive though... not sure how actual hardware is different from qemu.
- charliesome 14y agoIt might be something to do with me not enabling the A20 line, I'm not sure if QEMU starts with it disabled or not.
- charliesome 14y agoI use ELF as the object file format, but all the development was done on OS X. Maybe try updating your version of Rust. I had trouble using zero.rs on 0.6, but the latest from Git works well.
- jmgrosen 14y agoAh, that would explain it -- I'm trying it with 0.6. Building master now, have a feeling that it'll be a while though.
- 14y ago
- topbanana 14y agoThat isn't a kernel
- steveklabnik 14y agoUntrue. Now, it's not a _useful_ kernel, but it is one. In fact it does one thing and does it well. It's an exemplar of the UNIX philosophy! ;)
- brokenparser 14y agoIt only supports itself, so not a kernel. See: http://en.wikipedia.org/wiki/Kernel_(computing) http://en.wikipedia.org/wiki/Kernel_(computing)
- benatkin 14y agoI disagree. It ships with a single built-in application which turns the screen red. Someone can take the codebase and replace the application with a different one. I seem to remember some old 5 1/4 inch disks that contained both an OS and an app. That's approximately what this is in its current state.
- brokenparser 14y agoDon´t know why this was downvoted, you hit the nail on its head. The fact that it runs directly on hardware doesn't make it a kernel, it doesn't provide any abstractions for applications to run unmodified without specific hardware provisions.
- steveklabnik 14y agoExokernels provide no abstractions, just a few safety guarantees. So you could argue that this is just an unsafe exokernel. ;) That said, "is it really a kernel as per Wikipedia" is not particularly interesting. It's a damn cool hack that could be the starting point for something interesting and useful, that's all I care about.
- andrewflnr 14y agoThis is great, but I'm confused. Not that long ago, I remember reading that it was explicitly not a goal of Rust to be able to write an OS kernel in it. Is this done in spite of Rust not being designed/suited for it?
- steveklabnik 14y agoI'm not sure that I've ever heard that as an implicit goal, but a 'runtime-less Rust' hasn't existed yet. Now, you can't access arbitrary memory without an unsafe block, that may be what you're thinking of. Recently, zero.rs was released, which allows you to write some Rust programs without the runtime. This is because Rust basically expects certain functions to exist, so they have to be defined somewhere. That said, things like 'a GC' aren't implementd, they just throw an error. Please see: https://news.ycombinator.com/item?id=5771173 https://news.ycombinator.com/item?id=5771173 This is just one step further in demonstrating that these things work.
- usea 14y agoA link to the HN thread on zero.rs https://news.ycombinator.com/item?id=5770212 https://news.ycombinator.com/item?id=5770212
- gillianseed 14y agoI'm sure they (the Rust developers) don't have any particular interest in writing an OS kernel using Rust, but that doesn't mean someone else can't give it a try. Of course it's hard to pass off these ~200 lines of code as an attempt at writing an OS kernel, but it could be a spark, everything starts somewhere.
- masklinn 14y ago> I remember reading that it was explicitly not a goal of Rust to be able to write an OS kernel in it. It's not a goal of rust, but that doesn't mean rust can't be used for it (and the ability to run without a runtime if desired — at the loss of functionalities for which a runtime support is necessary — has been a goal of the project for as long as I've known about it)
- 14y ago
- pvnick 14y agoWow, cool! Great job :)
- phoenix24 14y agoThis is cool! One request, Can you detail out the steps, for noobies to be able to re-produce this effort? Thanks!
- steveklabnik 14y agoReproduce as in 'build a tiny kernel in something' or reproduce as in 'build and run this example?' If it's the first, OSDev has a great community, and some decent tutorials: http://wiki.osdev.org/Bare_Bones http://wiki.osdev.org/Bare_Bones If it's the second, the answer is 'have edge Rust installed, have qemu installed, then run `make`.'
- peterkelly 14y agoI wrote an example/tutorial (targeted in C though, not rust) a few years back which may have some of what you're looking for: http://adelaideos.sourceforge.net http://adelaideos.sourceforge.net
- jamesaguilar 14y agoIt's really impressive what people have done with rust. I don't know how they do it because when I write short rust programs I get internal compiler errors.
- steveklabnik 14y agoYou should open up issues for those: https://github.com/mozilla/rust/issues https://github.com/mozilla/rust/issues There's no reason for an internal compiler error, especially in a language with safety as its focus.
- jamesaguilar 14y agoHave done. Here are the ones I found in 300 loc. https://github.com/mozilla/rust/issues/6699 https://github.com/mozilla/rust/issues/6699 https://github.com/mozilla/rust/issues/6698 https://github.com/mozilla/rust/issues/6698 Don't get me wrong. I'm super excited to learn rust once it stabilizes. But right now I don't spend enough time on fun programming to deal with a language that has this many errors.
- steveklabnik 14y agoGreat! Thank you. I've been mostly sticking to documentation myself, but you can't fix what you don't know...
- S4M 14y agoI am confused: if it's a kernel, why do we have the mac user interface? Is this the screenshot from a VM or am I missing something else?
- DanWaterworth 14y agoYes, it's a VM. Note the title, "QEMU".
- fmstephe 14y agoI find this a very exciting project. Rust is always in my peripheral vision. To see a language operating at such a high level able to get down so low is very compelling.
- dysoco 14y agoGreat to see new Rust news every day. At first I was most interested in Go: But now it seems that Rust is much more close to the metal than Go is, which I find more interesting.
- tmzt 14y agoIf anybody is looking for something to do with this, consider writing a KVM-like virtual machine host which is barebones enough to boot from coreboot. I've dreamed of a checkpointed VM which could be used to press a key and fork the running system, or instantly reboot to a usable state when a fault occured, but was small enough to fit in a flash ROM and boot in milliseconds. The last attempt was linux+QEMU and was to large for most boards supported by coreboot.
- steveklabnik 14y agoYup, this kind of thing is one of the reasons I like exokernels so much.
- voltagex_ 14y agoWhat about as a UEFI image? I've never had a board that was supported by CoreBoot.
- wfunction 14y agoWow, if people like this, then maybe I should post my tiny 32-bit kernel in C++ somewhere. It has a physical, virtual, and kernel memory manager and support for text-mode I/O. And you can use pretty much anything C++ (even Boost) that doesn't rely on exception handling...
- trentmb 14y agoI'd like to see it if you don't mind.
- wfunction 14y agoHmm... since I'm not sure I want to share the code yet, here's a class diagram instead that should still give you an idea what state it's currently in: http://picpaste.com/pics/21616b59902f2992e1e488af35acba20.1369637934.png http://picpaste.com/pics/21616b59902f2992e1e488af35acba20.13... The Process class is just a dummy at the moment, it doesn't do anything.
- nathell 14y agoSomething similar I did with Clojure: https://news.ycombinator.com/item?id=5772632 https://news.ycombinator.com/item?id=5772632
- ginko 14y agoI guess this is kind of a factious question to ask, but why 32 bit and not 64 bit? Are there any technical reasons for this?
- steveklabnik 14y ago32 bit is waaaaaaay easier to write.