Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Generalize pci_find_rom and use it to locate x86 video R...
details: https://anonhg.NetBSD.org/src/rev/d7aa7d7daa74
branches: trunk
changeset: 333052:d7aa7d7daa74
user: riastradh <riastradh%NetBSD.org@localhost>
date: Thu Oct 16 12:31:23 2014 +0000
description:
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
diffstat:
sys/dev/pci/pci_map.c | 21 +++++++----------
sys/dev/pci/pcivar.h | 4 +-
sys/dev/pci/radeonfb.c | 6 ++--
sys/external/bsd/drm2/include/linux/pci.h | 37 ++++++++++++++++++++++++++++--
4 files changed, 48 insertions(+), 20 deletions(-)
diffs (174 lines):
diff -r d6baac562835 -r d7aa7d7daa74 sys/dev/pci/pci_map.c
--- a/sys/dev/pci/pci_map.c Thu Oct 16 00:04:35 2014 +0000
+++ b/sys/dev/pci/pci_map.c Thu Oct 16 12:31:23 2014 +0000
@@ -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.31 2014/10/16 12:31:23 riastradh 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.31 2014/10/16 12:31:23 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -347,24 +347,21 @@
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 @@
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 @@
(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;
}
diff -r d6baac562835 -r d7aa7d7daa74 sys/dev/pci/pcivar.h
--- a/sys/dev/pci/pcivar.h Thu Oct 16 00:04:35 2014 +0000
+++ b/sys/dev/pci/pcivar.h Thu Oct 16 12:31:23 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcivar.h,v 1.99 2014/03/29 19:28:25 christos Exp $ */
+/* $NetBSD: pcivar.h,v 1.100 2014/10/16 12:31:23 riastradh Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@@ -271,7 +271,7 @@
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 *);
diff -r d6baac562835 -r d7aa7d7daa74 sys/dev/pci/radeonfb.c
--- a/sys/dev/pci/radeonfb.c Thu Oct 16 00:04:35 2014 +0000
+++ b/sys/dev/pci/radeonfb.c Thu Oct 16 12:31:23 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: radeonfb.c,v 1.84 2014/07/22 15:42:59 riastradh Exp $ */
+/* $NetBSD: radeonfb.c,v 1.85 2014/10/16 12:31:23 riastradh 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.85 2014/10/16 12:31:23 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1321,7 +1321,7 @@
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));
diff -r d6baac562835 -r d7aa7d7daa74 sys/external/bsd/drm2/include/linux/pci.h
--- a/sys/external/bsd/drm2/include/linux/pci.h Thu Oct 16 00:04:35 2014 +0000
+++ b/sys/external/bsd/drm2/include/linux/pci.h Thu Oct 16 12:31:23 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci.h,v 1.8 2014/08/13 20:56:21 riastradh Exp $ */
+/* $NetBSD: pci.h,v 1.9 2014/10/16 12:31:23 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -430,6 +430,36 @@
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 @@
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;
}
Home |
Main Index |
Thread Index |
Old Index