Mezzano-Cheatsheet

Mezzano, an operating system written in Common Lisp.

The following are notes i took, when i started with Mezzano OS for the first time.

Download and Install

Documentation

First Boot

Slime Connect

Mezzano

Homepage

Libera/#mezzano - IRC Chatlog

Youtube

Glossary

Download and Install

Demos

Mezzano provides precompiled Demos, that can be booted in VirtualBox and qemu. Don't create a new HDD for Mezzano, but add the downloaded vmdk to VirtualBox/IDE-controller. The recommendation is to build a new image as the demos are somewhat outdated.

Build a new image

Follow the instructions at git README.

Note: `/some/file` to be entered for seriall/Port/COM1 at VirtualBox is destination for the boot-logfile.

Note: The instructions in the git README produce a local clone of Mezzano, that does not include the very latest changes to the repository. In order to get the Mezzanos bleeding edge technology say:


  git clone https://github.com/froggey/MBuild.git
  cd MBuild
  git submodule update --init
  cd Mezzano
  git pull --ff-only origin master
  cd ..
  make clean
  make cold-image-vmdk
  make run-file-server

The Git Primer.

Version Control (Git)

Port Forwarding

   host -- guest
  40050 -- 4005  swank-server   leave host/4005 for host/sbcl
   8080 --   80  http-server    leave host/80 for host/webserver

It is not necassary to provide VirtualBox with IP addresses of host or guest.

It is not necessary, to open these ports in host's firewall.

You can't open ports below 1024 without being root.

Screen resolution and video memory on VirtualBox

VirtualBox defaults video memory to 10MB. That is sufficient for a screen resolution up to FullHD (1920x1080)
(1920 * 1080 * 4 = 8294400 Bytes < 10MB)

WQHD (2560x1440) requires 16MB.
(2560 * 1440 * 4 = 14745600 < 16MB)

That said, Mezzano runs happily on VirtualBox on WQHD with 2560x1440 screen resultion.

Documentation

Quickstart.md
README
Mezzano/doc/


  Meta-Tab      ; mezzano-window-manager: other/next window

First Boot

Keyboard Layout

Mezzano comes with an application, called 'Keymap', that selects a keyboard layout per mouse click.

Alternatively Meta-F12, focus anywhere, rotates keyboard layouts: en us de es ... Yes, that's all: select layout per mouseclick or press Meta-F12 until keyboard layout fits.
Shift-Meta-F12 does rotate backwards.

VirtualBox uses a Host-Key (the right ctrl key) to get mouse and keyboard focus from guest back to host. As Mezzano comes with guest-integration it is save to turn host-key off, in order to be able to access Ctrl-a, Ctrl-e, etc in Mezzano.

Turn host-key on again, before playing around with other than Mezzano VirtualBox VMs in case they don't have proper guest-integration. In case of arrest try something like Ctrl-Meta-Delete or Ctrl-Meta-Backspace (restart XFCE on my Linux).

In case of a frozen mouse switch to a text console with Ctrl-Alt-F1, kill qemu and switch back with Crtl-Alt-F7.

Switch Package


  ;;switch package to cl-user
  mezzano.internals> (in-package :cl-user)
  CL-USER>

Snapshot

To make a snapshot of the current state of entire system invoke the following command:

  ;; make snapshot
  CL-USER>  (mezzano.supervisor:snapshot)

  ;; or
  ;; Terminate the current repl and take a snapshot.
  mezzano.internals>  (snapshot-and-exit)

Wait for the yellow light to turn off. (see: Quickstart.md/Blinkenlights)
Reboot.

Don't make a backup of the vmdk, created by VirtualBox; it would complain. Better export the entire VM from VirtualBox.

Reboot

 ;; In order to reboot call
 cl-user> (mezzano.supervisor:reboot)

Shutdown

In order to shutdown Mezzano wait for all blinkenlights to turn off.

Then just turn power/virtual-machine off.

Slime Connect

Slime connect to a running Mezzano is the common way of doing development.

