A minimal kernel in Swift, running in QEMU

(carette.xyz)

43 points | by surprisetalk 1 day ago

5 comments

  • aseipp 1 hour ago
    Embedded Swift is honestly very cool. I never really used Swift itself before, but I think it's a good niche since embedded dev could stand for another tool and the language is pretty nice. It also doesn't really suffer from most of the issues people have historically brought up with Swift (cross platform, slow compiles) etc as it is so small, at least to me. :)

    If you're starting from scratch I've found you can actually write ~everything in Swift quite easily (reset vectors, compiler emitted intrinsics, etc). But beyond that I think the best feature is that the C/C++ interop works really well and comes out of the box. Makes two-way adoption easy. I wrote a small boot firmware for a simulator and for fun decided to add signatures to the boot process (mldsa44+jq255). You can just copy the .c and .h files and import them into a modulemap file and you're off to the races. You can just get simple .o files and pass them to the linker. There are only 4-5 "freestanding" functions you have to implement. You can turn off heap allocation. Etc.

    It would probably be pretty cool and quite easy for instance to write Zephyr or U-Boot drivers, etc in Swift using these techniques.

  • mannyv 45 minutes ago
    Just pound values into registers! I love it, so old school!

    In fact, that's how i/o worked before DMA on many systems. Good times!

    • sitzkrieg 11 minutes ago
      everything still works like this
  • Narishma 1 hour ago
    More of a hello world than a kernel.
  • qubex 1 day ago
    “machine emulators for hackers”

    “Hack the Planet!”? “Mess with the best die like the rest”? WTF?

    • topham 3 hours ago
      Those are references to "Hackers" the movie from 1995.
      • monocasa 2 hours ago
        Missed the chance for a "RISC architecture is going to change everything" reference given that it's targeting aarch64.
    • Superfish57 3 hours ago
      The movie Hackers (1995).
  • 21-DOT-DEV 1 hour ago
    [dead]