From: Adrian M. <lkm...@gm...> - 2007-08-02 21:09:56
|
On 02/08/07, Adrian McMenamin <lkm...@gm...> wrote: > Paul/list > > This is my first attempt at this and it seems to work on the > Dreamcast. I need to add a set of fixups for the Dreamcast also (at > the moment it just replicates the behaviour in the current process.c) > - as that is the whole point. > Apologies, that patch was incomplete and in other ways messed up. This should be the proper patch diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile index 1f141a8..e019ad1 100644 --- a/arch/sh/kernel/Makefile +++ b/arch/sh/kernel/Makefile @@ -6,9 +6,10 @@ 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 \ - time.o topology.o traps.o + time.o topology.o traps.o reboot.o obj-y += cpu/ timers/ + obj-$(CONFIG_VSYSCALL) += vsyscall/ obj-$(CONFIG_SMP) += smp.o 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..3ae91f4 --- /dev/null +++ b/arch/sh/kernel/reboot.c @@ -0,0 +1,100 @@ +/* + * 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) +{ + printk(KERN_INFO "Got here\n"); + machine_ops.restart(cmd); +} + +void machine_halt(void) +{ + machine_ops.halt(); +} diff -ruN /dev/null include/asm-sh/reboot.h --- /dev/null 2007-04-19 22:41:52.000000000 +0100 +++ include/asm-sh/reboot.h 2007-08-02 00:06:49.000000000 +0100 @@ -0,0 +1,20 @@ +#ifndef _ASM_REBOOT_H +#define _ASM_REBOOT_H + +/*straight lift from i386 code*/ +struct pt_regs; + +struct machine_ops +{ + void (*restart)(char *cmd); + void (*halt)(void); + void (*power_off)(void); + void (*shutdown)(void); + void (*crash_shutdown)(struct pt_regs *); + void (*emergency_restart)(void); +}; + +extern struct machine_ops machine_ops; + + +#endif /* _ASM_REBOOT_H */ diff -ruN /dev/null include/asm-sh/emergency-restart.h --- /dev/null 2007-04-19 22:41:52.000000000 +0100 +++ include/asm-sh/emergency-restart.h 2007-08-02 21:09:09.000000000 +0100 @@ -0,0 +1,6 @@ +#ifndef _ASM_GENERIC_EMERGENCY_RESTART_H +#define _ASM_GENERIC_EMERGENCY_RESTART_H + +extern void machine_emergency_restart(void); + +#endif /* _ASM_GENERIC_EMERGENCY_RESTART_H */ |