static void linuxPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits) { int fd; CARD32 val = 0xffffffff; if (-1 != (fd = linuxPciOpenFile(tag,TRUE))) { lseek(fd,off,SEEK_SET); read(fd,&val,4); val = PCI_CPU(val); val = (val & ~mask) | (bits & mask); val = PCI_CPU(val); lseek(fd,off,SEEK_SET); write(fd,&val,4); } }
static void linuxPciCfgWrite(PCITAG tag, int off, CARD32 val) { int fd; if (-1 != (fd = linuxPciOpenFile(tag,TRUE))) { lseek(fd,off,SEEK_SET); val = PCI_CPU(val); write(fd,&val,4); } }
static void freebsdPciCfgWrite(PCITAG tag, int off, CARD32 val) { struct pci_io io; io.pi_sel.pc_bus = BUS(tag); io.pi_sel.pc_dev = DFN(tag) >> 3; io.pi_sel.pc_func = DFN(tag) & 7; io.pi_reg = off; io.pi_width = 4; io.pi_data = PCI_CPU(val); ioctl(pciFd, PCIOCWRITE, &io); }
static CARD32 linuxPciCfgRead(PCITAG tag, int off) { int fd; CARD32 val = 0xffffffff; if (-1 != (fd = linuxPciOpenFile(tag,FALSE))) { lseek(fd,off,SEEK_SET); read(fd,&val,4); } return PCI_CPU(val); }
static CARD32 freebsdPciCfgRead(PCITAG tag, int off) { struct pci_io io; int error; io.pi_sel.pc_bus = BUS(tag); io.pi_sel.pc_dev = DFN(tag) >> 3; io.pi_sel.pc_func = DFN(tag) & 7; io.pi_reg = off; io.pi_width = 4; error = ioctl(pciFd, PCIOCREAD, &io); if (error) return ~0; return PCI_CPU(io.pi_data); }