FreeBSD kernel amd64 PCI device code
pci_pci.c File Reference
#include <sys/cdefs.h>
#include "opt_pci.h"
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/pciio.h>
#include <sys/rman.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/taskqueue.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pci_private.h>
#include <dev/pci/pcib_private.h>
#include "pcib_if.h"
Include dependency graph for pci_pci.c:

Go to the source code of this file.

Functions

 __FBSDID ("$FreeBSD$")
 
static int pcib_probe (device_t dev)
 
static int pcib_suspend (device_t dev)
 
static int pcib_resume (device_t dev)
 
static int pcib_power_for_sleep (device_t pcib, device_t dev, int *pstate)
 
static int pcib_ari_get_id (device_t pcib, device_t dev, enum pci_id_type type, uintptr_t *id)
 
static uint32_t pcib_read_config (device_t dev, u_int b, u_int s, u_int f, u_int reg, int width)
 
static void pcib_write_config (device_t dev, u_int b, u_int s, u_int f, u_int reg, uint32_t val, int width)
 
static int pcib_ari_maxslots (device_t dev)
 
static int pcib_ari_maxfuncs (device_t dev)
 
static int pcib_try_enable_ari (device_t pcib, device_t dev)
 
static int pcib_ari_enabled (device_t pcib)
 
static void pcib_ari_decode_rid (device_t pcib, uint16_t rid, int *bus, int *slot, int *func)
 
static int pcib_request_feature_default (device_t pcib, device_t dev, enum pci_feature feature)
 
static int pcib_reset_child (device_t dev, device_t child, int flags)
 
 DEFINE_CLASS_0 (pcib, pcib_driver, pcib_methods, sizeof(struct pcib_softc))
 
 EARLY_DRIVER_MODULE (pcib, pci, pcib_driver, pcib_devclass, NULL, NULL, BUS_PASS_BUS)
 
static int pcib_is_prefetch_open (struct pcib_softc *sc)
 
static int pcib_is_nonprefetch_open (struct pcib_softc *sc)
 
static int pcib_is_io_open (struct pcib_softc *sc)
 
static void pcib_get_io_decode (struct pcib_softc *sc)
 
static void pcib_get_mem_decode (struct pcib_softc *sc)
 
static void pcib_set_io_decode (struct pcib_softc *sc)
 
static void pcib_set_mem_decode (struct pcib_softc *sc)
 
static void pcib_cfg_save (struct pcib_softc *sc)
 
static void pcib_cfg_restore (struct pcib_softc *sc)
 
void pcib_attach_common (device_t dev)
 
int pcib_attach_child (device_t dev)
 
int pcib_attach (device_t dev)
 
int pcib_detach (device_t dev)
 
void pcib_bridge_init (device_t dev)
 
int pcib_child_present (device_t dev, device_t child)
 
int pcib_read_ivar (device_t dev, device_t child, int which, uintptr_t *result)
 
int pcib_write_ivar (device_t dev, device_t child, int which, uintptr_t value)
 
