FreeBSD Rust Drivers
Based on the works of Johannes Lundberg and David Young. Planning on expanding this with different drivers as I learn more.
See Overview to get started learning about this enviroment's structure, how it works, and how to build your own driver.
- Clone the repo
- Install rust via Rustup: https://rustup.rs/
- Install llvm19:
pkg install llvm19 - do
rustup component add rust-src - do
cargo install cargo-make
- cd into drivers/hello , generate the bindings & build the kld by:
cargo make build-kmod - Load the kld:
kldload ./hello.ko - Check its existance:
kldstat | grep "hello" - Unload the kld:
kldunload hello
- cd into drivers/char , generate the bindings & build the kld by:
cargo make build-kmod - Load the kld:
kldload ./char_dev.ko - Check its existance:
kldstat | grep "char_dev" - Check the registration with devfs:
ls /dev/echo - Write to dev path:
echo "Hello :D" > /dev/echo - Read echo'ed message:
cat /dev/echo - Unload the kld:
kldunload char_dev