Index: sys/dev/pci/pci_map.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/pci_map.c,v retrieving revision 1.30 diff -p -u -r1.30 pci_map.c --- sys/dev/pci/pci_map.c 20 Oct 2012 06:03:38 -0000 1.30 +++ sys/dev/pci/pci_map.c 20 Aug 2014 15:20:45 -0000 @@ -347,24 +347,21 @@ pci_mapreg_submap(const struct pci_attac int pci_find_rom(const struct pci_attach_args *pa, bus_space_tag_t bst, - bus_space_handle_t bsh, int type, bus_space_handle_t *romh, bus_size_t *sz) + bus_space_handle_t bsh, bus_size_t sz, int type, + bus_space_handle_t *romh, bus_size_t *romsz) { - bus_size_t romsz, offset = 0, imagesz; + bus_size_t offset = 0, imagesz; uint16_t ptr; int done = 0; - if (pci_mem_find(pa->pa_pc, pa->pa_tag, PCI_MAPREG_ROM, - PCI_MAPREG_TYPE_ROM, NULL, &romsz, NULL)) - return 1; - /* * no upper bound check; i cannot imagine a 4GB ROM, but * it appears the spec would allow it! */ - if (romsz < 1024) + if (sz < 1024) return 1; - while (offset < romsz && !done){ + while (offset < sz && !done){ struct pci_rom_header hdr; struct pci_rom rom; @@ -379,7 +376,7 @@ pci_find_rom(const struct pci_attach_arg ptr = offset + hdr.romh_data_ptr; - if (ptr > romsz) { + if (ptr > sz) { printf("pci_find_rom: rom data ptr out of range\n"); return 1; } @@ -415,7 +412,7 @@ pci_find_rom(const struct pci_attach_arg (rom.rom_subclass == PCI_SUBCLASS(pa->pa_class)) && (rom.rom_interface == PCI_INTERFACE(pa->pa_class)) && (rom.rom_code_type == type)) { - *sz = imagesz; + *romsz = imagesz; bus_space_subregion(bst, bsh, offset, imagesz, romh); return 0; } Index: sys/dev/pci/pcivar.h =================================================================== RCS file: /cvsroot/src/sys/dev/pci/pcivar.h,v retrieving revision 1.99 diff -p -u -r1.99 pcivar.h --- sys/dev/pci/pcivar.h 29 Mar 2014 19:28:25 -0000 1.99 +++ sys/dev/pci/pcivar.h 20 Aug 2014 15:20:45 -0000 @@ -271,7 +271,7 @@ int pci_mapreg_map(const struct pci_atta bus_size_t *); int pci_find_rom(const struct pci_attach_args *, bus_space_tag_t, - bus_space_handle_t, + bus_space_handle_t, bus_size_t, int, bus_space_handle_t *, bus_size_t *); int pci_get_capability(pci_chipset_tag_t, pcitag_t, int, int *, pcireg_t *); Index: sys/dev/pci/radeonfb.c =================================================================== RCS file: /cvsroot/src/sys/dev/pci/radeonfb.c,v retrieving revision 1.84 diff -p -u -r1.84 radeonfb.c --- sys/dev/pci/radeonfb.c 22 Jul 2014 15:42:59 -0000 1.84 +++ sys/dev/pci/radeonfb.c 20 Aug 2014 15:20:46 -0000 @@ -1321,7 +1321,7 @@ radeonfb_loadbios(struct radeonfb_softc return; } - pci_find_rom(pa, romt, romh, PCI_ROM_CODE_TYPE_X86, &biosh, + pci_find_rom(pa, romt, romh, romsz, PCI_ROM_CODE_TYPE_X86, &biosh, &sc->sc_biossz); if (sc->sc_biossz == 0) { aprint_verbose("%s: Video BIOS not present\n", XNAME(sc)); Index: sys/external/bsd/drm2/include/linux/pci.h =================================================================== RCS file: /cvsroot/src/sys/external/bsd/drm2/include/linux/pci.h,v retrieving revision 1.8 diff -p -u -r1.8 pci.h --- sys/external/bsd/drm2/include/linux/pci.h 13 Aug 2014 20:56:21 -0000 1.8 +++ sys/external/bsd/drm2/include/linux/pci.h 20 Aug 2014 15:20:54 -0000 @@ -430,6 +430,36 @@ pci_unmap_rom(struct pci_dev *pdev, void pdev->pd_rom_vaddr = NULL; } +/* XXX Whattakludge! Should move this in sys/arch/. */ +static int +pci_map_rom_md(struct pci_dev *pdev) +{ +#if defined(__i386__) || defined(__x86_64__) || defined(__ia64__) + const bus_addr_t rom_base = 0xc0000; + const bus_size_t rom_size = 0x20000; + bus_space_handle_t rom_bsh; + int error; + + if (PCI_CLASS(pdev->pd_pa.pa_class) != PCI_CLASS_DISPLAY) + return ENXIO; + if (PCI_SUBCLASS(pdev->pd_pa.pa_class) != PCI_SUBCLASS_DISPLAY_VGA) + return ENXIO; + /* XXX Check whether this is the primary VGA card? */ + error = bus_space_map(pdev->pd_pa.pa_memt, rom_base, rom_size, + (BUS_SPACE_MAP_PREFETCHABLE | BUS_SPACE_MAP_LINEAR), &rom_bsh); + if (error) + return ENXIO; + + pdev->pd_rom_bst = pdev->pd_pa.pa_memt; + pdev->pd_rom_bsh = rom_bsh; + pdev->pd_rom_size = rom_size; + + return 0; +#else + return ENXIO; +#endif +} + static inline void __pci_rom_iomem * pci_map_rom(struct pci_dev *pdev, size_t *sizep) { @@ -441,13 +471,14 @@ pci_map_rom(struct pci_dev *pdev, size_t if (pci_mapreg_map(&pdev->pd_pa, PCI_MAPREG_ROM, PCI_MAPREG_TYPE_ROM, (BUS_SPACE_MAP_PREFETCHABLE | BUS_SPACE_MAP_LINEAR), &pdev->pd_rom_bst, &pdev->pd_rom_bsh, NULL, &pdev->pd_rom_size) - != 0) + != 0 && + pci_map_rom_md(pdev) != 0) return NULL; pdev->pd_kludges |= NBPCI_KLUDGE_MAP_ROM; /* XXX This type is obviously wrong in general... */ if (pci_find_rom(&pdev->pd_pa, pdev->pd_rom_bst, pdev->pd_rom_bsh, - PCI_ROM_CODE_TYPE_X86, &bsh, &size)) { + pdev->pd_rom_size, PCI_ROM_CODE_TYPE_X86, &bsh, &size)) { pci_unmap_rom(pdev, NULL); return NULL; }