The swank server is started automatically on port 4005, all you need to do is forward it out of the VM and use slime-connect to connect to it.

slime less workflow

For serious development at Mezzano slime/swank is the way to go.

As i do know neither slime nor swank, this is my current workflow:
Create two files in a save place at a your host, for instance `first.lisp` and `second.lisp`. ( File editing at host. )


;; file: first.lisp
(defun seven?() 'seven!)

(defun rr()
  "reread second.lisp"
  (load "remote:/home/me/path-to-my-files/second.lisp")
  )

;; file: second.lisp
(defun fac( i )
  "i -- i  // calc fac of i"
  (cond
    ((> i 1)  (* i (fac (- i 1))))
    (t 1)
    ))

Now, at Mezzano repl say:


  CL-USER>  (load "remote:/home/me/path-to-my-files/first.lisp")
  T
  CL-USER>  (seven?)
  seven!
  CL-USER>  (rr)
  T
  CL-USER>  (fac 10)
  3628800
  CL-USER>  (if (rr)  (fac 6))
  720
  CL-USER>  (rr)  (fac 7)
  T
  CL-USER>
  5040

Mezzano

Packages


  ;;modules
  CL-USER> *modules*
  ("SWANK-PRESENTATIONS" "SWANK-REPL" "SWANK-C-P-C" "SWANK-UTIL"
   "ITERATE" "UIOP" "uiop" "ASDF" "asdf")


  ;;features
  CL-USER> *features*
  (SWANK FLEXI-STREAMS BORDEAUX-THREADS THREAD-SUPPORT
   SPLIT-SEQUENCE
   ASDF3.3 ASDF3.2 ASDF3.1 ASDF3 ASDF2 ASDF ASDF-UNICODE
   PACKAGE-LOCAL-NICKNAMES
   UNICODE LITTLE-ENDIAN X86-64 MEZZANO IEEE-FLOATING-POINT
   ANSI-CL COMMON-LISP)


  ;;asdf
  CL-USER> (asdf:already-loaded-systems)
  ("uiop" "chipz" "med" "trivial-features" "cl-video-gif" "mezzano-usb"
   "skippy" "cl-video" "cl-jpeg" "flexi-streams" "pet" "cl-wav"
   "split-sequence" "png-read" "asdf-package-system" "iterate" "cl-vectors"
   "trivial-gray-streams" "bordeaux-threads" "cl-video-wav" "cl-riff"
   "mezzano-usb/class-drivers" "cl-paths-ttf" "cl-aa" "mezzano-usb/ohci"
   "cl-video-avi" "asdf" "alexandria" "cl-paths" "zpb-ttf" "babel")


  ;; fixnum
  ;; 63-bit signed integer: 62-bit mantissa, 1 bit sign, (1 tagbit)
  CL-USER> (eql most-positive-fixnum  (1- (expt 2 62)))
  T
  CL-USER> (=  62  (integer-length most-positive-fixnum)
                   (integer-length most-negative-fixnum))
  T


  ;; The upper exclusive bound on the value returned by the function char-code.
  CL-USER> char-code-limit
  1114112
  CL-USER> (integer-length char-code-limit)
  21

Mezzano's IP Address

Invoke application Peek, press 'n'.
As Mezzano is connected via VirtualBox/Network/NAT it's IP is not visible within the local net or to the local router.

http-demo

Do port forwarding in VirtualBox.

Point browser to: http://localhost:8080

File transfer to/from host

The Build does lots of file transfer while building via a file-server running at host. Keep this file server on host running while working on Mezzano. Mezzanos application `filer` provides GUI style access to both file systems, host and guest.


  ;; load a file, stored at host
  CL-USER>  (load "remote:/path-to-my-file/at-host/my-stuff.lisp")

Clipboard to host

There is currently no clipboard integration with the host system when Mezzano is running as guest in a VM. A workaround may be to read or write text from Mezzano via file-server to a file at host. And from that file read it into the host clipboard or write it from clipboard to file. That way copy/paste from for instance a web browser to Mezzano and back is quite straightforward.


# xclip - command line interface to X selections (clipboard)
# read hostclip.txt into host clipboard:
bash> xclip -selection c -i /home/heiko/q/mezzano/hostclip.txt

# write clipboard into file:
bash> xclip -o  >/home/heiko/q/mezzano/hostclip.txt

Colours


(defun as-colour( r g b &optional (f 255))
  (mezzano.gui:make-colour-from-octets r g b f))

(defparameter +in-white+        (as-colour 255 255 255))
(defparameter +in-red+          (as-colour 255   0   0))
(defparameter +in-green+        (as-colour   0 255   0))
(defparameter +in-blue+         (as-colour   0   0 255))
(defparameter +in-gray+         (as-colour 128 128 128))
(defparameter +in-black+        (as-colour   0   0   0))
(defparameter +on-background-like-clear-glass+ (as-colour 0 0 0   0))
(defparameter +on-background-like-sun-glasses+ (as-colour 0 0 0 128))
(defparameter +on-background-like-black-board+ (as-colour 0 0 0 255))

My colours on Mezzano.

Move birdy, the desktop background picture, a jaw length to left


  ;; In Mezzano/gui/desktop.lisp edit
  (defun redraw-desktop-window( desktop ) ...)

  ;; At repl say:
  (load "remote:/path-to-mezzano/Mezzano/gui/desktop.lisp")

  ;; Trigger some redraw event to apply changes.
  ;; With VirtualBox resize the window of mezzano os.
  ;; Or just click on the window background?

  (mezzano.supervisor:snapshot)

Initialization file init.lisp

MBuild/home/init.lisp init file of Mezzano.

init.lisp My personal initialization file for Mezzano.

Prints from this file go into the boot log file /some/file.

Homepage

The git repo.

At least i don't know about any other homepage of Mezzano OS.

Libera/#mezzano - IRC Chatlog

today

Youtube

gui-postprocessing-effect
More responsive window resizing (0:21)
Mezzano operating system written in Common Lisp
Introduction to Mezzano - Eugene Zaikonnikov - RevolverConf 2018.2
Virgl Demo

Glossary

32-bit
No, Mezzano is 64-bit.
arm
Under construction. Looks like froggey is going for the ARM-based M1, first.
cores
Yes, Mezzano supports multiple cores (CPU).
gc
The supervisor is the closest equivalent to a kernel and the GC mostly sits on top of it. The bulk of the GC exists in normal paged memory. The pager thread is treated specially by the GC and not scanned normally. It also follows some special rules that allow it to run without interfering with the GC.
That way: a GC in Lisp.
mcclim
Common Lisp GUI Toolkit
med
Mezzano Editor.
multi-user
No, Mezzano is single user. There are more computer than people, anyway.
qemu
Yes, Mezzano works with qemu.
security
Lisp systems trust all code on the system, if it runs then it can do anything.
Common Lisp guaranties memory safety.
slime
The Superior Lisp Interaction Mode for Emacs.
smp
Yes. Mezzano does symmetric multiprocessing (SMP).
swank
The Lisp server side of SLIME. Started automatically on port 4005.
virgl
Yes, on qemu. A virtual 3D GPU for use inside qemu virtual machines. Requires a qemu with virgl support and the virglrenderer library. Virgl and a Virgl Demo
virtualBox
Yes, Mezzano runs on VirtualBox. VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use.
wired pages/objects
VM-terminology: Accessing one will never cause a page fault, so they're safe for low-level code like interrupt handlers & disk drivers to use.
There are also wired objects, which have the same properties: never paged out, always safe to access and they're managed by a non-moving GC so they don't move around in memory. Wired objects are allocated in the wired allocation area, which is made of wired pages.
x84-64
Yes, Mezzano is 64-bit.

First published at 2019-06-12, last revision 2020-03-07, last update 2022-09-07 by sts-q .