Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Note and GDT definitions into Rust #37

Merged
merged 5 commits into from
Apr 15, 2020

Commits on Apr 13, 2020

  1. layout: Improve development workflow

    Right now, if layout.ld or target.json is changed, the firmware will
    not automatically relink when running "cargo xbuild". This can make
    working on layout.ld quite tedious, as you have to manually change the
    Rust code to get the firmware to rebuild.
    
    We solve this by adding a tiny build script which simply rebuilds the
    program if either layout.ld or target.json changes.
    
    We also stop using "-s" (aka "--strip-all") in the target options.
    Instead, we add a second /DISCARD/ section in the linker script. This
    puts all of our logic about sections in a single place. It also makes
    it easier for a developer to get the symbols (if they want them).
    
    Signed-off-by: Joe Richey <[email protected]>
    josephlr committed Apr 13, 2020
    Configuration menu
    Copy the full SHA
    1c47247 View commit details
    Browse the repository at this point in the history
  2. layout: Add explict .stack section

    This ensures that the stack region is mapped by the ELF loader and
    doesn't conflict with any hypervisor memory regions. To do this without
    increasing binary size, we place the stack right after the .bss section.
    
    Note that we still need an assert to make sure that our minimal page
    table setup in ram32.s covers our program + stack.
    
    Also, being able to see the stack as a section makes debugging easier.
    
    Signed-off-by: Joe Richey <[email protected]>
    josephlr committed Apr 13, 2020
    Configuration menu
    Copy the full SHA
    0f813a5 View commit details
    Browse the repository at this point in the history
  3. pvh: Move note definition/declaration to Rust

    The structure of the ELF note can be done with pure Rust code. We can
    definie the Name and Desc types and use a static struct to hold the
    note.
    
    Due to Rust's limitations on "pointer-to-integer cast", we have to have
    Desc have a function pointer type, which means that field is now 8 bytes
    long instead of 4. However, this doesn't seem to be an issue. The binary
    still works w/ PVH Boot on QEMU and CH.
    
    Signed-off-by: Joe Richey <[email protected]>
    josephlr committed Apr 13, 2020
    Configuration menu
    Copy the full SHA
    70ee5b7 View commit details
    Browse the repository at this point in the history
  4. gdt: Move GDT and GDT Definitions to Rust

    The GDT is just some data in static memory, so there's not a good
    reason to have this code in assembly. Ideally, we would use types
    from the x86_64 crate for this. However,
    
      - We can't use x86_64::structures::gdt::DescriptorFlags for the
        contents of the descriptors, as that definition is missing flags.
      - We can't use x86_64::structures::DescriptorTablePointer for the
        GDT pointers because its base is a u64, and Rust doesn't allow
        "pointer-to-integer cast" in statics.
    
    So we have to roll our own. The definitions aren't that bad. The only
    downside is that we have to add the bitflags dependency, but it was
    already a dependancy of x86_64, so that's also not bad.
    
    Signed-off-by: Joe Richey <[email protected]>
    josephlr committed Apr 13, 2020
    Configuration menu
    Copy the full SHA
    f7f5c6d View commit details
    Browse the repository at this point in the history

Commits on Apr 15, 2020

  1. Fix typos and add comments

    Signed-off-by: Joe Richey <[email protected]>
    josephlr committed Apr 15, 2020
    Configuration menu
    Copy the full SHA
    ae04b87 View commit details
    Browse the repository at this point in the history