I spent some time today completing chapter 1 and I gathered the following notes:
1.1. Making a Stand Alone Binary
- Better to specify target in
.cargo/config.toml in the following matter:
[build]
target = "x86_64-unknown-none"
1.2. Booting Our Binary
json-target-spec = true must be added under [unstable] in .cargo/config.toml
- Rust doesn't like JSON comments, they should be removed from
16bit_target.json
hexdump should be run on target/16bit_target/release/<project_name>. I believe it would be useful for the reader to know which file to run hexdump to. The binary path can also be obtained by running cargo build --release --message-format=json. There last JSON output should contain an executable field with the binary path.
Better to test qemu-system-x86_64 by running it with the --version flag
Not sure about that one, since we need to run it to compare before and after passing our binary. Do what you think is best.
- About the QEMU command: Perhaps it should be specified that the
\ is
to allow multiple lines (or it could also be removed)? Just saying because I got a bit confused about it.
&ch: u8 in msg is incorrect syntax; has been fixed in the repo, not in the book
- Instead of passing
--target, we can just set .cargo/config.toml build.target to 16bit_target.json
- The
hlt command doesn't actually halt the system: it halts it until an interrupt
is fired. I don't know if it is just me, but even with hlt, QEMU still uses 100% of one
of my cores, because apparently it is checking for interrupts the entire time
(source)
but when I invoke the cli instruction (CLear Interrupt flag) before hlt, the CPU usage drops to almost zero.
I spent some time today completing chapter 1 and I gathered the following notes:
1.1. Making a Stand Alone Binary
.cargo/config.tomlin the following matter:1.2. Booting Our Binary
json-target-spec = truemust be added under[unstable]in.cargo/config.toml16bit_target.jsonhexdumpshould be run ontarget/16bit_target/release/<project_name>. I believe it would be useful for the reader to know which file to runhexdumpto. The binary path can also be obtained by runningcargo build --release --message-format=json. There last JSON output should contain anexecutablefield with the binary path.Better to testqemu-system-x86_64by running it with the--versionflagNot sure about that one, since we need to run it to compare before and after passing our binary. Do what you think is best.
\isto allow multiple lines (or it could also be removed)? Just saying because I got a bit confused about it.
&ch: u8 in msgis incorrect syntax; has been fixed in the repo, not in the book--target, we can just set.cargo/config.tomlbuild.targetto16bit_target.jsonhltcommand doesn't actually halt the system: it halts it until an interruptis fired. I don't know if it is just me, but even with
hlt, QEMU still uses 100% of oneof my cores, because apparently it is checking for interrupts the entire time
(source)
but when I invoke the
cliinstruction (CLear Interrupt flag) beforehlt, the CPU usage drops to almost zero.