38#include <sys/kernel.h>
40#include <sys/sysctl.h>
45#include <machine/pci_cfgreg.h>
50 unsigned reg,
unsigned bytes);
52 unsigned reg,
int data,
unsigned bytes);
72 "Enable support for PCI-e memory mapped config access");
111 if (line == 0 || line >= 128)
112 line = PCI_INVALID_IRQ;
145 (
unsigned)bytes <= 4 && (
reg & (bytes - 1)) == 0) {
146 outl(CONF1_ADDR_PORT, (1U << 31) | (
bus << 16) | (
slot << 11)
147 | (
func << 8) | (
reg & ~0x03));
148 dataport = CONF1_DATA_PORT + (
reg & 0x03);
227 printf(
"PCIe: Memory Mapped configuration base @ 0x%lx\n",
231 pcie_base = (vm_offset_t)pmap_mapdev_pciecfg(base, (maxbus + 1) << 20);
245 if (val1 == 0xffffffff)
257#define PCIE_VADDR(base, reg, bus, slot, func) \
259 ((((bus) & 0xff) << 20) | \
260 (((slot) & 0x1f) << 15) | \
261 (((func) & 0x7) << 12) | \
287 __asm(
"movl %1, %0" :
"=a" (
data)
288 :
"m" (*(
volatile uint32_t *)va));
291 __asm(
"movzwl %1, %0" :
"=a" (
data)
292 :
"m" (*(
volatile uint16_t *)va));
295 __asm(
"movzbl %1, %0" :
"=a" (
data)
296 :
"m" (*(
volatile uint8_t *)va));
317 __asm(
"movl %1, %0" :
"=m" (*(
volatile uint32_t *)va)
321 __asm(
"movw %1, %0" :
"=m" (*(
volatile uint16_t *)va)
322 :
"a" ((uint16_t)
data));
325 __asm(
"movb %1, %0" :
"=m" (*(
volatile uint8_t *)va)
326 :
"a" ((uint8_t)
data));
u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes)
static int pci_cfgenable(unsigned bus, unsigned slot, unsigned func, int reg, int bytes)
MTX_SYSINIT(pcicfg_mtx, &pcicfg_mtx, "pcicfg_mtx", MTX_SPIN)
static int pcireg_cfgread(int bus, int slot, int func, int reg, int bytes)
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 struct mtx pcicfg_mtx
static uint32_t pcie_badslots
#define PCIE_VADDR(base, reg, bus, slot, func)
SYSCTL_INT(_hw_pci, OID_AUTO, mcfg, CTLFLAG_RDTUN, &mcfg_enable, 0, "Enable support for PCI-e memory mapped config access")
void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes)
static vm_offset_t pcie_base
static void pciereg_cfgwrite(int bus, unsigned slot, unsigned func, unsigned reg, int data, unsigned bytes)
static void pcireg_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes)
int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus)
static void pci_cfgdisable(void)