Date: Sat, 30 Aug 2003 23:45:02 -0700 (PDT) From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 37260 for review Message-ID: <200308310645.h7V6j2Bs013269@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=37260 Change 37260 by marcel@marcel_nfs on 2003/08/30 23:44:57 IFC @37254 Affected files ... .. //depot/projects/uart/alpha/alpha/pmap.c#9 integrate .. //depot/projects/uart/alpha/alpha/vm_machdep.c#6 integrate .. //depot/projects/uart/amd64/acpica/OsdEnvironment.c#3 integrate .. //depot/projects/uart/amd64/acpica/acpi_machdep.c#3 integrate .. //depot/projects/uart/amd64/acpica/acpi_wakeup.c#3 integrate .. //depot/projects/uart/amd64/amd64/vm_machdep.c#5 integrate .. //depot/projects/uart/amd64/pci/pci_bus.c#4 integrate .. //depot/projects/uart/conf/files#19 integrate .. //depot/projects/uart/ddb/db_ps.c#4 integrate .. //depot/projects/uart/dev/acpica/Osd/OsdHardware.c#3 integrate .. //depot/projects/uart/dev/acpica/acpi.c#7 integrate .. //depot/projects/uart/dev/acpica/acpi_cpu.c#3 integrate .. //depot/projects/uart/dev/acpica/acpi_lid.c#3 integrate .. //depot/projects/uart/dev/acpica/acpi_powerres.c#3 integrate .. //depot/projects/uart/dev/acpica/acpi_resource.c#3 integrate .. //depot/projects/uart/dev/acpica/acpi_thermal.c#3 integrate .. //depot/projects/uart/dev/acpica/acpi_timer.c#4 integrate .. //depot/projects/uart/dev/acpica/acpica_support.c#3 delete .. //depot/projects/uart/dev/acpica/acpica_support.h#2 delete .. //depot/projects/uart/dev/acpica/acpiio.h#3 integrate .. //depot/projects/uart/dev/acpica/acpivar.h#4 integrate .. //depot/projects/uart/dev/ata/ata-lowlevel.c#4 integrate .. //depot/projects/uart/dev/ata/ata-queue.c#3 integrate .. //depot/projects/uart/dev/ep/if_ep.c#5 integrate .. //depot/projects/uart/dev/ep/if_ep_isa.c#4 integrate .. //depot/projects/uart/dev/ep/if_ep_pccard.c#4 integrate .. //depot/projects/uart/dev/exca/exca.c#4 integrate .. //depot/projects/uart/dev/firewire/sbp.c#8 integrate .. //depot/projects/uart/dev/ichsmb/ichsmb_pci.c#4 integrate .. //depot/projects/uart/dev/pccard/pccardvar.h#2 integrate .. //depot/projects/uart/dev/pci/pci.c#6 integrate .. //depot/projects/uart/dev/pci/pcireg.h#3 integrate .. //depot/projects/uart/dev/puc/puc_pci.c#4 integrate .. //depot/projects/uart/dev/sound/pci/es137x.c#4 integrate .. //depot/projects/uart/dev/sound/pci/ich.c#7 integrate .. //depot/projects/uart/dev/sound/pcm/ac97.c#4 integrate .. //depot/projects/uart/geom/geom.h#2 integrate .. //depot/projects/uart/geom/geom_dev.c#4 integrate .. //depot/projects/uart/i386/acpica/OsdEnvironment.c#2 integrate .. //depot/projects/uart/i386/acpica/acpi_machdep.c#2 integrate .. //depot/projects/uart/i386/acpica/acpi_wakecode.S#2 integrate .. //depot/projects/uart/i386/acpica/acpi_wakeup.c#5 integrate .. //depot/projects/uart/i386/i386/vm_machdep.c#4 integrate .. //depot/projects/uart/i386/pci/pci_bus.c#4 integrate .. //depot/projects/uart/ia64/acpica/OsdEnvironment.c#2 integrate .. //depot/projects/uart/ia64/acpica/acpi_machdep.c#2 integrate .. //depot/projects/uart/ia64/acpica/acpi_wakeup.c#2 integrate .. //depot/projects/uart/ia64/ia64/vm_machdep.c#5 integrate .. //depot/projects/uart/kern/uipc_syscalls.c#4 integrate .. //depot/projects/uart/kern/vfs_bio.c#4 integrate .. //depot/projects/uart/kern/vfs_cluster.c#3 integrate .. //depot/projects/uart/modules/Makefile#6 integrate .. //depot/projects/uart/modules/acpi/Makefile#5 integrate .. //depot/projects/uart/modules/pst/Makefile#1 branch .. //depot/projects/uart/net/if_ethersubr.c#4 integrate .. //depot/projects/uart/netatalk/aarp.c#2 integrate .. //depot/projects/uart/netatalk/ddp_output.c#2 integrate .. //depot/projects/uart/netinet/igmp.c#3 integrate .. //depot/projects/uart/pc98/pc98/sio.c#4 integrate .. //depot/projects/uart/pccard/i82365.h#2 integrate .. //depot/projects/uart/pccard/pcic.c#3 integrate .. //depot/projects/uart/powerpc/powerpc/vm_machdep.c#5 integrate .. //depot/projects/uart/sparc64/sparc64/vm_machdep.c#4 integrate .. //depot/projects/uart/sys/buf.h#3 integrate .. //depot/projects/uart/sys/mac.h#4 integrate .. //depot/projects/uart/ufs/ffs/ffs_softdep.c#2 integrate .. //depot/projects/uart/vm/swap_pager.c#9 integrate .. //depot/projects/uart/vm/vm_map.c#8 integrate .. //depot/projects/uart/vm/vm_map.h#5 integrate .. //depot/projects/uart/vm/vm_page.c#5 integrate .. //depot/projects/uart/vm/vm_pageout.c#6 integrate .. //depot/projects/uart/vm/vnode_pager.c#5 integrate Differences ... ==== //depot/projects/uart/alpha/alpha/pmap.c#9 (text+ko) ==== @@ -148,7 +148,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/alpha/alpha/pmap.c,v 1.134 2003/08/20 20:12:05 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/alpha/alpha/pmap.c,v 1.135 2003/08/28 23:12:28 alc Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -340,7 +340,6 @@ static int pmap_release_free_page(pmap_t pmap, vm_page_t p); static vm_page_t _pmap_allocpte(pmap_t pmap, unsigned ptepindex); -static vm_page_t pmap_page_lookup(vm_object_t object, vm_pindex_t pindex); static int pmap_unuse_pt(pmap_t, vm_offset_t, vm_page_t); #ifdef SMP static void pmap_invalidate_page_action(void *arg); @@ -914,22 +913,6 @@ return ALPHA_PHYS_TO_K0SEG(start); } - -static vm_page_t -pmap_page_lookup(vm_object_t object, vm_pindex_t pindex) -{ - vm_page_t m; -retry: - m = vm_page_lookup(object, pindex); - if (m != NULL) { - vm_page_lock_queues(); - if (vm_page_sleep_if_busy(m, FALSE, "pplookp")) - goto retry; - vm_page_unlock_queues(); - } - return m; -} - /*************************************************** * Page table page management routines..... ***************************************************/ @@ -967,10 +950,8 @@ if (m->pindex < NUSERLEV3MAPS) { /* unhold the level 2 page table */ vm_page_t lev2pg; - lev2pg = vm_page_lookup(pmap->pm_pteobj, - NUSERLEV3MAPS + pmap_lev1_index(va)); - while (vm_page_sleep_if_busy(lev2pg, FALSE, "pulook")) - vm_page_lock_queues(); + + lev2pg = PHYS_TO_VM_PAGE(pmap_pte_pa(pmap_lev1pte(pmap, va))); vm_page_unhold(lev2pg); if (lev2pg->hold_count == 0) _pmap_unwire_pte_hold(pmap, va, lev2pg); @@ -1027,9 +1008,7 @@ (pmap->pm_ptphint->pindex == ptepindex)) { mpte = pmap->pm_ptphint; } else { - while ((mpte = vm_page_lookup(pmap->pm_pteobj, ptepindex)) != NULL && - vm_page_sleep_if_busy(mpte, FALSE, "pulook")) - vm_page_lock_queues(); + mpte = PHYS_TO_VM_PAGE(pmap_pte_pa(pmap_lev2pte(pmap, va))); pmap->pm_ptphint = mpte; } } @@ -1240,9 +1219,9 @@ if (!pmap_pte_v(l1pte)) _pmap_allocpte(pmap, NUSERLEV3MAPS + l1index); else { - vm_page_t l2page = - pmap_page_lookup(pmap->pm_pteobj, - NUSERLEV3MAPS + l1index); + vm_page_t l2page; + + l2page = PHYS_TO_VM_PAGE(pmap_pte_pa(l1pte)); l2page->hold_count++; } l2map = (pt_entry_t*) ALPHA_PHYS_TO_K0SEG(pmap_pte_pa(l1pte)); @@ -1297,7 +1276,7 @@ (pmap->pm_ptphint->pindex == ptepindex)) { m = pmap->pm_ptphint; } else { - m = pmap_page_lookup(pmap->pm_pteobj, ptepindex); + m = PHYS_TO_VM_PAGE(pmap_pte_pa(lev2pte)); pmap->pm_ptphint = m; } m->hold_count++; @@ -1999,7 +1978,6 @@ if (mpte && (mpte->pindex == ptepindex)) { mpte->hold_count++; } else { -retry: /* * Get the level 2 entry */ @@ -2014,12 +1992,9 @@ (pmap->pm_ptphint->pindex == ptepindex)) { mpte = pmap->pm_ptphint; } else { - mpte = pmap_page_lookup(pmap->pm_pteobj, - ptepindex); + mpte = PHYS_TO_VM_PAGE(pmap_pte_pa(l2pte)); pmap->pm_ptphint = mpte; } - if (mpte == NULL) - goto retry; mpte->hold_count++; } else { mpte = _pmap_allocpte(pmap, ptepindex); ==== //depot/projects/uart/alpha/alpha/vm_machdep.c#6 (text+ko) ==== @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/alpha/alpha/vm_machdep.c,v 1.93 2003/08/16 23:15:13 marcel Exp $"); +__FBSDID("$FreeBSD: src/sys/alpha/alpha/vm_machdep.c,v 1.94 2003/08/29 20:04:09 alc Exp $"); #include "opt_kstack_pages.h" @@ -82,6 +82,8 @@ #include <sys/vnode.h> #include <sys/vmmeter.h> #include <sys/kernel.h> +#include <sys/mbuf.h> +#include <sys/socketvar.h> #include <sys/sysctl.h> #include <sys/unistd.h> @@ -101,6 +103,20 @@ #include <sys/user.h> +static void sf_buf_init(void *arg); +SYSINIT(sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL) + +/* + * Expanded sf_freelist head. Really an SLIST_HEAD() in disguise, with the + * sf_freelist head with the sf_lock mutex. + */ +static struct { + SLIST_HEAD(, sf_buf) sf_head; + struct mtx sf_lock; +} sf_freelist; + +static u_int sf_buf_alloc_want; + /* * Finish a fork operation, with process p2 nearly set up. * Copy and update the pcb, set up the stack so that the child @@ -370,6 +386,91 @@ } /* + * Allocate a pool of sf_bufs (sendfile(2) or "super-fast" if you prefer. :-)) + */ +static void +sf_buf_init(void *arg) +{ + struct sf_buf *sf_bufs; + vm_offset_t sf_base; + int i; + + mtx_init(&sf_freelist.sf_lock, "sf_bufs list lock", NULL, MTX_DEF); + mtx_lock(&sf_freelist.sf_lock); + SLIST_INIT(&sf_freelist.sf_head); + sf_base = kmem_alloc_nofault(kernel_map, nsfbufs * PAGE_SIZE); + sf_bufs = malloc(nsfbufs * sizeof(struct sf_buf), M_TEMP, + M_NOWAIT | M_ZERO); + for (i = 0; i < nsfbufs; i++) { + sf_bufs[i].kva = sf_base + i * PAGE_SIZE; + SLIST_INSERT_HEAD(&sf_freelist.sf_head, &sf_bufs[i], free_list); + } + sf_buf_alloc_want = 0; + mtx_unlock(&sf_freelist.sf_lock); +} + +/* + * Get an sf_buf from the freelist. Will block if none are available. + */ +struct sf_buf * +sf_buf_alloc(struct vm_page *m) +{ + struct sf_buf *sf; + int error; + + mtx_lock(&sf_freelist.sf_lock); + while ((sf = SLIST_FIRST(&sf_freelist.sf_head)) == NULL) { + sf_buf_alloc_want++; + error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM|PCATCH, + "sfbufa", 0); + sf_buf_alloc_want--; + + /* + * If we got a signal, don't risk going back to sleep. + */ + if (error) + break; + } + if (sf != NULL) { + SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list); + sf->m = m; + pmap_qenter(sf->kva, &sf->m, 1); + } + mtx_unlock(&sf_freelist.sf_lock); + return (sf); +} + +/* + * Detatch mapped page and release resources back to the system. + */ +void +sf_buf_free(void *addr, void *args) +{ + struct sf_buf *sf; + struct vm_page *m; + + sf = args; + pmap_qremove((vm_offset_t)addr, 1); + m = sf->m; + vm_page_lock_queues(); + vm_page_unwire(m, 0); + /* + * Check for the object going away on us. This can + * happen since we don't hold a reference to it. + * If so, we're responsible for freeing the page. + */ + if (m->wire_count == 0 && m->object == NULL) + vm_page_free(m); + vm_page_unlock_queues(); + sf->m = NULL; + mtx_lock(&sf_freelist.sf_lock); + SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list); + if (sf_buf_alloc_want > 0) + wakeup_one(&sf_freelist); + mtx_unlock(&sf_freelist.sf_lock); +} + +/* * Software interrupt handler for queued VM system processing. */ void ==== //depot/projects/uart/amd64/acpica/OsdEnvironment.c#3 (text+ko) ==== @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/acpica/OsdEnvironment.c,v 1.10 2003/07/25 21:10:18 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/acpica/OsdEnvironment.c,v 1.11 2003/08/28 16:30:31 njl Exp $"); /* * 6.1 : Environmental support @@ -40,7 +40,7 @@ u_long amd64_acpi_root; SYSCTL_ULONG(_machdep, OID_AUTO, acpi_root, CTLFLAG_RD, &amd64_acpi_root, 0, - "The physical address of the RSDP"); + "The physical address of the RSDP"); ACPI_STATUS AcpiOsInitialize(void) ==== //depot/projects/uart/amd64/acpica/acpi_machdep.c#3 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/acpica/acpi_machdep.c,v 1.10 2003/07/25 21:10:19 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/acpica/acpi_machdep.c,v 1.11 2003/08/28 16:30:31 njl Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -38,9 +38,8 @@ { struct acpi_softc *sc; - if ((sc = device_get_softc(dev)) == NULL) { + if ((sc = device_get_softc(dev)) == NULL) return (ENXIO); - } acpi_install_wakeup_handler(sc); ==== //depot/projects/uart/amd64/acpica/acpi_wakeup.c#3 (text+ko) ==== @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/acpica/acpi_wakeup.c,v 1.20 2003/07/25 21:10:19 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/acpica/acpi_wakeup.c,v 1.21 2003/08/28 16:30:31 njl Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -37,7 +37,6 @@ int acpi_sleep_machdep(struct acpi_softc *sc, int state) { - return (0); } ==== //depot/projects/uart/amd64/amd64/vm_machdep.c#5 (text+ko) ==== @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/amd64/vm_machdep.c,v 1.216 2003/08/16 23:15:14 marcel Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/vm_machdep.c,v 1.217 2003/08/29 20:04:09 alc Exp $"); #include "opt_isa.h" #include "opt_kstack_pages.h" @@ -57,7 +57,9 @@ #include <sys/vmmeter.h> #include <sys/kernel.h> #include <sys/ktr.h> +#include <sys/mbuf.h> #include <sys/mutex.h> +#include <sys/socketvar.h> #include <sys/sysctl.h> #include <sys/unistd.h> @@ -78,8 +80,21 @@ #include <amd64/isa/isa.h> static void cpu_reset_real(void); +static void sf_buf_init(void *arg); +SYSINIT(sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL) /* + * Expanded sf_freelist head. Really an SLIST_HEAD() in disguise, with the + * sf_freelist head with the sf_lock mutex. + */ +static struct { + SLIST_HEAD(, sf_buf) sf_head; + struct mtx sf_lock; +} sf_freelist; + +static u_int sf_buf_alloc_want; + +/* * Finish a fork operation, with process p2 nearly set up. * Copy and update the pcb, set up the stack so that the child * ready to run and return to user mode. @@ -349,6 +364,86 @@ } /* + * Allocate a pool of sf_bufs (sendfile(2) or "super-fast" if you prefer. :-)) + */ +static void +sf_buf_init(void *arg) +{ + struct sf_buf *sf_bufs; + int i; + + mtx_init(&sf_freelist.sf_lock, "sf_bufs list lock", NULL, MTX_DEF); + mtx_lock(&sf_freelist.sf_lock); + SLIST_INIT(&sf_freelist.sf_head); + sf_bufs = malloc(nsfbufs * sizeof(struct sf_buf), M_TEMP, + M_NOWAIT | M_ZERO); + for (i = 0; i < nsfbufs; i++) + SLIST_INSERT_HEAD(&sf_freelist.sf_head, &sf_bufs[i], free_list); + sf_buf_alloc_want = 0; + mtx_unlock(&sf_freelist.sf_lock); +} + +/* + * Get an sf_buf from the freelist. Will block if none are available. + */ +struct sf_buf * +sf_buf_alloc(struct vm_page *m) +{ + struct sf_buf *sf; + int error; + + mtx_lock(&sf_freelist.sf_lock); + while ((sf = SLIST_FIRST(&sf_freelist.sf_head)) == NULL) { + sf_buf_alloc_want++; + error = msleep(&sf_freelist, &sf_freelist.sf_lock, PVM|PCATCH, + "sfbufa", 0); + sf_buf_alloc_want--; + + /* + * If we got a signal, don't risk going back to sleep. + */ + if (error) + break; + } + if (sf != NULL) { + SLIST_REMOVE_HEAD(&sf_freelist.sf_head, free_list); + sf->m = m; + sf->kva = PHYS_TO_DMAP(m->phys_addr); + } + mtx_unlock(&sf_freelist.sf_lock); + return (sf); +} + +/* + * Detatch mapped page and release resources back to the system. + */ +void +sf_buf_free(void *addr, void *args) +{ + struct sf_buf *sf; + struct vm_page *m; + + sf = args; + m = sf->m; + vm_page_lock_queues(); + vm_page_unwire(m, 0); + /* + * Check for the object going away on us. This can + * happen since we don't hold a reference to it. + * If so, we're responsible for freeing the page. + */ + if (m->wire_count == 0 && m->object == NULL) + vm_page_free(m); + vm_page_unlock_queues(); + sf->m = NULL; + mtx_lock(&sf_freelist.sf_lock); + SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list); + if (sf_buf_alloc_want > 0) + wakeup_one(&sf_freelist); + mtx_unlock(&sf_freelist.sf_lock); +} + +/* * Software interrupt handler for queued VM system processing. */ void ==== //depot/projects/uart/amd64/pci/pci_bus.c#4 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/pci/pci_bus.c,v 1.101 2003/08/22 07:36:49 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/pci/pci_bus.c,v 1.102 2003/08/28 21:22:24 jhb Exp $"); #include "opt_cpu.h" @@ -328,10 +328,18 @@ for (slot = 0; slot <= PCI_SLOTMAX; slot++) { func = 0; hdrtype = nexus_pcib_read_config(0, bus, slot, func, - PCIR_HEADERTYPE, 1); + PCIR_HDRTYPE, 1); + /* + * When enumerating bus devices, the standard says that + * one should check the header type and ignore the slots whose + * header types that the software doesn't know about. We use + * this to filter out devices. + */ + if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) + continue; if ((hdrtype & PCIM_MFDEV) && (!found_orion || hdrtype != 0xff)) - pcifunchigh = 7; + pcifunchigh = PCI_FUNCMAX; else pcifunchigh = 0; for (func = 0; func <= pcifunchigh; func++) { ==== //depot/projects/uart/conf/files#19 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/files,v 1.816 2003/08/24 09:22:25 sos Exp $ +# $FreeBSD: src/sys/conf/files,v 1.817 2003/08/29 04:02:18 njl Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -235,7 +235,6 @@ dev/aac/aac_cam.c optional aacp aac dev/aac/aac_linux.c optional aac compat_linux dev/acpica/acpi.c optional acpi -dev/acpica/acpica_support.c optional acpi dev/acpica/acpi_acad.c optional acpi dev/acpica/acpi_battery.c optional acpi dev/acpica/acpi_button.c optional acpi ==== //depot/projects/uart/ddb/db_ps.c#4 (text+ko) ==== @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/ddb/db_ps.c,v 1.48 2003/07/31 17:29:42 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/ddb/db_ps.c,v 1.49 2003/08/30 19:06:57 phk Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -70,7 +70,7 @@ p = &proc0; db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); - db_printf(" pid proc addr uid ppid pgrp flag stat wmesg wchan cmd\n"); + db_printf(" pid proc uarea uid ppid pgrp flag stat wmesg wchan cmd\n"); while (--np >= 0 && !quit) { if (p == NULL) { printf("oops, ran out of processes early!\n"); ==== //depot/projects/uart/dev/acpica/Osd/OsdHardware.c#3 (text+ko) ==== @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/acpica/Osd/OsdHardware.c,v 1.10 2003/07/13 22:57:16 njl Exp $ + * $FreeBSD: src/sys/dev/acpica/Osd/OsdHardware.c,v 1.11 2003/08/28 21:22:25 jhb Exp $ */ /* @@ -213,10 +213,10 @@ return (bus); subclass = pci_cfgregread(bus, slot, func, PCIR_SUBCLASS, 1); /* Find the header type, masking off the multifunction bit */ - header = pci_cfgregread(bus, slot, func, PCIR_HEADERTYPE, 1) & 0x7f; - if (header == 1 && subclass == PCIS_BRIDGE_PCI) + header = pci_cfgregread(bus, slot, func, PCIR_HDRTYPE, 1) & PCIM_HDRTYPE; + if (header == PCIM_HDRTYPE_BRIDGE && subclass == PCIS_BRIDGE_PCI) bus = pci_cfgregread(bus, slot, func, PCIR_SECBUS_1, 1); - if (header == 2 && subclass == PCIS_BRIDGE_CARDBUS) + if (header == PCIM_HDRTYPE_CARDBUS && subclass == PCIS_BRIDGE_CARDBUS) bus = pci_cfgregread(bus, slot, func, PCIR_SECBUS_2, 1); return (bus); } ==== //depot/projects/uart/dev/acpica/acpi.c#7 (text+ko) ==== @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/acpica/acpi.c,v 1.95 2003/08/15 02:10:38 njl Exp $ + * $FreeBSD: src/sys/dev/acpica/acpi.c,v 1.97 2003/08/29 04:02:19 njl Exp $ */ #include "opt_acpi.h" @@ -46,28 +46,18 @@ #include <machine/clock.h> #include <machine/resource.h> - #include <isa/isavar.h> #include "acpi.h" - -#include <dev/acpica/acpica_support.h> - #include <dev/acpica/acpivar.h> #include <dev/acpica/acpiio.h> MALLOC_DEFINE(M_ACPIDEV, "acpidev", "ACPI devices"); -/* - * Hooks for the ACPI CA debugging infrastructure - */ +/* Hooks for the ACPI CA debugging infrastructure */ #define _COMPONENT ACPI_BUS ACPI_MODULE_NAME("ACPI") -/* - * Character device - */ - static d_open_t acpiopen; static d_close_t acpiclose; static d_ioctl_t acpiioctl; @@ -95,34 +85,36 @@ static void acpi_identify(driver_t *driver, device_t parent); static int acpi_probe(device_t dev); static int acpi_attach(device_t dev); -static device_t acpi_add_child(device_t bus, int order, const char *name, int unit); +static device_t acpi_add_child(device_t bus, int order, const char *name, + int unit); static int acpi_print_child(device_t bus, device_t child); -static int acpi_read_ivar(device_t dev, device_t child, int index, uintptr_t *result); -static int acpi_write_ivar(device_t dev, device_t child, int index, uintptr_t value); -static int acpi_set_resource(device_t dev, device_t child, int type, int rid, u_long start, - u_long count); -static int acpi_get_resource(device_t dev, device_t child, int type, int rid, u_long *startp, - u_long *countp); -static struct resource *acpi_alloc_resource(device_t bus, device_t child, int type, int *rid, - u_long start, u_long end, u_long count, u_int flags); -static int acpi_release_resource(device_t bus, device_t child, int type, int rid, struct resource *r); +static int acpi_read_ivar(device_t dev, device_t child, int index, + uintptr_t *result); +static int acpi_write_ivar(device_t dev, device_t child, int index, + uintptr_t value); +static int acpi_set_resource(device_t dev, device_t child, int type, + int rid, u_long start, u_long count); +static int acpi_get_resource(device_t dev, device_t child, int type, + int rid, u_long *startp, u_long *countp); +static struct resource *acpi_alloc_resource(device_t bus, device_t child, + int type, int *rid, u_long start, u_long end, + u_long count, u_int flags); +static int acpi_release_resource(device_t bus, device_t child, int type, + int rid, struct resource *r); static u_int32_t acpi_isa_get_logicalid(device_t dev); static u_int32_t acpi_isa_get_compatid(device_t dev); -static int acpi_isa_pnp_probe(device_t bus, device_t child, struct isa_pnp_id *ids); - +static int acpi_isa_pnp_probe(device_t bus, device_t child, + struct isa_pnp_id *ids); static void acpi_probe_children(device_t bus); -static ACPI_STATUS acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status); - +static ACPI_STATUS acpi_probe_child(ACPI_HANDLE handle, UINT32 level, + void *context, void **status); static void acpi_shutdown_pre_sync(void *arg, int howto); static void acpi_shutdown_final(void *arg, int howto); - static void acpi_enable_fixed_events(struct acpi_softc *sc); - static void acpi_system_eventhandler_sleep(void *arg, int state); static void acpi_system_eventhandler_wakeup(void *arg, int state); static int acpi_supported_sleep_state_sysctl(SYSCTL_HANDLER_ARGS); static int acpi_sleep_state_sysctl(SYSCTL_HANDLER_ARGS); - static int acpi_pm_func(u_long cmd, void *arg, ...); static device_method_t acpi_methods[] = { @@ -165,15 +157,19 @@ DRIVER_MODULE(acpi, nexus, acpi_driver, acpi_devclass, acpi_modevent, 0); MODULE_VERSION(acpi, 100); -SYSCTL_INT(_debug, OID_AUTO, acpi_debug_layer, CTLFLAG_RW, &AcpiDbgLayer, 0, ""); -SYSCTL_INT(_debug, OID_AUTO, acpi_debug_level, CTLFLAG_RW, &AcpiDbgLevel, 0, ""); +SYSCTL_INT(_debug, OID_AUTO, acpi_debug_layer, CTLFLAG_RW, &AcpiDbgLayer, 0, + ""); +SYSCTL_INT(_debug, OID_AUTO, acpi_debug_level, CTLFLAG_RW, &AcpiDbgLevel, 0, + ""); static int acpi_ca_version = ACPI_CA_VERSION; -SYSCTL_INT(_debug, OID_AUTO, acpi_ca_version, CTLFLAG_RD, &acpi_ca_version, 0, ""); +SYSCTL_INT(_debug, OID_AUTO, acpi_ca_version, CTLFLAG_RD, &acpi_ca_version, 0, + ""); /* * ACPI can only be loaded as a module by the loader; activating it after * system bootstrap time is not useful, and can be fatal to the system. - * It also cannot be unloaded, since the entire system bus heirarchy hangs off it. + * It also cannot be unloaded, since the entire system bus heirarchy hangs + * off it. */ static int acpi_modevent(struct module *mod, int event, void *junk) @@ -182,17 +178,17 @@ case MOD_LOAD: if (!cold) { printf("The ACPI driver cannot be loaded after boot.\n"); - return(EPERM); + return (EPERM); } break; case MOD_UNLOAD: if (!cold && power_pm_get_type() == POWER_PM_TYPE_ACPI) - return(EBUSY); + return (EBUSY); break; default: break; } - return(0); + return (0); } /* @@ -201,10 +197,10 @@ static void acpi_identify(driver_t *driver, device_t parent) { - device_t child; - int error; + device_t child; + int error; #ifdef ACPI_DEBUGGER - char *debugpoint; + char *debugpoint; #endif ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); @@ -212,32 +208,26 @@ if (!cold) return_VOID; - /* - * Check that we haven't been disabled with a hint. - */ + /* Check that we haven't been disabled with a hint. */ if (resource_disabled("acpi", 0)) return_VOID; - /* - * Make sure we're not being doubly invoked. - */ + /* Make sure we're not being doubly invoked. */ if (device_find_child(parent, "acpi", 0) != NULL) return_VOID; #if __FreeBSD_version >= 500000 - /* initialise the ACPI mutex */ + /* Initialise the ACPI mutex */ mtx_init(&acpi_mutex, "ACPI global lock", NULL, MTX_DEF); #endif - /* - * Start up the ACPI CA subsystem. - */ + /* Start up the ACPI CA subsystem. */ #ifdef ACPI_DEBUGGER debugpoint = getenv("debug.acpi.debugger"); if (debugpoint) { if (!strcmp(debugpoint, "init")) acpi_EnterDebugger(); - freeenv(debugpoint); + freeenv(debugpoint); } #endif if (ACPI_FAILURE(error = AcpiInitializeSubsystem())) { @@ -249,7 +239,7 @@ if (debugpoint) { if (!strcmp(debugpoint, "tables")) acpi_EnterDebugger(); - freeenv(debugpoint); + freeenv(debugpoint); } #endif @@ -258,12 +248,10 @@ return_VOID; } - /* - * Attach the actual ACPI device. - */ + /* Attach the actual ACPI device. */ if ((child = BUS_ADD_CHILD(parent, 0, "acpi", 0)) == NULL) { - device_printf(parent, "ACPI: could not attach\n"); - return_VOID; + device_printf(parent, "ACPI: could not attach\n"); + return_VOID; } } @@ -282,7 +270,8 @@ ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); if (power_pm_get_type() != POWER_PM_TYPE_NONE && - power_pm_get_type() != POWER_PM_TYPE_ACPI) { + power_pm_get_type() != POWER_PM_TYPE_ACPI) { + device_printf(dev, "Other PM system enabled.\n"); return_VALUE(ENXIO); } @@ -290,7 +279,8 @@ ACPI_LOCK; if (ACPI_FAILURE(status = AcpiGetTableHeader(ACPI_TABLE_XSDT, 1, &th))) { - device_printf(dev, "couldn't get XSDT header: %s\n", AcpiFormatException(status)); + device_printf(dev, "couldn't get XSDT header: %s\n", + AcpiFormatException(status)); error = ENXIO; } else { sprintf(buf, "%.6s %.8s", th.OemId, th.OemTableId); @@ -325,61 +315,61 @@ if (debugpoint) { if (!strcmp(debugpoint, "spaces")) acpi_EnterDebugger(); - freeenv(debugpoint); + freeenv(debugpoint); } #endif - /* - * Install the default address space handlers. - */ + /* Install the default address space handlers. */ error = ENXIO; - if (ACPI_FAILURE(status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_SYSTEM_MEMORY, - ACPI_DEFAULT_HANDLER, - NULL, NULL))) { - device_printf(dev, "could not initialise SystemMemory handler: %s\n", AcpiFormatException(status)); + status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, + ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL); + if (ACPI_FAILURE(status)) { + device_printf(dev, "Could not initialise SystemMemory handler: %s\n", + AcpiFormatException(status)); goto out; } - if (ACPI_FAILURE(status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_SYSTEM_IO, - ACPI_DEFAULT_HANDLER, - NULL, NULL))) { - device_printf(dev, "could not initialise SystemIO handler: %s\n", AcpiFormatException(status)); + status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, + ACPI_ADR_SPACE_SYSTEM_IO, ACPI_DEFAULT_HANDLER, NULL, NULL); + if (ACPI_FAILURE(status)) { + device_printf(dev, "Could not initialise SystemIO handler: %s\n", + AcpiFormatException(status)); goto out; } - if (ACPI_FAILURE(status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, - ACPI_ADR_SPACE_PCI_CONFIG, - ACPI_DEFAULT_HANDLER, - NULL, NULL))) { - device_printf(dev, "could not initialise PciConfig handler: %s\n", AcpiFormatException(status)); + status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT, + ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL); + if (ACPI_FAILURE(status)) { + device_printf(dev, "could not initialise PciConfig handler: %s\n", + AcpiFormatException(status)); goto out; } /* * Bring ACPI fully online. * - * Note that some systems (specifically, those with namespace evaluation issues - * that require the avoidance of parts of the namespace) must avoid running _INI - * and _STA on everything, as well as dodging the final object init pass. + * Note that some systems (specifically, those with namespace evaluation + * issues that require the avoidance of parts of the namespace) must + * avoid running _INI and _STA on everything, as well as dodging the final + * object init pass. * * For these devices, we set ACPI_NO_DEVICE_INIT and ACPI_NO_OBJECT_INIT). * - * XXX We should arrange for the object init pass after we have attached all our - * child devices, but on many systems it works here. + * XXX We should arrange for the object init pass after we have attached + * all our child devices, but on many systems it works here. */ #ifdef ACPI_DEBUGGER debugpoint = getenv("debug.acpi.debugger"); if (debugpoint) { if (!strcmp(debugpoint, "enable")) acpi_EnterDebugger(); - freeenv(debugpoint); + freeenv(debugpoint); } #endif flags = 0; if (testenv("debug.acpi.avoid")) flags = ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT; if (ACPI_FAILURE(status = AcpiEnableSubsystem(flags))) { - device_printf(dev, "could not enable ACPI: %s\n", AcpiFormatException(status)); + device_printf(dev, "Could not enable ACPI: %s\n", + AcpiFormatException(status)); goto out; } @@ -390,7 +380,8 @@ acpi_ec_ecdt_probe(dev); if (ACPI_FAILURE(status = AcpiInitializeObjects(flags))) { - device_printf(dev, "could not initialize ACPI objects: %s\n", AcpiFormatException(status)); + device_printf(dev, "Could not initialize ACPI objects: %s\n", + AcpiFormatException(status)); goto out; } @@ -431,8 +422,8 @@ OID_AUTO, "verbose", CTLFLAG_RD | CTLFLAG_RW, &sc->acpi_verbose, 0, "verbose mode"); SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), - OID_AUTO, "disable_on_poweroff", CTLFLAG_RD | CTLFLAG_RW, - &sc->acpi_disable_on_poweroff, 0, "ACPI subsystem disable on poweroff"); + OID_AUTO, "disable_on_poweroff", CTLFLAG_RD | CTLFLAG_RW, + &sc->acpi_disable_on_poweroff, 0, "ACPI subsystem disable on poweroff"); /* * Default to 5 seconds before sleeping to give some machines time to @@ -472,51 +463,47 @@ } #endif - /* - * Register our shutdown handlers - */ - EVENTHANDLER_REGISTER(shutdown_pre_sync, acpi_shutdown_pre_sync, sc, SHUTDOWN_PRI_LAST); - EVENTHANDLER_REGISTER(shutdown_final, acpi_shutdown_final, sc, SHUTDOWN_PRI_LAST); + /* Register our shutdown handlers */ + EVENTHANDLER_REGISTER(shutdown_pre_sync, acpi_shutdown_pre_sync, sc, + SHUTDOWN_PRI_LAST); + EVENTHANDLER_REGISTER(shutdown_final, acpi_shutdown_final, sc, + SHUTDOWN_PRI_LAST); /* * Register our acpi event handlers. * XXX should be configurable eg. via userland policy manager. */ - EVENTHANDLER_REGISTER(acpi_sleep_event, acpi_system_eventhandler_sleep, sc, ACPI_EVENT_PRI_LAST); - EVENTHANDLER_REGISTER(acpi_wakeup_event, acpi_system_eventhandler_wakeup, sc, ACPI_EVENT_PRI_LAST); + EVENTHANDLER_REGISTER(acpi_sleep_event, acpi_system_eventhandler_sleep, + sc, ACPI_EVENT_PRI_LAST); + EVENTHANDLER_REGISTER(acpi_wakeup_event, acpi_system_eventhandler_wakeup, + sc, ACPI_EVENT_PRI_LAST); - /* - * Flag our initial states. - */ + /* Flag our initial states. */ sc->acpi_enabled = 1; sc->acpi_sstate = ACPI_STATE_S0; sc->acpi_sleep_disabled = 0; - /* - * Create the control device >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200308310645.h7V6j2Bs013269>