Mezzano on Librebooted ThinkPads

I decided to try running Mezzano on real hardware. I figured my Librebooted ThinkPads would be good targets, since, thanks to Coreboot and the Linux kernel, I have reference source code for all the hardware.

On boot, these machines load Libreboot from SPI flash; included in this Libreboot image is GRUB, as a Coreboot payload.

Mezzano, on the other hand, uses the KBoot bootloader. I considered chainloading KBoot from GRUB, but I wondered if I could have GRUB load the Mezzano image directly, primarily to save a video mode switch.

I didn’t want to have to reflash the Libreboot payload on each modification (writing to SPI flash is slow and annoying to recover from if something goes wrong), so I tried building a GRUB module “out-of-tree” and loading it in the existing GRUB. Eventually I got this working, at which point I could load the module from a USB drive, allowing fast development iteration. (I realize out-of-tree modules are non-ideal so if there’s interest I may try to contribute this work to GRUB.)

The resulting GRUB module, mezzano.mod, is largely the KBoot Mezzano loader code, ported to use GRUB facilities for memory allocation, disk access, etc. It’s feature-complete, so I released it to Sourcehut. (I’ve only tested it on Libreboot GRUB, not GRUB loaded by other firmware implementations.)

Here’s a demo of loading Mezzano on two similar ThinkPads:

For ease of use, mezzano.mod supports directly loading the mezzano.image file generated by MBuild — instead of requiring that mezzano.image be dd‘d to a disk. It does so by skipping the KBoot partitions to find the Mezzano disk image. The T500 in the video is booted this way. Alternatively, mezzano.mod can load the Mezzano disk image from a device, as is done for the W500 in the video. Both methods look for the Mezzano image magic — first at byte 0 and, failing that, just after the KBoot partitions.

I added the set-i8042-bits argument because Coreboot does not set these legacy bits, yet Mezzano’s PS/2 keyboard and mouse drivers expect them; at this point Mezzano does not have a full ACPI device tree implementation.

Join the Conversation

6 Comments

  1. If I ever finish my Java transpiler, you’ll be able to play your favorite game, slime volleyball, on it…

    1. I look forward to that day, hehe. I just read through https://nitter.net/antgreen/status/1429950386526359562 Exciting!

      The oneslime.net Slime Volleyball applets are still available at http://slimegames.eu/. Debian’s OpenJDK 8 appletviewer isn’t accepting mouse or keyboard events though — no idea why, maybe missing X11 JNI symbols? — so I can’t play it.

      The source code for those games was never published; will your project be able to do .class to .lisp?

      Have you seen Iota? Another brilliant froggey creation for transpiling C++ to Common Lisp. It uses Newlib as the C library! That’s how Mezzano got Doom and Quake.

Leave a comment

Leave a Reply to D-bot Cancel reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.