Skip to content

feat: add Battery FFA service + MCTP-via-PL011 EC relay#73

Closed
dymk wants to merge 2 commits into
mainfrom
dymk/phase-36-ec-battery-mctp-ffa
Closed

feat: add Battery FFA service + MCTP-via-PL011 EC relay#73
dymk wants to merge 2 commits into
mainfrom
dymk/phase-36-ec-battery-mctp-ffa

Conversation

@dymk
Copy link
Copy Markdown
Collaborator

@dymk dymk commented May 22, 2026

Summary

Adds a Battery FFA service to the QEMU SBSA secure partition, backed by a real EC connection over PL011 UART using MCTP serial (DSP0253) framing.

New crates

  • sp-mctp-framer — Lightweight MCTP serial framing layer on top of mctp-rs. Handles DSP0253 byte-stuffing, CRC-16, and packet assembly/disassembly over a raw byte stream.
  • qemu-sp-uart — Minimal PL011 MMIO UART driver for the secure partition (polled mode, no interrupts).

Changes to existing crates

  • qemu-sp — Wires up the new Battery FFA handler + EC relay pipeline: FFA request → MCTP serialize → PL011 TX → PL011 RX → MCTP deserialize → FFA response.

Architecture

UEFI (NS) ──FFA──▶ SP (qemu-sp)
                      │
                      ├── BatteryFfaHandler
                      │     └── ec_relay::send_request()
                      │           ├── sp-mctp-framer::serialize
                      │           ├── qemu-sp-uart::write
                      │           ├── qemu-sp-uart::read
                      │           └── sp-mctp-framer::deserialize
                      │
                      └── PL011 UART ──serial──▶ EC (dev-qemu)

dymk added 2 commits May 22, 2026 12:23
Adds a new qemu-sp-uart workspace member: a minimal blocking PL011 MMIO
driver for the SP-side ec_uart device-region (mapped at 0x60030000 in
the SP DTS manifest).

Public API:
  - Pl011Uart::new(base: u64) -> Self (unsafe, RawMmio backend)
  - Pl011Uart::from_mmio(mmio: M) -> Self (generic, for tests)
  - read_byte_blocking() -> Result<u8, Error> (busy-spin, no cap)
  - read_byte_with_iteration_cap(cap: u32) -> Result<u8, Error>
  - write_bytes(&[u8]) -> Result<(), Error>

Includes 5 host-side unit tests using a mock Mmio backend.
…11 to EC)

Add the SP-side infrastructure for relaying FFA service requests to the
EC over MCTP/serial (PL011 UART), and implement the Battery service as
the first consumer.

New modules:
  - ec_relay: generic relay that encodes service requests as MCTP
    messages, sends over PL011 to EC, reads responses
  - battery: Battery FFA service handler, routes GetBst through ec_relay

Also updates supply-chain exemptions for new git-sourced deps.
Copilot AI review requested due to automatic review settings May 22, 2026 20:55
@dymk dymk requested review from a team as code owners May 22, 2026 20:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial building blocks for a QEMU SBSA secure-partition EC relay path by introducing a minimal PL011 UART driver crate and adding MCTP-based relay + Battery service plumbing in ec-service-lib, along with dependency/supply-chain updates.

Changes:

  • Added new qemu-sp-uart crate providing a blocking, polled PL011 MMIO UART driver with host-side unit tests.
  • Added ec-service-lib EC relay infrastructure (ec_relay) and a Battery service that proxies GetBst over MCTP serial framing.
  • Updated workspace dependencies (mctp-rs, embedded-services crates), lockfiles, cargo-vet config/imports, and cargo-deny advisories ignore list.

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
supply-chain/imports.lock Updates imported cargo-vet audit entries to cover new/transitive dependencies.
supply-chain/config.toml Updates cargo-vet exemptions for updated dependency graph.
qemu-sp-uart/src/lib.rs New no_std PL011 UART driver with an MMIO abstraction and host tests.
qemu-sp-uart/README.md Crate documentation describing API/usage and safety contract.
qemu-sp-uart/Cargo.toml Adds the new UART crate to the workspace with no external deps.
ec-service-lib/src/services/mod.rs Registers new battery and ec_relay service modules and exports.
ec-service-lib/src/services/ec_relay.rs Introduces transport-agnostic ODP-over-MCTP relay and a UART-based serial transport.
ec-service-lib/src/services/battery.rs Adds Battery proxy service using the relay and a host-only wire-format compatibility test.
ec-service-lib/Cargo.toml Adds dependencies for MCTP serial + UART crate and host-only test deps for wire-format gating.
deny.toml Ignores RUSTSEC-2024-0436 for paste (transitive via embedded-services).
Cargo.toml Adds qemu-sp-uart workspace member and new git-based workspace dependencies.
Cargo.lock Updates dependency resolution to include embedded-services/mctp-rs and related crate version bumps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread qemu-sp-uart/README.md
Comment thread qemu-sp-uart/README.md
Comment thread qemu-sp-uart/README.md
Comment thread qemu-sp-uart/src/lib.rs
Comment thread ec-service-lib/src/services/battery.rs
Comment thread ec-service-lib/src/services/ec_relay.rs
Comment thread supply-chain/config.toml
Comment thread Cargo.toml
@dymk
Copy link
Copy Markdown
Collaborator Author

dymk commented May 22, 2026

Recreating from fork branch to allow force-push updates.

@dymk dymk closed this May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants