| #![feature(asm,alloc,compiler_builtins_lib,const_fn,global_allocator,lang_items,naked_functions)] |
| extern crate compiler_builtins; |
| extern crate linked_list_allocator; |
| use linked_list_allocator::BaseHeap; |
| static ALLOCATOR : BaseHeap = BaseHeap; |
| /// Tock programs' entry point |
| pub extern "C" fn _start(mem_start: usize, app_heap_break: usize, |
| _kernel_memory_break: usize) -> ! { |
| // NOTE `rustc` forces this signature on us. See `src/lang_items.rs` |
| fn main(argc: isize, argv: *const *const u8) -> isize; |
| asm!("mov r9, $0" : : "r"(app_heap_break) : : "volatile"); |
| syscalls::memop(0, mem_start + 2048); |
| let new_stack = mem_start + 1024; |
| asm!("mov sp, $0" : : "r"(new_stack) : : "volatile"); |
| let heap_start = new_stack + size_of::<usize>(); |
| BaseHeap.init(heap_start, heap_size); |
| // arguments are not used in Tock applications |