diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2014-03-13 03:52:57 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2014-03-13 03:52:57 +0000 |
commit | ddb81f81c6b53bdfc4bba2ced060724d2beb0270 (patch) | |
tree | 84af82316dccb1276e4f2db46dffa3136279a846 /sys | |
parent | 755327f10676720e29b6c5b380070fbdca133628 (diff) |
get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.
have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.
discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.
Diffstat (limited to 'sys')
33 files changed, 181 insertions, 108 deletions
diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c index b63dcfd3907..61c5dd8743a 100644 --- a/sys/arch/alpha/alpha/machdep.c +++ b/sys/arch/alpha/alpha/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.149 2014/02/18 19:37:32 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.150 2014/03/13 03:52:55 dlg Exp $ */ /* $NetBSD: machdep.c,v 1.210 2000/06/01 17:12:38 thorpej Exp $ */ /*- @@ -977,6 +977,7 @@ void boot(howto) int howto; { + struct device *mainbus; #if defined(MULTIPROCESSOR) u_long wait_mask; int i; @@ -1042,8 +1043,9 @@ boot(howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); #ifdef BOOTKEY printf("hit any key to %s...\n", howto & RB_HALT ? "halt" : "reboot"); diff --git a/sys/arch/amd64/amd64/acpi_machdep.c b/sys/arch/amd64/amd64/acpi_machdep.c index f8fce2d08ed..76bd120b04a 100644 --- a/sys/arch/amd64/amd64/acpi_machdep.c +++ b/sys/arch/amd64/amd64/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_machdep.c,v 1.57 2014/01/21 09:40:54 kettenis Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.58 2014/03/13 03:52:55 dlg Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * @@ -318,7 +318,7 @@ acpi_sleep_cpu(struct acpi_softc *sc, int state) * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + config_suspend(device_mainbus(), DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; acpi_sleep_pm(sc, state); diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index f63bb386144..ff40d3346b1 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.173 2014/01/05 20:23:56 mlarkin Exp $ */ +/* $OpenBSD: machdep.c,v 1.174 2014/03/13 03:52:55 dlg Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -745,6 +745,8 @@ struct pcb dumppcb; void boot(int howto) { + struct device *mainbus; + if (howto & RB_POWERDOWN) lid_suspend = 0; @@ -788,8 +790,9 @@ boot(int howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); #ifdef MULTIPROCESSOR x86_broadcast_ipi(X86_IPI_HALT); diff --git a/sys/arch/arm/xscale/pxa2x0_apm.c b/sys/arch/arm/xscale/pxa2x0_apm.c index 8f55ff95b54..7d4a97388a3 100644 --- a/sys/arch/arm/xscale/pxa2x0_apm.c +++ b/sys/arch/arm/xscale/pxa2x0_apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pxa2x0_apm.c,v 1.41 2013/12/06 21:03:05 deraadt Exp $ */ +/* $OpenBSD: pxa2x0_apm.c,v 1.42 2014/03/13 03:52:55 dlg Exp $ */ /*- * Copyright (c) 2001 Alexander Guy. All rights reserved. @@ -306,6 +306,7 @@ apm_power_info(struct pxa2x0_apm_softc *sc, void apm_suspend(struct pxa2x0_apm_softc *sc) { + struct device *mainbus = device_mainbus(); int s; #if NWSDISPLAY > 0 @@ -320,14 +321,14 @@ apm_suspend(struct pxa2x0_apm_softc *sc) sc->sc_suspend(sc); s = splhigh(); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_SUSPEND); + config_suspend(mainbus, DVACT_SUSPEND); /* XXX * Flag to disk drivers that they should "power down" the disk * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + config_suspend(mainbus, DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; splx(s); @@ -338,10 +339,11 @@ apm_suspend(struct pxa2x0_apm_softc *sc) void apm_resume(struct pxa2x0_apm_softc *sc) { + struct device *mainbus = device_mainbus(); int s; s = splhigh(); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_RESUME); + config_suspend(mainbus, DVACT_RESUME); splx(s); inittodr(0); @@ -355,7 +357,7 @@ apm_resume(struct pxa2x0_apm_softc *sc) bufq_restart(); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_WAKEUP); + config_suspend(mainbus, DVACT_WAKEUP); #if NWSDISPLAY > 0 wsdisplay_resume(); diff --git a/sys/arch/armish/armish/armish_machdep.c b/sys/arch/armish/armish/armish_machdep.c index b3b6ec557c9..c85f2bef99a 100644 --- a/sys/arch/armish/armish/armish_machdep.c +++ b/sys/arch/armish/armish/armish_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: armish_machdep.c,v 1.21 2013/11/13 18:30:48 jasper Exp $ */ +/* $OpenBSD: armish_machdep.c,v 1.22 2014/03/13 03:52:55 dlg Exp $ */ /* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */ /* @@ -282,8 +282,9 @@ boot(int howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); /* Make sure IRQ's are disabled */ IRQdisable; diff --git a/sys/arch/armv7/armv7/armv7_machdep.c b/sys/arch/armv7/armv7/armv7_machdep.c index 347aa8b6c84..bbc53753390 100644 --- a/sys/arch/armv7/armv7/armv7_machdep.c +++ b/sys/arch/armv7/armv7/armv7_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7_machdep.c,v 1.4 2013/11/13 17:30:44 syl Exp $ */ +/* $OpenBSD: armv7_machdep.c,v 1.5 2014/03/13 03:52:55 dlg Exp $ */ /* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */ /* @@ -245,19 +245,22 @@ int comcnmode = CONMODE; void boot(int howto) { + struct device *mainbus; #ifdef DIAGNOSTIC /* info */ printf("boot: howto=%08x curproc=%p\n", howto, curproc); #endif + mainbus = device_mainbus(); + /* * If we are still cold then hit the air brakes * and crash to earth fast */ if (cold) { doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if ((howto & (RB_HALT | RB_USERREQ)) != RB_USERREQ) { printf("The operating system has halted.\n"); printf("Please press any key to reboot.\n\n"); @@ -297,8 +300,8 @@ boot(int howto) /* Run any shutdown hooks */ doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); /* Make sure IRQ's are disabled */ IRQdisable; diff --git a/sys/arch/aviion/aviion/machdep.c b/sys/arch/aviion/aviion/machdep.c index 21c3585eb72..a8cb5910640 100644 --- a/sys/arch/aviion/aviion/machdep.c +++ b/sys/arch/aviion/aviion/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.60 2014/01/19 12:45:35 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.61 2014/03/13 03:52:55 dlg Exp $ */ /* * Copyright (c) 2007 Miodrag Vallat. * @@ -295,6 +295,8 @@ __dead void boot(howto) int howto; { + struct device *mainbus; + /* take a snapshot before clobbering any registers */ if (curproc && curproc->p_addr) savectx(curpcb); @@ -331,8 +333,9 @@ boot(howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if (howto & RB_HALT) { printf("System halted.\n\n"); diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c index 775b3637469..d4808dfddf6 100644 --- a/sys/arch/hp300/hp300/machdep.c +++ b/sys/arch/hp300/hp300/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.140 2013/11/20 23:57:07 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.141 2014/03/13 03:52:55 dlg Exp $ */ /* $NetBSD: machdep.c,v 1.121 1999/03/26 23:41:29 mycroft Exp $ */ /* @@ -570,6 +570,8 @@ void boot(howto) int howto; { + struct device *mainbus; + /* take a snap shot before clobbering any registers */ if (curproc && curproc->p_addr) savectx(&curproc->p_addr->u_pcb); @@ -616,8 +618,9 @@ boot(howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); /* Finally, halt/reboot the system. */ if (howto & RB_HALT) { diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c index 172f5a5a8d3..bbec65937c7 100644 --- a/sys/arch/hppa/hppa/machdep.c +++ b/sys/arch/hppa/hppa/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.213 2013/11/23 07:20:52 uebayasi Exp $ */ +/* $OpenBSD: machdep.c,v 1.214 2014/03/13 03:52:55 dlg Exp $ */ /* * Copyright (c) 1999-2003 Michael Shalayeff @@ -878,6 +878,8 @@ int waittime = -1; void boot(int howto) { + struct device *mainbus; + /* * On older systems without software power control, prevent mi code * from spinning disks off, in case the operator changes his mind @@ -922,8 +924,9 @@ boot(int howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); #ifdef MULTIPROCESSOR hppa_ipi_broadcast(HPPA_IPI_HALT); diff --git a/sys/arch/hppa64/hppa64/machdep.c b/sys/arch/hppa64/hppa64/machdep.c index 5fe3d4208e8..46e628da809 100644 --- a/sys/arch/hppa64/hppa64/machdep.c +++ b/sys/arch/hppa64/hppa64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.53 2013/11/23 07:20:52 uebayasi Exp $ */ +/* $OpenBSD: machdep.c,v 1.54 2014/03/13 03:52:55 dlg Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -537,6 +537,8 @@ int waittime = -1; void boot(int howto) { + struct device *mainbus; + /* If system is cold, just halt. */ if (cold) { /* (Unless the user explicitly asked for reboot.) */ @@ -572,8 +574,9 @@ boot(int howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); /* in case we came on powerfail interrupt */ if (cold_hook) diff --git a/sys/arch/i386/i386/acpi_machdep.c b/sys/arch/i386/i386/acpi_machdep.c index b8238257f51..2af0f10c6f3 100644 --- a/sys/arch/i386/i386/acpi_machdep.c +++ b/sys/arch/i386/i386/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_machdep.c,v 1.51 2014/01/24 21:20:23 kettenis Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.52 2014/03/13 03:52:55 dlg Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * @@ -341,7 +341,7 @@ acpi_sleep_cpu(struct acpi_softc *sc, int state) * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + config_suspend(device_mainbus(), DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; acpi_sleep_pm(sc, state); diff --git a/sys/arch/i386/i386/apm.c b/sys/arch/i386/i386/apm.c index 99767ce2cf7..15ced565928 100644 --- a/sys/arch/i386/i386/apm.c +++ b/sys/arch/i386/i386/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.102 2013/12/06 21:03:05 deraadt Exp $ */ +/* $OpenBSD: apm.c,v 1.103 2014/03/13 03:52:55 dlg Exp $ */ /*- * Copyright (c) 1998-2001 Michael Shalayeff. All rights reserved. @@ -242,6 +242,7 @@ apm_perror(const char *str, struct apmregs *regs) void apm_suspend(int state) { + struct device *mainbus = device_mainbus(); extern int perflevel; int s; @@ -249,18 +250,18 @@ apm_suspend(int state) wsdisplay_suspend(); #endif /* NWSDISPLAY > 0 */ bufq_quiesce(); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_QUIESCE); + config_suspend(mainbus, DVACT_QUIESCE); s = splhigh(); disable_intr(); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_SUSPEND); + config_suspend(mainbus, DVACT_SUSPEND); /* XXX * Flag to disk drivers that they should "power down" the disk * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + config_suspend(mainbus, DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; /* Send machine to sleep */ @@ -273,7 +274,7 @@ apm_suspend(int state) rtcstart(); /* in i8254 mode, rtc is profclock */ inittodr(time_second); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_RESUME); + config_suspend(mainbus, DVACT_RESUME); enable_intr(); splx(s); @@ -282,7 +283,7 @@ apm_suspend(int state) cpu_setperf(perflevel); bufq_restart(); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_WAKEUP); + config_suspend(mainbus, DVACT_WAKEUP); #if NWSDISPLAY > 0 wsdisplay_resume(); diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index f1c873cdf75..58c2f80af66 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.531 2014/01/05 20:23:57 mlarkin Exp $ */ +/* $OpenBSD: machdep.c,v 1.532 2014/03/13 03:52:55 dlg Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -2571,6 +2571,8 @@ struct pcb dumppcb; void boot(int howto) { + struct device *mainbus; + if (howto & RB_POWERDOWN) lid_suspend = 0; @@ -2617,8 +2619,9 @@ boot(int howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); #ifdef MULTIPROCESSOR i386_broadcast_ipi(I386_IPI_HALT); diff --git a/sys/arch/landisk/landisk/machdep.c b/sys/arch/landisk/landisk/machdep.c index ceddf4021fd..1c609da4726 100644 --- a/sys/arch/landisk/landisk/machdep.c +++ b/sys/arch/landisk/landisk/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.29 2013/09/28 12:40:30 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.30 2014/03/13 03:52:55 dlg Exp $ */ /* $NetBSD: machdep.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */ /*- @@ -192,6 +192,7 @@ landisk_startup(int howto, char *_esym) void boot(int howto) { + struct device *mainbus; if (cold) { if ((howto & RB_USERREQ) == 0) @@ -222,8 +223,9 @@ boot(int howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { _reg_write_1(LANDISK_PWRMNG, PWRMNG_POWEROFF); diff --git a/sys/arch/loongson/dev/apm.c b/sys/arch/loongson/dev/apm.c index d85c32cd520..7ffc588d9ce 100644 --- a/sys/arch/loongson/dev/apm.c +++ b/sys/arch/loongson/dev/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.17 2013/12/06 21:03:05 deraadt Exp $ */ +/* $OpenBSD: apm.c,v 1.18 2014/03/13 03:52:55 dlg Exp $ */ /*- * Copyright (c) 2001 Alexander Guy. All rights reserved. @@ -360,6 +360,7 @@ apm_record_event(u_int event, const char *src, const char *msg) int apm_suspend(int state) { + struct device *mainbus = device_mainbus(); int rv; int s; @@ -370,13 +371,13 @@ apm_suspend(int state) resettodr(); bufq_quiesce(); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_QUIESCE); + config_suspend(mainbus, DVACT_QUIESCE); s = splhigh(); (void)disableintr(); cold = 1; - rv = config_suspend(TAILQ_FIRST(&alldevs), DVACT_SUSPEND); + rv = config_suspend(mainbus, DVACT_SUSPEND); #ifdef HIBERNATE if (state == APM_IOC_HIBERNATE) { @@ -395,7 +396,7 @@ apm_suspend(int state) * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; - (void) config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + (void) config_suspend(mainbus, DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; if (rv == 0) { @@ -404,7 +405,7 @@ apm_suspend(int state) rv = sys_platform->resume(); } inittodr(time_second); /* Move the clock forward */ - config_suspend(TAILQ_FIRST(&alldevs), DVACT_RESUME); + config_suspend(mainbus, DVACT_RESUME); cold = 0; (void)enableintr(); @@ -412,7 +413,7 @@ apm_suspend(int state) bufq_restart(); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_WAKEUP); + config_suspend(mainbus, DVACT_WAKEUP); #if NWSDISPLAY > 0 wsdisplay_resume(); diff --git a/sys/arch/loongson/loongson/machdep.c b/sys/arch/loongson/loongson/machdep.c index bd328ef8bbc..05412107ff6 100644 --- a/sys/arch/loongson/loongson/machdep.c +++ b/sys/arch/loongson/loongson/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.43 2013/09/28 12:40:30 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.44 2014/03/13 03:52:55 dlg Exp $ */ /* * Copyright (c) 2009, 2010 Miodrag Vallat. @@ -814,6 +814,7 @@ int waittime = -1; void boot(int howto) { + struct device *mainbus; /* Take a snapshot before clobbering any registers. */ if (curproc) @@ -861,8 +862,9 @@ boot(int howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if (howto & RB_HALT) { if (howto & RB_POWERDOWN) { diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c index 2946e5af93b..3c432358cd3 100644 --- a/sys/arch/luna88k/luna88k/machdep.c +++ b/sys/arch/luna88k/luna88k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.94 2014/01/19 12:45:35 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.95 2014/03/13 03:52:55 dlg Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -469,6 +469,8 @@ __dead void boot(howto) int howto; { + struct device *mainbus; + /* take a snapshot before clobbering any registers */ if (curproc && curproc->p_addr) savectx(curpcb); @@ -505,8 +507,9 @@ boot(howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); /* Luna88k supports automatic powerdown */ if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c index ce7b9ddd17a..02a5ff8cf32 100644 --- a/sys/arch/macppc/macppc/machdep.c +++ b/sys/arch/macppc/macppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.144 2014/02/08 13:17:38 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.145 2014/03/13 03:52:55 dlg Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -803,6 +803,7 @@ lcsplx(int ipl) void boot(int howto) { + struct device *mainbus; static int syncing; if (cold) { @@ -841,8 +842,9 @@ boot(int howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if (howto & RB_HALT) { if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { diff --git a/sys/arch/mvme68k/mvme68k/machdep.c b/sys/arch/mvme68k/mvme68k/machdep.c index 4fc09ca1823..e8ca9b58c1f 100644 --- a/sys/arch/mvme68k/mvme68k/machdep.c +++ b/sys/arch/mvme68k/mvme68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.131 2013/09/28 12:40:31 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.132 2014/03/13 03:52:55 dlg Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -451,6 +451,8 @@ __dead void boot(howto) int howto; { + struct device *mainbus; + /* If system is cold, just halt. */ if (cold) { /* (Unless the user explicitly asked for reboot.) */ @@ -493,8 +495,9 @@ boot(howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if (howto & RB_HALT) { printf("System halted. Press any key to reboot...\n\n"); diff --git a/sys/arch/mvme88k/mvme88k/machdep.c b/sys/arch/mvme88k/mvme88k/machdep.c index 81aeae3376e..018cef9a92a 100644 --- a/sys/arch/mvme88k/mvme88k/machdep.c +++ b/sys/arch/mvme88k/mvme88k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.259 2014/01/19 12:45:35 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.260 2014/03/13 03:52:55 dlg Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -344,6 +344,8 @@ __dead void boot(howto) int howto; { + struct device *mainbus; + /* take a snapshot before clobbering any registers */ if (curproc && curproc->p_addr) savectx(curpcb); @@ -380,8 +382,9 @@ boot(howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if (howto & RB_HALT) { printf("System halted. Press any key to reboot...\n\n"); diff --git a/sys/arch/octeon/octeon/machdep.c b/sys/arch/octeon/octeon/machdep.c index 33a9da33443..b8550bc970e 100644 --- a/sys/arch/octeon/octeon/machdep.c +++ b/sys/arch/octeon/octeon/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.42 2014/03/09 10:12:17 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.43 2014/03/13 03:52:55 dlg Exp $ */ /* * Copyright (c) 2009, 2010 Miodrag Vallat. @@ -646,6 +646,7 @@ int waittime = -1; void boot(int howto) { + struct device *mainbus; /* Take a snapshot before clobbering any registers. */ if (curproc) @@ -693,8 +694,9 @@ boot(int howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if (howto & RB_HALT) { if (howto & RB_POWERDOWN) diff --git a/sys/arch/sgi/sgi/machdep.c b/sys/arch/sgi/sgi/machdep.c index 96114a5ea23..5e964d2ba75 100644 --- a/sys/arch/sgi/sgi/machdep.c +++ b/sys/arch/sgi/sgi/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.134 2014/03/09 10:12:17 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.135 2014/03/13 03:52:55 dlg Exp $ */ /* * Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -820,6 +820,7 @@ int waittime = -1; void boot(int howto) { + struct device *mainbus; /* Take a snapshot before clobbering any registers. */ if (curproc) @@ -867,8 +868,9 @@ boot(int howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if (howto & RB_HALT) { if (howto & RB_POWERDOWN) diff --git a/sys/arch/socppc/socppc/machdep.c b/sys/arch/socppc/socppc/machdep.c index f492f01f7db..59d0c15e05c 100644 --- a/sys/arch/socppc/socppc/machdep.c +++ b/sys/arch/socppc/socppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.39 2014/01/06 16:17:33 uebayasi Exp $ */ +/* $OpenBSD: machdep.c,v 1.40 2014/03/13 03:52:55 dlg Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -1037,6 +1037,7 @@ void boot(int howto) { static int syncing; + struct device *mainbus; if (cold) { /* @@ -1074,8 +1075,9 @@ boot(int howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if (howto & RB_HALT) { if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { diff --git a/sys/arch/solbourne/solbourne/machdep.c b/sys/arch/solbourne/solbourne/machdep.c index e512ccab7d5..c5371c495c0 100644 --- a/sys/arch/solbourne/solbourne/machdep.c +++ b/sys/arch/solbourne/solbourne/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.27 2013/11/20 23:57:07 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.28 2014/03/13 03:52:55 dlg Exp $ */ /* OpenBSD: machdep.c,v 1.105 2005/04/11 15:13:01 deraadt Exp */ /* @@ -519,6 +519,7 @@ boot(howto) { int i; static char str[4]; /* room for "-sd\0" */ + struct device *mainbus; /* If system is cold, just halt. */ if (cold) { @@ -560,8 +561,9 @@ boot(howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if ((howto & RB_HALT) || (howto & RB_POWERDOWN)) { printf("halted\n\n"); diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c index 70fd6f7230b..d336fae3e45 100644 --- a/sys/arch/sparc/sparc/machdep.c +++ b/sys/arch/sparc/sparc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.147 2013/09/28 12:40:32 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.148 2014/03/13 03:52:55 dlg Exp $ */ /* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */ /* @@ -528,6 +528,7 @@ boot(howto) { int i; static char str[4]; /* room for "-sd\0" */ + struct device *mainbus; /* If system is cold, just halt. */ if (cold) { @@ -569,8 +570,9 @@ boot(howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if ((howto & RB_HALT) || (howto & RB_POWERDOWN)) { #if defined(SUN4M) diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c index be3d7ca1675..23ff1327fd9 100644 --- a/sys/arch/sparc64/sparc64/machdep.c +++ b/sys/arch/sparc64/sparc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.149 2013/11/01 17:36:19 krw Exp $ */ +/* $OpenBSD: machdep.c,v 1.150 2014/03/13 03:52:56 dlg Exp $ */ /* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */ /*- @@ -610,6 +610,7 @@ boot(howto) { int i; static char str[128]; + struct device *mainbus; /* If system is cold, just halt. */ if (cold) { @@ -655,8 +656,9 @@ boot(howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); /* If powerdown was requested, do it. */ if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { diff --git a/sys/arch/vax/vax/machdep.c b/sys/arch/vax/vax/machdep.c index 80ad24114ac..79a451bf828 100644 --- a/sys/arch/vax/vax/machdep.c +++ b/sys/arch/vax/vax/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.130 2013/11/24 22:08:25 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.131 2014/03/13 03:52:56 dlg Exp $ */ /* $NetBSD: machdep.c,v 1.108 2000/09/13 15:00:23 thorpej Exp $ */ /* @@ -512,6 +512,8 @@ void boot(howto) register int howto; { + struct device *mainbus; + /* If system is cold, just halt. */ if (cold) { /* (Unless the user explicitly asked for reboot.) */ @@ -545,8 +547,9 @@ boot(howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); if (howto & RB_HALT) { if (dep_call->cpu_halt) diff --git a/sys/arch/zaurus/dev/zaurus_apm.c b/sys/arch/zaurus/dev/zaurus_apm.c index b01ffd2a5dc..942f4bca837 100644 --- a/sys/arch/zaurus/dev/zaurus_apm.c +++ b/sys/arch/zaurus/dev/zaurus_apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zaurus_apm.c,v 1.24 2013/12/06 21:03:05 deraadt Exp $ */ +/* $OpenBSD: zaurus_apm.c,v 1.25 2014/03/13 03:52:56 dlg Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de> @@ -570,7 +570,7 @@ zapm_suspend(struct pxa2x0_apm_softc *pxa_sc) struct zapm_softc *sc = (struct zapm_softc *)pxa_sc; bufq_quiesce(); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_QUIESCE); + config_suspend(device_mainbus(), DVACT_QUIESCE); /* Poll in suspended mode and forget the discharge timeout. */ sc->sc_suspended = 1; @@ -642,6 +642,7 @@ zapm_resume(struct pxa2x0_apm_softc *pxa_sc) void zapm_poweroff(void) { + struct device *mainbus = device_mainbus(); struct pxa2x0_apm_softc *sc; int s; @@ -653,14 +654,14 @@ zapm_poweroff(void) #endif /* NWSDISPLAY > 0 */ s = splhigh(); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_SUSPEND); + config_suspend(mainbus, DVACT_SUSPEND); /* XXX * Flag to disk drivers that they should "power down" the disk * when we get to DVACT_POWERDOWN. */ boothowto |= RB_POWERDOWN; - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + config_suspend(mainbus, DVACT_POWERDOWN); boothowto &= ~RB_POWERDOWN; /* XXX enable charging during suspend */ @@ -682,12 +683,12 @@ zapm_poweroff(void) zapm_restart(); /* NOTREACHED */ - config_suspend(TAILQ_FIRST(&alldevs), DVACT_RESUME); + config_suspend(mainbus, DVACT_RESUME); splx(s); bufq_restart(); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_WAKEUP); + config_suspend(mainbus, DVACT_WAKEUP); #if NWSDISPLAY > 0 wsdisplay_resume(); diff --git a/sys/arch/zaurus/zaurus/zaurus_machdep.c b/sys/arch/zaurus/zaurus/zaurus_machdep.c index 2ccc0236ad6..68bb1738332 100644 --- a/sys/arch/zaurus/zaurus/zaurus_machdep.c +++ b/sys/arch/zaurus/zaurus/zaurus_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zaurus_machdep.c,v 1.40 2013/09/28 14:16:42 miod Exp $ */ +/* $OpenBSD: zaurus_machdep.c,v 1.41 2014/03/13 03:52:56 dlg Exp $ */ /* $NetBSD: lubbock_machdep.c,v 1.2 2003/07/15 00:25:06 lukem Exp $ */ /* @@ -289,6 +289,7 @@ int comcnmode = CONMODE; void boot(int howto) { + struct device *mainbus; extern int lid_suspend; if (howto & RB_POWERDOWN) @@ -323,8 +324,9 @@ boot(int howto) haltsys: doshutdownhooks(); - if (!TAILQ_EMPTY(&alldevs)) - config_suspend(TAILQ_FIRST(&alldevs), DVACT_POWERDOWN); + mainbus = device_mainbus(); + if (mainbus != NULL) + config_suspend(mainbus, DVACT_POWERDOWN); /* Make sure IRQ's are disabled */ IRQdisable; diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 8c9f6064c7a..be06c51ea35 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.253 2014/02/21 23:48:38 deraadt Exp $ */ +/* $OpenBSD: acpi.c,v 1.254 2014/03/13 03:52:56 dlg Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -2098,6 +2098,7 @@ acpi_indicator(struct acpi_softc *sc, int led_state) int acpi_sleep_state(struct acpi_softc *sc, int state) { + struct device *mainbus = device_mainbus(); int error = ENXIO; int s; @@ -2127,7 +2128,7 @@ acpi_sleep_state(struct acpi_softc *sc, int state) #endif /* NWSDISPLAY > 0 */ bufq_quiesce(); - if (config_suspend(TAILQ_FIRST(&alldevs), DVACT_QUIESCE)) + if (config_suspend(mainbus, DVACT_QUIESCE)) goto fail_quiesce; #ifdef MULTIPROCESSOR @@ -2140,7 +2141,7 @@ acpi_sleep_state(struct acpi_softc *sc, int state) disable_intr(); /* PSL_I for resume; PIC/APIC broken until repair */ cold = 1; /* Force other code to delay() instead of tsleep() */ - if (config_suspend(TAILQ_FIRST(&alldevs), DVACT_SUSPEND) != 0) + if (config_suspend(mainbus, DVACT_SUSPEND) != 0) goto fail_suspend; acpi_sleep_clocks(sc, state); @@ -2172,7 +2173,7 @@ acpi_sleep_state(struct acpi_softc *sc, int state) acpi_resume_cpu(sc); fail_pts: - config_suspend(TAILQ_FIRST(&alldevs), DVACT_RESUME); + config_suspend(mainbus, DVACT_RESUME); fail_suspend: cold = 0; @@ -2192,7 +2193,7 @@ fail_suspend: fail_quiesce: bufq_restart(); - config_suspend(TAILQ_FIRST(&alldevs), DVACT_WAKEUP); + config_suspend(mainbus, DVACT_WAKEUP); #if NWSDISPLAY > 0 wsdisplay_resume(); diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index 63909888184..390dee9ca8b 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_autoconf.c,v 1.73 2013/12/12 20:56:01 guenther Exp $ */ +/* $OpenBSD: subr_autoconf.c,v 1.74 2014/03/13 03:52:56 dlg Exp $ */ /* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */ /* @@ -859,6 +859,16 @@ device_lookup(struct cfdriver *cd, int unit) return (dv); } +struct device * +device_mainbus(void) +{ + extern struct cfdriver mainbus_cd; + + if (mainbus_cd.cd_ndevs < 1) + return (NULL); + + return (mainbus_cd.cd_devs[0]); +} /* * Increments the ref count on the device structure. The device diff --git a/sys/kern/subr_hibernate.c b/sys/kern/subr_hibernate.c index 147a3e1803b..4d0efd949c6 100644 --- a/sys/kern/subr_hibernate.c +++ b/sys/kern/subr_hibernate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_hibernate.c,v 1.84 2014/02/01 07:10:33 mlarkin Exp $ */ +/* $OpenBSD: subr_hibernate.c,v 1.85 2014/03/13 03:52:56 dlg Exp $ */ /* * Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl> @@ -1152,14 +1152,14 @@ hibernate_resume(void) if (hibernate_read_image(&disk_hib)) goto fail; - if (config_suspend(TAILQ_FIRST(&alldevs), DVACT_QUIESCE) != 0) + if (config_suspend(device_mainbus(), DVACT_QUIESCE) != 0) goto fail; (void) splhigh(); hibernate_disable_intr_machdep(); cold = 1; - if (config_suspend(TAILQ_FIRST(&alldevs), DVACT_SUSPEND) != 0) { + if (config_suspend(device_mainbus(), DVACT_SUSPEND) != 0) { cold = 0; hibernate_enable_intr_machdep(); goto fail; diff --git a/sys/sys/device.h b/sys/sys/device.h index cf30e781e24..0758e40a877 100644 --- a/sys/sys/device.h +++ b/sys/sys/device.h @@ -1,4 +1,4 @@ -/* $OpenBSD: device.h,v 1.47 2013/12/06 21:03:01 deraadt Exp $ */ +/* $OpenBSD: device.h,v 1.48 2014/03/13 03:52:56 dlg Exp $ */ /* $NetBSD: device.h,v 1.15 1996/04/09 20:55:24 cgd Exp $ */ /* @@ -188,6 +188,7 @@ void config_defer(struct device *, void (*)(struct device *)); void config_pending_incr(void); void config_pending_decr(void); +struct device *device_mainbus(void); struct device *device_lookup(struct cfdriver *, int unit); void device_ref(struct device *); void device_unref(struct device *); |