Skip to content

Question on second stage #481

Open
Open

Description

@boredcoder411

I've read the through the first bootsector's code, and everything looks good with objdump: _second_stage_start label is supposed to be at ram 0x7e00 and the code calls it, but I'm trying to make my own second stage and don't understand just how the second stage is placed after the first one. I've tried assembling a program with nasm -f bin and just cat appending to the original file, but that doesn't seem to work, even if the new code is at offset 0x7e00. Am I missing something?

Activity

  1. bjorn3 commented on Jan 12, 2025

    @bjorn3
    Contributor

    create_mbr_disk inserts padding as necessary to write it to the right location on the disk. And the first stage then loads a fixed sector on the disk to a fixed address in ram.

  2. boredcoder411 commented on Jan 12, 2025

    @boredcoder411
    Author

    So I can't just write bytes at the second sector?

  3. bjorn3 commented on Jan 12, 2025

    @bjorn3
    Contributor

    Looks like the second stage is actually written to the second sector:

    let second_stage_start_sector = 1;
    When cat'ing are you sure the first file for the boot sector is exactly 512 bytes?

  4. boredcoder411 commented on Jan 12, 2025

    @boredcoder411
    Author

    Yep! Because the linker script fills with 00 and 55aa at the 511 and 512 bytes

  5. boredcoder411 commented on Jan 14, 2025

    @boredcoder411
    Author

    https://github.com/boredcoder411/rust_boot
    If you want to check it out, but it looks fine to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions