summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2022-12-12 21:41:55 -0700
committerJosh Rahm <joshuarahm@gmail.com>2022-12-12 21:41:55 -0700
commit8bb2d168044213ce9bd31a19efb6bab90f5c9722 (patch)
tree737ba66cd1405fb4aa9ac5df9415b2ea5d88ab20 /src/main.rs
parentef3a1919ce5c87179e8f1d7a3b1b835151fdf50f (diff)
downloadstm32l4-rust-8bb2d168044213ce9bd31a19efb6bab90f5c9722.tar.gz
stm32l4-rust-8bb2d168044213ce9bd31a19efb6bab90f5c9722.tar.bz2
stm32l4-rust-8bb2d168044213ce9bd31a19efb6bab90f5c9722.zip
Create an init system.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs53
1 files changed, 5 insertions, 48 deletions
diff --git a/src/main.rs b/src/main.rs
index a3e8071..146f601 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,56 +3,13 @@
use core::panic::PanicInfo;
-#[link_section = ".on_reset"]
-#[no_mangle]
-pub static __RESET_VECTOR: fn() -> ! = on_reset;
+mod init;
+#[link_section = ".inits.999"]
#[no_mangle]
-pub static mut DEADBEEF: u32 = 0xdeadbeef;
-pub static mut OTHER: u32 = 0;
-
-/** Load into the data segments */
-pub fn load_data_segments() -> () {
- extern "C" {
- static mut __data_load: u32;
- static mut __data_store_start: u32;
- static mut __data_store_end: u32;
- static mut __bss_start: u32;
- static mut __bss_end: u32;
- }
-
- unsafe {
- let mut data_load_addr: *mut u32 = &mut __data_load;
- let mut store_cursor: *mut u32 = &mut __data_store_start;
- let data_store_end_addr: *mut u32 = &mut __data_store_end;
-
- while store_cursor < data_store_end_addr {
- store_cursor.write_volatile(*data_load_addr);
- data_load_addr = data_load_addr.offset(1);
- store_cursor = store_cursor.offset(1);
- }
-
- let bss_end: *mut u32 = &mut __bss_end;
- let mut bss_cursor: *mut u32 = &mut __bss_start;
-
- while bss_cursor < bss_end {
- bss_cursor.write_volatile(0);
- bss_cursor = bss_cursor.offset(1);
- }
- }
-
- return;
-}
-
-pub fn on_reset() -> ! {
- load_data_segments();
-
- unsafe {
- DEADBEEF += 100;
- OTHER = DEADBEEF;
- }
-
- loop {}
+pub static __MAIN: fn() -> () = main;
+pub fn main() -> () {
+ loop {};
}
#[panic_handler]