Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions platform/dev-qemu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ bench = false
name = "dev-qemu"
test = false

[features]
default = []
# sp-serial off (default): SmbusEspiMedium (the framing ec-test-cli
# speaks). On: MctpSerialMedium / DSP0253 (the framing the SP speaks
# over the two-QEMU link). Pure compile-time selector — both medium
# constructors already exist in uart-service.
sp-serial = []

[profile.release]
lto = true # better optimizations
codegen-units = 1
Expand Down
23 changes: 20 additions & 3 deletions platform/dev-qemu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,29 @@ use platform_common::mock::MockOdpRelayHandler;
use semihosting as _; // Panic handler
use static_cell::StaticCell;

// MCTP medium for the uart-service, selected at build time: SmbusEspi
// by default (the framing ec-test-cli speaks), MctpSerialMedium under
// sp-serial (the framing the SP speaks over the two-QEMU link). Both
// constructors live in uart-service; dev-qemu holds no wire addressing.
#[cfg(not(feature = "sp-serial"))]
type EcUartService = uart_service::DefaultService<MockOdpRelayHandler>;
#[cfg(feature = "sp-serial")]
type EcUartService = uart_service::MctpSerialService<MockOdpRelayHandler>;

#[cfg(not(feature = "sp-serial"))]
fn new_uart_service(relay: MockOdpRelayHandler) -> EcUartService {
uart_service::DefaultService::default_smbusespi(relay).unwrap()
}
Comment on lines +27 to +29
#[cfg(feature = "sp-serial")]
fn new_uart_service(relay: MockOdpRelayHandler) -> EcUartService {
uart_service::MctpSerialService::default_mctp_serial(relay).unwrap()
}
Comment on lines +30 to +33

#[embassy_executor::task]
async fn uart_service(uart: buffered::Uart<'static, Async>, relay: MockOdpRelayHandler) {
info!("Starting uart service");
static UART_SERVICE: StaticCell<uart_service::DefaultService<MockOdpRelayHandler>> = StaticCell::new();
let uart_service = uart_service::DefaultService::default_smbusespi(relay).unwrap();
let uart_service = UART_SERVICE.init(uart_service);
static UART_SERVICE: StaticCell<EcUartService> = StaticCell::new();
let uart_service = UART_SERVICE.init(new_uart_service(relay));
let Err(e) = uart_service::task::uart_service(uart_service, uart).await;
panic!("uart-service error: {:?}", e);
}
Expand Down
Loading