Intro
The Hackaday tutorial to write an Operating System from scratch provided a wonderful inspiring introduction. It explained many features exclusive to supervisors: context switching, system calls, paging, scheduling, privileged instructions and user shells.
XV6 was written by MIT for their OS Engineering course. Originally they used Unix Version 6 running on a PDP-11 computer but later created XV6 which now runs on x86 and RISC-V. XV6 is based on the classic Unix V6 from Thompson and Ritchie and is therefore similar in architecture and design to Unix, Linux, MacOS etc.
As a teaching system it contains a subset of relevant features and is easier/quicker to build.
I first came across XV6 as Michael Engel had developed a 32-bit variant which ran on Nezha RISC-V hardware. I decided to implement XV6 on QEMU rather than on Nezha as it is easier to use an emulator initially. I may try to build on hardware eventually.
Environment
XV6 can be found on github which has some terse build instructions.
My Raspberry Pi PI41 already has QEMU 7.12 installed. It is necessary to have riscv64-softmmu configured tor "complete system emulation including an emulated MMU for running bare metal programs or OS" rather than "linux user mode" which just translates linux syscalls to host calls. Since the executable qemu-system-riscv64 exists I have the correct version.
In practice I struggled somewhat to get a working version until I found a note in the instructions that I needed to configure a switch "--enable-qemu-system" to create a complete/correct toolchain.
There is a lot of work to do to build all the necessary executables. On my RPI4 it took about four hours execution time and utilised 6.6GB.
No comments:
Post a Comment