Skip to content

Move Note and GDT definitions into Rust #37

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

Merged
merged 5 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions layout.ld
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ PHDRS

/* Loaders like to put stuff in low memory (< 1M), so we don't use it. */
ram_min = 1M;
ram_max = 2M;
/* Our stack grows down from ram_max. TODO: Add a guard for stack overflows. */
stack_size = 64K;

SECTIONS
{
Expand All @@ -28,16 +25,18 @@ SECTIONS
.data : { *(.data .data.*) }
data_size = . - data_start;

/* The BSS section isn't mapped from any file data. It is simply zeroed
in RAM. So our file size should be computed from here. */
file_size = . - ram_min;
/* The BSS section isn't mapped from file data. It is just zeroed in RAM. */
.bss : {
bss_start = .;
*(.bss .bss.*)
bss_size = . - bss_start;
}

ASSERT((. <= ram_max - stack_size), "firmware size too big for RAM region")
/* Our stack grows down and is page-algined. TODO: Add stack guard pages. */
.stack (NOLOAD) : ALIGN(4K) { . += 64K; }
stack_start = .;
/* ram32.s only maps the first 2 MiB, and that must include the stack. */
ASSERT((. <= 2M), "Stack overflows initial identity-mapped memory region")

/* Match edk2's GccBase.lds DISCARD section */
/DISCARD/ : {
Expand Down
4 changes: 2 additions & 2 deletions src/asm/ram64.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ linux64_start:
xorq %rdi, %rdi

ram64_start:
# Setup the stack (at the end of our RAM region)
movq $ram_max, %rsp
# Initialize the stack pointer (Rust code always uses the stack)
movq $stack_start, %rsp

# PVH start_info is in %rdi, the first paramter of the System V ABI.
# BootParams are in %rsi, the second paramter of the System V ABI.
Expand Down