Skip to content

Commit 369821f

Browse files
bors[bot]64
andcommitted
Merge #66
66: Add guide on chainloading r=phil-opp a=64 Co-authored-by: Matt Taylor <[email protected]>
2 parents b5d43ca + 8371044 commit 369821f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ The bootloader crate can be configured through some cargo features:
6666
- `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`.
6767
- 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`)).
6868

69+
## Advanced Documentation
70+
See these guides for advanced usage of this crate:
71+
72+
- [Chainloading](doc/chainloading.md)
73+
- Higher Half Kernel - TODO
74+
6975
## License
7076

7177
Licensed under either of

doc/chainloading.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Chainloading
2+
3+
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.
4+
5+
Create a file under `iso/boot/grub/grub.cfg` in the root directory of your OS's source tree. In it, put:
6+
7+
```
8+
menuentry "myOS" {
9+
chainloader (hd1)+1
10+
}
11+
```
12+
13+
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.
14+
15+
Next, create the ISO with:
16+
```
17+
grub-mkrescue -o grub.iso iso
18+
```
19+
20+
Testing with QEMU (replacing `my_os` with the name of your OS's target):
21+
```
22+
qemu-system-x86_64 -hda grub.iso -hdb target/x86_64-my_os/debug/bootimage-my_os.bin
23+
```

0 commit comments

Comments
 (0)