Index: pci_map.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pci_map.c,v
retrieving revision 1.23
diff -u -r1.23 pci_map.c
--- pci_map.c 28 Apr 2008 20:23:55 -0000 1.23
+++ pci_map.c 8 Jun 2008 03:52:28 -0000
@@ -320,6 +320,67 @@
}
int
+pci_mapreg_submap(struct pci_attach_args *pa, int reg, pcireg_t type,
+ int busflags, bus_size_t maxsize, bus_size_t offset, bus_space_tag_t *tagp,
+ bus_space_handle_t *handlep, bus_addr_t *basep, bus_size_t *sizep)
+{
+ bus_space_tag_t tag;
+ bus_space_handle_t handle;
+ bus_addr_t base;
+ bus_size_t size;
+ int flags;
+
+ if (PCI_MAPREG_TYPE(type) == PCI_MAPREG_TYPE_IO) {
+ if ((pa->pa_flags & PCI_FLAGS_IO_ENABLED) == 0)
+ return (1);
+ if (pci_io_find(pa->pa_pc, pa->pa_tag, reg, type, &base,
+ &size, &flags))
+ return (1);
+ tag = pa->pa_iot;
+ } else {
+ if ((pa->pa_flags & PCI_FLAGS_MEM_ENABLED) == 0)
+ return (1);
+ if (pci_mem_find(pa->pa_pc, pa->pa_tag, reg, type, &base,
+ &size, &flags))
+ return (1);
+ tag = pa->pa_memt;
+ }
+
+ if (reg == PCI_MAPREG_ROM) {
+ pcireg_t mask;
+ int s;
+ /* we have to enable the ROM address decoder... */
+ s = splhigh();
+ mask = pci_conf_read(pa->pa_pc, pa->pa_tag, reg);
+ mask |= PCI_MAPREG_ROM_ENABLE;
+ pci_conf_write(pa->pa_pc, pa->pa_tag, reg, mask);
+ splx(s);
+ }
+
+
+ if ((maxsize < size && offset + maxsize <= size) || offset != 0)
+ return (1);
+
+ base += offset;
+ size = maxsize;
+
+
+ if (bus_space_map(tag, base, maxsize, busflags | flags, &handle))
+ return (1);
+
+ if (tagp != 0)
+ *tagp = tag;
+ if (handlep != 0)
+ *handlep = handle;
+ if (basep != 0)
+ *basep = base;
+ if (sizep != 0)
+ *sizep = size;
+
+ return (0);
+}
+
+int
pci_find_rom(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)
{
Index: pcivar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pcivar.h,v
retrieving revision 1.82
diff -u -r1.82 pcivar.h
--- pcivar.h 30 May 2008 19:26:35 -0000 1.82
+++ pcivar.h 8 Jun 2008 03:52:28 -0000
@@ -198,6 +198,9 @@
int pci_mapreg_map(struct pci_attach_args *, int, pcireg_t, int,
bus_space_tag_t *, bus_space_handle_t *, bus_addr_t *,
bus_size_t *);
+int pci_mapreg_submap(struct pci_attach_args *, int, pcireg_t, int,
+ bus_size_t, bus_size_t, bus_space_tag_t *, bus_space_handle_t *,
+ bus_addr_t *, bus_size_t *);
int pci_find_rom(struct pci_attach_args *, bus_space_tag_t, bus_space_handle_t,
int, bus_space_handle_t *, bus_size_t *);