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

Aarch64 Add Linux Image Header #191

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*.bin
qemu.log
rusty-tags.vi
/.project.toml
2 changes: 2 additions & 0 deletions modules/axhal/linker.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ SECTIONS
}

_ekernel = .;

_kernel_size = _ekernel - _skernel;

/DISCARD/ : {
*(.comment) *(.gnu*) *(.note*) *(.eh_frame*)
Expand Down
37 changes: 36 additions & 1 deletion modules/axhal/src/platform/aarch64_common/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,46 @@ unsafe fn init_boot_page_table() {
crate::platform::mem::init_boot_page_table(addr_of_mut!(BOOT_PT_L0), addr_of_mut!(BOOT_PT_L1));
}

/// The earliest entry point for the primary CPU.
/// The Linux Header.
#[naked]
#[no_mangle]
#[link_section = ".text.boot"]
unsafe extern "C" fn _start() -> ! {
core::arch::asm!(
"
// code0/code1
nop
b _start_entry

// text_offset
.quad 0x80000

// image_size
.quad _kernel_size

// flags
.quad 0

// Reserved fields
.quad 0
.quad 0
.quad 0

// magic - yes 0x644d5241 is the same as ASCII string \"ARM\\x64\"
.ascii \"ARM\\x64\"

// Another reserved field at the end of the header
.byte 0, 0, 0, 0
",
options(noreturn),
)
}

/// The earliest entry point for the primary CPU.
#[naked]
#[no_mangle]
#[link_section = ".text.boot"]
unsafe extern "C" fn _start_entry() -> ! {
// PC = 0x8_0000
// X0 = dtb
core::arch::asm!("
Expand Down
Loading