Merge #190

190: Added i.MX RT 1050 board support r=valexandru a=valexandru

This adds the memory layout for building applications for the i.MX RT 1050 board support.

Co-authored-by: Vochescu Alexandru <alexvochescu@gmail.com>
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 3f1723b..bfa9570 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -5,7 +5,8 @@
 edition = "2018"
 
 [features]
-alloc = [ "linked_list_allocator" ]
+alloc = ["alloc_init", "linked_list_allocator"]
+alloc_init = []
 custom_panic_handler = []
 custom_alloc_error_handler = []
 
diff --git a/core/src/alloc.rs b/core/src/alloc.rs
index 05e9669..f971849 100644
--- a/core/src/alloc.rs
+++ b/core/src/alloc.rs
@@ -4,7 +4,12 @@
 use core::ptr::NonNull;
 use linked_list_allocator::Heap;
 
-pub static mut HEAP: Heap = Heap::empty();
+static mut HEAP: Heap = Heap::empty();
+
+#[no_mangle]
+unsafe fn libtock_alloc_init(app_heap_start: usize, app_heap_size: usize) {
+    HEAP.init(app_heap_start, app_heap_size);
+}
 
 struct TockAllocator;
 
diff --git a/core/src/entry_point/mod.rs b/core/src/entry_point/mod.rs
index 40bdb62..2ab2351 100644
--- a/core/src/entry_point/mod.rs
+++ b/core/src/entry_point/mod.rs
@@ -127,8 +127,8 @@
     // Tell the kernel the new app heap break.
     memop::set_brk(app_heap_end as *const u8);
 
-    #[cfg(feature = "alloc")]
-    crate::alloc::HEAP.init(app_heap_start, app_heap_size);
+    #[cfg(feature = "alloc_init")]
+    crate::libtock_alloc_init(app_heap_start, app_heap_size);
 
     main(0, ptr::null());
 
diff --git a/core/src/lib.rs b/core/src/lib.rs
index f451950..3bdfe5b 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -8,6 +8,11 @@
 #[cfg(any(target_arch = "arm", target_arch = "riscv32"))]
 mod lang_items;
 
+#[cfg(feature = "alloc_init")]
+extern "Rust" {
+    fn libtock_alloc_init(app_heap_start: usize, app_heap_size: usize);
+}
+
 pub mod callback;
 pub mod debug;
 pub mod memop;