|
7 | 7 | #![no_std] |
8 | 8 | #![no_main] |
9 | 9 |
|
| 10 | +#[cfg_attr( |
| 11 | + any( |
| 12 | + target_board = "sidecar-b", |
| 13 | + target_board = "sidecar-c", |
| 14 | + target_board = "sidecar-d" |
| 15 | + ), |
| 16 | + path = "bsp/sidecar_bcd.rs" |
| 17 | +)] |
| 18 | +#[cfg_attr(target_board = "medusa-a", path = "bsp/medusa_a.rs")] |
| 19 | +mod bsp; |
| 20 | + |
| 21 | +use crate::bsp::Bsp; |
10 | 22 | use core::convert::Infallible; |
11 | 23 | use drv_fpga_api::{DeviceState, FpgaError, WriteOp}; |
12 | 24 | use drv_front_io_api::{ |
@@ -38,6 +50,9 @@ include!(concat!(env!("OUT_DIR"), "/i2c_config.rs")); |
38 | 50 | #[derive(Copy, Clone, PartialEq)] |
39 | 51 | enum Trace { |
40 | 52 | None, |
| 53 | + BspInit, |
| 54 | + BspInitComplete, |
| 55 | + BspInitFailed, |
41 | 56 | FpgaInitError(FpgaError), |
42 | 57 | PhyOscGood, |
43 | 58 | PhyOscBad, |
@@ -69,6 +84,9 @@ enum Trace { |
69 | 84 | ringbuf!(Trace, 32, Trace::None); |
70 | 85 |
|
71 | 86 | struct ServerImpl { |
| 87 | + /// A BSP to help deliver core functionality whose implementation varies from board to board |
| 88 | + bsp: Bsp, |
| 89 | + |
72 | 90 | /// Handle for the auxflash task |
73 | 91 | auxflash_task: userlib::TaskId, |
74 | 92 |
|
@@ -254,6 +272,25 @@ impl ServerImpl { |
254 | 272 | } |
255 | 273 |
|
256 | 274 | impl idl::InOrderFrontIOImpl for ServerImpl { |
| 275 | + /// Enable or disable the front IO power per `enable` |
| 276 | + fn set_power_enable( |
| 277 | + &mut self, |
| 278 | + _: &RecvMessage, |
| 279 | + enable: bool, |
| 280 | + ) -> Result<(), RequestError<FrontIOError>> { |
| 281 | + self.bsp |
| 282 | + .set_power_enable(enable) |
| 283 | + .map_err(RequestError::from) |
| 284 | + } |
| 285 | + |
| 286 | + /// Returns if front IO power is good |
| 287 | + fn power_good( |
| 288 | + &mut self, |
| 289 | + _: &RecvMessage, |
| 290 | + ) -> Result<bool, RequestError<FrontIOError>> { |
| 291 | + self.bsp.power_good().map_err(RequestError::from) |
| 292 | + } |
| 293 | + |
257 | 294 | /// Blow away server state, resulting in a resequencing |
258 | 295 | fn board_reset( |
259 | 296 | &mut self, |
@@ -794,11 +831,23 @@ impl NotificationHandler for ServerImpl { |
794 | 831 |
|
795 | 832 | impl Default for ServerImpl { |
796 | 833 | fn default() -> Self { |
| 834 | + ringbuf_entry!(Trace::BspInit); |
| 835 | + let bsp = match Bsp::new() { |
| 836 | + Ok(bsp) => { |
| 837 | + ringbuf_entry!(Trace::BspInitComplete); |
| 838 | + bsp |
| 839 | + } |
| 840 | + Err(_) => { |
| 841 | + ringbuf_entry!(Trace::BspInitFailed); |
| 842 | + panic!(); |
| 843 | + } |
| 844 | + }; |
797 | 845 | let i2c_task = I2C.get_task_id(); |
798 | 846 | let fpga_task = FRONT_IO.get_task_id(); |
799 | 847 | let auxflash_task = AUXFLASH.get_task_id(); |
800 | 848 |
|
801 | 849 | ServerImpl { |
| 850 | + bsp, |
802 | 851 | auxflash_task, |
803 | 852 | controllers: [ |
804 | 853 | FrontIOController::new(fpga_task, 0), |
|
0 commit comments