From: Adrian M. <lkm...@gm...> - 2007-07-29 18:04:27
|
In the light of more up to date technical information I have discovered there is a register at physical address 0x005F6890 on the Dreamcast that if written a magic number (0x00007611) will force a reboot under software control. Presumably a better option than the current catch-all mechanism. Signed-off by: Adrian McMenamin <ad...@mc...> diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c index 6334a4c..6f5e9e4 100644 --- a/arch/sh/kernel/process.c +++ b/arch/sh/kernel/process.c @@ -97,6 +97,11 @@ void cpu_idle(void) void machine_restart(char * __unused) { + +#ifdef CONFIG_SH_DREAMCAST + /*reboot the Dreamcast under software control*/ + writel(0x00007611, 0xA05F6890); +#endif /* 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)); |
From: Adrian M. <lkm...@gm...> - 2007-07-29 18:25:25
|
Apologies. I meant to cc: this to the lists first time round and appear to have bcc'ed it instead. ---------- Forwarded message ---------- From: Adrian McMenamin <lkm...@gm...> Date: 29-Jul-2007 19:04 Subject: [PATCH] Reboot Dreamcast under software control To: le...@li... In the light of more up to date technical information I have discovered there is a register at physical address 0x005F6890 on the Dreamcast that if written a magic number (0x00007611) will force a reboot under software control. Presumably a better option than the current catch-all mechanism. Signed-off by: Adrian McMenamin <ad...@mc...> diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c index 6334a4c..6f5e9e4 100644 --- a/arch/sh/kernel/process.c +++ b/arch/sh/kernel/process.c @@ -97,6 +97,11 @@ void cpu_idle(void) void machine_restart(char * __unused) { + +#ifdef CONFIG_SH_DREAMCAST + /*reboot the Dreamcast under software control*/ + writel(0x00007611, 0xA05F6890); +#endif /* 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)); |
From: Paul M. <le...@li...> - 2007-07-29 22:51:08
|
On Sun, Jul 29, 2007 at 07:25:21PM +0100, Adrian McMenamin wrote: > diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c > index 6334a4c..6f5e9e4 100644 > --- a/arch/sh/kernel/process.c > +++ b/arch/sh/kernel/process.c > @@ -97,6 +97,11 @@ void cpu_idle(void) > > void machine_restart(char * __unused) > { > + > +#ifdef CONFIG_SH_DREAMCAST > + /*reboot the Dreamcast under software control*/ > + writel(0x00007611, 0xA05F6890); > +#endif > /* 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)); No, if you want to do this, at least use a function pointer and leave this as the default implementation. The dreamcast presumably only needs this magic write anyways, rather than the SR.BL trick. |
From: Adrian M. <ad...@ne...> - 2007-07-29 23:05:58
|
On Mon, 2007-07-30 at 07:50 +0900, Paul Mundt wrote: > On Sun, Jul 29, 2007 at 07:25:21PM +0100, Adrian McMenamin wrote: > > diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c > > index 6334a4c..6f5e9e4 100644 > > --- a/arch/sh/kernel/process.c > > +++ b/arch/sh/kernel/process.c > > @@ -97,6 +97,11 @@ void cpu_idle(void) > > > > void machine_restart(char * __unused) > > { > > + > > +#ifdef CONFIG_SH_DREAMCAST > > + /*reboot the Dreamcast under software control*/ > > + writel(0x00007611, 0xA05F6890); > > +#endif > > /* 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)); > > No, if you want to do this, at least use a function pointer and leave > this as the default implementation. The dreamcast presumably only needs > this magic write anyways, rather than the SR.BL trick. > Well, when I tested it, it did have a "return" in after the call and it worked - but I took that out as it looked like code bloat to me :) Explain what you mean by using a function pointer and I'll do that. Adrian |
From: Paul M. <le...@li...> - 2007-07-29 23:26:37
|
On Mon, Jul 30, 2007 at 12:05:31AM +0100, Adrian McMenamin wrote: > On Mon, 2007-07-30 at 07:50 +0900, Paul Mundt wrote: > > On Sun, Jul 29, 2007 at 07:25:21PM +0100, Adrian McMenamin wrote: > > > diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c > > > index 6334a4c..6f5e9e4 100644 > > > --- a/arch/sh/kernel/process.c > > > +++ b/arch/sh/kernel/process.c > > > @@ -97,6 +97,11 @@ void cpu_idle(void) > > > > > > void machine_restart(char * __unused) > > > { > > > + > > > +#ifdef CONFIG_SH_DREAMCAST > > > + /*reboot the Dreamcast under software control*/ > > > + writel(0x00007611, 0xA05F6890); > > > +#endif > > > /* 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)); > > > > No, if you want to do this, at least use a function pointer and leave > > this as the default implementation. The dreamcast presumably only needs > > this magic write anyways, rather than the SR.BL trick. > > > > Well, when I tested it, it did have a "return" in after the call and it > worked - but I took that out as it looked like code bloat to me :) > > Explain what you mean by using a function pointer and I'll do that. > Look at the other implementations that are overloaded by the boards. machine_power_off, the idle loop, etc. |
From: Adrian M. <ad...@ne...> - 2007-07-30 19:50:03
|
On Mon, 2007-07-30 at 07:50 +0900, Paul Mundt wrote: > On Sun, Jul 29, 2007 at 07:25:21PM +0100, Adrian McMenamin wrote: > > diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c > > index 6334a4c..6f5e9e4 100644 > > --- a/arch/sh/kernel/process.c > > +++ b/arch/sh/kernel/process.c > > @@ -97,6 +97,11 @@ void cpu_idle(void) > > > > void machine_restart(char * __unused) > > { > > + > > +#ifdef CONFIG_SH_DREAMCAST > > + /*reboot the Dreamcast under software control*/ > > + writel(0x00007611, 0xA05F6890); > > +#endif > > /* 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)); > > No, if you want to do this, at least use a function pointer and leave > this as the default implementation. The dreamcast presumably only needs > this magic write anyways, rather than the SR.BL trick. > OK, stupid question time: How does the build process know what to link with - ie how to overload? If I just put a small .c file in /arch/sh/Dreamcast with appropriate exported function will the linker automagically link in my function or will it clash with the other generic or generic-SH4 function? I've tried to work this out from looking at the code but haven't managed it so far. |
From: Paul M. <le...@li...> - 2007-07-30 22:05:30
|
On Mon, Jul 30, 2007 at 08:49:27PM +0100, Adrian McMenamin wrote: > On Mon, 2007-07-30 at 07:50 +0900, Paul Mundt wrote: > > On Sun, Jul 29, 2007 at 07:25:21PM +0100, Adrian McMenamin wrote: > > > diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c > > > index 6334a4c..6f5e9e4 100644 > > > --- a/arch/sh/kernel/process.c > > > +++ b/arch/sh/kernel/process.c > > > @@ -97,6 +97,11 @@ void cpu_idle(void) > > > > > > void machine_restart(char * __unused) > > > { > > > + > > > +#ifdef CONFIG_SH_DREAMCAST > > > + /*reboot the Dreamcast under software control*/ > > > + writel(0x00007611, 0xA05F6890); > > > +#endif > > > /* 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)); > > > > No, if you want to do this, at least use a function pointer and leave > > this as the default implementation. The dreamcast presumably only needs > > this magic write anyways, rather than the SR.BL trick. > > > OK, stupid question time: How does the build process know what to link > with - ie how to overload? > If you look at machine_power_off() you can see how there's a function pointer nested within it that boards can optionally set to their own implementations, or if it's unset, we just go with the default behaviour. Something like that is probably more in line with how we want to go. On the other hand, this isn't crucial for 2.6.23, and if we're going to do this for 2.6.24, we should probably consider something more like the i386 machine_ops for implementing these various bits of functionality, rather than abusing some of the tie-in with the pm ops. I'll take a look at cobbling something together for the 2.6.24 dev tree, and move some of the boards over to it. It should be pretty apparent from this how to wire it up on the dreamcast, with the restart functionality you're after. |