svn commit: r215696 - in stable/8/sys: conf powerpc/aim
powerpc/booke powerpc/include powerpc/mpc85xx
powerpc/powermac powerpc/powerpc
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Mon Nov 22 17:39:19 UTC 2010
Author: nwhitehorn
Date: Mon Nov 22 17:39:18 2010
New Revision: 215696
URL: http://svn.freebsd.org/changeset/base/215696
Log:
MFC r212054:
Restructure how reset and poweroff are handled on PowerPC systems, since
the existing code was very platform specific, and broken for SMP systems
trying to reboot from KDB.
- Add a new PLATFORM_RESET() method to the platform KOBJ interface, and
migrate existing reset functions into platform modules.
- Modify the OF_reboot() routine to submit the request by hand to avoid
the IPIs involved in the regular openfirmware() routine. This fixes
reboot from KDB on SMP machines.
- Move non-KDB reset and poweroff functions on the Powermac platform
into the relevant power control drivers (cuda, pmu, smu), instead of
using them through the Open Firmware backdoor.
- Rename platform_chrp to platform_powermac since it has become
increasingly Powermac specific. When we gain support for IBM systems,
we will grow a new platform_chrp.
Added:
stable/8/sys/powerpc/powermac/platform_powermac.c
- copied unchanged from r212054, head/sys/powerpc/powermac/platform_powermac.c
Modified:
stable/8/sys/conf/files.powerpc
stable/8/sys/powerpc/aim/machdep.c
stable/8/sys/powerpc/aim/ofw_machdep.c
stable/8/sys/powerpc/aim/vm_machdep.c
stable/8/sys/powerpc/booke/platform_bare.c
stable/8/sys/powerpc/include/ofw_machdep.h
stable/8/sys/powerpc/mpc85xx/mpc85xx.c
stable/8/sys/powerpc/powermac/cuda.c
stable/8/sys/powerpc/powermac/pmu.c
stable/8/sys/powerpc/powermac/smu.c
stable/8/sys/powerpc/powerpc/platform.c
stable/8/sys/powerpc/powerpc/platform_if.m
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/conf/files.powerpc
==============================================================================
--- stable/8/sys/conf/files.powerpc Mon Nov 22 17:15:41 2010 (r215695)
+++ stable/8/sys/conf/files.powerpc Mon Nov 22 17:39:18 2010 (r215696)
@@ -82,7 +82,6 @@ powerpc/aim/mp_cpudep.c optional aim sm
powerpc/aim/nexus.c optional aim
powerpc/aim/ofw_machdep.c optional aim
powerpc/aim/ofwmagic.S optional aim
-powerpc/aim/platform_chrp.c optional aim
powerpc/aim/swtch.S optional aim
powerpc/aim/trap.c optional aim
powerpc/aim/uma_machdep.c optional aim
@@ -137,6 +136,7 @@ powerpc/powermac/kiic.c optional powerm
powerpc/powermac/macgpio.c optional powermac pci
powerpc/powermac/macio.c optional powermac pci
powerpc/powermac/openpic_macio.c optional powermac pci
+powerpc/powermac/platform_powermac.c optional powermac
powerpc/powermac/pswitch.c optional powermac pswitch
powerpc/powermac/pmu.c optional powermac pmu
powerpc/powermac/smu.c optional powermac smu
Modified: stable/8/sys/powerpc/aim/machdep.c
==============================================================================
--- stable/8/sys/powerpc/aim/machdep.c Mon Nov 22 17:15:41 2010 (r215695)
+++ stable/8/sys/powerpc/aim/machdep.c Mon Nov 22 17:39:18 2010 (r215696)
@@ -167,15 +167,6 @@ struct bat battable[16];
struct kva_md_info kmi;
static void
-powerpc_ofw_shutdown(void *junk, int howto)
-{
- if (howto & RB_HALT) {
- OF_halt();
- }
- OF_reboot();
-}
-
-static void
cpu_startup(void *dummy)
{
@@ -227,9 +218,6 @@ cpu_startup(void *dummy)
*/
bufinit();
vm_pager_bufferinit();
-
- EVENTHANDLER_REGISTER(shutdown_final, powerpc_ofw_shutdown, 0,
- SHUTDOWN_PRI_LAST);
}
extern char kernel_text[], _end[];
Modified: stable/8/sys/powerpc/aim/ofw_machdep.c
==============================================================================
--- stable/8/sys/powerpc/aim/ofw_machdep.c Mon Nov 22 17:15:41 2010 (r215695)
+++ stable/8/sys/powerpc/aim/ofw_machdep.c Mon Nov 22 17:39:18 2010 (r215696)
@@ -463,20 +463,21 @@ openfirmware(void *args)
}
void
-OF_halt()
-{
- int retval; /* dummy, this may not be needed */
-
- OF_interpret("shut-down", 1, &retval);
- for (;;); /* just in case */
-}
-
-void
OF_reboot()
{
- int retval; /* dummy, this may not be needed */
+ struct {
+ cell_t name;
+ cell_t nargs;
+ cell_t nreturns;
+ cell_t arg;
+ } args;
+
+ args.name = (cell_t)(uintptr_t)"interpret";
+ args.nargs = 1;
+ args.nreturns = 0;
+ args.arg = (cell_t)(uintptr_t)"reset-all";
+ openfirmware_core(&args); /* Don't do rendezvous! */
- OF_interpret("reset-all", 1, &retval);
for (;;); /* just in case */
}
Modified: stable/8/sys/powerpc/aim/vm_machdep.c
==============================================================================
--- stable/8/sys/powerpc/aim/vm_machdep.c Mon Nov 22 17:15:41 2010 (r215695)
+++ stable/8/sys/powerpc/aim/vm_machdep.c Mon Nov 22 17:39:18 2010 (r215696)
@@ -225,15 +225,6 @@ cpu_exit(td)
}
/*
- * Reset back to firmware.
- */
-void
-cpu_reset()
-{
- OF_reboot();
-}
-
-/*
* Allocate a pool of sf_bufs (sendfile(2) or "super-fast" if you prefer. :-))
*/
static void
Modified: stable/8/sys/powerpc/booke/platform_bare.c
==============================================================================
--- stable/8/sys/powerpc/booke/platform_bare.c Mon Nov 22 17:15:41 2010 (r215695)
+++ stable/8/sys/powerpc/booke/platform_bare.c Mon Nov 22 17:39:18 2010 (r215696)
@@ -67,6 +67,8 @@ static int bare_smp_next_cpu(platform_t,
static int bare_smp_get_bsp(platform_t, struct cpuref *cpuref);
static int bare_smp_start_cpu(platform_t, struct pcpu *cpu);
+static void e500_reset(platform_t);
+
static platform_method_t bare_methods[] = {
PLATFORMMETHOD(platform_probe, bare_probe),
PLATFORMMETHOD(platform_mem_regions, bare_mem_regions),
@@ -77,6 +79,8 @@ static platform_method_t bare_methods[]
PLATFORMMETHOD(platform_smp_get_bsp, bare_smp_get_bsp),
PLATFORMMETHOD(platform_smp_start_cpu, bare_smp_start_cpu),
+ PLATFORMMETHOD(platform_reset, e500_reset);
+
{ 0, 0 }
};
@@ -229,3 +233,30 @@ bare_smp_start_cpu(platform_t plat, stru
return (ENXIO);
#endif
}
+
+static void
+e500_reset(platform_t plat)
+{
+ uint32_t ver = SVR_VER(mfspr(SPR_SVR));
+
+ if (ver == SVR_MPC8572E || ver == SVR_MPC8572 ||
+ ver == SVR_MPC8548E || ver == SVR_MPC8548)
+ /* Systems with dedicated reset register */
+ ccsr_write4(OCP85XX_RSTCR, 2);
+ else {
+ /* Clear DBCR0, disables debug interrupts and events. */
+ mtspr(SPR_DBCR0, 0);
+ __asm __volatile("isync");
+
+ /* Enable Debug Interrupts in MSR. */
+ mtmsr(mfmsr() | PSL_DE);
+
+ /* Enable debug interrupts and issue reset. */
+ mtspr(SPR_DBCR0, mfspr(SPR_DBCR0) | DBCR0_IDM |
+ DBCR0_RST_SYSTEM);
+ }
+
+ printf("Reset failed...\n");
+ while (1);
+}
+
Modified: stable/8/sys/powerpc/include/ofw_machdep.h
==============================================================================
--- stable/8/sys/powerpc/include/ofw_machdep.h Mon Nov 22 17:15:41 2010 (r215695)
+++ stable/8/sys/powerpc/include/ofw_machdep.h Mon Nov 22 17:39:18 2010 (r215696)
@@ -43,7 +43,6 @@ void OF_getetheraddr(device_t dev, u_cha
void OF_initial_setup(void *fdt_ptr, void *junk, int (*openfirm)(void *));
boolean_t OF_bootstrap(void);
-void OF_halt(void);
void OF_reboot(void);
void ofw_mem_regions(struct mem_region **, int *, struct mem_region **, int *);
Modified: stable/8/sys/powerpc/mpc85xx/mpc85xx.c
==============================================================================
--- stable/8/sys/powerpc/mpc85xx/mpc85xx.c Mon Nov 22 17:15:41 2010 (r215695)
+++ stable/8/sys/powerpc/mpc85xx/mpc85xx.c Mon Nov 22 17:39:18 2010 (r215696)
@@ -129,28 +129,3 @@ law_disable(int trgt, u_long addr, u_lon
return (ENOENT);
}
-void
-cpu_reset(void)
-{
- uint32_t ver = SVR_VER(mfspr(SPR_SVR));
-
- if (ver == SVR_MPC8572E || ver == SVR_MPC8572 ||
- ver == SVR_MPC8548E || ver == SVR_MPC8548)
- /* Systems with dedicated reset register */
- ccsr_write4(OCP85XX_RSTCR, 2);
- else {
- /* Clear DBCR0, disables debug interrupts and events. */
- mtspr(SPR_DBCR0, 0);
- __asm __volatile("isync");
-
- /* Enable Debug Interrupts in MSR. */
- mtmsr(mfmsr() | PSL_DE);
-
- /* Enable debug interrupts and issue reset. */
- mtspr(SPR_DBCR0, mfspr(SPR_DBCR0) | DBCR0_IDM |
- DBCR0_RST_SYSTEM);
- }
-
- printf("Reset failed...\n");
- while (1);
-}
Modified: stable/8/sys/powerpc/powermac/cuda.c
==============================================================================
--- stable/8/sys/powerpc/powermac/cuda.c Mon Nov 22 17:15:41 2010 (r215695)
+++ stable/8/sys/powerpc/powermac/cuda.c Mon Nov 22 17:39:18 2010 (r215696)
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/clock.h>
+#include <sys/reboot.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
@@ -72,6 +73,7 @@ static u_int cuda_adb_autopoll(device_t
static u_int cuda_poll(device_t dev);
static void cuda_send_inbound(struct cuda_softc *sc);
static void cuda_send_outbound(struct cuda_softc *sc);
+static void cuda_shutdown(void *xsc, int howto);
/*
* Clock interface
@@ -249,6 +251,8 @@ cuda_attach(device_t dev)
}
clock_register(dev, 1000);
+ EVENTHANDLER_REGISTER(shutdown_final, cuda_shutdown, sc,
+ SHUTDOWN_PRI_LAST);
return (bus_generic_attach(dev));
}
@@ -739,6 +743,20 @@ cuda_adb_autopoll(device_t dev, uint16_t
return (0);
}
+static void
+cuda_shutdown(void *xsc, int howto)
+{
+ struct cuda_softc *sc = xsc;
+ uint8_t cmd[] = {CUDA_PSEUDO, 0};
+
+ cmd[1] = (howto & RB_HALT) ? CMD_POWEROFF : CMD_RESET;
+ cuda_poll(sc->sc_dev);
+ cuda_send(sc, 1, 2, cmd);
+
+ while (1)
+ cuda_poll(sc->sc_dev);
+}
+
#define DIFF19041970 2082844800
static int
Copied: stable/8/sys/powerpc/powermac/platform_powermac.c (from r212054, head/sys/powerpc/powermac/platform_powermac.c)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ stable/8/sys/powerpc/powermac/platform_powermac.c Mon Nov 22 17:39:18 2010 (r215696, copy of r212054, head/sys/powerpc/powermac/platform_powermac.c)
@@ -0,0 +1,288 @@
+/*-
+ * Copyright (c) 2008 Marcel Moolenaar
+ * Copyright (c) 2009 Nathan Whitehorn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/pcpu.h>
+#include <sys/proc.h>
+#include <sys/smp.h>
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/bus.h>
+#include <machine/cpu.h>
+#include <machine/hid.h>
+#include <machine/platformvar.h>
+#include <machine/pmap.h>
+#include <machine/smp.h>
+#include <machine/spr.h>
+
+#include <dev/ofw/openfirm.h>
+#include <machine/ofw_machdep.h>
+
+#include "platform_if.h"
+
+#ifdef SMP
+extern void *ap_pcpu;
+#endif
+
+static int powermac_probe(platform_t);
+void powermac_mem_regions(platform_t, struct mem_region **phys, int *physsz,
+ struct mem_region **avail, int *availsz);
+static u_long powermac_timebase_freq(platform_t, struct cpuref *cpuref);
+static int powermac_smp_first_cpu(platform_t, struct cpuref *cpuref);
+static int powermac_smp_next_cpu(platform_t, struct cpuref *cpuref);
+static int powermac_smp_get_bsp(platform_t, struct cpuref *cpuref);
+static int powermac_smp_start_cpu(platform_t, struct pcpu *cpu);
+static void powermac_reset(platform_t);
+
+static platform_method_t powermac_methods[] = {
+ PLATFORMMETHOD(platform_probe, powermac_probe),
+ PLATFORMMETHOD(platform_mem_regions, powermac_mem_regions),
+ PLATFORMMETHOD(platform_timebase_freq, powermac_timebase_freq),
+
+ PLATFORMMETHOD(platform_smp_first_cpu, powermac_smp_first_cpu),
+ PLATFORMMETHOD(platform_smp_next_cpu, powermac_smp_next_cpu),
+ PLATFORMMETHOD(platform_smp_get_bsp, powermac_smp_get_bsp),
+ PLATFORMMETHOD(platform_smp_start_cpu, powermac_smp_start_cpu),
+
+ PLATFORMMETHOD(platform_reset, powermac_reset),
+
+ { 0, 0 }
+};
+
+static platform_def_t powermac_platform = {
+ "powermac",
+ powermac_methods,
+ 0
+};
+
+PLATFORM_DEF(powermac_platform);
+
+static int
+powermac_probe(platform_t plat)
+{
+ if (OF_finddevice("/memory") != -1 || OF_finddevice("/memory at 0") != -1)
+ return (BUS_PROBE_GENERIC);
+
+ return (ENXIO);
+}
+
+void
+powermac_mem_regions(platform_t plat, struct mem_region **phys, int *physsz,
+ struct mem_region **avail, int *availsz)
+{
+ ofw_mem_regions(phys,physsz,avail,availsz);
+}
+
+static u_long
+powermac_timebase_freq(platform_t plat, struct cpuref *cpuref)
+{
+ phandle_t phandle;
+ int32_t ticks = -1;
+
+ phandle = cpuref->cr_hwref;
+
+ OF_getprop(phandle, "timebase-frequency", &ticks, sizeof(ticks));
+
+ if (ticks <= 0)
+ panic("Unable to determine timebase frequency!");
+
+ return (ticks);
+}
+
+
+static int
+powermac_smp_fill_cpuref(struct cpuref *cpuref, phandle_t cpu)
+{
+ cell_t cpuid, res;
+
+ cpuref->cr_hwref = cpu;
+ res = OF_getprop(cpu, "reg", &cpuid, sizeof(cpuid));
+
+ /*
+ * psim doesn't have a reg property, so assume 0 as for the
+ * uniprocessor case in the CHRP spec.
+ */
+ if (res < 0) {
+ cpuid = 0;
+ }
+
+ cpuref->cr_cpuid = cpuid & 0xff;
+ return (0);
+}
+
+static int
+powermac_smp_first_cpu(platform_t plat, struct cpuref *cpuref)
+{
+ char buf[8];
+ phandle_t cpu, dev, root;
+ int res;
+
+ root = OF_peer(0);
+
+ dev = OF_child(root);
+ while (dev != 0) {
+ res = OF_getprop(dev, "name", buf, sizeof(buf));
+ if (res > 0 && strcmp(buf, "cpus") == 0)
+ break;
+ dev = OF_peer(dev);
+ }
+ if (dev == 0) {
+ /*
+ * psim doesn't have a name property on the /cpus node,
+ * but it can be found directly
+ */
+ dev = OF_finddevice("/cpus");
+ if (dev == 0)
+ return (ENOENT);
+ }
+
+ cpu = OF_child(dev);
+
+ while (cpu != 0) {
+ res = OF_getprop(cpu, "device_type", buf, sizeof(buf));
+ if (res > 0 && strcmp(buf, "cpu") == 0)
+ break;
+ cpu = OF_peer(cpu);
+ }
+ if (cpu == 0)
+ return (ENOENT);
+
+ return (powermac_smp_fill_cpuref(cpuref, cpu));
+}
+
+static int
+powermac_smp_next_cpu(platform_t plat, struct cpuref *cpuref)
+{
+ char buf[8];
+ phandle_t cpu;
+ int res;
+
+ cpu = OF_peer(cpuref->cr_hwref);
+ while (cpu != 0) {
+ res = OF_getprop(cpu, "device_type", buf, sizeof(buf));
+ if (res > 0 && strcmp(buf, "cpu") == 0)
+ break;
+ cpu = OF_peer(cpu);
+ }
+ if (cpu == 0)
+ return (ENOENT);
+
+ return (powermac_smp_fill_cpuref(cpuref, cpu));
+}
+
+static int
+powermac_smp_get_bsp(platform_t plat, struct cpuref *cpuref)
+{
+ ihandle_t inst;
+ phandle_t bsp, chosen;
+ int res;
+
+ chosen = OF_finddevice("/chosen");
+ if (chosen == 0)
+ return (ENXIO);
+
+ res = OF_getprop(chosen, "cpu", &inst, sizeof(inst));
+ if (res < 0)
+ return (ENXIO);
+
+ bsp = OF_instance_to_package(inst);
+ return (powermac_smp_fill_cpuref(cpuref, bsp));
+}
+
+static int
+powermac_smp_start_cpu(platform_t plat, struct pcpu *pc)
+{
+#ifdef SMP
+ phandle_t cpu;
+ volatile uint8_t *rstvec;
+ static volatile uint8_t *rstvec_virtbase = NULL;
+ int res, reset, timeout;
+
+ cpu = pc->pc_hwref;
+ res = OF_getprop(cpu, "soft-reset", &reset, sizeof(reset));
+ if (res < 0) {
+ reset = 0x58;
+
+ switch (pc->pc_cpuid) {
+ case 0:
+ reset += 0x03;
+ break;
+ case 1:
+ reset += 0x04;
+ break;
+ case 2:
+ reset += 0x0f;
+ break;
+ case 3:
+ reset += 0x10;
+ break;
+ default:
+ return (ENXIO);
+ }
+ }
+
+ ap_pcpu = pc;
+
+ if (rstvec_virtbase == NULL)
+ rstvec_virtbase = pmap_mapdev(0x80000000, PAGE_SIZE);
+
+ rstvec = rstvec_virtbase + reset;
+
+ *rstvec = 4;
+ powerpc_sync();
+ (void)(*rstvec);
+ powerpc_sync();
+ DELAY(1);
+ *rstvec = 0;
+ powerpc_sync();
+ (void)(*rstvec);
+ powerpc_sync();
+
+ timeout = 10000;
+ while (!pc->pc_awake && timeout--)
+ DELAY(100);
+
+ return ((pc->pc_awake) ? 0 : EBUSY);
+#else
+ /* No SMP support */
+ return (ENXIO);
+#endif
+}
+
+static void
+powermac_reset(platform_t platform)
+{
+ OF_reboot();
+}
+
Modified: stable/8/sys/powerpc/powermac/pmu.c
==============================================================================
--- stable/8/sys/powerpc/powermac/pmu.c Mon Nov 22 17:15:41 2010 (r215695)
+++ stable/8/sys/powerpc/powermac/pmu.c Mon Nov 22 17:39:18 2010 (r215696)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/clock.h>
+#include <sys/reboot.h>
#include <sys/sysctl.h>
#include <dev/ofw/ofw_bus.h>
@@ -81,6 +82,11 @@ static u_int pmu_adb_send(device_t dev,
static u_int pmu_adb_autopoll(device_t dev, uint16_t mask);
static u_int pmu_poll(device_t dev);
+/*
+ * Power interface
+ */
+
+static void pmu_shutdown(void *xsc, int howto);
static void pmu_set_sleepled(void *xsc, int onoff);
static int pmu_server_mode(SYSCTL_HANDLER_ARGS);
static int pmu_acline_state(SYSCTL_HANDLER_ARGS);
@@ -474,6 +480,12 @@ pmu_attach(device_t dev)
clock_register(dev, 1000);
+ /*
+ * Register power control handler
+ */
+ EVENTHANDLER_REGISTER(shutdown_final, pmu_shutdown, sc,
+ SHUTDOWN_PRI_LAST);
+
return (bus_generic_attach(dev));
}
@@ -751,6 +763,20 @@ pmu_adb_autopoll(device_t dev, uint16_t
}
static void
+pmu_shutdown(void *xsc, int howto)
+{
+ struct pmu_softc *sc = xsc;
+ uint8_t cmd[] = {'M', 'A', 'T', 'T'};
+
+ if (howto & RB_HALT)
+ pmu_send(sc, PMU_POWER_OFF, 4, cmd, 0, NULL);
+ else
+ pmu_send(sc, PMU_RESET_CPU, 0, NULL, 0, NULL);
+
+ for (;;);
+}
+
+static void
pmu_set_sleepled(void *xsc, int onoff)
{
struct pmu_softc *sc = xsc;
Modified: stable/8/sys/powerpc/powermac/smu.c
==============================================================================
--- stable/8/sys/powerpc/powermac/smu.c Mon Nov 22 17:15:41 2010 (r215695)
+++ stable/8/sys/powerpc/powermac/smu.c Mon Nov 22 17:39:18 2010 (r215696)
@@ -166,6 +166,7 @@ static void smu_manage_fans(device_t smu
static void smu_set_sleepled(void *xdev, int onoff);
static int smu_server_mode(SYSCTL_HANDLER_ARGS);
static void smu_doorbell_intr(void *xdev);
+static void smu_shutdown(void *xdev, int howto);
/* where to find the doorbell GPIO */
@@ -396,6 +397,12 @@ smu_attach(device_t dev)
*/
clock_register(dev, 1000);
+ /*
+ * Learn about shutdown events
+ */
+ EVENTHANDLER_REGISTER(shutdown_final, smu_shutdown, dev,
+ SHUTDOWN_PRI_LAST);
+
return (bus_generic_attach(dev));
}
@@ -1123,6 +1130,25 @@ smu_server_mode(SYSCTL_HANDLER_ARGS)
return (smu_run_cmd(smu, &cmd, 1));
}
+static void
+smu_shutdown(void *xdev, int howto)
+{
+ device_t smu = xdev;
+ struct smu_cmd cmd;
+
+ cmd.cmd = SMU_POWER;
+ if (howto & RB_HALT)
+ strcpy(cmd.data, "SHUTDOWN");
+ else
+ strcpy(cmd.data, "RESTART");
+
+ cmd.len = strlen(cmd.data);
+
+ smu_run_cmd(smu, &cmd, 1);
+
+ for (;;);
+}
+
static int
smu_gettime(device_t dev, struct timespec *ts)
{
Modified: stable/8/sys/powerpc/powerpc/platform.c
==============================================================================
--- stable/8/sys/powerpc/powerpc/platform.c Mon Nov 22 17:15:41 2010 (r215695)
+++ stable/8/sys/powerpc/powerpc/platform.c Mon Nov 22 17:39:18 2010 (r215696)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm.h>
#include <vm/vm_page.h>
+#include <machine/cpu.h>
#include <machine/platform.h>
#include <machine/platformvar.h>
#include <machine/smp.h>
@@ -105,6 +106,15 @@ platform_smp_start_cpu(struct pcpu *cpu)
}
/*
+ * Reset back to firmware.
+ */
+void
+cpu_reset()
+{
+ PLATFORM_RESET(plat_obj);
+}
+
+/*
* Platform install routines. Highest priority wins, using the same
* algorithm as bus attachment.
*/
Modified: stable/8/sys/powerpc/powerpc/platform_if.m
==============================================================================
--- stable/8/sys/powerpc/powerpc/platform_if.m Mon Nov 22 17:15:41 2010 (r215695)
+++ stable/8/sys/powerpc/powerpc/platform_if.m Mon Nov 22 17:39:18 2010 (r215696)
@@ -161,3 +161,10 @@ METHOD int smp_start_cpu {
struct pcpu *_cpu;
};
+/**
+ * @brief Reset system
+ */
+METHOD void reset {
+ platform_t _plat;
+};
+
More information about the svn-src-stable
mailing list