Better user programs with a special std. Sleep and exit are calling scheduler instead of wfi.

This commit is contained in:
2026-02-21 18:29:27 +01:00
parent 235f17e7cf
commit 8a8034bd11
25 changed files with 263 additions and 210 deletions

View File

@@ -3,16 +3,23 @@ cargo_flags := if release != "" { "--release" } else { "" }
default: run
build_user_prog prog:
cd {{ "user" / prog }} && \
RUSTFLAGS="-C relocation-model=pic" cargo b {{ cargo_flags }}
riscv64-elf-objcopy -O binary {{ "target/riscv64/debug" / prog }} {{ "user" / prog / prog + ".mem" }}
mount_filesystem:
# Add some permissions to be able to do next operations without sudo
@mountpoint -q mnt || sudo mount -o umask=0022,gid=$(id -g $USER),uid=$(id -u $USER) disk.img mnt
build: (map_dir "user" "build_user_prog")
sync_filesystem:
sync
build_user_prog prog:
RUSTFLAGS="-C relocation-model=pic -C link-arg=-Tilm.ld" cargo b {{ cargo_flags }} --package {{ prog }}
riscv64-elf-objcopy -O binary {{ "target/riscv64/debug" / prog }} {{ "mnt/usr/bin" / prog }}
build: mount_filesystem (map_dir "user" "build_user_prog")
cargo b {{ cargo_flags }}
just sync_filesystem
run: build
cargo r {{ cargo_flags }} --bin kernel-rust
cargo r {{ cargo_flags }}
map_dir dir recipe:
@for file in `ls {{ dir }}`; do \