struct resource * pcib_alloc_resource (device_t dev, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
 
static __inline void pcib_xlate_ari (device_t pcib, int bus, int *slot, int *func)
 
static void pcib_enable_ari (struct pcib_softc *sc, uint32_t pcie_pos)
 
int pcib_maxslots (device_t dev)
 
int pcib_route_interrupt (device_t pcib, device_t dev, int pin)
 
int pcib_alloc_msi (device_t pcib, device_t dev, int count, int maxcount, int *irqs)
 
int pcib_release_msi (device_t pcib, device_t dev, int count, int *irqs)
 
int pcib_alloc_msix (device_t pcib, device_t dev, int *irq)
 
int pcib_release_msix (device_t pcib, device_t dev, int irq)
 
int pcib_map_msi (device_t pcib, device_t dev, int irq, uint64_t *addr, uint32_t *data)
 
int pcib_request_feature_allow (device_t pcib, device_t dev, enum pci_feature feature)
 
int pcib_request_feature (device_t dev, enum pci_feature feature)
 

Variables

static device_method_t pcib_methods []
 
static devclass_t pcib_devclass
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DEFINE_CLASS_0()

DEFINE_CLASS_0 ( pcib  ,
pcib_driver  ,
pcib_methods  ,
sizeof(struct pcib_softc  
)

◆ EARLY_DRIVER_MODULE()

EARLY_DRIVER_MODULE ( pcib  ,
pci  ,
pcib_driver  ,
pcib_devclass  ,
NULL  ,
NULL  ,
BUS_PASS_BUS   
)

◆ pcib_alloc_msi()

int pcib_alloc_msi ( device_t  pcib,
device_t  dev,
int  count,
int  maxcount,
int *  irqs 
)

Definition at line 2773 of file pci_pci.c.

References bus, count, dev, pcib_softc::flags, irqs, maxcount, pcib, and PCIB_DISABLE_MSI.

◆ pcib_alloc_msix()

int pcib_alloc_msix ( device_t  pcib,
device_t  dev,
int *  irq 
)

Definition at line 2797 of file pci_pci.c.

References bus, dev, pcib_softc::flags, irq, pcib, and PCIB_DISABLE_MSIX.

◆ pcib_alloc_resource()

struct resource * pcib_alloc_resource ( device_t  dev,
device_t  child,
int  type,
int *  rid,
rman_res_t  start,
rman_res_t  end,
rman_res_t  count,
u_int  flags 
)

◆ pcib_ari_decode_rid()

static void pcib_ari_decode_rid ( device_t  pcib,
uint16_t  rid,
int *  bus,
int *  slot,
int *  func 
)
static

◆ pcib_ari_enabled()

static int pcib_ari_enabled ( device_t  pcib)
static

Definition at line 2846 of file pci_pci.c.

References pcib_softc::flags, pcib, and PCIB_ENABLE_ARI.

◆ pcib_ari_get_id()

static int pcib_ari_get_id ( device_t  pcib,
device_t  dev,
enum pci_id_type  type,
uintptr_t *  id 
)
static

Definition at line 2856 of file pci_pci.c.

References bus, dev, pcib_softc::flags, func, PCI_ARI_RID, PCI_ID_RID, PCI_RID, pcib, PCIB_ENABLE_ARI, slot, and type.

◆ pcib_ari_maxfuncs()

static int pcib_ari_maxfuncs ( device_t  dev)
static

Definition at line 2664 of file pci_pci.c.

References dev, pcib_softc::flags, PCI_FUNCMAX, PCIB_ENABLE_ARI, and PCIE_ARI_FUNCMAX.

◆ pcib_ari_maxslots()

static int pcib_ari_maxslots ( device_t  dev)
static

Definition at line 2651 of file pci_pci.c.

References dev, pcib_softc::flags, PCIB_ENABLE_ARI, pcib_maxslots(), and PCIE_ARI_SLOTMAX.

Here is the call graph for this function:

◆ pcib_attach()

int pcib_attach ( device_t  dev)

Definition at line 1755 of file pci_pci.c.

References dev, pcib_attach_child(), and pcib_attach_common().

Here is the call graph for this function:

◆ pcib_attach_child()

int pcib_attach_child ( device_t  dev)

Definition at line 1733 of file pci_pci.c.

References pcib_softc::bus, pcib_softc::child, dev, and pcib_secbus::sec.

Referenced by pcib_attach().

Here is the caller graph for this function:

◆ pcib_attach_common()

◆ pcib_bridge_init()

void pcib_bridge_init ( device_t  dev)

◆ pcib_cfg_restore()

static void pcib_cfg_restore ( struct pcib_softc sc)
static

Definition at line 1505 of file pci_pci.c.

References pcib_softc::dev, pcib_set_io_decode(), pcib_set_mem_decode(), PCIM_CMD_MEMEN, PCIM_CMD_PORTEN, and PCIR_COMMAND.

Referenced by pcib_resume().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pcib_cfg_save()

static void pcib_cfg_save ( struct pcib_softc sc)
static

Definition at line 1485 of file pci_pci.c.

References dev, pcib_softc::dev, pcib_get_io_decode(), pcib_get_mem_decode(), PCIM_CMD_MEMEN, PCIM_CMD_PORTEN, and PCIR_COMMAND.

Referenced by pcib_attach_common(), and pcib_suspend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pcib_child_present()

int pcib_child_present ( device_t  dev,
device_t  child 
)

Definition at line 1833 of file pci_pci.c.

References dev, pcib_softc::flags, and PCIB_HOTPLUG.

◆ pcib_detach()

int pcib_detach ( device_t  dev)

Definition at line 1763 of file pci_pci.c.

References pcib_softc::bus, dev, pcib_softc::flags, and PCIB_HOTPLUG.

◆ pcib_enable_ari()

static void pcib_enable_ari ( struct pcib_softc sc,
uint32_t  pcie_pos 
)
static

Definition at line 2614 of file pci_pci.c.

References pcib_softc::dev, pcib_softc::flags, PCIB_ENABLE_ARI, PCIEM_CTL2_ARI, and PCIER_DEVICE_CTL2.

Referenced by pcib_try_enable_ari().

Here is the caller graph for this function:

◆ pcib_get_io_decode()

static void pcib_get_io_decode ( struct pcib_softc sc)
static

Definition at line 832 of file pci_pci.c.

References dev, pcib_softc::dev, pcib_softc::iobase, pcib_softc::iolimit, PCI_PPBIOBASE, PCI_PPBIOLIMIT, PCIM_BRIO_32, PCIM_BRIO_MASK, PCIR_IOBASEH_1, PCIR_IOBASEL_1, PCIR_IOLIMITH_1, and PCIR_IOLIMITL_1.

Referenced by pcib_cfg_save().

Here is the caller graph for this function:

◆ pcib_get_mem_decode()

static void pcib_get_mem_decode ( struct pcib_softc sc)
static

◆ pcib_is_io_open()

static int pcib_is_io_open ( struct pcib_softc sc)
static

Definition at line 823 of file pci_pci.c.

References pcib_softc::iobase, and pcib_softc::iolimit.

Referenced by pcib_alloc_resource(), and pcib_attach_common().

Here is the caller graph for this function:

◆ pcib_is_nonprefetch_open()

static int pcib_is_nonprefetch_open ( struct pcib_softc sc)
static

Definition at line 814 of file pci_pci.c.

References pcib_softc::membase, and pcib_softc::memlimit.

Referenced by pcib_alloc_resource(), and pcib_attach_common().

Here is the caller graph for this function:

◆ pcib_is_prefetch_open()

static int pcib_is_prefetch_open ( struct pcib_softc sc)
static

Definition at line 805 of file pci_pci.c.

References pcib_softc::pmembase, and pcib_softc::pmemlimit.

Referenced by pcib_alloc_resource(), and pcib_attach_common().

Here is the caller graph for this function:

◆ pcib_map_msi()

int pcib_map_msi ( device_t  pcib,
device_t  dev,
int  irq,
uint64_t *  addr,
uint32_t *  data 
)

Definition at line 2820 of file pci_pci.c.

References addr, bus, data, dev, irq, pci_ht_map_msi(), and pcib.

Here is the call graph for this function:

◆ pcib_maxslots()

int pcib_maxslots ( device_t  dev)

Definition at line 2629 of file pci_pci.c.

References dev, PCI_SLOTMAX, PCIEM_FLAGS_TYPE, PCIEM_TYPE_DOWNSTREAM_PORT, PCIEM_TYPE_ROOT_PORT, PCIER_FLAGS, PCIY_EXPRESS, and val.

Referenced by pcib_ari_maxslots().

Here is the caller graph for this function:

◆ pcib_power_for_sleep()

int pcib_power_for_sleep ( device_t  pcib,
device_t  dev,
int *  pstate 
)
static

Definition at line 2837 of file pci_pci.c.

References bus, dev, pcib, and pstate.

◆ pcib_probe()

static int pcib_probe ( device_t  dev)
static

Definition at line 1526 of file pci_pci.c.

References dev, PCIC_BRIDGE, and PCIS_BRIDGE_PCI.

◆ pcib_read_config()

static uint32_t pcib_read_config ( device_t  dev,
u_int  b,
u_int  s,
u_int  f,
u_int  reg,
int  width 
)
static

Definition at line 2698 of file pci_pci.c.

References dev, pcib_xlate_ari(), reg, and width.

Here is the call graph for this function:

◆ pcib_read_ivar()

int pcib_read_ivar ( device_t  dev,
device_t  child,
int  which,
uintptr_t *  result 
)

Definition at line 1849 of file pci_pci.c.

References pcib_softc::bus, dev, pcib_softc::domain, and pcib_secbus::sec.

◆ pcib_release_msi()

int pcib_release_msi ( device_t  pcib,
device_t  dev,
int  count,
int *  irqs 
)

Definition at line 2787 of file pci_pci.c.

References bus, count, dev, irqs, and pcib.

◆ pcib_release_msix()

int pcib_release_msix ( device_t  pcib,
device_t  dev,
int  irq 
)

Definition at line 2810 of file pci_pci.c.

References bus, dev, irq, and pcib.

◆ pcib_request_feature()

int pcib_request_feature ( device_t  dev,
enum pci_feature  feature 
)

Definition at line 2963 of file pci_pci.c.

References dev, and feature.

◆ pcib_request_feature_allow()

int pcib_request_feature_allow ( device_t  pcib,
device_t  dev,
enum pci_feature  feature 
)

Definition at line 2944 of file pci_pci.c.

References feature, PCI_FEATURE_AER, and PCI_FEATURE_HP.

◆ pcib_request_feature_default()

static int pcib_request_feature_default ( device_t  pcib,
device_t  dev,
enum pci_feature  feature 
)
static

Definition at line 2981 of file pci_pci.c.

References bus, dev, feature, and pcib.

◆ pcib_reset_child()

static int pcib_reset_child ( device_t  dev,
device_t  child,
int  flags 
)
static

Definition at line 2996 of file pci_pci.c.

References child, dev, pcie_link_reset(), PCIEM_TYPE_DOWNSTREAM_PORT, and PCIEM_TYPE_ROOT_PORT.

Here is the call graph for this function:

◆ pcib_resume()

int pcib_resume ( device_t  dev)
static

Definition at line 1804 of file pci_pci.c.

References dev, pcib_cfg_restore(), and PCIR_COMMAND.

Here is the call graph for this function:

◆ pcib_route_interrupt()

int pcib_route_interrupt ( device_t  pcib,
device_t  dev,
int  pin 
)

Definition at line 2739 of file pci_pci.c.

References bus, dev, pcib, and pin.

◆ pcib_set_io_decode()

static void pcib_set_io_decode ( struct pcib_softc sc)
static

Definition at line 889 of file pci_pci.c.

References dev, pcib_softc::dev, pcib_softc::iobase, pcib_softc::iolimit, PCIR_IOBASEH_1, PCIR_IOBASEL_1, PCIR_IOLIMITH_1, and PCIR_IOLIMITL_1.

Referenced by pcib_cfg_restore().

Here is the caller graph for this function:

◆ pcib_set_mem_decode()

static void pcib_set_mem_decode ( struct pcib_softc sc)
static

◆ pcib_suspend()

int pcib_suspend ( device_t  dev)
static

Definition at line 1796 of file pci_pci.c.

References dev, and pcib_cfg_save().

Here is the call graph for this function:

◆ pcib_try_enable_ari()

static int pcib_try_enable_ari ( device_t  pcib,
device_t  dev 
)
static

Definition at line 2891 of file pci_pci.c.

References dev, PCI_EXTCAP_VER, pcib, pcib_enable_ari(), PCIB_SUPPORTED_ARI_VER, PCIEM_CAP2_ARI, PCIER_DEVICE_CAP2, PCIY_EXPRESS, and PCIZ_ARI.

Here is the call graph for this function:

◆ pcib_write_config()

static void pcib_write_config ( device_t  dev,
u_int  b,
u_int  s,
u_int  f,
u_int  reg,
uint32_t  val,
int  width 
)
static

Definition at line 2721 of file pci_pci.c.

References dev, pcib_xlate_ari(), reg, val, and width.

Here is the call graph for this function:

◆ pcib_write_ivar()

int pcib_write_ivar ( device_t  dev,
device_t  child,
int  which,
uintptr_t  value 
)

Definition at line 1865 of file pci_pci.c.

◆ pcib_xlate_ari()

static __inline void pcib_xlate_ari ( device_t  pcib,
int  bus,
int *  slot,
int *  func 
)
static

Definition at line 2597 of file pci_pci.c.

References pcib_softc::flags, func, pcib, PCIB_ENABLE_ARI, PCIE_ARI_FUNC, PCIE_ARI_SLOT, and slot.

Referenced by pcib_read_config(), and pcib_write_config().

Here is the caller graph for this function:

Variable Documentation

◆ pcib_devclass

devclass_t pcib_devclass
static

Definition at line 136 of file pci_pci.c.

◆ pcib_methods

device_method_t pcib_methods[]
static

Definition at line 88 of file pci_pci.c.