12
12
//! /* code */
13
13
//! }
14
14
//! ```
15
- #![ feature( naked_functions) ]
16
15
#![ no_std]
17
16
18
17
#[ macro_use]
@@ -53,25 +52,24 @@ pub struct EgonHead {
53
52
///
54
53
/// NOTE: `mxstatus` is a custom T-Head register. Do not confuse with `mstatus`.
55
54
/// It allows for configuring special eXtensions. See further below for details.
56
- #[ naked]
55
+ #[ unsafe ( naked) ]
57
56
#[ unsafe( link_section = ".text.entry" ) ]
58
57
unsafe extern "C" fn start ( ) -> ! {
59
- unsafe {
60
- const STACK_SIZE : usize = 4 * 1024 ;
61
- #[ unsafe( link_section = ".bss.uninit" ) ]
62
- static mut STACK : [ u8 ; STACK_SIZE ] = [ 0 ; STACK_SIZE ] ;
63
- core:: arch:: naked_asm!(
64
- // Enable T-Head ISA extension
65
- "li t1, 1 << 22" ,
66
- "csrs 0x7C0, t1" ,
67
- // Invalidate instruction and data cache, branch history table
68
- // and branch target buffer table
69
- "li t1, 0x30013" ,
70
- "csrs 0x7C2, t1" ,
71
- // Disable interrupt
72
- "csrw mie, zero" ,
73
- // Prepare programming language stack
74
- "la sp, {stack}
58
+ const STACK_SIZE : usize = 4 * 1024 ;
59
+ #[ unsafe( link_section = ".bss.uninit" ) ]
60
+ static mut STACK : [ u8 ; STACK_SIZE ] = [ 0 ; STACK_SIZE ] ;
61
+ core:: arch:: naked_asm!(
62
+ // Enable T-Head ISA extension
63
+ "li t1, 1 << 22" ,
64
+ "csrs 0x7C0, t1" ,
65
+ // Invalidate instruction and data cache, branch history table
66
+ // and branch target buffer table
67
+ "li t1, 0x30013" ,
68
+ "csrs 0x7C2, t1" ,
69
+ // Disable interrupt
70
+ "csrw mie, zero" ,
71
+ // Prepare programming language stack
72
+ "la sp, {stack}
75
73
li t0, {stack_size}
76
74
add sp, sp, t0" ,
77
75
// Clear `.bss` section
@@ -82,16 +80,15 @@ unsafe extern "C" fn start() -> ! {
82
80
addi t1, t1, 8
83
81
j 3b
84
82
3: " ,
85
- // Start Rust main function
86
- "call {main}" ,
87
- // Platform halt if main function returns
88
- "3: wfi
89
- j 3b" ,
90
- stack = sym STACK ,
91
- stack_size = const STACK_SIZE ,
92
- main = sym main,
93
- )
94
- }
83
+ // Start Rust main function
84
+ "call {main}" ,
85
+ // Platform halt if main function returns
86
+ "3: wfi
87
+ j 3b" ,
88
+ stack = sym STACK ,
89
+ stack_size = const STACK_SIZE ,
90
+ main = sym main,
91
+ )
95
92
}
96
93
97
94
#[ rustfmt:: skip]
0 commit comments