Skip to content

Commit fe45fd6

Browse files
committed
Hook up GPIO cycle counter for cosmo
1 parent fba710f commit fe45fd6

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

app/cosmo/base.toml

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

186186
[tasks.ignition_flash]

drv/cosmo-seq-server/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
4242

4343
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", "espi"] {
45+
for periph in ["sequencer", "info", "espi", "debug_ctrl"] {
4646
write!(
4747
&mut file,
4848
"pub mod {periph} {{\n{}\n}}",

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ struct ServerImpl {
378378
hf: HostFlash,
379379
seq: fmc_sequencer::Sequencer,
380380
espi: fmc_periph::espi::Espi,
381+
debug: fmc_periph::debug_ctrl::DebugCtrl,
381382
vcore: VCore,
382383
/// Static buffer for encoding ereports. This is a static so that we don't
383384
/// have it on the stack when encoding ereports.
@@ -395,6 +396,7 @@ impl ServerImpl {
395396

396397
let seq = fmc_sequencer::Sequencer::new(loader.get_token());
397398
let espi = fmc_periph::espi::Espi::new(loader.get_token());
399+
let debug = fmc_periph::debug_ctrl::DebugCtrl::new(loader.get_token());
398400

399401
ringbuf_entry!(Trace::Startup {
400402
early_power_rdbks: (&seq.early_power_rdbks).into(),
@@ -422,6 +424,7 @@ impl ServerImpl {
422424
hf: HostFlash::from(HF.get_task_id()),
423425
seq,
424426
espi,
427+
debug,
425428
vcore: VCore::new(I2C.get_task_id(), packrat),
426429
ereport_buf,
427430
}
@@ -919,18 +922,14 @@ impl idl::InOrderSequencerImpl for ServerImpl {
919922
&mut self,
920923
_: &RecvMessage,
921924
) -> Result<u32, RequestError<core::convert::Infallible>> {
922-
Err(RequestError::Fail(
923-
idol_runtime::ClientError::BadMessageContents,
924-
))
925+
Ok(self.debug.sp5_dbg2_toggle_counter.cnts())
925926
}
926927

927928
fn gpio_cycle_count(
928929
&mut self,
929930
_: &RecvMessage,
930931
) -> Result<u32, RequestError<core::convert::Infallible>> {
931-
Err(RequestError::Fail(
932-
idol_runtime::ClientError::BadMessageContents,
933-
))
932+
Ok(self.debug.sp5_dbg2_toggle_timer.cnts())
934933
}
935934
}
936935

task/control-plane-agent/src/inventory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ impl Inventory {
4444
match Index::try_from(component)? {
4545
Index::OurDevice(d) => {
4646
match OUR_DEVICES[d].component {
47-
// The SP5 CPU can report a POST code
48-
SpComponent::SP5_HOST_CPU => Ok(1),
47+
// The SP5 CPU can report a POST code and GPIO cycle count
48+
SpComponent::SP5_HOST_CPU => Ok(2),
4949
// The SP3 CPU can report GPIO toggle counts
5050
SpComponent::SP3_HOST_CPU => Ok(1),
5151
_ => Ok(0),

task/control-plane-agent/src/mgs_compute_sled.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -920,13 +920,20 @@ impl SpHandler for MgsHandler {
920920
index,
921921
|dev, index| {
922922
match dev.component {
923-
SpComponent::SP5_HOST_CPU => {
924-
// Only one component detail for now
925-
assert_eq!(index.0, 0);
926-
ComponentDetails::LastPostCode(LastPostCode(
923+
SpComponent::SP5_HOST_CPU => match index.0 {
924+
0 => ComponentDetails::LastPostCode(LastPostCode(
927925
self.sequencer.last_post_code(),
928-
))
929-
}
926+
)),
927+
1 => {
928+
ComponentDetails::GpioToggleCount(GpioToggleCount {
929+
edge_count: self.sequencer.gpio_edge_count(),
930+
cycles_since_last_edge: self
931+
.sequencer
932+
.gpio_cycle_count(),
933+
})
934+
}
935+
_ => panic!("invalid index"),
936+
},
930937
SpComponent::SP3_HOST_CPU => {
931938
// Only one component detail for now
932939
assert_eq!(index.0, 0);

0 commit comments

Comments
 (0)