Pull up following revision(s) (requested by riastradh in ticket #144):
sys/dev/pci/radeonfb.c: revision 1.85 sys/dev/pci/pcivar.h: revision 1.100 sys/dev/pci/pci_map.c: revision 1.31 sys/external/bsd/drm2/include/linux/pci.h: revision 1.9 Generalize pci_find_rom and use it to locate x86 video ROM in drm2. - Make pci_find_rom take the ROM `BAR' size as a parameter, instead of using pci_find_mem with the ROM `BAR' to detect the size. - Use it to find the x86 video ROM in [0xc0000, 0xe0000) in drm2, when nothing else reports that location. - Adapt the one other caller in radeonfb, which already has the maximum ROM size handy (romsz). XXX pullup to netbsd-7
This commit is contained in:
parent
ca5b63fd99
commit
425dcd6810
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pci_map.c,v 1.30 2012/10/20 06:03:38 matt Exp $ */
|
||||
/* $NetBSD: pci_map.c,v 1.30.12.1 2014/10/17 07:14:32 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: pci_map.c,v 1.30 2012/10/20 06:03:38 matt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: pci_map.c,v 1.30.12.1 2014/10/17 07:14:32 martin Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -347,24 +347,21 @@ pci_mapreg_submap(const struct pci_attach_args *pa, int reg, pcireg_t type,
|
|||
|
||||
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_args *pa, bus_space_tag_t bst,
|
|||
|
||||
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_args *pa, bus_space_tag_t bst,
|
|||
(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;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pcivar.h,v 1.99 2014/03/29 19:28:25 christos Exp $ */
|
||||
/* $NetBSD: pcivar.h,v 1.99.4.1 2014/10/17 07:14:32 martin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
|
||||
|
@ -271,7 +271,7 @@ int pci_mapreg_map(const struct pci_attach_args *, int, pcireg_t, int,
|
|||
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 *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: radeonfb.c,v 1.84 2014/07/22 15:42:59 riastradh Exp $ */
|
||||
/* $NetBSD: radeonfb.c,v 1.84.2.1 2014/10/17 07:14:32 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 Itronix Inc.
|
||||
|
@ -70,7 +70,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.84 2014/07/22 15:42:59 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.84.2.1 2014/10/17 07:14:32 martin Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -1321,7 +1321,7 @@ radeonfb_loadbios(struct radeonfb_softc *sc, const struct pci_attach_args *pa)
|
|||
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));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pci.h,v 1.7.2.1 2014/08/15 11:11:59 martin Exp $ */
|
||||
/* $NetBSD: pci.h,v 1.7.2.2 2014/10/17 07:14:33 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2013 The NetBSD Foundation, Inc.
|
||||
|
@ -430,6 +430,36 @@ pci_unmap_rom(struct pci_dev *pdev, void __pci_rom_iomem *vaddr __unused)
|
|||
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_LINEAR | BUS_SPACE_MAP_PREFETCHABLE), &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 *sizep)
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue