Skip to content

🌠You can use rust to quickly build your own operating system based on this project!

License

Notifications You must be signed in to change notification settings

ShelterLab/SystemTemplateForRust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌠System Template

🔧This is a template that can help you quickly build your own OS using rust.

🦀HanabiOS is built on it.

🙏I hope that everyone can use it to understand and learn the underlying principles of computers and the operation of operating systems without barriers!

📕Prepare For It

  1. 🌙Use the following command to install the nightly version of rust,

    😀because we may need to use some features that only this version provides.

rustup install nightly
  1. 🔧Then set the toolchain used in this project to nightly version of rust.

    🔭In the future we can enable some experimental features by adding feature flags at the beginning of main.rs,

    😫such as adding #![feature(asm)] to enable experimental introverted compilation.

rustup override add nightly
  1. 🔧Configure your target.json,

    📜here we only provide target.json to help you build the system for the x86_64 architecture platform.

    😀If you have other written target.json,

    welcome to submit it to us!

  2. 📦Install xbuild and bootimage,

    🏭they can help you quickly build an operating system image.

rustup component add rust-src
rustup component add llvm-tools-preview
cargo install cargo-xbuild
cargo install bootimage
  1. ✍From now on you can directly start writing the code of the operating system!

    The entry point of this operating system is the _start function in main.rs!

🏃‍Build And Run

cargo bootimage --target target.json
qemu-system-x86_64 -drive format=raw,file=./target/target/debug/bootimage-os_template.bin

🛑Precautions

  1. 😫You will not be able to use anything in std::,

    🔨you need to construct your own api and call it.

  2. 📜The target.json given here can only help you build an operating system for the x86_64 platform,

    ✍please write your own for other platforms!

    🤝If you have target.json for other platforms,

    🤣please submit it to us!

    ❤Thank you!

👍Special Thanks

  1. OSDev (Wiki)
  2. Writing an OS in Rust