Skip to content
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
fb470e7
Add ereports crate, use shared types in CPU sequencer tasks
hawkw Feb 26, 2026
e0c60d4
cpu_seq: start on seq ereports
hawkw Feb 25, 2026
761a3d4
cosmo_seq: wire up thermtrip and smerr
hawkw Feb 25, 2026
e98ef68
include current state in (some) seq ereports
hawkw Feb 25, 2026
f83f43a
reticulating
hawkw Feb 25, 2026
2da7f35
oops there's no derive feature
hawkw Feb 26, 2026
4d3c3da
oops
hawkw Feb 26, 2026
9343353
punt on MAPOs for a future PR
hawkw Feb 26, 2026
3b5852b
give gimlet the same treatment
hawkw Feb 26, 2026
6495feb
blargh
hawkw Feb 26, 2026
6717b05
get rid of unused `drv-i2c-devices` dep
hawkw Feb 26, 2026
2090a1b
Revert "get rid of unused `drv-i2c-devices` dep"
hawkw Feb 26, 2026
af575d9
fix build (real)
hawkw Feb 26, 2026
a0d2071
Merge branch 'master' into eliza/seq-ereports2
hawkw Feb 27, 2026
092f494
psc_seq: also use shared pmbus registers types
hawkw Feb 27, 2026
2534fd8
wip cool idea
hawkw Feb 27, 2026
acce9ba
wip
hawkw Feb 26, 2026
98eeb9a
rough draft `declare_ereporter!` macro
hawkw Feb 27, 2026
6396b89
broken
hawkw Feb 28, 2026
493c26c
whoa it works
hawkw Mar 2, 2026
028ffbf
just publicly reexport microcbor
hawkw Mar 4, 2026
6d2fac0
wip docs
hawkw Mar 4, 2026
9e18d0b
Merge branch 'master' into eliza/seq-ereports2
hawkw Mar 4, 2026
af9db70
docs
hawkw Mar 4, 2026
7a1bf64
finish docs
hawkw Mar 4, 2026
06e167d
allow trailing commas
hawkw Mar 6, 2026
b005a4b
add it in gimlet-seq
hawkw Mar 6, 2026
13717a3
trait must always be `pub(super)`
hawkw Mar 6, 2026
7dda055
also use it in `psc_seq`
hawkw Mar 6, 2026
d4444b3
Merge branch 'eliza/seq-ereports2' into eliza/ereporter-macro-broken
hawkw Mar 9, 2026
352f56e
demo
hawkw Mar 6, 2026
738fd22
don't ereports twice
hawkw Mar 9, 2026
a97ede7
Merge branch 'master' into eliza/ereporter-macro-broken
hawkw Mar 10, 2026
ad86473
i'll overindent YOUR docs list, clippy
hawkw Mar 10, 2026
c071430
remove nix shell
hawkw Mar 11, 2026
4ddacd9
@mkeeter's typo fixes
hawkw Mar 11, 2026
d9df7de
more typo fixes
hawkw Mar 11, 2026
e6cf26e
document reexports module
hawkw Mar 11, 2026
3381206
cleanup merge detritus
hawkw Mar 11, 2026
98337fc
tidy up demo task
hawkw Mar 11, 2026
db9a8b8
Merge branch 'master' into eliza/ereporter-macro-broken
hawkw Mar 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion drv/cosmo-seq-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ drv-packrat-vpd-loader = { path = "../packrat-vpd-loader" }
drv-spartan7-loader-api = { path = "../spartan7-loader-api" }
drv-spi-api = { path = "../spi-api" }
drv-stm32xx-sys-api = { path = "../stm32xx-sys-api" }
ereports = { path = "../../lib/ereports" }
ereports = { path = "../../lib/ereports", features = ["ereporter-macro"] }
gnarle = { path = "../../lib/gnarle" }
ringbuf = { path = "../../lib/ringbuf" }
userlib = { path = "../../sys/userlib", features = ["panic-messages"] }
Expand Down
73 changes: 18 additions & 55 deletions drv/cosmo-seq-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ enum Trace {
},
UnexpectedInterrupt,
CPUNotPresent,
EreportSent(usize),
EreportLost(usize, task_packrat_api::EreportWriteError),
EreportTooBig,
}
counted_ringbuf!(Trace, 128, Trace::None);

