class FakePciProtocol

Defined at line 35 of file ../../src/devices/pci/testing/pci_protocol_fake.h

FakePciProtocol provides a PciProtocol implementation that can be configured

to match the layout of a given PCI device. It implements a PCI FIDL server

and can be trivially constructed for tests. All public methods are safe to

use and it has been written in mind to validate correctness of the

configuration space whenever possible as well as to behave similarly to the

actual PciProtocol driver proved by the userspace PCI Bus Driver.

Public Methods

void GetBar (GetBarRequestView request, GetBarCompleter::Sync & completer)

FIDL methods

Defined at line 9 of file ../../src/devices/pci/testing/protocol/fidl.cc

void GetDeviceInfo (GetDeviceInfoCompleter::Sync & completer)

Defined at line 33 of file ../../src/devices/pci/testing/protocol/fidl.cc

zx::interrupt & AddLegacyInterrupt ()

Add an interrupt for the specified PCI interrupt mode. A reference to the

interrupt object created is returned.

Defined at line 40 of file ../../src/devices/pci/testing/pci_protocol_fake.h

zx::interrupt & AddMsiInterrupt ()

Defined at line 43 of file ../../src/devices/pci/testing/pci_protocol_fake.h

zx::interrupt & AddMsixInterrupt ()

Defined at line 46 of file ../../src/devices/pci/testing/pci_protocol_fake.h

fuchsia_hardware_pci::wire::DeviceInfo SetDeviceInfo (fuchsia_hardware_pci::wire::DeviceInfo info)

Sets the structure returned by |PciGetDeviceInfo|.

Defined at line 51 of file ../../src/devices/pci/testing/pci_protocol_fake.h

void GetBti (GetBtiRequestView request, GetBtiCompleter::Sync & completer)

Defined at line 54 of file ../../src/devices/pci/testing/protocol/fidl.cc

void AddVendorCapability (uint8_t position, uint8_t size)

Adds a vendor capability of size |size| to the device at |position| in PCI Configuration Space.

Defined at line 57 of file ../../src/devices/pci/testing/pci_protocol_fake.h

void WriteConfig8 (WriteConfig8RequestView request, WriteConfig8Completer::Sync & completer)

Defined at line 64 of file ../../src/devices/pci/testing/protocol/fidl.cc

void AddPciExpressCapability (uint8_t position)

Adds a PCI Express capability at |position|.

No registers are configured, but most devices that check for this

capability do so just to understand the configuration space they have

available, not to actually attempt to modify this capability.

Defined at line 70 of file ../../src/devices/pci/testing/pci_protocol_fake.h

void WriteConfig16 (WriteConfig16RequestView request, WriteConfig16Completer::Sync & completer)

Defined at line 74 of file ../../src/devices/pci/testing/protocol/fidl.cc

void AddCapability (uint8_t capability_id, uint8_t position, uint8_t size)

Adds a capability of a given type corresponding to |capability_id| at the

specified position. This is only recommended for drivers that check for

existence of a capability rather than those that expect to read and write

from one. For MSI and MSI-X capabilities you should use the interrupt

methods to add interrupts. For a PCI Express capability you should use

AddPciExpressCapability instead.

Defined at line 81 of file ../../src/devices/pci/testing/pci_protocol_fake.h

void WriteConfig32 (WriteConfig32RequestView request, WriteConfig32Completer::Sync & completer)

Defined at line 84 of file ../../src/devices/pci/testing/protocol/fidl.cc

zx::vmo & CreateBar (uint32_t bar_id, size_t size, bool is_mmio)

Creates a BAR corresponding to the provided |bar_id| of the requested |size| and returns

a reference to the VMO backing its mapped region. |is_mmio| determines whether the bar

is MMIO or IO backed. The caller is responsible for mocking/faking the IO access in their

driver.

Defined at line 89 of file ../../src/devices/pci/testing/pci_protocol_fake.h

void ReadConfig8 (ReadConfig8RequestView request, ReadConfig8Completer::Sync & completer)

Defined at line 94 of file ../../src/devices/pci/testing/protocol/fidl.cc

void ReadConfig16 (ReadConfig16RequestView request, ReadConfig16Completer::Sync & completer)

Defined at line 105 of file ../../src/devices/pci/testing/protocol/fidl.cc

zx::vmo & GetBar (uint32_t bar_id)

Returns a reference to the VMO backing a given BAR id |bar_id|.

Defined at line 110 of file ../../src/devices/pci/testing/pci_protocol_fake.h

void ReadConfig32 (ReadConfig32RequestView request, ReadConfig32Completer::Sync & completer)

Defined at line 116 of file ../../src/devices/pci/testing/protocol/fidl.cc

zx::unowned_vmo GetConfigVmo ()

Returns a VMO corresponding to the device's configuration space.

Defined at line 119 of file ../../src/devices/pci/testing/pci_protocol_fake.h

fuchsia_hardware_pci::InterruptMode GetIrqMode ()

Returns the presently configured interrupt mode.

Defined at line 121 of file ../../src/devices/pci/testing/pci_protocol_fake.h

uint32_t GetIrqCount ()

Returns the present number of interrupts configured by |PciSetInterruptMode|.

Defined at line 123 of file ../../src/devices/pci/testing/pci_protocol_fake.h

uint32_t GetResetCount ()

Returns how many times |PciResetDevice| has been called.

Defined at line 125 of file ../../src/devices/pci/testing/pci_protocol_fake.h

void GetInterruptModes (GetInterruptModesCompleter::Sync & completer)

Defined at line 127 of file ../../src/devices/pci/testing/protocol/fidl.cc

std::optional<bool> GetBusMasterEnabled ()

Returns the state of the device's Bus Mastering setting. If std::nullopt is returned

then |PciSetBusMastering| was never called. Returned as an optional

so that the caller can differentiate between off and "never set" states in driver

testing.

Defined at line 131 of file ../../src/devices/pci/testing/pci_protocol_fake.h

void SetInterruptMode (SetInterruptModeRequestView request, SetInterruptModeCompleter::Sync & completer)

Defined at line 133 of file ../../src/devices/pci/testing/protocol/fidl.cc

void Reset ()

Reset all internal state of the fake PciProtocol.

Defined at line 134 of file ../../src/devices/pci/testing/pci_protocol_fake.h

void MapInterrupt (MapInterruptRequestView request, MapInterruptCompleter::Sync & completer)

Defined at line 143 of file ../../src/devices/pci/testing/protocol/fidl.cc

void GetCapabilities (GetCapabilitiesRequestView request, GetCapabilitiesCompleter::Sync & completer)

Defined at line 154 of file ../../src/devices/pci/testing/protocol/fidl.cc

void NotImplemented_ (const std::string & name, fidl::CompleterBase & completer)

Defined at line 163 of file ../../src/devices/pci/testing/pci_protocol_fake.h

void SetBusMastering (SetBusMasteringRequestView request, SetBusMasteringCompleter::Sync & completer)

Defined at line 181 of file ../../src/devices/pci/testing/protocol/fidl.cc

void ResetDevice (ResetDeviceCompleter::Sync & completer)

Defined at line 191 of file ../../src/devices/pci/testing/protocol/fidl.cc

void AckInterrupt (AckInterruptCompleter::Sync & completer)

Defined at line 200 of file ../../src/devices/pci/testing/protocol/fidl.cc

ddk::Pci SetUpFidlServer (async::Loop & loop)

Convenience method to set up a FIDL server in tests.

Defined at line 209 of file ../../src/devices/pci/testing/protocol/fidl.cc