Giter VIP home page Giter VIP logo

anton-mel / weensyos Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 221 KB

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 with minimal unsafe code (currently used 15 times for port/register write-read).

Dockerfile 1.14% Rust 98.86%
boot cpu vga-buffer idt mcu pic serialization pic8259 paging dynamic-mem

weensyos's Introduction

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

weensyos's People

Contributors

anton-mel avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.