Skip to content
/ advos Public

RISC-V OS in Rust with hardware support for SiFive's HiFive1 board

Notifications You must be signed in to change notification settings

mgoin/advos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ADVOS: RISC-V Operating System in Rust

Overview

ADVOS is an operating system developed for RISC-V architecture, particularly targeting SiFive's HiFive1 board. Written in Rust, ADVOS aims to leverage the safety and concurrency features of Rust to build a robust and efficient operating system. The project includes custom implementations for memory management, process scheduling, console I/O, and more, making it a comprehensive example of a modern OS.

Features

1. Memory Management

ADVOS implements a custom memory manager that includes functionalities for:

  • Allocation and deallocation of memory blocks (kmalloc, kfree).
  • Memory coalescing to manage fragmentation.

2. Process Scheduling

The scheduler in ADVOS uses a round-robin algorithm with the following features:

  • Support for multiple processes with context switching.
  • A simple process control block (PCB) structure to manage process states.
  • System call handling to support process exit and other operations.

3. Console I/O

The console module provides basic input/output functionalities via UART, including:

  • Writing strings and characters to the console.
  • Reading characters from the console.

4. Trap Handling

ADVOS includes a comprehensive trap handling mechanism to manage:

  • Timer interrupts for context switching.
  • Software and hardware interrupts.
  • Exception handling to maintain system stability.

5. Filesystem

A simple filesystem interface to interact with storage, providing:

  • Superblock reading to gather filesystem metadata.
  • Inode reading for accessing file data.
  • Support for printing data blocks and handling indirect block pointers.

Repository Structure

The repository is structured as follows:

  • Makefile: Build automation script using make.
  • Cargo.toml: Rust package configuration.
  • Xargo.toml: Xargo configuration for cross-compilation.
  • asm/: Assembly files for bootstrapping and low-level operations.
    • start.S: Entry point and initial setup.
    • mem.S: Memory layout definitions.
    • trap.S: Trap and interrupt handling.
    • fs.S: Filesystem definitions.
  • lds/: Linker script for memory layout.
    • hifive.lds: Linker script for SiFive HiFive1 board.
  • src/: Rust source files.
    • lib.rs: Main module and entry point for the OS.
    • global_constants.rs: Constants used throughout the OS.
    • memman/mod.rs: Memory manager implementation.
    • scheduler/mod.rs: Scheduler and process management.
    • sys/: System call handling.
    • lock/mod.rs: Synchronization primitives like mutexes and barriers.
    • console/mod.rs: Console input/output.
    • filesystem/mod.rs: Filesystem management.
    • utils/mod.rs: Utility modules, including custom data structures.

License

This project is licensed under the MIT License. See the LICENSE file for details.


ADVOS demonstrates the potential of using Rust for systems programming, providing a modern and safe approach to building an operating system. Whether you are an enthusiast or a professional, exploring ADVOS will give you insights into low-level programming and OS development on RISC-V architecture.

About

RISC-V OS in Rust with hardware support for SiFive's HiFive1 board

Resources

Stars

Watchers

Forks

Packages

No packages published