class PcieDevice
Defined at line 64 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
Base used to manage the relationship between a PCIe device/function and its
associated driver. During a bus scan/probe operation, all drivers will have
their registered probe methods called until a driver claims a device. A
driver may claim a device by returning a pointer to a driver-managed
pcie_device_state struct, with the driver owned fields filled out.
Protected Members
PcieBusDriver & bus_drv_
const PciConfig * cfg_
paddr_t cfg_phys_
LockDep cmd_reg_lock_
const bool is_bridge_
const uint bus_id_
const uint dev_id_
const uint func_id_
uint16_t vendor_id_
uint16_t device_id_
uint8_t class_id_
uint8_t subclass_
uint8_t prog_if_
uint8_t rev_id_
RefPtr upstream_
LockDep dev_lock_
bool plugged_in_
bool disabled_
bool quirks_done_
pcie_bar_info_t[6] bars_
const uint bar_count_
Public Methods
void PcieDevice (const PcieDevice & )
Disallow copying, assigning and moving.
Defined at line 71 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
void PcieDevice (PcieDevice && )
Disallow copying, assigning and moving.
Defined at line 71 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
PcieDevice & operator= (const PcieDevice & )
Disallow copying, assigning and moving.
Defined at line 71 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
PcieDevice & operator= (PcieDevice && )
Disallow copying, assigning and moving.
Defined at line 71 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
fbl::RefPtr<PcieDevice> Create (PcieUpstreamNode & upstream, uint dev_id, uint func_id)
Defined at line 98 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
void ~PcieDevice ()
Defined at line 84 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
void AddRef ()
Require that derived classes implement ref counting.
void Adopt ()
Require that derived classes implement ref counting.
fbl::RefPtr<PcieUpstreamNode> GetUpstream ()
Defined at line 155 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t Claim ()
zx_status_t EnablePio (bool enabled)
Enable or disable PIO access in a device's configuration.
Parameters
Returns
A zx_status_t indicating success or failure of the operation.
Defined at line 115 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
void Unplug ()
Defined at line 157 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t DoFunctionLevelReset ()
Trigger a function level reset (if possible)
Defined at line 185 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t EnableMmio (bool enabled)
Enable or disable MMIO access in a device's configuration.
Parameters
Returns
A zx_status_t indicating success or failure of the operation.
Defined at line 128 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
const pcie_bar_info_t * GetBarInfo (uint bar_ndx)
Return information about the requested base address register, if it has been
allocated. Otherwise, return NULL.
Parameters
Returns
A pointer to the BAR info, including where in the bus address space
the BAR window has been mapped, or NULL if the BAR window does not exist or
has not been allocated.
Defined at line 145 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
void SetIrqModeDisabled ()
Set the current IRQ mode to PCIE_IRQ_MODE_DISABLED
Convenience function.
Defined at line 223 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
void SetQuirksDone ()
Defined at line 276 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
zx_status_t MaskIrq (uint irq_id)
Convenience functions.
Defined at line 281 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
bool Release ()
Require that derived classes implement ref counting.
void Unclaim ()
zx_status_t UnmaskIrq (uint irq_id)
Defined at line 282 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
const PciConfig * config ()
Defined at line 284 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
paddr_t config_phys ()
Defined at line 285 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
PcieBusDriver & driver ()
Defined at line 286 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
bool plugged_in ()
Defined at line 288 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
bool disabled ()
Defined at line 289 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
bool quirks_done ()
Defined at line 290 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
bool is_bridge ()
Defined at line 292 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
bool is_pcie ()
Defined at line 293 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
uint16_t vendor_id ()
Defined at line 294 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
uint16_t device_id ()
Defined at line 295 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
uint8_t class_id ()
Defined at line 296 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
uint8_t subclass ()
Defined at line 297 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
uint8_t prog_if ()
Defined at line 298 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
uint8_t rev_id ()
Defined at line 299 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
uint bus_id ()
Defined at line 300 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
uint dev_id ()
Defined at line 301 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
uint func_id ()
Defined at line 302 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
uint bar_count ()
Defined at line 303 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
uint8_t legacy_irq_pin ()
Defined at line 304 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
const CapabilityList & capabilities ()
Defined at line 305 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
const pcie_irq_mode_t & irq_mode ()
Defined at line 306 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
pcie_device_type_t pcie_device_type ()
TODO(cja): This doesn't really make sense in a pcie capability optional world.
It is only used by bridge and debug code, so it might make sense to just have those check if
the device is pcie first, then use dev->pcie()->devtype().
Defined at line 310 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
Lock<Mutex> * dev_lock ()
TODO(johngro) : make these protected. They are currently only visible
because of debug code.
Defined at line 319 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
zx_status_t ModifyCmd (uint16_t clr_bits, uint16_t set_bits)
Modify bits in the device's command register (in the device config space),
clearing the bits specified by clr_bits and setting the bits specified by set
bits. Specifically, the operation will be applied as...
WR(cmd, (RD(cmd)
&
~clr) | set)
Parameters
Returns
A zx_status_t indicating success or failure of the operation.
Defined at line 335 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t EnableBusMaster (bool enabled)
Enable or disable bus mastering in a device's configuration.
Parameters
Returns
A zx_status_t indicating success or failure of the operation.
Defined at line 363 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t QueryIrqModeCapabilities (pcie_irq_mode_t mode, pcie_irq_mode_caps_t * out_caps)
Query the number of IRQs which are supported for a given IRQ mode by a given
device.
Parameters
Returns
A zx_status_t indicating the success or failure of the operation.
Defined at line 761 of file ../../zircon/kernel/dev/pcie/pcie_irqs.cc
zx_status_t GetIrqMode (pcie_irq_mode_info_t * out_info)
Fetch details about the currently configured IRQ mode.
++ ZX_ERR_UNAVAILABLE
The device has become unplugged and is waiting to be released.
Parameters
Returns
A zx_status_t indicating the success or failure of the operation.
Status codes may include (but are not limited to)...
Defined at line 772 of file ../../zircon/kernel/dev/pcie/pcie_irqs.cc
zx_status_t SetIrqMode (pcie_irq_mode_t mode, uint requested_irqs)
Configure the base IRQ mode, requesting a specific number of vectors and
sharing mode in the process.
Devices are not permitted to transition from an active mode (anything but
DISABLED) to a different active mode. They must first transition to
DISABLED, then request the new mode.
Transitions to the DISABLED state will automatically mask and un-register all
IRQ handlers, and return all allocated resources to the system pool. IRQ
dispatch may continue to occur for unmasked IRQs during a transition to
DISABLED, but is guaranteed not to occur after the call to pcie_set_irq_mode
has completed.
++ ZX_ERR_UNAVAILABLE
The device has become unplugged and is waiting to be released.
++ ZX_ERR_BAD_STATE
The device cannot transition into the selected mode at this point in time
due to the mode it is currently in.
++ ZX_ERR_NOT_SUPPORTED
++ The chosen mode is not supported by the device
++ The device supports the chosen mode, but does not support the number of
IRQs requested.
++ ZX_ERR_NO_RESOURCES
The system is unable to allocate sufficient system IRQs to satisfy the
number of IRQs and exclusivity mode requested the device driver.
Parameters
Returns
A zx_status_t indicating the success or failure of the operation.
Status codes may include (but are not limited to)...
Defined at line 781 of file ../../zircon/kernel/dev/pcie/pcie_irqs.cc
zx_status_t RegisterIrqHandler (uint irq_id, pcie_irq_handler_fn_t handler, void * ctx)
Register an IRQ handler for the specified IRQ ID.
++ ZX_ERR_UNAVAILABLE
The device has become unplugged and is waiting to be released.
++ ZX_ERR_BAD_STATE
The device is in DISABLED IRQ mode.
++ ZX_ERR_INVALID_ARGS
The irq_id parameter is out of range for the currently configured mode.
Parameters
Returns
A zx_status_t indicating the success or failure of the operation.
Status codes may include (but are not limited to)...
Defined at line 799 of file ../../zircon/kernel/dev/pcie/pcie_irqs.cc
zx_status_t MaskUnmaskIrq (uint irq_id, bool mask)
Mask or unmask the specified IRQ for the given device.
++ ZX_ERR_UNAVAILABLE
The device has become unplugged and is waiting to be released.
++ ZX_ERR_BAD_STATE
Attempting to mask or unmask an IRQ while in the DISABLED mode or with no
handler registered.
++ ZX_ERR_INVALID_ARGS
The irq_id parameter is out of range for the currently configured mode.
++ ZX_ERR_NOT_SUPPORTED
The device is operating in MSI mode, but neither the PCI device nor the
platform interrupt controller support masking the MSI vector.
Parameters
Returns
A zx_status_t indicating the success or failure of the operation.
Status codes may include (but are not limited to)...
Defined at line 805 of file ../../zircon/kernel/dev/pcie/pcie_irqs.cc
void Dump ()
Dump some information about the device
Defined at line 673 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
Protected Methods
void PcieDevice (PcieBusDriver & bus_drv, uint bus_id, uint dev_id, uint func_id, bool is_bridge)
Defined at line 75 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t Init (PcieUpstreamNode & upstream)
Initialization and probing.
Defined at line 102 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t InitLocked (PcieUpstreamNode & upstream)
Defined at line 116 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t ParseStdCapabilitiesLocked ()
TODO(cja): It may be worth moving to table based solution like we had before
where we have a single parse function and a function table for it to use,
but it involves a bit more worrying about ownership of capabilities and
std / ext attributes.
Defined at line 273 of file ../../zircon/kernel/dev/pcie/pcie_caps.cc
void AssignCmdLocked (uint16_t value)
Defined at line 330 of file ../../zircon/kernel/dev/pcie/include/dev/pcie_device.h
void ModifyCmdLocked (uint16_t clr_bits, uint16_t set_bits)
Defined at line 353 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t ProbeBarsLocked ()
Defined at line 377 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t ProbeBarLocked (uint bar_id)
Defined at line 417 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t ProbeCapabilitiesLocked ()
Parse PCI Standard Capabilities starting with the pointer in the PCI
config structure.
Defined at line 348 of file ../../zircon/kernel/dev/pcie/pcie_caps.cc
zx_status_t ParseExtCapabilitiesLocked ()
Defined at line 338 of file ../../zircon/kernel/dev/pcie/pcie_caps.cc
zx_status_t MapPinToIrqLocked (fbl::RefPtr<PcieUpstreamNode> && upstream)
Map from a device's interrupt pin ID to the proper system IRQ ID. Follow the
PCIe graph up to the root, swizzling as we traverse PCIe switches,
PCIe-to-PCI bridges, and native PCI-to-PCI bridges. Once we hit the root,
perform the final remapping using the platform supplied remapping routine.
Platform independent swizzling behavior is documented in the PCIe base
specification in section 2.2.8.1 and Table 2-20.
Platform dependent remapping is an exercise for the reader. FWIW: PC
architectures use the _PRT tables in ACPI to perform the remapping.
Defined at line 822 of file ../../zircon/kernel/dev/pcie/pcie_irqs.cc
zx_status_t InitLegacyIrqStateLocked (PcieUpstreamNode & upstream)
Defined at line 918 of file ../../zircon/kernel/dev/pcie/pcie_irqs.cc
zx_status_t AllocateBars ()
BAR allocation
Defined at line 505 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t AllocateBarsLocked ()
Defined at line 510 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
zx_status_t AllocateBarLocked (pcie_bar_info_t & info)
Defined at line 531 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
void Disable ()
Disable a device, and anything downstream of it. The device will
continue to enumerate, but users will only be able to access config (and
only in a read only fashion). BAR windows, bus mastering, and interrupts
will all be disabled.
Defined at line 649 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
void DisableLocked ()
Defined at line 655 of file ../../zircon/kernel/dev/pcie/pcie_device.cc
Friends
class SharedHandlerTrait
class SharedLegacyIrqHandler
class PcieBusDriver
class PcieUpstreamNode