Skip to content

Commit

Permalink
Minor host/SP update: implement "get BSU", bugfix ack response (oxide…
Browse files Browse the repository at this point in the history
…computer#847)

* Return correct answers when host asks "Which BSU?"
* Return "Ack" to host's SP startup ack
  • Loading branch information
jgallagher authored Oct 14, 2022
1 parent 4948731 commit d9d3bf0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions 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 app/gimlet/rev-b.toml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ priority = 5
max-sizes = {flash = 16384, ram = 16384}
stacksize = 2048
start = true
task-slots = ["sys", "gimlet_seq"]
task-slots = ["sys", "gimlet_seq", "hf"]

[tasks.udpecho]
name = "task-udpecho"
Expand Down
2 changes: 1 addition & 1 deletion app/gimletlet/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ priority = 3
max-sizes = {flash = 16384, ram = 16384}
stacksize = 2048
start = true
task-slots = ["sys", "gimlet_seq"]
task-slots = ["sys", "gimlet_seq", "hf"]

[tasks.hiffy]
name = "task-hiffy"
Expand Down
1 change: 1 addition & 0 deletions task/host-sp-comms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ringbuf = {path = "../../lib/ringbuf"}
userlib = {path = "../../sys/userlib"}

drv-stm32h7-usart = {path = "../../drv/stm32h7-usart", optional = true}
drv-gimlet-hf-api = {path = "../../drv/gimlet-hf-api"}
drv-gimlet-seq-api = {path = "../../drv/gimlet-seq-api"}
host-sp-messages = {path = "../../lib/host-sp-messages"}

Expand Down
26 changes: 23 additions & 3 deletions task/host-sp-comms/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use core::ops::Range;
#[cfg(any(feature = "stm32h743", feature = "stm32h753"))]
use drv_stm32h7_usart as drv_usart;

use drv_gimlet_hf_api::{HfDevSelect, HostFlash};
use drv_gimlet_seq_api::{PowerState, SeqError, Sequencer};
use drv_usart::Usart;
use heapless::Vec;
Expand All @@ -26,6 +27,7 @@ use userlib::{

task_slot!(SYS, sys);
task_slot!(GIMLET_SEQ, gimlet_seq);
task_slot!(HOST_FLASH, hf);

// TODO: When rebooting the host, we need to wait for the relevant power rails
// to decay. We ought to do this properly by monitoring the rails, but for now,
Expand Down Expand Up @@ -112,6 +114,7 @@ struct ServerImpl {
rx_buf: &'static mut Vec<u8, MAX_PACKET_SIZE>,
status: Status,
sequencer: Sequencer,
hf: HostFlash,
reboot_state: Option<RebootState>,
}

Expand All @@ -130,6 +133,7 @@ impl ServerImpl {
rx_buf: claim_uart_rx_buf(),
status,
sequencer: Sequencer::from(GIMLET_SEQ.get_task_id()),
hf: HostFlash::from(HOST_FLASH.get_task_id()),
reboot_state: None,
}
}
Expand Down Expand Up @@ -533,8 +537,24 @@ impl ServerImpl {
None
}
HostToSp::GetBootStorageUnit => {
// TODO how do we know the real answer?
Some(SpToHost::BootStorageUnit(Bsu::A))
// Per RFD 241, the phase 1 device (which we can read via
// `hf`) is tightly bound to the BSU, so we can map flash0 to
// BSU A and flash1 to BSU B.
//
// What should we do if we fail to get the device from the host
// flash task? That should only happen if `hf` is unable to
// respond to us at all, which makes it seem unlikely that the
// host could even be up. We'll default to returning Bsu::A.
//
// Minor TODO: Attempting to get the BSU on a gimletlet will
// hang, because the host-flash task hangs indefinitely. We
// could replace gimlet-hf-server with a fake on gimletlet if
// that becomes onerous.
let bsu = match self.hf.get_dev() {
Ok(HfDevSelect::Flash0) | Err(_) => Bsu::A,
Ok(HfDevSelect::Flash1) => Bsu::B,
};
Some(SpToHost::BootStorageUnit(bsu))
}
HostToSp::GetIdentity => {
// TODO how do we get our real identity?
Expand Down Expand Up @@ -564,7 +584,7 @@ impl ServerImpl {
HostToSp::AckSpStart => {
ringbuf_entry!(Trace::AckSpStart);
self.status.remove(Status::SP_TASK_RESTARTED);
Some(SpToHost::Status(self.status))
Some(SpToHost::Ack)
}
HostToSp::GetAlert => {
// TODO define alerts
Expand Down

0 comments on commit d9d3bf0

Please sign in to comment.