Skip to content

Commit 2517b94

Browse files
committed
Update Readme
1 parent a703656 commit 2517b94

File tree

1 file changed

+48
-6
lines changed

1 file changed

+48
-6
lines changed

Readme.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Creates a bootable disk image from a Rust OS kernel.
1010

1111
## Usage
1212

13-
First you need to add a dependency on the `bootloader` crate:
13+
First you need to add a dependency on the [`bootloader`](https://github.com/rust-osdev/bootloader) crate:
1414

1515
```toml
1616
# in your Cargo.toml
@@ -21,30 +21,72 @@ bootloader = "0.5.0"
2121

2222
**Note**: At least bootloader version `0.5.0` is required.
2323

24+
If you want to use a custom bootloader with a different name, you can use Cargo's [rename functionality](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml).
25+
26+
### Building
27+
2428
Now you can build the kernel project and create a bootable disk image from it by running:
2529

2630
```
27-
> bootimage build --target your_custom_target.json [other_args]
31+
bootimage build --target your_custom_target.json [other_args]
2832
```
2933

3034
The command will invoke [`cargo xbuild`](https://github.com/rust-osdev/cargo-xbuild), forwarding all passed options. Then it will build the specified bootloader together with the kernel to create a bootable disk image.
3135

36+
If you prefer a cargo subcommand, you can use the equivalent `cargo bootimage` command:
37+
38+
```
39+
cargo bootimage --target your_custom_target.json [other_args]
40+
```
41+
42+
### Running
43+
44+
To run your kernel in QEMU, you can use `bootimage run`:
45+
46+
```
47+
bootimage run --target your_custom_target.json [other_args] -- [qemu args]
48+
```
49+
50+
All arguments after `--` are passed to QEMU. If you want to use a custom run command, see the _Configuration_ section below.
51+
52+
If you prefer working directly with cargo, you can use `bootimage runner` as a custom runner in your `.cargo/config`:
53+
54+
```toml
55+
[target.'cfg(target_os = "none")']
56+
runner = "bootimage runner"
57+
```
58+
59+
Now you can run your kernel through `cargo xrun --target […]`.
60+
3261
## Configuration
3362

34-
Configuration is done through a through a `[package.metadata.bootimage]` table in the `Cargo.toml`. The following options are available:
63+
Configuration is done through a through a `[package.metadata.bootimage]` table in the `Cargo.toml` of your kernel. The following options are available:
3564

3665
```toml
3766
[package.metadata.bootimage]
3867
# This target is used if no `--target` is passed
3968
default-target = ""
4069

41-
# The command invoked on `bootimage run`
70+
# The command invoked on `bootimage run` or `bootimage runner`
4271
# (the "{}" will be replaced with the path to the bootable disk image)
4372
run-command = ["qemu-system-x86_64", "-drive", "format=raw,file={}"]
4473

45-
# The timeout for running an integration test in seconds
74+
# Additional arguments passed to the runner on `bootimage run` or `bootimage runner`
75+
# (this is useful when you want to add some arguments to the default QEMU command)
76+
run-args = []
77+
78+
# The timeout for running an integration test through `bootimage test` in seconds
4679
test-timeout = 300
4780
```
4881

4982
## License
50-
Dual-licensed under MIT or the Apache License (Version 2.0).
83+
84+
Licensed under either of
85+
86+
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
87+
http://www.apache.org/licenses/LICENSE-2.0)
88+
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
89+
90+
at your option.
91+
92+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

0 commit comments

Comments
 (0)