forked from M-Labs/zynq-rs
alloc: support initializing from linker information
This commit is contained in:
parent
aa93794632
commit
dfcdeb09ca
@ -77,7 +77,7 @@ pub fn main_core0() {
|
||||
let mut ddr = zynq::ddr::DdrRam::new();
|
||||
#[cfg(not(feature = "target_zc706"))]
|
||||
ddr.memtest();
|
||||
ram::init_alloc(&mut ddr);
|
||||
ram::init_alloc_ddr(&mut ddr);
|
||||
|
||||
for i in 0..=1 {
|
||||
let mut flash_io = flash.manual_mode(i);
|
||||
|
@ -27,13 +27,27 @@ unsafe impl GlobalAlloc for CortexA9Alloc {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_alloc(ddr: &mut DdrRam) {
|
||||
pub fn init_alloc_ddr(ddr: &mut DdrRam) {
|
||||
unsafe {
|
||||
ALLOCATOR.0.lock()
|
||||
.init(ddr.ptr::<u8>() as usize, ddr.size());
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
static __heap_start: usize;
|
||||
static __heap_end: usize;
|
||||
}
|
||||
|
||||
pub fn init_alloc_linker() {
|
||||
unsafe {
|
||||
let start = &__heap_start as *const usize as usize;
|
||||
let end = &__heap_end as *const usize as usize;
|
||||
ALLOCATOR.0.lock()
|
||||
.init(start, end - start);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[alloc_error_handler]
|
||||
fn alloc_error(_: core::alloc::Layout) -> ! {
|
||||
|
Loading…
Reference in New Issue
Block a user