3
3
use core:: panic:: PanicInfo ;
4
4
// use core::ptr;
5
5
6
- #[ no_mangle]
6
+ #[ unsafe ( no_mangle) ]
7
7
pub unsafe extern "C" fn Reset ( ) -> ! {
8
8
// Omitted to simplify the `objdump` output
9
9
// Initialize RAM
10
- extern "C" {
10
+ unsafe extern "C" {
11
11
// static mut _sbss: u8;
12
12
// static mut _ebss: u8;
13
13
@@ -23,16 +23,16 @@ pub unsafe extern "C" fn Reset() -> ! {
23
23
// ptr::copy_nonoverlapping(&_sidata as *const u8, &mut _sdata as *mut u8, count);
24
24
25
25
// Call user entry point
26
- extern "Rust" {
27
- fn main ( ) -> !;
26
+ unsafe extern "Rust" {
27
+ safe fn main ( ) -> !;
28
28
}
29
29
30
30
main ( )
31
31
}
32
32
33
33
// The reset vector, a pointer into the reset handler
34
- #[ link_section = ".vector_table.reset_vector" ]
35
- #[ no_mangle]
34
+ #[ unsafe ( link_section = ".vector_table.reset_vector" ) ]
35
+ #[ unsafe ( no_mangle) ]
36
36
pub static RESET_VECTOR : unsafe extern "C" fn ( ) -> ! = Reset ;
37
37
38
38
#[ panic_handler]
@@ -43,22 +43,22 @@ fn panic(_panic: &PanicInfo<'_>) -> ! {
43
43
#[ macro_export]
44
44
macro_rules! entry {
45
45
( $path: path) => {
46
- #[ export_name = "main" ]
46
+ #[ unsafe ( export_name = "main" ) ]
47
47
pub unsafe fn __main( ) -> ! {
48
48
// type check the given path
49
49
let f: fn ( ) -> ! = $path;
50
50
51
51
f( )
52
52
}
53
- }
53
+ } ;
54
54
}
55
55
56
56
pub union Vector {
57
57
reserved : u32 ,
58
58
handler : unsafe extern "C" fn ( ) ,
59
59
}
60
60
61
- extern "C" {
61
+ unsafe extern "C" {
62
62
fn NMI ( ) ;
63
63
fn HardFaultTrampoline ( ) ; // <- CHANGED!
64
64
fn MemManage ( ) ;
@@ -69,16 +69,14 @@ extern "C" {
69
69
fn SysTick ( ) ;
70
70
}
71
71
72
- #[ link_section = ".vector_table.exceptions" ]
73
- #[ no_mangle]
72
+ #[ unsafe ( link_section = ".vector_table.exceptions" ) ]
73
+ #[ unsafe ( no_mangle) ]
74
74
pub static EXCEPTIONS : [ Vector ; 14 ] = [
75
75
Vector { handler : NMI } ,
76
76
Vector { handler : HardFaultTrampoline } , // <- CHANGED!
77
77
Vector { handler : MemManage } ,
78
78
Vector { handler : BusFault } ,
79
- Vector {
80
- handler : UsageFault ,
81
- } ,
79
+ Vector { handler : UsageFault } ,
82
80
Vector { reserved : 0 } ,
83
81
Vector { reserved : 0 } ,
84
82
Vector { reserved : 0 } ,
@@ -90,7 +88,7 @@ pub static EXCEPTIONS: [Vector; 14] = [
90
88
Vector { handler : SysTick } ,
91
89
] ;
92
90
93
- #[ no_mangle]
91
+ #[ unsafe ( no_mangle) ]
94
92
pub extern "C" fn DefaultExceptionHandler ( ) {
95
93
loop { }
96
94
}
0 commit comments