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
24 changes: 23 additions & 1 deletion sw/host/opentitanlib/src/transport/qemu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::transport::qemu::monitor::{Chardev, ChardevKind, Monitor};
use crate::transport::qemu::reset::QemuReset;
use crate::transport::qemu::spi::QemuSpi;
use crate::transport::qemu::uart::QemuUart;
use crate::transport::qemu::usbdev::QemuVbusSense;
use crate::transport::qemu::usbdev::{QemuUsbHost, QemuVbusSense};
use crate::transport::{
Capabilities, Capability, Transport, TransportError, TransportInterfaceType,
};
Expand Down Expand Up @@ -73,6 +73,8 @@ pub struct Qemu {
/// VBUS sense pin (actually goes via the `usbdev-cmd` chardev).
vbus_sense: Option<Rc<dyn GpioPin>>,

_usb_host: Option<Rc<QemuUsbHost>>,

/// QEMU log modelled as a UART.
log: Option<Rc<dyn Uart>>,

Expand Down Expand Up @@ -152,6 +154,25 @@ impl Qemu {
}
};

// USBDEV host:
let usb_host = match find_chardev(&chardevs, "usbdev-host") {
Some(ChardevKind::Pty { path }) => {
let tty = serialport::new(
path.to_str().context("TTY path not UTF8")?,
CONSOLE_BAUDRATE,
)
.open_native()
.context("failed to open QEMU usbdev-host PTY")?;

let usb_host = Rc::new(QemuUsbHost::new(tty));
Some(usb_host)
}
_ => {
log::info!("could not find pty chardev with id=usbdev-host, skipping USBDEV");
None
}
};

// QEMU log, not really a UART but modelled as one:
let log = match find_chardev(&chardevs, "log") {
Some(ChardevKind::Pty { path }) => {
Expand Down Expand Up @@ -237,6 +258,7 @@ impl Qemu {
reset,
uarts,
vbus_sense,
_usb_host: usb_host,
log,
spi,
i2cs,
Expand Down
Loading
Loading