chipset_legacy/
piix4_uhci.rs1use chipset_device::ChipsetDevice;
7use chipset_device::io::IoResult;
8use chipset_device::pci::ByteEnabledDwordRead;
9use chipset_device::pci::ByteEnabledDwordWrite;
10use chipset_device::pci::PciConfigSpace;
11use chipset_resources::piix4_uhci::PIIX4_PCI_USB_UHCI_STUB_BDF;
12use inspect::InspectMut;
13use vmcore::device_state::ChangeDeviceState;
14
15pub mod resolver;
16
17#[derive(Debug, InspectMut)]
27#[non_exhaustive] pub struct Piix4UsbUhciStub {}
29
30impl Piix4UsbUhciStub {
31 pub fn new() -> Self {
32 Self {}
33 }
34}
35
36impl ChangeDeviceState for Piix4UsbUhciStub {
37 fn start(&mut self) {}
38
39 async fn stop(&mut self) {}
40
41 async fn reset(&mut self) {}
42}
43
44impl ChipsetDevice for Piix4UsbUhciStub {
45 fn supports_pci(&mut self) -> Option<&mut dyn PciConfigSpace> {
46 Some(self)
47 }
48}
49
50impl PciConfigSpace for Piix4UsbUhciStub {
52 fn pci_cfg_read(&mut self, offset: u16, mut value: ByteEnabledDwordRead<'_>) -> IoResult {
53 use pci_core::spec::cfg_space::HeaderType00;
54 value.set(match HeaderType00(offset) {
55 HeaderType00::BIST_HEADER => 0,
56 HeaderType00::BAR4 => 0,
57 HeaderType00::STATUS_COMMAND => 0x02800000,
58 HeaderType00::LATENCY_INTERRUPT => 0x000000FF | (4 << 8),
61 HeaderType00::DEVICE_VENDOR => 0xFFFFFFFF,
64 HeaderType00::CLASS_REVISION => 0x00000000,
67 _ if offset < 0x40 => 0, _ => {
69 tracing::debug!(?offset, "unimplemented config space read");
70 0
72 }
73 });
74
75 IoResult::Ok
76 }
77
78 fn pci_cfg_write(&mut self, offset: u16, value: ByteEnabledDwordWrite) -> IoResult {
79 use pci_core::spec::cfg_space::HeaderType00;
80 match HeaderType00(offset) {
81 HeaderType00::BIST_HEADER => {}
82 HeaderType00::BAR4 => {}
83 HeaderType00::STATUS_COMMAND => {}
84 HeaderType00::LATENCY_INTERRUPT => {}
85 HeaderType00::DEVICE_VENDOR => {}
86 _ => {
87 tracing::debug!(?offset, ?value, "unimplemented config space write");
88 }
90 }
91
92 IoResult::Ok
93 }
94
95 fn suggested_bdf(&mut self) -> Option<(u8, u8, u8)> {
96 Some(PIIX4_PCI_USB_UHCI_STUB_BDF) }
98}
99
100mod save_restore {
101 use super::*;
102 use vmcore::save_restore::NoSavedState;
103 use vmcore::save_restore::RestoreError;
104 use vmcore::save_restore::SaveError;
105 use vmcore::save_restore::SaveRestore;
106
107 impl SaveRestore for Piix4UsbUhciStub {
109 type SavedState = NoSavedState;
110
111 fn save(&mut self) -> Result<Self::SavedState, SaveError> {
112 Ok(NoSavedState)
113 }
114
115 fn restore(&mut self, NoSavedState: Self::SavedState) -> Result<(), RestoreError> {
116 Ok(())
117 }
118 }
119}