Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Mirror] Rust version of WeensyOS——a tiny kernel that can run on bare-metal x86-64 machines (including QEMU's emulated CPUs), aiming for easy physical and virtual memory display.

Notifications You must be signed in to change notification settings

anton-mel/RWeensyOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

108 Commits

Repository files navigation

WeesyOS in Rust 🦀 (Safe)

WeensyOS is a tiny kernel that can run on bare-metal x86-64 machines (QEMU's emulated CPUs). The initial state of the kernel contains code for bootstrapping kernel, handling exceptions/syscalls, executing user-level program, and helper functions for your CPSC 323 exercises.

Host CPU-arch: x86_64, Operating System: Linux (Fedora), Application binary interface: GNU

By compiling for our host triple, the Rust compiler and the linker assume that there is an underlying operating system such as Linux (Frog Node) that uses the C runtime by default, which causes the linker errors. So, to avoid the linker errors, we compile for our own environment x86_64-weensyos.json with no underlying operating system [look how to build].

How to build

Execute only once
  1. Get to the root: cd ./starter-code-rust
  2. Change rust-toolchain: rustup override set nightly, you might need rustup component add rust-src --toolchain nightly-aarch64-apple-darwin for MacOS-Darwin
  3. Build Target: cargo +nightly build --target x86_64-weensyos.json
  4. Create Cargo Image: cargo bootimage (look for dependencies below). Image Created at ./target/x86_64-weensyos/debug/bootimage-weensyos.bin

Run QEMU-Display

Finally, run QEMU via bootimage runner cargo run --target your_custom_target.json [other_args] -- [qemu args]. EDIT: Should work with just cargo run. Note: if you are stuck in the loop and cannot exit QEMU (press q for quit), try to pkill qemu from another terminal. You can also run QEMU directly via qemu-system-x86_64 -nographic -drive format=raw,file=target/x86_64-weensyos/debug/bootimage-weensyos.bin (you can also enable QEMU graphic display if you work locally).

How to test

Current implementation provides our own simple cargo test setup using standart #[test_case] implementation that outputs directly to the terminal via serial port and quits qemu. Public test cases for the project 4/5 will be implemented throuhgout WeensyOS growth.

Environment Configs

Rust has three release channels: stable, beta, and nightly. We will need some experimental features that are only available on the nightly channel, so we need to install a nightly version of Rust. rustc 1.80.0-nightly (87293c958 2024年05月08日)

Instead of writing our own bootloader, which is a project on its own, we use the bootloader crate. This crate implements a basic BIOS bootloader without any C dependencies, just Rust and inline assembly. Read more how bootimage linking works here: https://github.com/rust-osdev/bootimage.

Dependency List
  1. curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. cargo install bootimage
  3. rustup component add llvm-tools-preview
  4. apt install qemu-system-x86_64 for Linux or brew isntall qemu for MacOS

Source Inspirations & How to contribute

Please, consider reading through these documentations is you plan to contribute:

 1. https://os.phil-opp.com/
 2. https://www.theseus-os.com/
 3. https://zoo.cs.yale.edu/classes/cs323/323/proj5/starter-code/

Use Cisco VPN to connect off-campus https://docs.ycrc.yale.edu/clusters-at-yale/access/vpn/ or develop locally.

Preview

68747470733a2f2f692e696d6775722e636f6d2f38356a677446622e676966

About

[Mirror] Rust version of WeensyOS——a tiny kernel that can run on bare-metal x86-64 machines (including QEMU's emulated CPUs), aiming for easy physical and virtual memory display.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /