Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
jlkiri committed Mar 26, 2024
0 parents commit d5bc6c3
Show file tree
Hide file tree
Showing 56 changed files with 3,306 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[build]
target = "riscv64gc-unknown-none-elf"

[target.riscv64gc-unknown-none-elf]
rustflags = "-C target-feature=-c" # Disable compressed instructions

[unstable]
build-std = ["core", "alloc", "compiler_builtins"]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
log.txt
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rust-analyzer.cargo.target": "riscv64gc-unknown-none-elf",
"rust-analyzer.check.allTargets": false,
"rust-analyzer.imports.preferNoStd": true,
"rust-analyzer.showUnlinkedFileNotification": false,
}
127 changes: 127 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[workspace]
members = ["allocator", "hal-core", "hal-riscv"]
exclude = ["runner", "usercode"]
resolver = "2"

[package]
name = "pathos"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
harness = false
test = false

[[bin]]
name = "pathos"
harness = false

[dependencies]
hal-riscv = { path = "hal-riscv" }
hal-core = { path = "hal-core" }
allocator = { path = "allocator" }
owo-colors = "4.0.0"
spin = "0.9.8"
once_cell = { version = "1.19.0", features = [
"alloc",
"race",
], default-features = false }
elf = { version = "0.7.4", default-features = false }
uart_16550 = "0.3.0"
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## PathOS kernel code

This is the kernel code for the PathOS operating system. It is a simple kernel that runs on the RISC-V architecture.

## Development

Install riscv64 toolchain to ~/.local/bin
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-riscv64-linux.tar.gz

Install `qemu-system` and `qemu-system-riscv64`.

zzz
4 changes: 4 additions & 0 deletions allocator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "allocator"
version = "0.1.0"
edition = "2021"
18 changes: 18 additions & 0 deletions allocator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
```
// Smallest block = 8 bytes
// Allocatable memory size = 64 bytes
// Highest order = 3 (2^3 * 8 = 64)
// Calculate order from smallest block and allocatable memory size:
// 2 ^ n = memsize / blocksize
// n = log2(memsize / blocksize)
// 3 64
// 2 32 32
// 1 16 16 16 16
// 0 8 8 8 8 8 8 8 8
// Number of nodes = 2 ^ (order + 1) - 1
// Total size required to bookkeep allocatable memory = num_nodes * node_size
// For order = 3 and node_size = 8, total size = (2 ^ (3 + 1) - 1) * 8 = 15 * 8
// = 120
```
5 changes: 5 additions & 0 deletions allocator/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test:
cargo test --lib --target x86_64-unknown-linux-gnu --jobs 1



Loading

0 comments on commit d5bc6c3

Please sign in to comment.