Asterinas

3 min read Original article ↗

Introduce OSDK

Asterinas Operating System Development Kit (OSDK) helps OS devs to create, build, run, and test Rust projects for OS kernels effortless. Imagine crafting kernels with the same simplicity as apps!

img

Jump start

img

Crate reuse

img

Rapid testing

img

Safe coding

img

Jump start

img

With OSDK, you can start building your own Rust OS kernel with three simple steps.

1. Install Asterinas OSDK

cargo install cargo-osdk

2. Create a Rust project for your "Hello World" kernel.

cargo osdk new my-first-os --kernel

3. Compile the kernel, generate a bootable image, and run it in a VM with just one single command.

cd my-first-os && cargo osdk run

img

Crate reuse

img

All OSDK-based Rust crates for an OS kernel or library share a common foundation, a crate called ostd. This fosters a more vibrant ecosystem of OS crates, reusable across different Rust OSes.

img

img

Rapid testing

img

Writing unit tests for OSDK-based Rust projects is a breeze with ktest.

                              #[cfg(ktest)] 
mod tests {
    #[ktest]
    fn it_works() {
        assert_eq!(true, true);
    }
}
                              
                            

Running these unit tests in the kernel mode can be done with a simple command:

cargo osdk test

img

Safe coding

img

OSDK is based on ostd, a minimal, expressive, and solid foundation that enables OS devs to implement OS functionalities on top of it in safe Rust.

The effectiveness of ostd has been validated by our extensive experience in developing Asterinas. In Asterinas, all unsafe Rust code is confined to ostd, whereas the rest of the kernel, including all drivers for peripheral devices, is composed of safe Rust code exclusively.

With OSDK, you can start building your own Rust OS kernel with three simple steps.

1. Install Asterinas OSDK

cargo install cargo-osdk

2. Create a Rust project for your "Hello World" kernel.

cargo osdk new my-first-os --kernel

3. Compile the kernel, generate a bootable image, and run it in a VM with just one single command.

cd my-first-os && cargo osdk run

Writing unit tests for OSDK-based Rust projects is a breeze with ktest.

                              #[cfg(ktest)] 
mod tests {
    #[ktest]
    fn it_works() {
        assert_eq!(true, true);
    }
}
                              
                            

Running these unit tests in the kernel mode can be done with a simple command:

cargo osdk test

All OSDK-based Rust crates for an OS kernel or library share a common foundation, a crate called ostd. This fosters a more vibrant ecosystem of OS crates, reusable across different Rust OSes.

img

OSDK is based on ostd, a minimal, expressive, and solid foundation that enables OS devs to implement OS functionalities on top of it in safe Rust.

The effectiveness of ostd has been validated by our extensive experience in developing Asterinas. In Asterinas, all unsafe Rust code is confined to ostd, whereas the rest of the kernel, including all drivers for peripheral devices, is composed of safe Rust code exclusively.

OSDK can be utilized to build any Rust kernel based on the framekernel architecture: Asterinas is built with OSDK; your kernel can too!