From f1fb6d81b7d0d21a4c8ad79ab45d62cbe7e2fa41 Mon Sep 17 00:00:00 2001 From: Matt Taylor Date: Wed, 10 Jul 2019 22:50:13 +0100 Subject: [PATCH 1/2] Add guide on chainloading --- README.md | 6 ++++++ doc/chainloading.md | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 doc/chainloading.md diff --git a/README.md b/README.md index a9b345ff..2bc376e1 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,12 @@ The bootloader crate can be configured through some cargo features: - `map_physical_memory`: Maps the complete physical memory in the virtual address space and passes a [`physical_memory_offset`](https://docs.rs/bootloader/0.4.0/bootloader/bootinfo/struct.BootInfo.html#structfield.physical_memory_offset) field in the `BootInfo`. - The virtual address where the physical memory should be mapped is configurable by setting the `BOOTLOADER_PHYSICAL_MEMORY_OFFSET` environment variable (supports decimal and hex numbers (prefixed with `0x`)). +## Advanced Documentation +See these guides for advanced usage of this crate: + +- [Chainloading](https://github.com/rust-osdev/bootloader/blob/master/doc/chainloading.md) +- Higher Half Kernel - TODO + ## License Licensed under either of diff --git a/doc/chainloading.md b/doc/chainloading.md new file mode 100644 index 00000000..99c2e134 --- /dev/null +++ b/doc/chainloading.md @@ -0,0 +1,23 @@ +# Chainloading + +Chainloading is a technique that allows one bootloader to call another bootloader as if the system had just booted up. [GNU GRUB](https://www.gnu.org/software/grub/) is one such bootloader which is commonly used for chainloading, as it presents a menu which you can use to select the OS you'd like to boot from. We're using `grub2` here. + +Create a file under `iso/boot/grub/grub.cfg` in the root directory of your OS's source tree. In it, put: + +``` +menuentry "BlogOS" { + chainloader (hd1)+1 +} +``` + +This tells grub that our binary is installed on the first partition of the `hd1` disk. If you're trying to boot on real hardware you may need to edit this value as appropriate. Alternatively, you should be able to create a partition on the same ISO file that grub creates and copy the binary there. + +Next, create the ISO with: +``` +grub-mkrescue -o grub.iso iso +``` + +Testing with QEMU: +``` +qemu-system-x86_64 -hda grub.iso -hdb target/x86_64-blog_os/debug/bootimage-blog_os.bin +``` From 8371044c22903d681a0fe06711606ca1529b5179 Mon Sep 17 00:00:00 2001 From: Matt Taylor Date: Thu, 11 Jul 2019 18:37:40 +0100 Subject: [PATCH 2/2] Use relative link and myOS in chainload docs --- README.md | 2 +- doc/chainloading.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2bc376e1..0cf89bf5 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ The bootloader crate can be configured through some cargo features: ## Advanced Documentation See these guides for advanced usage of this crate: -- [Chainloading](https://github.com/rust-osdev/bootloader/blob/master/doc/chainloading.md) +- [Chainloading](doc/chainloading.md) - Higher Half Kernel - TODO ## License diff --git a/doc/chainloading.md b/doc/chainloading.md index 99c2e134..fa10f35a 100644 --- a/doc/chainloading.md +++ b/doc/chainloading.md @@ -5,7 +5,7 @@ Chainloading is a technique that allows one bootloader to call another bootloade Create a file under `iso/boot/grub/grub.cfg` in the root directory of your OS's source tree. In it, put: ``` -menuentry "BlogOS" { +menuentry "myOS" { chainloader (hd1)+1 } ``` @@ -17,7 +17,7 @@ Next, create the ISO with: grub-mkrescue -o grub.iso iso ``` -Testing with QEMU: +Testing with QEMU (replacing `my_os` with the name of your OS's target): ``` -qemu-system-x86_64 -hda grub.iso -hdb target/x86_64-blog_os/debug/bootimage-blog_os.bin +qemu-system-x86_64 -hda grub.iso -hdb target/x86_64-my_os/debug/bootimage-my_os.bin ```