Skip to content

Commit d2ca3fe

Browse files
committed
Add LastPostCode component details to SP5 host CPU
1 parent e2ecf16 commit d2ca3fe

File tree

15 files changed

+432
-343
lines changed

15 files changed

+432
-343
lines changed

Cargo.lock

Lines changed: 290 additions & 291 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ zip = { version = "0.6", default-features = false, features = ["bzip2", "deflate
145145
# Oxide forks and repos
146146
attest-data = { git = "https://github.com/oxidecomputer/dice-util", default-features = false, version = "0.4.0" }
147147
dice-mfg-msgs = { git = "https://github.com/oxidecomputer/dice-util", default-features = false, version = "0.2.1" }
148-
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", default-features = false, features = ["smoltcp"] }
148+
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", default-features = false, features = ["smoltcp"], branch = "mkeeter/last-post-code" }
149149
gateway-ereport-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", default-features = false }
150150
gimlet-inspector-protocol = { git = "https://github.com/oxidecomputer/gimlet-inspector-protocol", version = "0.1.0" }
151151
hif = { git = "https://github.com/oxidecomputer/hif", default-features = false }

app/cosmo/base.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ max-sizes = {flash = 131072, ram = 16384 }
181181
stacksize = 2600
182182
start = true
183183
task-slots = ["sys", "i2c_driver", {spi_front = "spi3_driver"}, "jefe", "packrat", "auxflash", "spartan7_loader", "hf"]
184-
uses = ["mmio_sequencer", "mmio_info"]
184+
uses = ["mmio_sequencer", "mmio_info", "mmio_espi"]
185185
notifications = ["timer", "vcore", "seq-irq"]
186186

187187
[tasks.ignition_flash]

app/grapefruit/base.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ max-sizes = {flash = 131072, ram = 16384 }
181181
stacksize = 2600
182182
start = true
183183
task-slots = ["sys", "jefe", "packrat", "spartan7_loader"]
184-
uses = ["mmio_sgpio"]
184+
uses = ["mmio_sgpio", "mmio_espi"]
185185

186186
[tasks.spartan7_loader]
187187
name = "drv-spartan7-loader"

drv/cosmo-seq-server/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
4040
idol::server::ServerStyle::InOrder,
4141
)?;
4242

43-
let out_file = out_dir.join("fmc_sequencer.rs");
43+
let out_file = out_dir.join("fmc_periph.rs");
4444
let mut file = std::fs::File::create(out_file)?;
45-
for periph in ["sequencer", "info"] {
45+
for periph in ["sequencer", "info", "espi"] {
4646
write!(
4747
&mut file,
48-
"{}",
48+
"pub mod {periph} {{\n{}\n}}",
4949
build_fpga_regmap::fpga_peripheral(
5050
periph,
5151
"drv_spartan7_loader_api::Spartan7Token"

drv/cosmo-seq-server/src/main.rs

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ enum Trace {
5252
Programmed,
5353

5454
Startup {
55-
early_power_rdbks: fmc_periph::EarlyPowerRdbksView,
55+
early_power_rdbks: fmc_sequencer::EarlyPowerRdbksView,
5656
},
5757
RegStateValues {
58-
seq_api_status: fmc_periph::SeqApiStatusView,
59-
seq_raw_status: fmc_periph::SeqRawStatusView,
60-
nic_api_status: fmc_periph::NicApiStatusView,
61-
nic_raw_status: fmc_periph::NicRawStatusView,
58+
seq_api_status: fmc_sequencer::SeqApiStatusView,
59+
seq_raw_status: fmc_sequencer::SeqRawStatusView,
60+
nic_api_status: fmc_sequencer::NicApiStatusView,
61+
nic_raw_status: fmc_sequencer::NicRawStatusView,
6262
},
6363
RegPgValues {
64-
rail_pgs: fmc_periph::RailPgsView,
65-
rail_pgs_max_hold: fmc_periph::RailPgsMaxHoldView,
64+
rail_pgs: fmc_sequencer::RailPgsView,
65+
rail_pgs_max_hold: fmc_sequencer::RailPgsMaxHoldView,
6666
},
6767
SetState {
6868
prev: Option<PowerState>,
@@ -73,12 +73,12 @@ enum Trace {
7373
},
7474
UnexpectedPowerOff {
7575
our_state: PowerState,
76-
seq_state: Result<fmc_periph::A0Sm, u8>,
76+
seq_state: Result<fmc_sequencer::A0Sm, u8>,
7777
},
7878
SequencerInterrupt {
7979
our_state: PowerState,
80-
seq_state: Result<fmc_periph::A0Sm, u8>,
81-
ifr: fmc_periph::IfrView,
80+
seq_state: Result<fmc_sequencer::A0Sm, u8>,
81+
ifr: fmc_sequencer::IfrView,
8282
},
8383
PowerDownError(drv_cpu_seq_api::SeqError),
8484
Coretype {
@@ -155,8 +155,8 @@ use gpio_irq_pins::SEQ_IRQ;
155155

156156
/// Helper type which includes both sequencer and NIC state machine states
157157
struct StateMachineStates {
158-
seq: Result<fmc_periph::A0Sm, u8>,
159-
nic: Result<fmc_periph::NicSm, u8>,
158+
seq: Result<fmc_sequencer::A0Sm, u8>,
159+
nic: Result<fmc_sequencer::NicSm, u8>,
160160
}
161161

162162
#[export_name = "main"]
@@ -260,7 +260,7 @@ fn init(packrat: Packrat) -> Result<ServerImpl, SeqError> {
260260

261261
// Set up the checksum registers for the Spartan7 FPGA
262262
let token = loader.get_token();
263-
let info = fmc_periph::Info::new(token);
263+
let info = fmc_periph::info::Info::new(token);
264264
let short_checksum = gen::SPARTAN7_FPGA_BITSTREAM_CHECKSUM[..4]
265265
.try_into()
266266
.unwrap();
@@ -298,8 +298,7 @@ fn init(packrat: Packrat) -> Result<ServerImpl, SeqError> {
298298
// Turn on the chassis LED!
299299
sys.gpio_set(SP_CHASSIS_STATUS_LED);
300300

301-
let token = loader.get_token();
302-
Ok(ServerImpl::new(token, packrat))
301+
Ok(ServerImpl::new(loader, packrat))
303302
}
304303

305304
/// Configures the front FPGA pins and holds it in reset
@@ -376,7 +375,8 @@ struct ServerImpl {
376375
jefe: Jefe,
377376
sys: Sys,
378377
hf: HostFlash,
379-
seq: fmc_periph::Sequencer,
378+
seq: fmc_sequencer::Sequencer,
379+
espi: fmc_periph::espi::Espi,
380380
vcore: VCore,
381381
/// Static buffer for encoding ereports. This is a static so that we don't
382382
/// have it on the stack when encoding ereports.
@@ -387,11 +387,14 @@ const EREPORT_BUF_LEN: usize = 256;
387387

388388
impl ServerImpl {
389389
fn new(
390-
token: drv_spartan7_loader_api::Spartan7Token,
390+
loader: drv_spartan7_loader_api::Spartan7Loader,
391391
packrat: Packrat,
392392
) -> Self {
393393
let now = sys_get_timer().now;
394-
let seq = fmc_periph::Sequencer::new(token);
394+
395+
let seq = fmc_sequencer::Sequencer::new(loader.get_token());
396+
let espi = fmc_periph::espi::Espi::new(loader.get_token());
397+
395398
ringbuf_entry!(Trace::Startup {
396399
early_power_rdbks: (&seq.early_power_rdbks).into(),
397400
});
@@ -417,6 +420,7 @@ impl ServerImpl {
417420
sys: Sys::from(SYS.get_task_id()),
418421
hf: HostFlash::from(HF.get_task_id()),
419422
seq,
423+
espi,
420424
vcore: VCore::new(I2C.get_task_id(), packrat),
421425
ereport_buf,
422426
}
@@ -464,7 +468,7 @@ impl ServerImpl {
464468
now,
465469
});
466470

467-
use fmc_periph::A0Sm;
471+
use fmc_sequencer::A0Sm;
468472
match (self.get_state_impl(), state) {
469473
(PowerState::A2, PowerState::A0) => {
470474
// Reset edge counters in the sequencer
@@ -881,6 +885,13 @@ impl idl::InOrderSequencerImpl for ServerImpl {
881885
idol_runtime::ClientError::BadMessageContents,
882886
))
883887
}
888+
889+
fn last_post_code(
890+
&mut self,
891+
_: &RecvMessage,
892+
) -> Result<u32, RequestError<core::convert::Infallible>> {
893+
Ok(self.espi.last_post_code.payload())
894+
}
884895
}
885896

886897
impl NotificationHandler for ServerImpl {
@@ -897,7 +908,7 @@ impl NotificationHandler for ServerImpl {
897908
return;
898909
}
899910
let state = self.log_state_registers();
900-
use fmc_periph::{A0Sm, NicSm};
911+
use fmc_sequencer::{A0Sm, NicSm};
901912

902913
// Detect when the NIC comes online
903914
// TODO: should we handle the NIC powering down while the main CPU
@@ -940,8 +951,9 @@ mod gen {
940951
}
941952

942953
mod fmc_periph {
943-
include!(concat!(env!("OUT_DIR"), "/fmc_sequencer.rs"));
954+
include!(concat!(env!("OUT_DIR"), "/fmc_periph.rs"));
944955
}
956+
use fmc_periph::sequencer as fmc_sequencer;
945957

946958
include!(concat!(env!("OUT_DIR"), "/notifications.rs"));
947959
include!(concat!(env!("OUT_DIR"), "/gpio_irq_pins.rs"));

drv/gimlet-seq-server/src/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,15 @@ impl<S: SpiServer> idl::InOrderSequencerImpl for ServerImpl<S> {
11351135

11361136
Ok(buf)
11371137
}
1138+
1139+
fn last_post_code(
1140+
&mut self,
1141+
_: &RecvMessage,
1142+
) -> Result<u32, RequestError<core::convert::Infallible>> {
1143+
Err(RequestError::Fail(
1144+
idol_runtime::ClientError::BadMessageContents,
1145+
))
1146+
}
11381147
}
11391148

11401149
fn read_spd_data_and_load_packrat(

drv/grapefruit-seq-server/build.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
1212
)?;
1313

1414
let out_dir = build_util::out_dir();
15-
let out_file = out_dir.join("fmc_sgpio.rs");
15+
let out_file = out_dir.join("fmc_periph.rs");
1616
let mut file = std::fs::File::create(out_file)?;
17-
write!(
18-
&mut file,
19-
"{}",
20-
build_fpga_regmap::fpga_peripheral(
21-
"sgpio",
22-
"drv_spartan7_loader_api::Spartan7Token"
23-
)?
24-
)?;
17+
for p in ["sgpio", "espi"] {
18+
write!(
19+
&mut file,
20+
"pub mod {p} {{\n{}\n}}",
21+
build_fpga_regmap::fpga_peripheral(
22+
p,
23+
"drv_spartan7_loader_api::Spartan7Token"
24+
)?
25+
)?;
26+
}
2527

2628
Ok(())
2729
}

drv/grapefruit-seq-server/src/main.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ fn main() -> ! {
7373
#[allow(unused)]
7474
struct ServerImpl {
7575
jefe: Jefe,
76-
sgpio: fmc_periph::Sgpio,
76+
sgpio: fmc_periph::sgpio::Sgpio,
77+
espi: fmc_periph::espi::Espi,
7778
}
7879

7980
impl ServerImpl {
@@ -94,7 +95,8 @@ impl ServerImpl {
9495

9596
let server = Self {
9697
jefe: Jefe::from(JEFE.get_task_id()),
97-
sgpio: fmc_periph::Sgpio::new(loader.get_token()),
98+
sgpio: fmc_periph::sgpio::Sgpio::new(loader.get_token()),
99+
espi: fmc_periph::espi::Espi::new(loader.get_token()),
98100
};
99101

100102
// Note that we don't use `Self::set_state_impl` here, as that will
@@ -182,6 +184,13 @@ impl idl::InOrderSequencerImpl for ServerImpl {
182184
) -> Result<[u8; 64], RequestError<core::convert::Infallible>> {
183185
Ok([0; 64])
184186
}
187+
188+
fn last_post_code(
189+
&mut self,
190+
_: &RecvMessage,
191+
) -> Result<u32, RequestError<core::convert::Infallible>> {
192+
Ok(self.espi.last_post_code.payload())
193+
}
185194
}
186195

187196
impl NotificationHandler for ServerImpl {
@@ -200,5 +209,5 @@ mod idl {
200209
}
201210

202211
mod fmc_periph {
203-
include!(concat!(env!("OUT_DIR"), "/fmc_sgpio.rs"));
212+
include!(concat!(env!("OUT_DIR"), "/fmc_periph.rs"));
204213
}

drv/mock-gimlet-seq-server/src/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ impl idl::InOrderSequencerImpl for ServerImpl {
103103
) -> Result<[u8; 64], RequestError<core::convert::Infallible>> {
104104
Ok([0; 64])
105105
}
106+
107+
fn last_post_code(
108+
&mut self,
109+
_: &RecvMessage,
110+
) -> Result<u32, RequestError<core::convert::Infallible>> {
111+
Err(RequestError::Fail(
112+
idol_runtime::ClientError::BadMessageContents,
113+
))
114+
}
106115
}
107116

108117
impl NotificationHandler for ServerImpl {

0 commit comments

Comments
 (0)