Daphnis 0.1.0

How it is built

The kernel, the desk and the programs of Daphnis are written in cint, and a small C runtime and a few short assembly stubs remain. One rule runs through all of it: every integer operation is checked, and a result that does not fit stops the program with a fault record.

Checked arithmetic

A whole number in a computer has a fixed size, so it has a largest value, the way a car's odometer has a last reading before it rolls back to zero. In many languages a sum that passes that value wraps around to a wrong number, and the program carries on. In cint every integer operation is checked: add, subtract, multiply, divide, remainder and shift. When the exact result does not fit, the program stops with a fault record that says where and why.

This function turns a count of pages into bytes by multiplying by 4096, and it is called with a count that is too large.

I64 page_bytes(I64 slots) {
    return slots * 4096;
}

I64 bad = page_bytes(4611686018427387904);
"{bad}\n";

The largest value an I64 can hold is 9223372036854775807. The product here is larger, so the program stops at line 2, column 18. A language that wraps would hand back 0 and carry on.

codeE_OVERFLOW
operationmul.checked.i64
operandsI64 4611686018427387904 and I64 4096
exact result18889465931478580854784
limitI64 9223372036854775807

The record gives what was tried, with which values, the exact result and the limit it passed.

The same rule holds everywhere in Daphnis: for a page count in the kernel, a rectangle on the desk and a sum in Calc. The language is specified at integerc.dev/specifications.

Static Linux x86-64 programs run unmodified on the part of the Linux system call set Daphnis implements.

Rights and the AUTH mark

A Parent approval prompt from Settings for a change of time zone, with the AUTH mark in the bar

How it is tested

Daphnis has started so far on an MSI MPG Z390 Gaming Edge AC (Core i7-8700K) and an HP Laptop 15-da0xxx (Core i5-8250U).

Build it from source

You can build the desk from a checkout of the source and run it under QEMU, on a Linux PC with QEMU and KVM. To run the released image instead, see First run.

  1. Build the desk and make a volume. The volume is a disk file that holds /home and the toolchain, and it keeps your files between runs.
    B=~/daphnis-work/build-hdesk
    make FLAVORS=hdesk COMPILERS=gcc O="$B"
    tools/mkcintvol.sh ~/daphnis-work/scratch.img 256M
  2. Start the desk. Give every path in full, and point --out at a new folder outside the checkout.
    bash tools/desk.sh \
      --kernel "$HOME/daphnis-work/build-hdesk/gcc-hdesk/kernel32.elf" \
      --initrd "$HOME/daphnis-work/build-hdesk/hdesk/initrd.cpio" \
      --volume "$HOME/daphnis-work/scratch.img" \
      --out "$HOME/daphnis-work/runs/run-01"
  3. To stop, tap Super, press the power button at the foot of the plane, and choose Shut Down.

You can add these to the command of step 2.

optionwhat it does
--mode WxHSets the screen size, from 640x480 to 3840x2160. Leave it out for 1920x1080.
--accel tcgRuns without KVM. Leave it out to use KVM. If your PC cannot use KVM, desk.sh stops with exit status 2 and you add this option yourself.
--dry-runChecks everything and prints the QEMU command. It starts nothing and writes nothing.

desk.sh runs without sudo and leaves your volume as it is. Daphnis gets 4096 MiB of memory, and no network or sound. After each run, receipt.json and serial.log are in the --out folder.

The release image itself, tools/build-release-stick.sh, builds on Debian or Ubuntu only.