A very WIP RISCV64 OS written in Rust to learn about low-level and OS development

Related tags

Database river
Overview

river

A very WIP Rust-based RISCV64 OS for learning. The name is based off of the name RISCV with some added letters: "riscv" + er

Make sure you have submodules cloned, as it's required by build-debug.sh and run-debug.sh. I have not provided a build-release.sh script as this is nowhere close to anything production-ready, and anyway the debug build has -Copt-level=1 due to compiler bugs.

Tips for debugging (especially before paging is enabled)

The .gdbinit provided on this repository works very well for pre-paging debugging. It requires gef to be installed at ~/.gdbinit-gef.py.

Use the wrapper script [run-debug.sh][run-debug.sh], as it will launch QEMU and connect GDB to it.

Here's a quick rundown of some of my custom commands, only for debugging pre-paging code (after that, you can use typical commands--and even have the luxury of stack frames and panics):

  • addrof <symbol> gives the physical kernel address of the symbol provided
  • set-break is required to set a breakpoint to a symbol before paging is enabled
  • symof gets the symbol name of a physical kernel address
  • lst lists around the current physical kernel address
  • p2v converts a physical kernel address to a virtual one (that can be used to look up addresses with addr2line and info addr & co.)
  • v2p converts a virtual kernel address to a physical one (that can be used to examine memory with x/... when given a virtual address)
  • until_ret is like finish, but just goes until the next ret
  • until_ret_ni is until_ret then an ni
  • sio steps over the next instruction (it does this by setting a breakpoint, disabling other breakpoints, and continuing, then reenabling other breakpoints), do note that it may re-enable breakpoints you had previously disabled, I have not checked the code completely as it was copied from StackOverflow (developer moment)

Virtual kernel addresses start with 0xFFFFFFD0 or higher, whereas physical kernel addresses start with 0x802.

Once paging is enabled, you can generally use the addresses that GDB gives you. It's recommended, if you're debugging something after paging is enabled, which will be the case in most of the time, to do break kmain, then continue until kmain. This is the only breakpoint I've been able to set starting with a stopped QEMU, and once you get to it, you should be able to set any other breakpoint as the addresses will be correctly resolved in GDB's mind.

Additionally to virtual kernel addresses, there are 64GiB of virtual direct-mapped (i.e. contiguous pages) addresses starting at 0xFFFF_FFC0_0000_0000 mapped to 0x0 (physical memory) and ending at 0xFFFF_FFCF_C000_0000, mapped to 0x10_0000_0000 (physical memory).

This can be helpful to know if you just need to probe or poke and prod at a specific address, as it will always be readable and writable.

