Mini operating system written in Rust.
This is the course project/assignments for "Operating System Capstone," 2024 Spring, at NYCU.
GitHub Account | Student ID | Name |
---|---|---|
alan910127 | 109652039 | Li-Lun Lin |
Note
Rust uses LLVM as its compiler backend, making cross-compilation straightforward with the same set of commands after installing the toolchains.
-
Install Rust:
Make sure you have Rust installed on your system. For this project, we require the following Rust toolchains:
- Channel:
nightly-2024-04-04
- Target:
aarch64-unknown-none-softfloat
- Components:
llvm-tools
rustup
should recognize the settings inrust-toolchain.toml
and automatically install the required toolchains for you. - Channel:
-
Install tools for building the kernel image:
In addition to Rust, you'll need tools like
rust-objcopy
for building the carno image. You can install these tools using Cargo.# Alternatively, you can replace the following command with `cargo binstall`. cargo install cargo-binutils
This repository follows the cargo-xtask
pattern, enabling you to execute necessary tasks with a single command: cargo xtask
in your terminal.
There are four subcommands available under the cargo xtask
command:
check
: Performs formatting and linting checks.build
: Compiles the binary and executes post-processing steps (if any).qemu
: Launches the target in a QEMU emulation environment.push-kernel
: Transfers the kernel through a UART-connected serial device for loading by uartload.
For instance, to experience the full booting process from the bootloader, follow these steps:
- Create your CPIO archive file and download the device tree binary for Raspberry Pi 3b+.
- Execute
cargo xtask qemu uartload
in your terminal. - Open another terminal session and run
cargo xtask build kernel
. - Issue
cargo xtask push-kernel --image ./target/aarch64-unknown-none-softfloat/release/rpi3-kernel.img --device /dev/pts/N
, replacing/dev/pts/N
with the appropriate device path as shown in your QEMU output. - The operating system should be running after pushing the kernel.
This repository contains the following entrypoints that might be great to start from:
Lab 0: Environment Setup (website)
Prepare the environment for developing the mini operating system.
Lab 1: Hello World (website)
Getting into the world of embedded programming, and try to play with pheripherals.
Tasks:
- Basic Initialization: Initialize the memory/registers to be ready to jump into the program.
- Mini UART: Setup mini UART to bridge the host and the Raspberry PI.
- Simple Shell: Implement a simple shell that display text and read input through mini UART.
- Mailbox: Set up the Mailbox service and get the hardware information from it.
- Reboot: Add a
reboot
command to the shell to reset the Raspberry PI.
Lab 2: Booting (website)
Booting the mini operating system, take care of system initialization and preparation
Tasks:
- UART Bootloader: Implement a bootloader that loads kernel through mini UART for fast development.
- Initial Ramdisk: Parse "New ASCII Format Cpio" archive file and implement
ls
andcat
. - Simple Allocator: Implement a simple allocator that can be used in the early booting stage.
- Bootloader Self Relocation: Add self-relocation feature to the bootloader so it does not need to specify the kernel starting address.
- DeivceTree: Integrate DeviceTree support for hardware configuration.
Lab 3: Exception and Interrupt (website)
Get familiar with exception levels, exceptions, and interrupts.
Tasks:
- Exception: Switch between different exception levels and implement exception handlers.
- Interrupt: Enable and handle the core timer's interrupt.
- Rpi3's Peripheral Interrupt: Implement asynchronous UART read/write by interrupt handlers.
- Timer Multiplexing: Implement the non-blocking shell command
setTimeout
which prints message after specified delay. - Concurrent I/O Devices Handling: Implement a preemptive task queue for interrupts.