blob: 51f1e6a51164d9ba311662fa165802b8011230e0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#[link_section = ".on_reset"]
#[no_mangle]
pub static __RESET_VECTOR: fn() -> ! = on_reset;
/**
* The init sections are run. The order in which they are run is deterined by the name of the
* section the pointer to the function is located in. By convention the section name is 'inits.nnn'
* where 'nnn' is a number from 000-999.
*/
fn run_init_sections() -> () {
extern "C" {
static mut _sinits: extern "C" fn() -> ();
static mut _einits: extern "C" fn() -> ();
}
unsafe {
let mut cursor: *mut extern "C" fn() -> () = &mut _sinits;
let einits_end: *mut extern "C" fn() -> () = &mut _einits;
while cursor < einits_end {
cursor.read()();
cursor = cursor.offset(1);
}
}
}
fn on_reset() -> ! {
run_init_sections();
loop {}
}
|