(I'll probably add a command to help with converting direct-mapped addresses in the .gdbinit at some point.)

Credits

  • Thanks very much to repnop for creating vanadinite, which has been helpful for learning.
  • Additional thanks to the creators and contributors of xv6-riscv which has been very helpful as a resource

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Some files, explicitly marked with a header, are licensed individually under MPL-2.0. This is because they have a large portion of code taken from vanadinite, licensed under these terms. Any contribution to these marked files will be licensed under these terms.

You might also like...
FeOphant - A SQL database server written in Rust and inspired by PostreSQL.

A PostgreSQL inspired SQL database written in Rust.

Appendable and iterable key/list storage, backed by S3, written in rust

klstore Appendable and iterable key/list storage, backed by S3. General Overview Per key, a single writer appends to underlying storage, enabling many

ReadySet is a lightweight SQL caching engine written in Rust that helps developers enhance the performance and scalability of existing applications.
ReadySet is a lightweight SQL caching engine written in Rust that helps developers enhance the performance and scalability of existing applications.

ReadySet is a SQL caching engine designed to help developers enhance the performance and scalability of their existing database-backed applications. W

A fast and simple in-memory database with a key-value data model written in Rust

Segment Segment is a simple & fast in-memory database with a key-value data model written in Rust. Features Dynamic keyspaces Keyspace level control o

Lightweight async Redis client with connection pooling written in pure Rust and 100% memory safe
Lightweight async Redis client with connection pooling written in pure Rust and 100% memory safe

redi-rs (or redirs) redi-rs is a Lightweight Redis client with connection pooling written in Rust and 100% memory safe redi-rs is a Redis client writt

A highly scalable MySQL Proxy framework written in Rust

mysql-proxy-rs An implementation of a MySQL proxy server built on top of tokio-core. Overview This crate provides a MySQL proxy server that you can ex

A user crud written in Rust, designed to connect to a MySQL database with full integration test coverage.

SQLX User CRUD Purpose This application demonstrates the how to implement a common design for CRUDs in, potentially, a system of microservices. The de

An API Wrapper for https://paste.myst.rs written in rust
An API Wrapper for https://paste.myst.rs written in rust

PasteMyst.RS pastemyst-rs is an api wrapper for pastemyst written in Rust. ⚠ This package is under development ⚠ Sample usage To get a paste from past

A programmable document database inspired by CouchDB written in Rust

PliantDB PliantDB aims to be a Rust-written, ACID-compliant, document-database inspired by CouchDB. While it is inspired by CouchDB, this project will

Owner
James [Undefined]
I do program stuff. I typically use Rust and Elixir. he/him.
James [Undefined]
Learn Rust black magics by implementing basic types in database systems

Type Exercise in Rust (In Chinese) 数据库表达式执行的黑魔法:用 Rust 做类型体操 This is a short lecture on how to use the Rust type system to build necessary components

Alex Chi 996 Jan 3, 2023
Very rudimentary library shim to read the Swinsian db in Rust.

Swinsian Rust Library Shim My favorite OSX music player is by far Swinsian. The API however ranges from non-existant to absolute trash (AppleScript).

coral 1 Sep 30, 2022
A Distributed SQL Database - Building the Database in the Public to Learn Database Internals

Table of Contents Overview Usage TODO MVCC in entangleDB SQL Query Execution in entangleDB entangleDB Raft Consensus Engine What I am trying to build

Sarthak Dalabehera 38 Jan 2, 2024
High-level async Cassandra client written in 100% Rust.

CDRS tokio CDRS is production-ready Apache Cassandra driver written in pure Rust. Focuses on providing high level of configurability to suit most use

Kamil Rojewski 73 Dec 26, 2022
Materialize simplifies application development with streaming data. Incrementally-updated materialized views - in PostgreSQL and in real time. Materialize is powered by Timely Dataflow.

Materialize is a streaming database for real-time applications. Get started Check out our getting started guide. About Materialize lets you ask questi

Materialize, Inc. 4.7k Jan 8, 2023
Seed your development database with real data ⚡️

Seed Your Development Database With Real Data ⚡️ Replibyte is a blazingly fast tool to seed your databases with your production data while keeping sen

Qovery 3.4k Jan 2, 2023
Tools to streamline development of Wasm UDFs for SingleStoreDB.

SingleStore Wasm Toolkit And Examples This repository provides utilities intended to help you streamline development of Wasm UDFs for SingleStoreDB. I

SingleStore Labs 14 Dec 13, 2022
Async Lightweight HTTP client using system native library if possible. (Currently under heavy development)

Async Lightweight HTTP Client (aka ALHC) What if we need async but also lightweight http client without using such a large library like reqwest, isahc

SteveXMH 7 Dec 15, 2022
ReefDB is a minimalistic, in-memory and on-disk database management system written in Rust, implementing basic SQL query capabilities and full-text search.

ReefDB ReefDB is a minimalistic, in-memory and on-disk database management system written in Rust, implementing basic SQL query capabilities and full-

Sacha Arbonel 75 Jun 12, 2023
AgateDB is an embeddable, persistent and fast key-value (KV) database written in pure Rust

AgateDB is an embeddable, persistent and fast key-value (KV) database written in pure Rust. It is designed as an experimental engine for the TiKV project, and will bring aggressive optimizations for TiKV specifically.

TiKV Project 535 Jan 9, 2023