Module Name: xsrc
Committed By: mrg
Date: Tue Jan 12 03:05:32 UTC 2010
Modified Files:
xsrc/external/mit/libpciaccess/dist/src: netbsd_pci.c
Log Message:
in pci_device_netbsd_probe() probe the expansion ROM and size.
if it's there, set priv->rom_base and device->rom_size.
originally from mhitch, and it's basically the same code as present in
both freebsd_pci.c and openbsd_pci.c.
add a comment about needing to avoid the default bios mapping if this
card is not the console.
mmap() with MAP_SHARED, since the kernel forces this anyway, and it is
again the same in both freebsd_pci.c and openbsd_pci.c.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c
diff -u xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c:1.5 xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c:1.6
--- xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c:1.5 Wed Dec 23 22:21:01 2009
+++ xsrc/external/mit/libpciaccess/dist/src/netbsd_pci.c Tue Jan 12 03:05:31 2010
@@ -354,6 +354,23 @@
}
}
+ /* Probe expansion ROM if present */
+ err = pci_read(domain, bus, dev, func, PCI_MAPREG_ROM, ®);
+ if (err)
+ return err;
+ if (reg != 0) {
+ err = pci_write(domain, bus, dev, func, PCI_MAPREG_ROM,
+ (uint32_t)(~PCI_MAPREG_ROM_ENABLE));
+ if (err)
+ return err;
+ pci_read(domain, bus, dev, func, PCI_MAPREG_ROM, &size);
+ pci_write(domain, bus, dev, func, PCI_MAPREG_ROM, reg);
+ if ((reg & PCI_MAPREG_MEM_ADDR_MASK) != 0) {
+ priv->rom_base = reg & PCI_MAPREG_MEM_ADDR_MASK;
+ device->rom_size = -(size & PCI_MAPREG_MEM_ADDR_MASK);
+ }
+ }
+
return 0;
}
@@ -379,6 +396,10 @@
if (priv->rom_base == 0) {
#if defined(__amd64__) || defined(__i386__)
+ /*
+ * We need a way to detect when this isn't the console and reject
+ * this request outright.
+ */
rom_base = 0xc0000;
rom_size = 0x10000;
pci_rom = 0;
@@ -419,7 +440,7 @@
if (memfd == -1)
return errno;
- bios = mmap(NULL, rom_size, PROT_READ, 0, memfd, (off_t)rom_base);
+ bios = mmap(NULL, rom_size, PROT_READ, MAP_SHARED, memfd, (off_t)rom_base);
if (bios == MAP_FAILED) {
int serrno = errno;
close(memfd);