MCPcopy Index your code
hub / github.com/dancrossnyc/r9

github.com/dancrossnyc/r9 @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
554 symbols 1,258 edges 56 files 133 documented · 24%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

r9

Plan 9 in Rust

R9 is a reimplementation of the plan9 kernel in Rust. It is not only inspired by but in many ways derived from the original Plan 9 source code.

Building

We use cargo and the xtask pattern to build the kernel.

To build r9 for x86_64, we assume you have cloned the git repository somewhere convenient. Then simply change into the top-level directory and, cargo xtask build --arch x86-64.

To build for aarch64, run cargo xtask build --arch aarch64 (Currently only Raspberry Pi 3 is supported).

There are other useful xtask subcommands; run cargo xtask help to see what is available.

Right now, r9 is not self-hosting.

Runtime Dependencies

cargo xtask dist, which cargo xtask qemu depends on, requires llvm-objcopy. This is expected to live in the rust toolchain path. You can install by running:

rustup component add llvm-tools

If you get No such file or directory (os error 2) messages, then install llvm separate from the rust toolchain and set:

OBJCOPY=$(which llvm-objcopy) cargo xtask qemukvm

If No such file or directory (os error 2) messages persist, check to ensure qemu or qemu-kvm is installed and the qemu-system-x86_64 binary is in your path (or qemu-system-aarch64 in the case of aarch64).

Running on Qemu

R9 can be run using qemu for the various supported architectures:

Arch Platform Commandline
aarch64 raspi3b cargo xtask qemu --arch aarch64 --verbose
aarch64 raspi4b cargo xtask qemu --arch aarch64 --config raspi4b --verbose
x86-64 q35 cargo xtask qemu --arch x86-64 --verbose
x86-64 (with kvm) q35 cargo xtask qemu --arch x86-64 --kvm --verbose
riscv virt cargo xtask qemu --arch riscv64 --verbose

Running on Real Hardware™️

R9 has been run on the following hardware to a greater or lesser degree: - Raspberry Pi 4 (Gets as far as printing 'r9' via the miniuart)

Raspberry Pi, Netboot

Assuming you can set up a TFTP server (good luck, it's incredibly fiddly, but for what it's worth, dnsmasq can work occasionally), and assuming the location of your netboot directory, you can build and copy the binary using the following command:

cargo xtask dist --arch aarch64 --verbose && cp target/aarch64-unknown-none-elf/debug/aarch64-qemu.gz ../netboot/kernel8.img

This copies a compressed binary, which should be much faster to copy across the network.

The Raspberry Pi firmware loads config.txt before the kernel. Here we can set which UART to use, amongst other things. The following contents will set up to use the miniuart:

enable_uart=1
core_freq_min=500

Extension points exported contracts — how you extend this code

VmTrait (Interface)
I guess we need a better name. This is to wrap all things that would break if run in a test, or if run before we have t [2 …
aarch64/src/vm.rs
Uart (Interface)
(no doc) [4 implementers]
port/src/devcons.rs
Stack (Interface)
A trait for retrieving the top of various kinds of stacks. [2 implementers]
x86_64/src/dat.rs
PageAllocator (Interface)
(no doc) [3 implementers]
aarch64/src/vm.rs
Dev (Interface)
(no doc)
port/src/dat.rs

Core symbols most depended-on inside this repo

ptr2hpa
called by 54
x86_64/src/node0.rs
addr
called by 49
port/src/mem.rs
add
called by 45
port/src/mem.rs
array_mut
called by 43
x86_64/src/dat.rs
map
called by 31
aarch64/src/vm.rs
putstr
called by 30
aarch64/src/pre_mmu/util.rs
next
called by 26
aarch64/src/vm.rs
write_reg
called by 25
aarch64/src/io.rs

Shape

Method 228
Function 210
Class 86
Enum 25
Interface 5

Languages

Rust100%

Modules by API surface

aarch64/src/vm.rs61 symbols
port/src/fdt.rs56 symbols
port/src/allocator.rs33 symbols
port/src/bitmapalloc.rs32 symbols
xtask/src/main.rs31 symbols
port/src/mem.rs27 symbols
aarch64/src/pre_mmu/vminit.rs26 symbols
aarch64/src/mailbox.rs26 symbols
x86_64/src/dat.rs24 symbols
x86_64/src/vsvm.rs23 symbols
aarch64/src/kmem.rs19 symbols
aarch64/src/vmdebug.rs14 symbols

For agents

$ claude mcp add r9 \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact