Philipp Oppermann writes a tutorial series on building an operating system kernel in Rust, covering paging, heap allocation, and async/await.
HN commenters recommend it as an approachable series for writing a kernel, one that shows how little unsafe code low-level Rust needs.
There's a no-std tutorial on how to write a demo kernel in Rust. https://os.phil-opp.com
osdev.org, sandpile.org, RBIL, and freevga. The biggest PITA is hardware support. There are many good vintage hardcopy books with recipes for things like reliable port IO and undocumented hardware tricks.
- Intel® 64 and IA-32 Architectures Software Developer’s Manual Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, and 4
- Microsoft MS-DOS Programmer's Reference (also includes real-mode BIOS calls)
- PC Interrupts
- Undocumented PC
- PC Intern
- Programmer's Guide To The EGA, VGA, And Super VGA Cards
- Graphics Programming Black Book Special Edition
Also, it's worth toying with advances in OS dev past the era of monolithic, microkernel, and hybrid.
1. Capability-based like seL4. It has a number of inherent performance and security advantages including capabilities and excellent IPC.
2. POSIX compatibility layer. Even embedded OSes without the concept of threads or processes can implement POSIX.
3. Hypervisor. They're much easier to add with intel's VT-[xd]. Failing that, fall back to emulation. Translational emulation is very performant.
4. Get good at generalizing interrupt handlers, making them fast, avoiding race conditions, and using lock-free patterns.
Also:
5. Rewriting or trapping unsupported instructions including x87 and MMX.
6. The failure of pure microkernel was the added complexity and management of sequencing multiple resources in a transactional manner.…
> Any Rust code that goes low level liberally uses unsafe{} blocks
This isn't an accurate statement. Liberal use of unsafe is not common or best practice in Rust. My favorite educational series that shows how little unsafe is required to work in low-level spaces is Phil Opperman's, "Writing an OS in Rust": https://os.phil-opp.com/
That being said, I don't think most people use "Rust is safe" in an particular way that's different from saying Java is safe. Rust in many ways offers similar (and stronger) safety guarantees than Java (one of the safest langauges to date). Is Java safe? We all know that bugs can be created in every language, it's really the different classes of bugs that each language offers some defense against that sets them apart from each other.
Sadly no, they moved all courses to a private platform, but we used a lot of external resources not too much of our own except the exercises.
The kernel development one was pretty much what you can find in the Intel Manuals + osdev wiki [1] or some of the many osdev tutorials [2].
For SIMD I'm not aware of good tutorials or books, we did use again Intel manuals for reference and also [3]. For the image filters I assume you can search algorithms for basic filters such as pixelate, edges, etc. expressed as matrix operations and see how you can write that as SIMD ops.
[1]: https://wiki.osdev.org/Expanded_Main_Page [2]: https://os.phil-opp.com/ [3]: https://www.felixcloutier.com/x86/
That's it?
While the point of this project is to go for developing a very small kernel, I afraid I can't recommend this as a way to "learn to write your first OS kernel".
Particularly, this project has been fossilised for two years, (last commit was in 2018) with a single commit each year hardly qualifies as an updated tutorial for writing OS kernels.
My first recommendation would be the "writing an OS in Rust" tutorials [0] and the xv6 tutorials [1].
[0] https://os.phil-opp.com/
[1] https://pdos.csail.mit.edu/6.828/2019/xv6.html
If anybody enjoys this and wants to take it much further, you might want to check out https://os.phil-opp.com/. This is basically a book-in-progress that shows how to build an OS in Rust OS from scratch. It shows how boot up an OS, and it goes on to show how to set up basic drivers and memory management. He does a great job of explaining each step as he goes.
(This is linked near the end of the article, but I think it's worth pointing out.)
Full disclosure: I think he uses a library I wrote to initialize the keyboard controller.
The osdev wiki is the best source for this and they have the bare bones tutorials with all the linker scripts, bootstrap code, makefiles, etc you might need. They have examples for multiboot and UEFI (and BIOS boot sector).
For Rust there's this popular series: https://os.phil-opp.com/
If I were to start a new OS project I would do it in Rust too but as awesome as Rust is, I can't recommend doing a bare metal project as your first foray into the language. Learning two or more things at once doesn't work for me.