From: Adrian M. <lkm...@gm...> - 2007-08-02 20:59:44
|
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. Comments? Signed-off by: Adrian McMenamin <ad...@mc...> 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 --git a/include/asm-sh/emergency-restart.h b/include/asm-sh/emergency-restart.h index 108d8c4..7d73a4b 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_GENERIC_EMERGENCY_RESTART_H +#define _ASM_GENERIC_EMERGENCY_RESTART_H -#include <asm-generic/emergency-restart.h> +extern void machine_emergency_restart(void); -#endif /* _ASM_EMERGENCY_RESTART_H */ +#endif /* _ASM_GENERIC_EMERGENCY_RESTART_H */ |
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 */ |
From: Paul M. <le...@li...> - 2007-08-02 22:01:29
|
On Thu, Aug 02, 2007 at 10:09:51PM +0100, Adrian McMenamin wrote: > 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 > And here I was happy to have kept that alphabetized for so many years ;-) > +void machine_emergency_restart(void) > +{ > + machine_ops.emergency_restart(); > +} > + Some whitespace damage here. > +void machine_restart(char *cmd) > +{ > + printk(KERN_INFO "Got here\n"); > + machine_ops.restart(cmd); Debugging printk(). > --- /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; > + I wonder if we care about shutdown/crash_shutdown() at all. Note that machine_crash_shutdown() is currently defined by the kexec code, in arch/sh/kernel/machine_kexec.c. Can you consolidate the definitions from there in to your reboot.c and test the build with CONFIG_KEXEC=y? > + > +#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 */ > I also wonder if this is worth it. Perhaps we should just consolidate the native_machine_emergency_restart() logic in native_machine_restart(), and stick with the asm-generic/emergency_restart.h, we don't requite the cmd parsing at all, so it's probably not something we care about. This also allows emergency_restart to be killed off from the machine_ops struct. |
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 */ |