FreeBSD kernel amd64 PCI device code
pci_cfgreg.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/lock.h>
#include <sys/kernel.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/pci_cfgreg.h>
Include dependency graph for pci_cfgreg.c:

Go to the source code of this file.

Macros

#define PCIE_VADDR(base, reg, bus, slot, func)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static uint32_t pci_docfgregread (int bus, int slot, int func, int reg, int bytes)
 
static int pciereg_cfgread (int bus, unsigned slot, unsigned func, unsigned reg, unsigned bytes)
 
static void pciereg_cfgwrite (int bus, unsigned slot, unsigned func, unsigned reg, int data, unsigned bytes)
 
static int pcireg_cfgread (int bus, int slot, int func, int reg, int bytes)
 
static void pcireg_cfgwrite (int bus, int slot, int func, int reg, int data, int bytes)
 
 SYSCTL_DECL (_hw_pci)
 
 MTX_SYSINIT (pcicfg_mtx, &pcicfg_mtx, "pcicfg_mtx", MTX_SPIN)
 
 SYSCTL_INT (_hw_pci, OID_AUTO, mcfg, CTLFLAG_RDTUN, &mcfg_enable, 0, "Enable support for PCI-e memory mapped config access")
 
int pci_cfgregopen (void)
 
u_int32_t pci_cfgregread (int bus, int slot, int func, int reg, int bytes)
 
void pci_cfgregwrite (int bus, int slot, int func, int reg, u_int32_t data, int bytes)
 
static int pci_cfgenable (unsigned bus, unsigned slot, unsigned func, int reg, int bytes)
 
static void pci_cfgdisable (void)
 
int pcie_cfgregopen (uint64_t base, uint8_t minbus, uint8_t maxbus)
 

Variables

int cfgmech = CFGMECH_1
 
static vm_offset_t pcie_base
 
static int pcie_minbus
 
static int pcie_maxbus
 
static uint32_t pcie_badslots
 
static struct mtx pcicfg_mtx
 
static int mcfg_enable = 1
 

Macro Definition Documentation

◆ PCIE_VADDR

#define PCIE_VADDR (   base,
  reg,
  bus,
  slot,
  func 
)
Value:
((base) + \
((((bus) & 0xff) << 20) | \
(((slot) & 0x1f) << 15) | \
(((func) & 0x7) << 12) | \
((reg) & 0xfff)))
u_int reg
Definition: pci_dw_if.m:42
u_int func
Definition: pcib_if.m:81
u_int bus
Definition: pcib_if.m:79
u_int slot
Definition: pcib_if.m:80

Definition at line 257 of file pci_cfgreg.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ MTX_SYSINIT()

MTX_SYSINIT ( pcicfg_mtx  ,
pcicfg_mtx,
"pcicfg_mtx"  ,
MTX_SPIN   
)

◆ pci_cfgdisable()

static void pci_cfgdisable ( void  )
static

Definition at line 155 of file pci_cfgreg.c.

Referenced by pcireg_cfgread(), and pcireg_cfgwrite().

Here is the caller graph for this function:

◆ pci_cfgenable()

static int pci_cfgenable ( unsigned  bus,
unsigned  slot,
unsigned  func,
int  reg,
int  bytes 
)
static

Definition at line 139 of file pci_cfgreg.c.

References bus, func, PCI_BUSMAX, PCI_FUNCMAX, PCI_REGMAX, PCI_SLOTMAX, reg, and slot.

Referenced by pcireg_cfgread(), and pcireg_cfgwrite().

Here is the caller graph for this function:

◆ pci_cfgregopen()

int pci_cfgregopen ( void  )

Definition at line 75 of file pci_cfgreg.c.

Referenced by pcie_cfgregopen().

Here is the caller graph for this function:

◆ pci_cfgregread()

u_int32_t pci_cfgregread ( int  bus,
int  slot,
int  func,
int  reg,
int  bytes 
)

Definition at line 97 of file pci_cfgreg.c.

References bus, func, pci_docfgregread(), PCIR_INTLINE, reg, and slot.

Here is the call graph for this function:

◆ pci_cfgregwrite()

void pci_cfgregwrite ( int  bus,
int  slot,
int  func,
int  reg,
u_int32_t  data,
int  bytes 
)

Definition at line 122 of file pci_cfgreg.c.

References bus, cfgmech, data, func, pcie_badslots, pcie_maxbus, pcie_minbus, pciereg_cfgwrite(), pcireg_cfgwrite(), reg, and slot.

