1
0
Fork 0

extend linker script

This commit is contained in:
Astro 2019-05-27 01:44:24 +02:00
parent d10ffe9eb9
commit 75bb755327
4 changed files with 35 additions and 38 deletions

View File

@ -2,7 +2,7 @@
runner = "./runner.sh" runner = "./runner.sh"
linker = "arm-none-eabihf-gcc" linker = "arm-none-eabihf-gcc"
rustflags = [ rustflags = [
"-C", "link-arg=-Wl,-Tlink.x", "-C", "link-arg=-Wl,-Tlink.x,-N",
"-C", "target-feature=a9,armv7-a,neon", "-C", "target-feature=a9,armv7-a,neon",
"-C", "target-cpu=cortex-a9", "-C", "target-cpu=cortex-a9",
] ]

52
link.x
View File

@ -1,57 +1,49 @@
ENTRY(_boot_cores); ENTRY(_boot_cores);
/* SECTIONS */ STACK_SIZE = 0x2000 - 0x10;
/* { */
/* . = 0x8000; */
/* .text : */
/* { */
/* KEEP(*(.text.boot)) *(.text .text.*) */
/* } */
/* /DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) } */
/* } */
MEMORY
{
/* 256 kB On-Chip Memory */
OCM : ORIGIN = 0, LENGTH = 0x40000
}
SECTIONS SECTIONS
{ {
/* Starts at LOADER_ADDR. */
. = 0x8000;
__start = .;
__text_start = .;
.text : .text :
{ {
/* Starts at LOADER_ADDR. */
. = 0x8000;
KEEP(*(.text.boot)) KEEP(*(.text.boot))
*(.text) *(.text .text.*)
}
. = ALIGN(4096); /* align to page size */ . = ALIGN(4096); /* align to page size */
__text_end = .; } > OCM
__rodata_start = .;
.rodata : .rodata :
{ {
*(.rodata) *(.rodata)
}
. = ALIGN(4096); /* align to page size */ . = ALIGN(4096); /* align to page size */
__rodata_end = .; } > OCM
__data_start = .;
.data : .data :
{ {
*(.data) *(.data)
}
. = ALIGN(4096); /* align to page size */ . = ALIGN(4096); /* align to page size */
__data_end = .; } > OCM
__bss_start = .; .bss (NOLOAD) :
.bss :
{ {
bss = .;
*(.bss) *(.bss)
}
. = ALIGN(4096); /* align to page size */ . = ALIGN(4096); /* align to page size */
__bss_end = .; } > OCM
__end = .; __bss_start = ADDR(.bss);
__bss_end = ADDR(.bss) + SIZEOF(.bss);
.stack (NOLOAD) : {
. += STACK_SIZE;
} > OCM
__stack_end = ADDR(.stack);
__stack_start = ADDR(.stack) + SIZEOF(.stack);
/DISCARD/ : /DISCARD/ :
{ {

View File

@ -30,10 +30,16 @@ macro_rules! def_reg_set {
} }
} }
/// Stack Pointer
pub struct SP; pub struct SP;
def_reg_get!(SP, u32, "mov $0, sp"); def_reg_get!(SP, u32, "mov $0, sp");
def_reg_set!(SP, u32, "mov sp, $0"); def_reg_set!(SP, u32, "mov sp, $0");
/// Link register (function call return address)
pub struct LR;
def_reg_get!(LR, u32, "mov $0, lr");
def_reg_set!(LR, u32, "mov lr, $0");
pub struct MPIDR; pub struct MPIDR;
def_reg_get!(MPIDR, u32, "mrc p15, 0, $0, c0, c0, 5"); def_reg_get!(MPIDR, u32, "mrc p15, 0, $0, c0, c0, 5");

View File

@ -20,7 +20,7 @@ use crate::cortex_a9::{asm, regs::*};
extern "C" { extern "C" {
static mut __bss_start: u32; static mut __bss_start: u32;
static mut __bss_end: u32; static mut __bss_end: u32;
static mut __end: u32; static mut __stack_start: u32;
} }
#[link_section = ".text.boot"] #[link_section = ".text.boot"]
@ -28,11 +28,10 @@ extern "C" {
#[naked] #[naked]
pub unsafe extern "C" fn _boot_cores() -> ! { pub unsafe extern "C" fn _boot_cores() -> ! {
const CORE_MASK: u32 = 0x3; const CORE_MASK: u32 = 0x3;
let stack_start = __end + 4096;
match MPIDR.get() & CORE_MASK { match MPIDR.get() & CORE_MASK {
0 => { 0 => {
SP.set(stack_start); SP.set(&mut __stack_start as *mut _ as u32);
boot_core0(); boot_core0();
} }
_ => loop { _ => loop {