From: Adrian M. <ad...@ne...> - 2007-08-02 23:41:29
|
Here is a new patch that hopefully answers some of your points. This has been tested on the Dreamcast but does need to be tested on various builds to ensure there are no hidden nasties with the build. Here's a description: This patch adds a set machine-ops callbacks - as with the existing i386 code - that will allow better, per machine, shutdown code to be implemented. Signed-off by: Adrian McMenamin <ad...@mc...> diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile index 1f141a8..7ab2359 100644 --- a/arch/sh/kernel/Makefile +++ b/arch/sh/kernel/Makefile @@ -5,10 +5,11 @@ extra-y := head.o init_task.o vmlinux.lds obj-y := debugtraps.o io.o io_generic.o irq.o machvec.o process.o ptrace.o \ - semaphore.o setup.o signal.o sys_sh.o syscalls.o \ + reboot.o semaphore.o setup.o signal.o sys_sh.o syscalls.o \ time.o topology.o traps.o obj-y += cpu/ timers/ + obj-$(CONFIG_VSYSCALL) += vsyscall/ obj-$(CONFIG_SMP) += smp.o diff --git a/arch/sh/kernel/machine_kexec.c b/arch/sh/kernel/machine_kexec.c index 790ed69..201b370 100644 --- a/arch/sh/kernel/machine_kexec.c +++ b/arch/sh/kernel/machine_kexec.c @@ -29,9 +29,6 @@ extern const unsigned char relocate_new_kernel[]; extern const unsigned int relocate_new_kernel_size; extern void *gdb_vbr_vector; -void machine_shutdown(void) -{ -} void machine_crash_shutdown(struct pt_regs *regs) { diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c index 15ae322..5484e30 100644 --- a/arch/sh/kernel/process.c +++ b/arch/sh/kernel/process.c @@ -24,13 +24,12 @@ #include <asm/pgalloc.h> #include <asm/system.h> #include <asm/ubc.h> +#include <asm/reboot.h> static int hlt_counter; int ubc_usercnt = 0; void (*pm_idle)(void); -void (*pm_power_off)(void); -EXPORT_SYMBOL(pm_power_off); void disable_hlt(void) { @@ -96,27 +95,6 @@ void cpu_idle(void) } } -void machine_restart(char * __unused) -{ - /* SR.BL=1 and invoke address error to let CPU reset (manual reset) */ - asm volatile("ldc %0, sr\n\t" - "mov.l @%1, %0" : : "r" (0x10000000), "r" (0x80000001)); -} - -void machine_halt(void) -{ - local_irq_disable(); - - while (1) - cpu_sleep(); -} - -void machine_power_off(void) -{ - if (pm_power_off) - pm_power_off(); -} - void show_regs(struct pt_regs * regs) { printk("\n"); diff --git a/arch/sh/kernel/reboot.c b/arch/sh/kernel/reboot.c new file mode 100644 index 0000000..00a8afe --- /dev/null +++ b/arch/sh/kernel/reboot.c @@ -0,0 +1,99 @@ +/* + * linux/arch/sh/kernel/reboot.c + * + * Essentially copied from i386 code + * some SuperH code copyright Adrian McMenamin, 2007 + * Most copied from process.c + * + * Copyright (C) 1995 Linus Torvalds + * + * SuperH version: Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima + * Copyright (C) 2006 Lineo Solutions Inc. support SH4A UBC + * Copyright (C) 2002 - 2007 Paul Mundt + * + * Licensed under the terms of version 2 of GNU GPL + */ + +#include <linux/mm.h> +#include <linux/module.h> +#include <linux/delay.h> +#include <linux/init.h> +#include <asm/reboot.h> + +/* + * Power off function, if any + */ +void (*pm_power_off)(void); +EXPORT_SYMBOL(pm_power_off); + + + +static void native_machine_shutdown(void) +{ +/* Is there anything we can do here? */ +} + + +static void native_machine_emergency_restart(void) +{ + /* SR.BL=1 and invoke address error to let CPU reset (manual reset) */ + asm volatile("ldc %0, sr\n\t" + "mov.l @%1, %0" : : "r" (0x10000000), "r" (0x80000001)); +} + +static void native_machine_restart(char * __unused) +{ + native_machine_shutdown(); + native_machine_emergency_restart(); +} + +static void native_machine_halt(void) +{ + local_irq_disable(); + + while (1) + cpu_sleep(); + +} + +static void native_machine_power_off(void) +{ + if (pm_power_off) { + native_machine_shutdown(); + pm_power_off(); + } +} + + +struct machine_ops machine_ops = { + .power_off = native_machine_power_off, + .shutdown = native_machine_shutdown, + .emergency_restart = native_machine_emergency_restart, + .restart = native_machine_restart, + .halt = native_machine_halt, +}; + +void machine_power_off(void) +{ + machine_ops.power_off(); +} + +void machine_shutdown(void) +{ + machine_ops.shutdown(); +} + +void machine_emergency_restart(void) +{ + machine_ops.emergency_restart(); +} + +void machine_restart(char *cmd) +{ + machine_ops.restart(cmd); +} + +void machine_halt(void) +{ + machine_ops.halt(); +} diff --git a/include/asm-sh/emergency-restart.h b/include/asm-sh/emergency-restart.h index 108d8c4..d6bec92 100644 --- a/include/asm-sh/emergency-restart.h +++ b/include/asm-sh/emergency-restart.h @@ -1,6 +1,6 @@ -#ifndef _ASM_EMERGENCY_RESTART_H -#define _ASM_EMERGENCY_RESTART_H +#ifndef _ASM_SH_EMERGENCY_RESTART_H +#define _ASM_SH_EMERGENCY_RESTART_H -#include <asm-generic/emergency-restart.h> +extern void machine_emergency_restart(void); -#endif /* _ASM_EMERGENCY_RESTART_H */ +#endif /* _ASM_SH_EMERGENCY_RESTART_H */ |