1- //! Board file for the SiFive E21 Bitstream running on the Arty FPGA
2-
31#![ no_std]
42#![ no_main]
53#![ feature( const_fn, in_band_lifetimes) ]
@@ -66,12 +64,10 @@ impl Write for Writer {
6664 }
6765}
6866
69- /// Panic handler.
7067#[ cfg( not( test) ) ]
7168#[ no_mangle]
7269#[ panic_handler]
7370pub unsafe extern "C" fn panic_fmt ( pi : & PanicInfo ) -> ! {
74- // turn off the non panic leds, just in case
7571 let led_green = & arty_e21:: gpio:: PORT [ 19 ] ;
7672 gpio:: Pin :: make_output ( led_green) ;
7773 gpio:: Pin :: set ( led_green) ;
@@ -86,29 +82,20 @@ pub unsafe extern "C" fn panic_fmt(pi: &PanicInfo) -> ! {
8682}
8783}
8884
89- // State for loading and holding applications.
90-
91- // Number of concurrent processes this platform supports.
9285const NUM_PROCS : usize = 4 ;
9386
94- // How should the kernel respond when a process faults.
9587const FAULT_RESPONSE : kernel:: procs:: FaultResponse = kernel:: procs:: FaultResponse :: Panic ;
9688
97- // RAM to be shared by all application processes.
9889#[ link_section = ".app_memory" ]
9990static mut APP_MEMORY : [ u8 ; 8192 ] = [ 0 ; 8192 ] ;
10091
101- // Actual memory for holding the active process structures.
10292static mut PROCESSES : [ Option < & ' static dyn kernel:: procs:: ProcessType > ; NUM_PROCS ] =
10393 [ None , None , None , None ] ;
10494
105- /// Dummy buffer that causes the linker to reserve enough space for the stack.
10695#[ no_mangle]
10796#[ link_section = ".stack_buffer" ]
10897pub static mut STACK_MEMORY : [ u8 ; 0x1000 ] = [ 0 ; 0x1000 ] ;
10998
110- /// A structure representing this platform that holds references to all
111- /// capsules for this platform.
11299struct ArtyE21 {
113100 console : & ' static capsules:: console:: Console < ' static > ,
114101 gpio : & ' static capsules:: gpio:: GPIO < ' static > ,
@@ -118,10 +105,8 @@ struct ArtyE21 {
118105 > ,
119106 led : & ' static capsules:: led:: LED < ' static > ,
120107 button : & ' static capsules:: button:: Button < ' static > ,
121- // ipc: kernel::ipc::IPC,
122108}
123109
124- /// Mapping of integer syscalls to objects that implement syscalls.
125110impl Platform for ArtyE21 {
126111 fn with_driver < F , R > ( & self , driver_num : usize , f : F ) -> R
127112 where
@@ -135,19 +120,13 @@ impl Platform for ArtyE21 {
135120 capsules:: led:: DRIVER_NUM => f ( Some ( self . led ) ) ,
136121 capsules:: button:: DRIVER_NUM => f ( Some ( self . button ) ) ,
137122
138- // kernel::ipc::DRIVER_NUM => f(Some(&self.ipc)),
139123 _ => f ( None ) ,
140124 }
141125 }
142126}
143127
144- /// Reset Handler.
145- ///
146- /// This function is called from the arch crate after some very basic RISC-V
147- /// setup.
148128#[ no_mangle]
149129pub unsafe fn reset_handler ( ) {
150- // Basic setup of the platform.
151130 rv32i:: init_memory ( ) ;
152131
153132 let chip = static_init ! ( arty_e21:: chip:: ArtyExx , arty_e21:: chip:: ArtyExx :: new( ) ) ;
@@ -159,14 +138,12 @@ pub unsafe fn reset_handler() {
159138
160139 let board_kernel = static_init ! ( kernel:: Kernel , kernel:: Kernel :: new( & PROCESSES ) ) ;
161140
162- // Configure kernel debug gpios as early as possible
163141 kernel:: debug:: assign_gpios (
164142 Some ( & arty_e21:: gpio:: PORT [ 0 ] ) , // Red
165143 Some ( & arty_e21:: gpio:: PORT [ 1 ] ) ,
166144 Some ( & arty_e21:: gpio:: PORT [ 8 ] ) ,
167145 ) ;
168146
169- // Create a shared UART channel for the console and for kernel debug.
170147 let uart_mux = static_init ! (
171148 MuxUart <' static >,
172149 MuxUart :: new(
@@ -182,50 +159,31 @@ pub unsafe fn reset_handler() {
182159
183160 let console = components:: console:: ConsoleComponent :: new ( board_kernel, uart_mux) . finalize ( ( ) ) ;
184161
185- // Create a shared virtualization mux layer on top of a single hardware
186- // alarm.
187162 let mux_alarm = static_init ! (
188163 MuxAlarm <' static , rv32i:: machine_timer:: MachineTimer >,
189164 MuxAlarm :: new( & rv32i:: machine_timer:: MACHINETIMER )
190165 ) ;
191166 hil:: time:: Alarm :: set_client ( & rv32i:: machine_timer:: MACHINETIMER , mux_alarm) ;
192167
193- // Alarm
194168 let alarm = components:: alarm:: AlarmDriverComponent :: new ( board_kernel, mux_alarm) . finalize (
195169 components:: alarm_component_helper!( rv32i:: machine_timer:: MachineTimer ) ,
196170 ) ;
197171
198- // TEST for timer
199- //
200- // let virtual_alarm_test = static_init!(
201- // VirtualMuxAlarm<'static, rv32i::machine_timer::MachineTimer>,
202- // VirtualMuxAlarm::new(mux_alarm)
203- // );
204- // let timertest = static_init!(
205- // timer_test::TimerTest<'static, VirtualMuxAlarm<'static, rv32i::machine_timer::MachineTimer>>,
206- // timer_test::TimerTest::new(virtual_alarm_test)
207- // );
208- // virtual_alarm_test.set_client(timertest);
209-
210- // LEDs
211172 let led_pins = static_init ! (
212173 [ (
213174 & ' static dyn kernel:: hil:: gpio:: Pin ,
214175 capsules:: led:: ActivationMode
215176 ) ; 3 ] ,
216177 [
217178 (
218- // Red
219179 & arty_e21:: gpio:: PORT [ 0 ] ,
220180 capsules:: led:: ActivationMode :: ActiveHigh
221181 ) ,
222182 (
223- // Green
224183 & arty_e21:: gpio:: PORT [ 1 ] ,
225184 capsules:: led:: ActivationMode :: ActiveHigh
226185 ) ,
227186 (
228- // Blue
229187 & arty_e21:: gpio:: PORT [ 2 ] ,
230188 capsules:: led:: ActivationMode :: ActiveHigh
231189 ) ,
@@ -236,7 +194,6 @@ pub unsafe fn reset_handler() {
236194 capsules:: led:: LED :: new( led_pins)
237195 ) ;
238196
239- // BUTTONs
240197 let button_pins = static_init ! (
241198 [ (
242199 & ' static dyn kernel:: hil:: gpio:: InterruptValuePin ,
@@ -262,7 +219,6 @@ pub unsafe fn reset_handler() {
262219 btn. set_client ( button) ;
263220 }
264221
265- // set GPIO driver controlling remaining GPIO pins
266222 let gpio_pins = static_init ! (
267223 [ & ' static dyn kernel:: hil:: gpio:: InterruptValuePin ; 3 ] ,
268224 [
@@ -299,10 +255,8 @@ pub unsafe fn reset_handler() {
299255 alarm : alarm,
300256 led : led,
301257 button : button,
302- // ipc: kernel::ipc::IPC::new(board_kernel),
303258 } ;
304259
305- // Create virtual device for kernel debug.
306260 let debugger_uart = static_init ! ( UartDevice , UartDevice :: new( uart_mux, false ) ) ;
307261 debugger_uart. setup ( ) ;
308262 let ring_buffer = static_init ! (
@@ -321,16 +275,9 @@ pub unsafe fn reset_handler() {
321275 ) ;
322276 kernel:: debug:: set_debug_writer_wrapper ( debug_wrapper) ;
323277
324- // arty_e21::uart::UART0.initialize_gpio_pins(&arty_e21::gpio::PORT[17], &arty_e21::gpio::PORT[16]);
325-
326278 debug ! ( "Initialization complete. Entering main loop." ) ;
327279
328- // timertest.start();
329-
330280 extern "C" {
331- /// Beginning of the ROM region containing app images.
332- ///
333- /// This symbol is defined in the linker script.
334281 static _sapps: u8 ;
335282 }
336283
0 commit comments