Skip to content

Chapter 1 notes/room for improvement #73

@Oakchris1955

Description

@Oakchris1955

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions