logo

drewdevault.com

[mirror] blog and personal website of Drew DeVault git clone https://hacktivis.me/git/mirror/drewdevault.com.git

helios.md (5314B)


  1. ---
  2. title: The Helios microkernel
  3. date: 2022-06-13
  4. ---
  5. I've been working on a cool project lately that I'd like to introduce you to:
  6. [the Helios microkernel][Helios]. Helios is written in [Hare] and currently
  7. targets x86\_64, and riscv64 and aarch64 are on the way. It's very much a
  8. work-in-progress: don't expect to pick this up and start building anything with
  9. it today.
  10. [Helios]: https://sr.ht/~sircmpwn/helios
  11. [Hare]: https://harelang.org
  12. [seL4]: https://sel4.systems
  13. ![A picture of a ThinkPad running Helios, demonstrating userspace memory allocation](https://l.sr.ht/gnrA.jpg)
  14. Drawing some inspiration from seL4, Helios uses a capability-based design for
  15. isolation and security. The kernel offers primitives for allocating physical
  16. pages, mapping them into address spaces, and managing tasks, plus features like
  17. platform-specific I/O (e.g. reading and writing x86 ports). The entire system is
  18. written in Hare, plus some necessary assembly for the platform bits (e.g.
  19. configuring the GDT or IDT).
  20. Things are still quite early, but I'm pretty excited about this project. I
  21. haven't had this much fun hacking in some time :) We have several kernel
  22. services working, including memory management and virtual address spaces, and
  23. I've written a couple of simple drivers in userspace (serial and BIOS VGA
  24. consoles). Next up is preemptive multi-tasking — we already have
  25. interrupts working reliably, including the PIT, so all that's left for
  26. multi-tasking is to actually implement the context switch. I'd like to aim for
  27. an seL4-style single-stack system, though some finageling will be required
  28. to make that work.
  29. Again, much of the design comes from seL4, but unlike seL4, we intend to build
  30. upon this kernel and develop a userspace as well. Each of the planned components
  31. is named after celestial bodies, getting further from the sun as they get
  32. higher-level:
  33. - Helios: the kernel
  34. - Mercury: low-level userspace services & service bus
  35. - Venus: real-world driver collection
  36. - Gaia: high-level programming environment
  37. - Ares: a complete operating system; package management, GUI, etc
  38. A few other components are planned — "Vulcan" is the userspace kernel
  39. testing framework, named for the (now disproved) hypothetical planet between
  40. Mercury and the Sun, and "Luna" is the planned POSIX compatibility layer. One of
  41. the goals is to be practical for use on real-world hardware. I've been testing
  42. it continuously on my ThinkPads to ensure real-world hardware support, and I
  43. plan on writing drivers for its devices — Intel HD graphics, HD Audio, and
  44. Intel Gigabit Ethernet at the least. A basic AMD graphics driver is also likely
  45. to appear, and perhaps drivers for some SoC's, like Raspberry Pi's VideoCore. I
  46. have some neat ideas for the higher-level components as well, but I'll save
  47. those for later.
  48. Why build a new operating system? Well, for a start, it's really fun. But I also
  49. take most of my projects pretty seriously and aim for real-world usability,
  50. though it remains to be seen if this will be achieved. This is a hugely
  51. ambitious project, or, in other words, my favorite kind of project. Even if it's
  52. not ultimately useful, it will drive the development of a lot of useful stuff.
  53. We're planning to design a debugger that will be ported to Linux as well, and
  54. we'll be developing DWARF support for Hare to facilitate this. The GUI toolkit
  55. we want to build for Ares will also be generally applicable. And Helios and
  56. Mercury together have a reasonably small scope and makes for an interesting and
  57. useful platform in their own right, even if the rest of the stack never
  58. completely materializes. If nothing else, it will probably be able to run DOOM
  59. fairly soon.
  60. The kernel *is* a microkernel, so it is fairly narrow in scope and will probably
  61. be more-or-less complete in the foreseeable future. The next to-do items are
  62. context switching, so we can set up multi-tasking, IPC, fault handling, and
  63. userspace support for interrupts. We'll also need to parse the ACPI tables and
  64. bring up PCI in the kernel before handing it off to userspace. Once these things
  65. are in place, the kernel is essentially ready to be used to write most drivers,
  66. and the focus will move to fleshing out Mercury and Venus, followed by a small
  67. version of Gaia that can at least support an interactive shell. There are some
  68. longer-term features which will be nice to have in the kernel at some point,
  69. though, such as SMP, IOMMU, or VT-x support.
  70. Feel free to pull down the code and check it out, though remember my warning
  71. that it doesn't do too much yet. You can download the [latest ISO] from the CI,
  72. if you want to reproduce the picture at the top of this post, and write it to a
  73. flash drive to stick in the x86\_64 computer of your choice (boot via legacy
  74. BIOS). If you want to mess with the code, you could play around with the Vulcan
  75. system to get simple programs running in userspace. The kernel serial driver is
  76. write-only, but a serial driver written in userspace could easily be made to
  77. support interactive programs. If you're feeling extra adventureous, it probably
  78. wouldn't be too difficult to get a framebuffer online and draw some pixels
  79. — ping me in #helios on Libera Chat for a few words of guidance if you
  80. want to try it.
  81. [latest ISO]: https://builds.sr.ht/~sircmpwn/helios/commits/master