@@ -52,107 +52,34 @@ pub struct ArtyExx {
52
52
}
53
53
54
54
impl ArtyExx {
55
- pub unsafe fn new ( ) -> ArtyExx {
56
- // Make a bit-vector of all interrupt locations that we actually intend
57
- // to use on this chip.
58
- // 0001 1111 1111 1111 1111 0000 0000 1000 0000
59
- let in_use_interrupts: u64 = 0x1FFFF0080 ;
60
-
61
- ArtyExx {
62
- userspace_kernel_boundary : rv32i:: syscall:: SysCall :: new ( ) ,
63
- clic : rv32i:: clic:: Clic :: new ( in_use_interrupts) ,
64
- }
65
- }
66
-
67
- pub fn enable_all_interrupts ( & self ) {
68
- self . clic . enable_all ( ) ;
69
- }
55
+ pub unsafe fn new ( ) -> ArtyExx { loop { } }
56
+
57
+ pub fn enable_all_interrupts ( & self ) { loop { } }
70
58
71
59
/// Configure the PMP to allow all accesses in both machine mode (the
72
60
/// default) and in user mode.
73
61
///
74
62
/// This needs to be replaced with a real PMP driver. See
75
63
/// https://github.com/tock/tock/issues/1135
76
- pub unsafe fn disable_pmp ( & self ) {
77
- asm ! ( "
78
- // PMP PMP PMP
79
- // PMP PMP PMP
80
- // PMP PMP PMP
81
- // PMP PMP PMP
82
- // TODO: Add a real PMP driver!!
83
- // Take some time to disable the PMP.
84
-
85
- // Set the first region address to 0xFFFFFFFF. When using top-of-range mode
86
- // this will include the entire address space.
87
- lui t0, %hi(0xFFFFFFFF)
88
- addi t0, t0, %lo(0xFFFFFFFF)
89
- csrw 0x3b0, t0 // CSR=pmpaddr0
90
-
91
- // Set the first region to use top-of-range and allow everything.
92
- // This is equivalent to:
93
- // R=1, W=1, X=1, A=01, L=0
94
- li t0, 0x0F
95
- csrw 0x3a0, t0 // CSR=pmpcfg0
96
- "
97
- :
98
- :
99
- :
100
- : "volatile" ) ;
101
- }
64
+ pub unsafe fn disable_pmp ( & self ) { loop { } }
102
65
103
66
/// By default the machine timer is enabled and will trigger interrupts. To
104
67
/// prevent that we can make the compare register very large to effectively
105
68
/// stop the interrupt from triggering, and then the machine timer can be
106
69
/// used later as needed.
107
- pub unsafe fn disable_machine_timer ( & self ) {
108
- asm ! ( "
109
- // Initialize machine timer mtimecmp to disable the machine timer
110
- // interrupt.
111
- li t0, -1 // Set mtimecmp to 0xFFFFFFFF
112
- lui t1, %hi(0x02004000) // Load the address of mtimecmp to t1
113
- addi t1, t1, %lo(0x02004000) // Load the address of mtimecmp to t1
114
- sw t0, 0(t1) // mtimecmp is 64 bits, set to all ones
115
- sw t0, 4(t1) // mtimecmp is 64 bits, set to all ones
116
- "
117
- :
118
- :
119
- :
120
- : "volatile" ) ;
121
- }
70
+ pub unsafe fn disable_machine_timer ( & self ) { loop { } }
122
71
123
72
/// Setup the function that should run when a trap happens.
124
73
///
125
74
/// This needs to be chip specific because how the CLIC works is configured
126
75
/// when the trap handler address is specified in mtvec, and that is only
127
76
/// valid for platforms with a CLIC.
128
- pub unsafe fn configure_trap_handler ( & self ) {
129
- asm ! ( "
130
- // The csrw instruction writes a Control and Status Register (CSR)
131
- // with a new value.
132
- //
133
- // CSR 0x305 (mtvec, 'Machine trap-handler base address.') sets the
134
- // address of the trap handler. We do not care about its old value,
135
- // so we don't bother reading it. We want to enable direct CLIC mode
136
- // so we set the second lowest bit.
137
- lui t0, %hi(_start_trap)
138
- addi t0, t0, %lo(_start_trap)
139
- ori t0, t0, 0x02 // Set CLIC direct mode
140
- csrw 0x305, t0 // Write the mtvec CSR.
141
- "
142
- :
143
- :
144
- :
145
- : "volatile" ) ;
146
- }
77
+ pub unsafe fn configure_trap_handler ( & self ) { loop { } }
147
78
148
79
/// Generic helper initialize function to setup all of the chip specific
149
80
/// operations. Different boards can call the functions that `initialize()`
150
81
/// calls directly if it needs to use a custom setup operation.
151
- pub unsafe fn initialize ( & self ) {
152
- self . disable_pmp ( ) ;
153
- self . disable_machine_timer ( ) ;
154
- self . configure_trap_handler ( ) ;
155
- }
82
+ pub unsafe fn initialize ( & self ) { loop { } }
156
83
}
157
84
158
85
impl kernel:: Chip for ArtyExx {
@@ -167,69 +94,22 @@ impl kernel::Chip for ArtyExx {
167
94
type UserspaceKernelBoundary = rv32i:: syscall:: SysCall ;
168
95
type SysTick = ( ) ;
169
96
170
- fn mpu ( & self ) -> & Self :: MPU {
171
- & ( )
172
- }
173
-
174
- fn systick ( & self ) -> & Self :: SysTick {
175
- & ( )
176
- }
177
-
178
- fn userspace_kernel_boundary ( & self ) -> & rv32i:: syscall:: SysCall {
179
- & self . userspace_kernel_boundary
180
- }
181
-
182
- fn service_pending_interrupts ( & self ) {
183
- unsafe {
184
- while let Some ( interrupt) = self . clic . next_pending ( ) {
185
- match interrupt {
186
- interrupts:: MTIP => machine_timer:: MACHINETIMER . handle_interrupt ( ) ,
187
-
188
- interrupts:: GPIO0 => gpio:: PORT [ 3 ] . handle_interrupt ( ) ,
189
- interrupts:: GPIO1 => gpio:: PORT [ 3 ] . handle_interrupt ( ) ,
190
- interrupts:: GPIO2 => gpio:: PORT [ 3 ] . handle_interrupt ( ) ,
191
- interrupts:: GPIO3 => gpio:: PORT [ 3 ] . handle_interrupt ( ) ,
192
- interrupts:: GPIO4 => gpio:: PORT [ 4 ] . handle_interrupt ( ) ,
193
- interrupts:: GPIO5 => gpio:: PORT [ 5 ] . handle_interrupt ( ) ,
194
- interrupts:: GPIO6 => gpio:: PORT [ 6 ] . handle_interrupt ( ) ,
195
- interrupts:: GPIO7 => gpio:: PORT [ 7 ] . handle_interrupt ( ) ,
196
- interrupts:: GPIO8 => gpio:: PORT [ 8 ] . handle_interrupt ( ) ,
197
- interrupts:: GPIO9 => gpio:: PORT [ 9 ] . handle_interrupt ( ) ,
198
- interrupts:: GPIO10 => gpio:: PORT [ 10 ] . handle_interrupt ( ) ,
199
- interrupts:: GPIO11 => gpio:: PORT [ 11 ] . handle_interrupt ( ) ,
200
- interrupts:: GPIO12 => gpio:: PORT [ 12 ] . handle_interrupt ( ) ,
201
- interrupts:: GPIO13 => gpio:: PORT [ 13 ] . handle_interrupt ( ) ,
202
- interrupts:: GPIO14 => gpio:: PORT [ 14 ] . handle_interrupt ( ) ,
203
- interrupts:: GPIO15 => gpio:: PORT [ 15 ] . handle_interrupt ( ) ,
204
-
205
- interrupts:: UART0 => uart:: UART0 . handle_interrupt ( ) ,
206
-
207
- _ => debug ! ( "Pidx {}" , interrupt) ,
208
- }
209
-
210
- // Mark that we are done with this interrupt and the hardware
211
- // can clear it.
212
- self . clic . complete ( interrupt) ;
213
- }
214
- }
215
- }
216
-
217
- fn has_pending_interrupts ( & self ) -> bool {
218
- self . clic . has_pending ( )
219
- }
220
-
221
- fn sleep ( & self ) {
222
- unsafe {
223
- rv32i:: support:: wfi ( ) ;
224
- }
225
- }
97
+ fn mpu ( & self ) -> & Self :: MPU { loop { } }
98
+
99
+ fn systick ( & self ) -> & Self :: SysTick { loop { } }
100
+
101
+ fn userspace_kernel_boundary ( & self ) -> & rv32i:: syscall:: SysCall { loop { } }
102
+
103
+ fn service_pending_interrupts ( & self ) { loop { } }
104
+
105
+ fn has_pending_interrupts ( & self ) -> bool { loop { } }
106
+
107
+ fn sleep ( & self ) { loop { } }
226
108
227
109
unsafe fn atomic < F , R > ( & self , f : F ) -> R
228
110
where
229
111
F : FnOnce ( ) -> R ,
230
- {
231
- rv32i:: support:: atomic ( f)
232
- }
112
+ { loop { } }
233
113
}
234
114
235
115
/// Trap handler for board/chip specific code.
@@ -238,49 +118,13 @@ impl kernel::Chip for ArtyExx {
238
118
/// in kernel mode. All we need to do is check which interrupt occurred and
239
119
/// disable it.
240
120
#[ export_name = "_start_trap_rust" ]
241
- pub extern "C" fn start_trap_rust ( ) {
242
- let mut mcause: i32 ;
243
-
244
- unsafe {
245
- asm ! ( "
246
- // Read the mcause CSR to determine why we entered the trap handler.
247
- // Since we are using the CLIC, the hardware includes the interrupt
248
- // index in the mcause register.
249
- csrr $0, 0x342 // CSR=0x342=mcause
250
- "
251
- : "=r" ( mcause)
252
- :
253
- :
254
- : "volatile" ) ;
255
- }
256
-
257
- // Check if the trap was from an interrupt or some other exception.
258
- if mcause < 0 {
259
- // If the most significant bit is set (i.e. mcause is negative) then
260
- // this was an interrupt. The interrupt number is then the lowest 8
261
- // bits.
262
- let interrupt_index = mcause & 0xFF ;
263
- unsafe {
264
- rv32i:: clic:: disable_interrupt ( interrupt_index as u32 ) ;
265
- }
266
- } else {
267
- // Otherwise, the kernel encountered a fault...so panic!()?
268
- panic ! ( "kernel exception" ) ;
269
- }
270
- }
121
+ pub extern "C" fn start_trap_rust ( ) { loop { } }
271
122
272
123
/// Function that gets called if an interrupt occurs while an app was running.
273
124
/// mcause is passed in, and this function should correctly handle disabling the
274
125
/// interrupt that fired so that it does not trigger again.
275
126
#[ export_name = "_disable_interrupt_trap_handler" ]
276
- pub extern "C" fn disable_interrupt_trap_handler ( mcause : u32 ) {
277
- // The interrupt number is then the lowest 8
278
- // bits.
279
- let interrupt_index = mcause & 0xFF ;
280
- unsafe {
281
- rv32i:: clic:: disable_interrupt ( interrupt_index as u32 ) ;
282
- }
283
- }
127
+ pub extern "C" fn disable_interrupt_trap_handler ( mcause : u32 ) { loop { } }
284
128
}
285
129
mod gpio {
286
130
use core:: ops:: { Index , IndexMut } ;
@@ -298,15 +142,11 @@ pub struct Port {
298
142
impl Index < usize > for Port {
299
143
type Output = GpioPin ;
300
144
301
- fn index ( & self , index : usize ) -> & GpioPin {
302
- & self . pins [ index]
303
- }
145
+ fn index ( & self , index : usize ) -> & GpioPin { loop { } }
304
146
}
305
147
306
148
impl IndexMut < usize > for Port {
307
- fn index_mut ( & mut self , index : usize ) -> & mut GpioPin {
308
- & mut self . pins [ index]
309
- }
149
+ fn index_mut ( & mut self , index : usize ) -> & mut GpioPin { loop { } }
310
150
}
311
151
312
152
pub static mut PORT : Port = Port {
0 commit comments