Expand Down Expand Up @@ -183,17 +180,7 @@ fn main() -> ! {
let packrat = Packrat::from(PACKRAT.get_task_id());
read_vpd_and_load_packrat(&packrat, I2C.get_task_id());

let ereport_buf = {
use static_cell::ClaimOnceCell;
static EREPORT_BUF: ClaimOnceCell<[u8; EREPORT_BUF_LEN]> =
ClaimOnceCell::new([0; EREPORT_BUF_LEN]);
EREPORT_BUF.claim()
};

let mut ereporter = Ereporter {
packrat,
buf: ereport_buf,
};
let mut ereporter = Ereporter::claim_static_resources(packrat);

//
// Apply the configuration mitigation on the BMR491, if required. This
Expand Down Expand Up @@ -227,7 +214,7 @@ fn main() -> ! {
last_cause,
succeeded,
};
ereporter.try_send_ereport(&ereport);
ereporter.deliver_ereport(&ereport);
}
}

Expand Down Expand Up @@ -568,7 +555,7 @@ impl ServerImpl {

if !present {
ringbuf_entry!(Trace::CPUNotPresent);
self.ereporter.try_send_ereport(
self.ereporter.deliver_ereport(
&ereports::cpu::CpuMissing {
cpu: &HOST_CPU_REFDES,
},
Expand Down Expand Up @@ -637,7 +624,7 @@ impl ServerImpl {
ok: sp5rx_ok,
},
};
self.ereporter.try_send_ereport(&ereport);
self.ereporter.deliver_ereport(&ereport);
return Err(CpuSeqError::UnrecognizedCPU);
}

Expand Down Expand Up @@ -936,7 +923,7 @@ impl ServerImpl {
self.seq.ifr.modify(|h| h.set_thermtrip(true));
ringbuf_entry!(Trace::Thermtrip);
action = InternalAction::ThermTrip;
self.ereporter.try_send_ereport(&ereports::cpu::Thermtrip {
self.ereporter.deliver_ereport(&ereports::cpu::Thermtrip {
cpu: &HOST_CPU_REFDES,
state: self.ereport_current_state(),
});
Expand All @@ -954,7 +941,7 @@ impl ServerImpl {
self.seq.ifr.modify(|h| h.set_smerr_assert(true));
ringbuf_entry!(Trace::SmerrInterrupt);
action = InternalAction::Smerr;
self.ereporter.try_send_ereport(&ereports::cpu::Smerr {
self.ereporter.deliver_ereport(&ereports::cpu::Smerr {
cpu: &HOST_CPU_REFDES,
state: self.ereport_current_state(),
});
Expand Down Expand Up @@ -1236,49 +1223,25 @@ impl NotificationHandler for ServerImpl {

////////////////////////////////////////////////////////////////////////////////

const EREPORT_BUF_LEN: usize = microcbor::max_cbor_len_for![
ereports::pwr::PmbusAlert<vcore::Rail, { REFDES_LEN }>,
ereports::pwr::Bmr491MitigationFailure<{ REFDES_LEN }>,
ereports::cpu::Thermtrip,
ereports::cpu::Smerr,
ereports::cpu::UnsupportedCpu<3, 4>,
ereports::cpu::CpuMissing,
];
ereports::declare_ereporter! {
pub(crate) struct Ereporter<SeqEreport> {
PmbusAlert(ereports::pwr::PmbusAlert<vcore::Rail, { REFDES_LEN }>),
Bmr491MitigationFailure(
ereports::pwr::Bmr491MitigationFailure<{ REFDES_LEN }>
),
Thermtrip(ereports::cpu::Thermtrip),
Smerr(ereports::cpu::Smerr),
UnsupportedCpu(ereports::cpu::UnsupportedCpu<3, 4>),
CpuMissing(ereports::cpu::CpuMissing),
}
}

static HOST_CPU_REFDES: ereports::cpu::HostCpuRefdes =
ereports::cpu::HostCpuRefdes {
refdes: fixedstr::FixedString::from_str("P0"),
dev_id: fixedstr::FixedString::from_str("sp5-host-cpu"),
};

/// This is just the Packrat API handle and the ereport buffer bundled together
/// in one thing so that it can be passed into various places as a single
/// argument.
pub(crate) struct Ereporter {
packrat: task_packrat_api::Packrat,
buf: &'static mut [u8; EREPORT_BUF_LEN],
}

impl Ereporter {
pub(crate) fn try_send_ereport(
&mut self,
ereport: &impl microcbor::StaticCborLen,
) {
let eresult = self
.packrat
.deliver_microcbor_ereport(&ereport, &mut self.buf[..]);
match eresult {
Ok(len) => ringbuf_entry!(Trace::EreportSent(len)),
Err(task_packrat_api::EreportEncodeError::Packrat { len, err }) => {
ringbuf_entry!(Trace::EreportLost(len, err))
}
Err(task_packrat_api::EreportEncodeError::Encoder(_)) => {
ringbuf_entry!(Trace::EreportTooBig)
}
}
}
}

////////////////////////////////////////////////////////////////////////////////

mod idl {
Expand Down
2 changes: 1 addition & 1 deletion drv/cosmo-seq-server/src/vcore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ impl VCore {
pmbus_status,
pwr_good: power_good,
};
ereporter.try_send_ereport(&ereport);
ereporter.deliver_ereport(&ereport);
// TODO(eliza): if POWER_GOOD has been deasserted, we should produce a
// subsequent ereport for that.

Expand Down
2 changes: 1 addition & 1 deletion drv/gimlet-seq-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ drv-spi-api = { path = "../spi-api" }
drv-stm32h7-spi = { path = "../stm32h7-spi" }
drv-stm32xx-sys-api = { path = "../stm32xx-sys-api" }
counters = { path = "../../lib/counters" }
ereports = { path = "../../lib/ereports" }
ereports = { path = "../../lib/ereports", features = ["ereporter-macro"] }
gnarle = { path = "../../lib/gnarle" }
ringbuf = { path = "../../lib/ringbuf" }
task-jefe-api = { path = "../../task/jefe-api" }
Expand Down
75 changes: 25 additions & 50 deletions drv/gimlet-seq-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use idol_runtime::{NotificationHandler, RequestError};
use seq_spi::{Addr, Reg};
use static_assertions::const_assert;
use task_jefe_api::Jefe;
use task_packrat_api as packrat_api;

task_slot!(SYS, sys);
task_slot!(SPI, spi_driver);
Expand Down Expand Up @@ -158,9 +157,6 @@ enum Trace {
retries_remaining: u8,
},
StartFailed(#[count(children)] SeqError),
EreportSent(usize),
EreportLost(usize, packrat_api::EreportWriteError),
EreportTooBig,
}

counted_ringbuf!(Trace, 128, Trace::None);
Expand Down Expand Up @@ -452,15 +448,7 @@ impl<S: SpiServer + Clone> ServerImpl<S> {
}

let packrat = Packrat::from(PACKRAT.get_task_id());
let mut ereporter = {
use static_cell::ClaimOnceCell;
static EREPORT_BUF: ClaimOnceCell<[u8; EREPORT_BUF_LEN]> =
ClaimOnceCell::new([0; EREPORT_BUF_LEN]);
Ereporter {
buf: EREPORT_BUF.claim(),
packrat: packrat.clone(),
}
};
let mut ereporter = Ereporter::claim_static_resources(packrat.clone());

//
// Apply the configuration mitigation on the BMR491, if required. This
Expand Down Expand Up @@ -495,7 +483,7 @@ impl<S: SpiServer + Clone> ServerImpl<S> {
last_cause,
succeeded,
};
ereporter.try_send_ereport(&ereport);
ereporter.deliver_ereport(&ereport);
}
}

Expand Down Expand Up @@ -859,7 +847,7 @@ impl<S: SpiServer> ServerImpl<S> {
ringbuf_entry!(Trace::CPUPresent(present));

if !present {
self.ereporter.try_send_ereport(
self.ereporter.deliver_ereport(
&ereports::cpu::CpuMissing {
cpu: &HOST_CPU_REFDES,
},
Expand All @@ -885,7 +873,7 @@ impl<S: SpiServer> ServerImpl<S> {
//
let rev_ok = sp3r1 && !sp3r2;
if !coretype || !rev_ok {
self.ereporter.try_send_ereport(
self.ereporter.deliver_ereport(
&ereports::cpu::UnsupportedCpu {
cpu: &HOST_CPU_REFDES,
coretype: ereports::cpu::CpuTypeBits {
Expand Down Expand Up @@ -1108,7 +1096,7 @@ impl<S: SpiServer> ServerImpl<S> {

if ifr & thermtrip != 0 {
self.seq.clear_bytes(Addr::IFR, &[thermtrip]).unwrap_lite();
self.ereporter.try_send_ereport(&ereports::cpu::Thermtrip {
self.ereporter.deliver_ereport(&ereports::cpu::Thermtrip {
cpu: &HOST_CPU_REFDES,
state: self.ereport_current_state(),
});
Expand Down Expand Up @@ -1627,46 +1615,33 @@ cfg_if::cfg_if! {

////////////////////////////////////////////////////////////////////////////////

const EREPORT_BUF_LEN: usize = microcbor::max_cbor_len_for![
ereports::pwr::PmbusAlert<FixedStr<'static, 9>, { REFDES_LEN }>,
ereports::pwr::Bmr491MitigationFailure<{ REFDES_LEN }>,
ereports::cpu::Thermtrip,
ereports::cpu::UnsupportedCpu<1, 2>,
ereports::cpu::CpuMissing,
];
ereports::declare_ereporter! {
pub(crate) struct Ereporter<SeqEreport> {
PmbusAlert(
ereports::pwr::PmbusAlert<
FixedStr<'static, 9>,
{ REFDES_LEN },
>,
),
Bmr491MitigationFailure(
ereports::pwr::Bmr491MitigationFailure<{ REFDES_LEN }>
),
Thermtrip(ereports::cpu::Thermtrip),
UnsupportedCpu(ereports::cpu::UnsupportedCpu<1, 2>),
CpuMissing(ereports::cpu::CpuMissing),
}
}

static HOST_CPU_REFDES: ereports::cpu::HostCpuRefdes =
ereports::cpu::HostCpuRefdes {
refdes: fixedstr::FixedString::from_str("P0"),
dev_id: fixedstr::FixedString::from_str("sp3-host-cpu"),
};

/// This is just the Packrat API handle and the ereport buffer bundled together
/// in one thing so that it can be passed into various places as a single
/// argument.
pub(crate) struct Ereporter {
packrat: task_packrat_api::Packrat,
buf: &'static mut [u8; EREPORT_BUF_LEN],
}

impl Ereporter {
pub(crate) fn try_send_ereport(
&mut self,
ereport: &impl microcbor::StaticCborLen,
) {
let eresult = self
.packrat
.deliver_microcbor_ereport(&ereport, &mut self.buf[..]);
match eresult {
Ok(len) => ringbuf_entry!(Trace::EreportSent(len)),
Err(task_packrat_api::EreportEncodeError::Packrat { len, err }) => {
ringbuf_entry!(Trace::EreportLost(len, err))
}
Err(task_packrat_api::EreportEncodeError::Encoder(_)) => {
ringbuf_entry!(Trace::EreportTooBig)
}
}
}
#[derive(Clone, microcbor::EncodeFields)]
struct CpuTypeBits {
coretype: bool,
sp3rx: [bool; 2],
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion drv/gimlet-seq-server/src/vcore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl VCore {
pwr_good,
pmbus_status: status,
};
ereporter.try_send_ereport(&ereport);
ereporter.deliver_ereport(&ereport);
// TODO(eliza): if POWER_GOOD has been deasserted, we should produce a
// subsequent ereport for that.

Expand Down
2 changes: 1 addition & 1 deletion drv/psc-seq-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ task-packrat-api = { path = "../../task/packrat-api", features = ["microcbor"] }
userlib = { path = "../../sys/userlib", features = ["panic-messages"] }
ringbuf = { path = "../../lib/ringbuf", features = ["counters"] }
counters = { path = "../../lib/counters" }
ereports = { path = "../../lib/ereports" }
ereports = { path = "../../lib/ereports", features = ["ereporter-macro"] }
static-cell = { path = "../../lib/static-cell" }
microcbor.path = "../../lib/microcbor"
fixedstr = { path = "../../lib/fixedstr", features = ["microcbor"] }
Expand Down
Loading
Loading