Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/pci added context parameter to pciaddr_resourc...
details: https://anonhg.NetBSD.org/src/rev/ef37caf04d8a
branches: trunk
changeset: 512133:ef37caf04d8a
user: mcr <mcr%NetBSD.org@localhost>
date: Fri Jul 06 18:02:35 2001 +0000
description:
added context parameter to pciaddr_resource_{reserve,allocate}
and to pci_device_foreach().
added new function pci_device_foreach_min().
diffstat:
sys/arch/i386/pci/pci_addr_fixup.c | 71 +++++++++++++++++++++----------------
sys/arch/i386/pci/pci_addr_fixup.h | 16 ++++++++-
2 files changed, 56 insertions(+), 31 deletions(-)
diffs (215 lines):
diff -r 1a368b99dbaa -r ef37caf04d8a sys/arch/i386/pci/pci_addr_fixup.c
--- a/sys/arch/i386/pci/pci_addr_fixup.c Fri Jul 06 18:01:26 2001 +0000
+++ b/sys/arch/i386/pci/pci_addr_fixup.c Fri Jul 06 18:02:35 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_addr_fixup.c,v 1.8 2001/04/23 19:15:29 kanaoka Exp $ */
+/* $NetBSD: pci_addr_fixup.c,v 1.9 2001/07/06 18:02:35 mcr Exp $ */
/*-
* Copyright (c) 2000 UCHIYAMA Yasushi. All rights reserved.
@@ -45,21 +45,17 @@
struct pciaddr pciaddr;
-typedef int (*pciaddr_resource_manage_func_t)
- (pci_chipset_tag_t, pcitag_t, int, struct extent *, int,
- bus_addr_t *, bus_size_t);
-void pciaddr_resource_manage __P((pci_chipset_tag_t, pcitag_t,
- pciaddr_resource_manage_func_t));
-void pciaddr_resource_reserve __P((pci_chipset_tag_t, pcitag_t));
+void pciaddr_resource_reserve __P((pci_chipset_tag_t, pcitag_t,
+ void *context));
int pciaddr_do_resource_reserve __P((pci_chipset_tag_t, pcitag_t, int,
- struct extent *, int, bus_addr_t *,
+ void *, int, bus_addr_t *,
bus_size_t));
-void pciaddr_resource_allocate __P((pci_chipset_tag_t, pcitag_t));
+void pciaddr_resource_allocate __P((pci_chipset_tag_t, pcitag_t,
+ void *context));
int pciaddr_do_resource_allocate __P((pci_chipset_tag_t, pcitag_t, int,
- struct extent *, int, bus_addr_t *,
+ void *, int, bus_addr_t *,
bus_size_t));
-bus_addr_t pciaddr_ioaddr __P((u_int32_t));
-void pciaddr_print_devid __P((pci_chipset_tag_t, pcitag_t));
+int device_is_agp __P((pci_chipset_tag_t, pcitag_t));
int device_is_agp __P((pci_chipset_tag_t, pcitag_t));
@@ -115,7 +111,7 @@
* 1. check & reserve system BIOS setting.
*/
PCIBIOS_PRINTV((verbose_header, "System BIOS Setting"));
- pci_device_foreach(pc, maxbus, pciaddr_resource_reserve);
+ pci_device_foreach(pc, maxbus, pciaddr_resource_reserve, NULL);
PCIBIOS_PRINTV((verbose_footer, pciaddr.nbogus));
/*
@@ -151,42 +147,48 @@
*/
PCIBIOS_PRINTV((verbose_header, "PCIBIOS fixup stage"));
pciaddr.nbogus = 0;
- pci_device_foreach(pc, maxbus, pciaddr_resource_allocate);
+ pci_device_foreach_min(pc, 0, maxbus, pciaddr_resource_allocate, NULL);
PCIBIOS_PRINTV((verbose_footer, pciaddr.nbogus));
}
void
-pciaddr_resource_reserve(pc, tag)
+pciaddr_resource_reserve(pc, tag, context)
pci_chipset_tag_t pc;
pcitag_t tag;
+ void *context;
{
#ifdef PCIBIOSVERBOSE
if (pcibiosverbose)
pciaddr_print_devid(pc, tag);
#endif
- pciaddr_resource_manage(pc, tag, pciaddr_do_resource_reserve);
+ pciaddr_resource_manage(pc, tag,
+ pciaddr_do_resource_reserve,
+ &pciaddr);
}
void
-pciaddr_resource_allocate(pc, tag)
+pciaddr_resource_allocate(pc, tag, context)
pci_chipset_tag_t pc;
pcitag_t tag;
+ void *context;
{
#ifdef PCIBIOSVERBOSE
if (pcibiosverbose)
pciaddr_print_devid(pc, tag);
#endif
- pciaddr_resource_manage(pc, tag, pciaddr_do_resource_allocate);
+ pciaddr_resource_manage(pc, tag,
+ pciaddr_do_resource_allocate,
+ &pciaddr);
}
void
-pciaddr_resource_manage(pc, tag, func)
+pciaddr_resource_manage(pc, tag, func, ctx)
pci_chipset_tag_t pc;
pcitag_t tag;
pciaddr_resource_manage_func_t func;
+ void *ctx;
{
- struct extent *ex;
pcireg_t val, mask;
bus_addr_t addr;
bus_size_t size;
@@ -238,10 +240,8 @@
width = 8;
}
size = PCI_MAPREG_MEM_SIZE(mask);
- ex = pciaddr.extent_mem;
} else {
size = PCI_MAPREG_IO_SIZE(mask);
- ex = pciaddr.extent_port;
}
addr = pciaddr_ioaddr(val);
@@ -254,7 +254,7 @@
++useport;
/* reservation/allocation phase */
- error += (*func) (pc, tag, mapreg, ex, type, &addr, size);
+ error += (*func) (pc, tag, mapreg, ctx, type, &addr, size);
PCIBIOS_PRINTV(("\n\t%02xh %s 0x%08x 0x%08x",
mapreg, type ? "port" : "mem ",
@@ -278,26 +278,32 @@
}
int
-pciaddr_do_resource_allocate(pc, tag, mapreg, ex, type, addr, size)
+pciaddr_do_resource_allocate(pc, tag, mapreg, ctx, type, addr, size)
pci_chipset_tag_t pc;
pcitag_t tag;
- struct extent *ex;
+ void *ctx;
int mapreg, type;
bus_addr_t *addr;
bus_size_t size;
{
+ struct pciaddr *pciaddrmap = (struct pciaddr *)ctx;
bus_addr_t start;
int error;
-
+ struct extent *ex;
+
if (*addr) /* no need to allocate */
return (0);
+ ex = (type == PCI_MAPREG_TYPE_MEM ?
+ pciaddrmap->extent_mem : pciaddrmap->extent_port);
+
/* XXX Don't allocate if device is AGP device to avoid conflict. */
if (device_is_agp(pc, tag))
return (0);
- start = type == PCI_MAPREG_TYPE_MEM ? pciaddr.mem_alloc_start
- : pciaddr.port_alloc_start;
+ start = (type == PCI_MAPREG_TYPE_MEM ?
+ pciaddrmap->mem_alloc_start : pciaddrmap->port_alloc_start);
+
if (start < ex->ex_start || start + size - 1 >= ex->ex_end) {
PCIBIOS_PRINTV(("No available resources. fixup failed\n"));
return (1);
@@ -334,19 +340,24 @@
}
int
-pciaddr_do_resource_reserve(pc, tag, mapreg, ex, type, addr, size)
+pciaddr_do_resource_reserve(pc, tag, mapreg, ctx, type, addr, size)
pci_chipset_tag_t pc;
pcitag_t tag;
- struct extent *ex;
+ void *ctx;
int type, mapreg;
bus_addr_t *addr;
bus_size_t size;
{
+ struct extent *ex;
+ struct pciaddr *pciaddrmap = (struct pciaddr *)ctx;
int error;
if (*addr == 0)
return (1);
+ ex = (type == PCI_MAPREG_TYPE_MEM ?
+ pciaddrmap->extent_mem : pciaddrmap->extent_port);
+
error = extent_alloc_region(ex, *addr, size, EX_NOWAIT| EX_MALLOCOK);
if (error) {
PCIBIOS_PRINTV(("Resource conflict.\n"));
diff -r 1a368b99dbaa -r ef37caf04d8a sys/arch/i386/pci/pci_addr_fixup.h
--- a/sys/arch/i386/pci/pci_addr_fixup.h Fri Jul 06 18:01:26 2001 +0000
+++ b/sys/arch/i386/pci/pci_addr_fixup.h Fri Jul 06 18:02:35 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_addr_fixup.h,v 1.2 2000/05/31 16:38:55 uch Exp $ */
+/* $NetBSD: pci_addr_fixup.h,v 1.3 2001/07/06 18:02:35 mcr Exp $ */
/*-
* Copyright (c) 2000 UCHIYAMA Yasushi. All rights reserved.
@@ -37,3 +37,17 @@
extern struct pciaddr pciaddr;
void pci_addr_fixup __P((pci_chipset_tag_t, int));
+
+/* for cardbus stuff */
+typedef int (*pciaddr_resource_manage_func_t)
+ (pci_chipset_tag_t, pcitag_t, int, void *, int,
+ bus_addr_t *, bus_size_t);
+
+void pciaddr_resource_manage __P((pci_chipset_tag_t, pcitag_t,
+ pciaddr_resource_manage_func_t,
+ void *));
+
+void pciaddr_print_devid __P((pci_chipset_tag_t, pcitag_t));
+
+bus_addr_t pciaddr_ioaddr __P((u_int32_t));
+
Home |
Main Index |
Thread Index |
Old Index