Here is the call graph for this function:

◆ pci_docfgregread()

static uint32_t pci_docfgregread ( int  bus,
int  slot,
int  func,
int  reg,
int  bytes 
)
static

Definition at line 82 of file pci_cfgreg.c.

References bus, cfgmech, func, pcie_badslots, pcie_maxbus, pcie_minbus, pciereg_cfgread(), pcireg_cfgread(), reg, and slot.

Referenced by pci_cfgregread().

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

◆ pcie_cfgregopen()

int pcie_cfgregopen ( uint64_t  base,
uint8_t  minbus,
uint8_t  maxbus 
)

Definition at line 215 of file pci_cfgreg.c.

References cfgmech, mcfg_enable, pci_cfgregopen(), PCI_SLOTMAX, pcie_badslots, pcie_base, pcie_maxbus, pcie_minbus, pciereg_cfgread(), pcireg_cfgread(), and slot.

Here is the call graph for this function:

◆ pciereg_cfgread()

static int pciereg_cfgread ( int  bus,
unsigned  slot,
unsigned  func,
unsigned  reg,
unsigned  bytes 
)
static

Definition at line 273 of file pci_cfgreg.c.

References bus, data, func, PCI_FUNCMAX, PCI_SLOTMAX, pcie_base, pcie_maxbus, PCIE_REGMAX, PCIE_VADDR, reg, and slot.

Referenced by pci_docfgregread(), and pcie_cfgregopen().

Here is the caller graph for this function:

◆ pciereg_cfgwrite()

static void pciereg_cfgwrite ( int  bus,
unsigned  slot,
unsigned  func,
unsigned  reg,
int  data,
unsigned  bytes 
)
static

Definition at line 304 of file pci_cfgreg.c.

References bus, data, func, PCI_FUNCMAX, PCI_SLOTMAX, pcie_base, pcie_maxbus, PCIE_REGMAX, PCIE_VADDR, reg, and slot.

Referenced by pci_cfgregwrite().

Here is the caller graph for this function:

◆ pcireg_cfgread()

static int pcireg_cfgread ( int  bus,
int  slot,
int  func,
int  reg,
int  bytes 
)
static

Definition at line 165 of file pci_cfgreg.c.

References bus, data, func, pci_cfgdisable(), pci_cfgenable(), pcicfg_mtx, reg, and slot.

Referenced by pci_docfgregread(), and pcie_cfgregopen().

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

◆ pcireg_cfgwrite()

static void pcireg_cfgwrite ( int  bus,
int  slot,
int  func,
int  reg,
int  data,
int  bytes 
)
static

Definition at line 191 of file pci_cfgreg.c.

References bus, data, func, pci_cfgdisable(), pci_cfgenable(), pcicfg_mtx, reg, and slot.

Referenced by pci_cfgregwrite().

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

◆ SYSCTL_DECL()

SYSCTL_DECL ( _hw_pci  )

◆ SYSCTL_INT()

SYSCTL_INT ( _hw_pci  ,
OID_AUTO  ,
mcfg  ,
CTLFLAG_RDTUN  ,
mcfg_enable,
,
"Enable support for PCI-e memory mapped config access"   
)

Variable Documentation

◆ cfgmech

int cfgmech = CFGMECH_1

Definition at line 63 of file pci_cfgreg.c.

Referenced by pci_cfgregwrite(), pci_docfgregread(), and pcie_cfgregopen().

◆ mcfg_enable

int mcfg_enable = 1
static

Definition at line 70 of file pci_cfgreg.c.

Referenced by pcie_cfgregopen().

◆ pcicfg_mtx

struct mtx pcicfg_mtx
static

Definition at line 68 of file pci_cfgreg.c.

Referenced by pcireg_cfgread(), and pcireg_cfgwrite().

◆ pcie_badslots

uint32_t pcie_badslots
static

Definition at line 67 of file pci_cfgreg.c.

Referenced by pci_cfgregwrite(), pci_docfgregread(), and pcie_cfgregopen().

◆ pcie_base

vm_offset_t pcie_base
static

Definition at line 65 of file pci_cfgreg.c.

Referenced by pcie_cfgregopen(), pciereg_cfgread(), and pciereg_cfgwrite().

◆ pcie_maxbus

int pcie_maxbus
static

◆ pcie_minbus

int pcie_minbus
static

Definition at line 66 of file pci_cfgreg.c.

Referenced by pci_cfgregwrite(), pci_docfgregread(), and pcie_cfgregopen().