* reboot and halt commands for the PPC
@ 2005-01-28 20:09 Marco Gerards
2005-01-28 20:43 ` Vincent Pelletier
0 siblings, 1 reply; 7+ messages in thread
From: Marco Gerards @ 2005-01-28 20:09 UTC (permalink / raw)
To: grub-devel
Hi,
Here is a patch that adds the reboot and halt commands for the PPC.
In order to make it work I have added grub_ieee1275_interpret. It is
used for reset-all for reboot, it is in the specs so it should work.
The shut-down command that is run the same way is more problematic
because I can not find it in the spec. I have added a note to the
help output of this command about this.
If I don't hear anything I will apply this patch on Monday.
Thanks,
Marco
2005-01-28 Marco Gerards <metgerards@student.han.nl>
* boot/powerpc/ieee1275/ieee1275.c (grub_ieee1275_interpret): New
function.
* commands/ieee1275/halt.c: New file.
* commands/ieee1275/reboot.c: Likewise.
* commands/ieee1275/suspend.c (grub_cmd_suspend): Use
`__attribute__ ((unused))'. Some GCS related fixed.
(grub_suspend_init) [GRUB_UTIL]: Function removed.
(grub_suspend_fini): Likewise.
* conf/powerpc-ieee1275.rmk (pkgdata_MODULES): Add `reboot.mod'
and `halt.mod'.
(reboot_mod_SOURCES, reboot_mod_CFLAGS, halt_mod_SOURCES)
(halt_mod_CFLAGS): New variables.
* include/grub/powerpc/ieee1275/ieee1275.h
(grub_ieee1275_interpret): New prototype.
Index: boot/powerpc/ieee1275/ieee1275.c
===================================================================
RCS file: /cvsroot/grub/grub2/boot/powerpc/ieee1275/ieee1275.c,v
retrieving revision 1.10
diff -u -p -r1.10 ieee1275.c
--- boot/powerpc/ieee1275/ieee1275.c 21 Jan 2005 02:45:02 -0000 1.10
+++ boot/powerpc/ieee1275/ieee1275.c 28 Jan 2005 19:59:47 -0000
@@ -332,6 +332,25 @@ grub_ieee1275_parent (grub_ieee1275_phan
}
int
+grub_ieee1275_interpret (const char *command, int *catch)
+{
+ struct enter_args {
+ struct grub_ieee1275_common_hdr common;
+ const char *command;
+ int catch;
+ } args;
+
+ INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1);
+ args.command = command;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ return -1;
+ if (catch)
+ *catch = args.catch;
+ return 0;
+}
+
+int
grub_ieee1275_enter (void)
{
struct enter_args {
Index: commands/ieee1275/halt.c
===================================================================
RCS file: commands/ieee1275/halt.c
diff -N commands/ieee1275/halt.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ commands/ieee1275/halt.c 28 Jan 2005 19:59:47 -0000
@@ -0,0 +1,48 @@
+/* halt.c - command to halt the computer. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005 Free Software Foundation, Inc.
+ *
+ * GRUB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/machine/ieee1275.h>
+
+static grub_err_t
+grub_cmd_halt (struct grub_arg_list *state __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_ieee1275_interpret ("shut-down", 0);
+ return 0;
+}
+
+\f
+GRUB_MOD_INIT
+{
+ (void)mod; /* To stop warning. */
+ grub_register_command ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH,
+ "halt", "halts the computer. This command does not"
+ " work on every firmware.", 0);
+}
+
+GRUB_MOD_FINI
+{
+ grub_unregister_command ("halt");
+}
+
Index: commands/ieee1275/reboot.c
===================================================================
RCS file: commands/ieee1275/reboot.c
diff -N commands/ieee1275/reboot.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ commands/ieee1275/reboot.c 28 Jan 2005 19:59:47 -0000
@@ -0,0 +1,46 @@
+/* reboot.c - command to reboot the computer. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005 Free Software Foundation, Inc.
+ *
+ * GRUB is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <grub/normal.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/machine/ieee1275.h>
+
+static grub_err_t
+grub_cmd_reboot (struct grub_arg_list *state __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_ieee1275_interpret ("reset-all", 0);
+ return 0;
+}
+
+\f
+GRUB_MOD_INIT
+{
+ (void)mod; /* To stop warning. */
+ grub_register_command ("reboot", grub_cmd_reboot, GRUB_COMMAND_FLAG_BOTH,
+ "reboot", "Reboot the computer", 0);
+}
+
+GRUB_MOD_FINI
+{
+ grub_unregister_command ("reboot");
+}
Index: commands/ieee1275/suspend.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/ieee1275/suspend.c,v
retrieving revision 1.1
diff -u -p -r1.1 suspend.c
--- commands/ieee1275/suspend.c 21 Jan 2005 02:45:02 -0000 1.1
+++ commands/ieee1275/suspend.c 28 Jan 2005 19:59:47 -0000
@@ -24,32 +24,16 @@
#include <grub/machine/ieee1275.h>
static grub_err_t
-grub_cmd_suspend (struct grub_arg_list *state, int argc, char **args)
+grub_cmd_suspend (struct grub_arg_list *state __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
{
- (void)state;
- (void)argc;
- (void)args;
-
- grub_printf("Run 'go' to resume GRUB.\n");
- grub_ieee1275_enter();
+ grub_printf ("Run 'go' to resume GRUB.\n");
+ grub_ieee1275_enter ();
return 0;
}
\f
-#ifdef GRUB_UTIL
-void
-grub_suspend_init (void)
-{
- grub_register_command ("suspend", grub_cmd_suspend, GRUB_COMMAND_FLAG_BOTH,
- "suspend", "Return to Open Firmware prompt", 0);
-}
-
-void
-grub_suspend_fini (void)
-{
- grub_unregister_command ("suspend");
-}
-#else /* ! GRUB_UTIL */
GRUB_MOD_INIT
{
(void)mod; /* To stop warning. */
@@ -61,4 +45,3 @@ GRUB_MOD_FINI
{
grub_unregister_command ("suspend");
}
-#endif /* ! GRUB_UTIL */
Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v
retrieving revision 1.21
diff -u -p -r1.21 powerpc-ieee1275.rmk
--- conf/powerpc-ieee1275.rmk 21 Jan 2005 21:32:03 -0000 1.21
+++ conf/powerpc-ieee1275.rmk 28 Jan 2005 19:59:48 -0000
@@ -65,7 +65,7 @@ genmoddep_SOURCES = util/genmoddep.c
pkgdata_MODULES = _linux.mod linux.mod fat.mod ufs.mod ext2.mod minix.mod \
hfs.mod jfs.mod normal.mod hello.mod font.mod \
boot.mod cmp.mod cat.mod terminal.mod fshelp.mod amiga.mod apple.mod \
- pc.mod suspend.mod loopback.mod
+ pc.mod suspend.mod loopback.mod reboot.mod halt.mod
# For fshelp.mod.
fshelp_mod_SOURCES = fs/fshelp.c
@@ -160,3 +160,11 @@ loopback_mod_CFLAGS = $(COMMON_CFLAGS)
# For suspend.mod
suspend_mod_SOURCES = commands/ieee1275/suspend.c
suspend_mod_CFLAGS = $(COMMON_CFLAGS)
+
+# For reboot.mod
+reboot_mod_SOURCES = commands/ieee1275/reboot.c
+reboot_mod_CFLAGS = $(COMMON_CFLAGS)
+
+# For halt.mod
+halt_mod_SOURCES = commands/ieee1275/halt.c
+halt_mod_CFLAGS = $(COMMON_CFLAGS)
Index: include/grub/powerpc/ieee1275/ieee1275.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v
retrieving revision 1.13
diff -u -p -r1.13 ieee1275.h
--- include/grub/powerpc/ieee1275/ieee1275.h 21 Jan 2005 02:45:03 -0000 1.13
+++ include/grub/powerpc/ieee1275/ieee1275.h 28 Jan 2005 19:59:48 -0000
@@ -106,6 +106,7 @@ int EXPORT_FUNC(grub_ieee1275_child) (gr
grub_ieee1275_phandle_t *result);
int EXPORT_FUNC(grub_ieee1275_parent) (grub_ieee1275_phandle_t node,
grub_ieee1275_phandle_t *result);
+int EXPORT_FUNC(grub_ieee1275_interpret) (const char *command, int *catch);
int EXPORT_FUNC(grub_ieee1275_enter) (void);
int EXPORT_FUNC(grub_ieee1275_exit) (void);
int EXPORT_FUNC(grub_ieee1275_open) (char *node,
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: reboot and halt commands for the PPC
2005-01-28 20:09 reboot and halt commands for the PPC Marco Gerards
@ 2005-01-28 20:43 ` Vincent Pelletier
2005-01-28 21:08 ` Marco Gerards
0 siblings, 1 reply; 7+ messages in thread
From: Vincent Pelletier @ 2005-01-28 20:43 UTC (permalink / raw)
To: The development of GRUB 2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Marco Gerards wrote:
| The shut-down command that is run the same way is more problematic
| because I can not find it in the spec.
| +static grub_err_t
| +grub_cmd_halt (struct grub_arg_list *state __attribute__ ((unused)),
| + int argc __attribute__ ((unused)),
| + char **args __attribute__ ((unused)))
| +{
| + grub_ieee1275_interpret ("shut-down", 0);
| + return 0;
Isn't it "power-off" ?
afaik, my sparc only understand power-off to cut the power.
Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFB+qPYFEQoKRQyjtURAqXwAJ9ZCBY53aqTgBhWyPcp8tbgigjCgwCfWbBp
5e5i5X2AgBpzxfs/AmBMhzE=
=pjHx
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: reboot and halt commands for the PPC
2005-01-28 20:43 ` Vincent Pelletier
@ 2005-01-28 21:08 ` Marco Gerards
2005-01-29 1:10 ` Yoshinori K. Okuji
0 siblings, 1 reply; 7+ messages in thread
From: Marco Gerards @ 2005-01-28 21:08 UTC (permalink / raw)
To: The development of GRUB 2
Vincent Pelletier <subdino2004@yahoo.fr> writes:
> Marco Gerards wrote:
> | The shut-down command that is run the same way is more problematic
> | because I can not find it in the spec.
> | +static grub_err_t
> | +grub_cmd_halt (struct grub_arg_list *state __attribute__ ((unused)),
> | + int argc __attribute__ ((unused)),
> | + char **args __attribute__ ((unused)))
> | +{
> | + grub_ieee1275_interpret ("shut-down", 0);
> | + return 0;
>
> Isn't it "power-off" ?
> afaik, my sparc only understand power-off to cut the power.
Is that a client interface command or a command for the command line
interface? On my pegasos I have the shut-down command on the command
line interface. The power-off command does not exist.
--
Marco
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: reboot and halt commands for the PPC
2005-01-28 21:08 ` Marco Gerards
@ 2005-01-29 1:10 ` Yoshinori K. Okuji
2005-01-29 18:40 ` Hollis Blanchard
0 siblings, 1 reply; 7+ messages in thread
From: Yoshinori K. Okuji @ 2005-01-29 1:10 UTC (permalink / raw)
To: The development of GRUB 2
On Friday 28 January 2005 22:08, Marco Gerards wrote:
> > Isn't it "power-off" ?
> > afaik, my sparc only understand power-off to cut the power.
>
> Is that a client interface command or a command for the command line
> interface? On my pegasos I have the shut-down command on the command
> line interface. The power-off command does not exist.
IIRC, power-off is used on Sparc, and shut-down on PowerPC. I don't know
why they are inconsistent, though.
Okuji
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: reboot and halt commands for the PPC
2005-01-29 1:10 ` Yoshinori K. Okuji
@ 2005-01-29 18:40 ` Hollis Blanchard
2005-01-30 15:07 ` Marco Gerards
0 siblings, 1 reply; 7+ messages in thread
From: Hollis Blanchard @ 2005-01-29 18:40 UTC (permalink / raw)
To: The development of GRUB 2
On Jan 28, 2005, at 7:10 PM, Yoshinori K. Okuji wrote:
> On Friday 28 January 2005 22:08, Marco Gerards wrote:
>>> Isn't it "power-off" ?
>>> afaik, my sparc only understand power-off to cut the power.
>>
>> Is that a client interface command or a command for the command line
>> interface? On my pegasos I have the shut-down command on the command
>> line interface. The power-off command does not exist.
>
> IIRC, power-off is used on Sparc, and shut-down on PowerPC. I don't
> know
> why they are inconsistent, though.
Unfortunately, neither are listed in IEEE1275.
Further, "interpret" is an optional client interface command, and will
not exist on systems without the Forth user interface (like PIBS, IBM's
firmware for embedded PPC). I think the flow will need to go something
like this:
grub_cmd_shutdown (...) {
grub_ieee1275_interpret ("shut-down", 0); /* Apple Open Firmware */
grub_ieee1275_interpret ("power-off", 0); /* IBM Open Firmware and Sun
OpenBoot */
return grub_error(GRUB_ERR_INVALID_COMMAND, "don't know how to shut
down");
}
grub_cmd_reboot (...) {
grub_ieee1275_interpret ("reset-all", 0);
hard_reset ();
}
/* Manually jump to firmware's System Reset exception handler. */
hard_reset:
lis 3, 0xfff0
ori 3, 3, 0x0100
mtctr r3
mfmsr 3
ori 3, 3, MSR_IP
mtmsr 3
bctr
-Hollis
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: reboot and halt commands for the PPC
2005-01-29 18:40 ` Hollis Blanchard
@ 2005-01-30 15:07 ` Marco Gerards
2005-01-30 17:05 ` Hollis Blanchard
0 siblings, 1 reply; 7+ messages in thread
From: Marco Gerards @ 2005-01-30 15:07 UTC (permalink / raw)
To: The development of GRUB 2
Hollis Blanchard <hollis@penguinppc.org> writes:
> On Jan 28, 2005, at 7:10 PM, Yoshinori K. Okuji wrote:
>
>> On Friday 28 January 2005 22:08, Marco Gerards wrote:
>>>> Isn't it "power-off" ?
>>>> afaik, my sparc only understand power-off to cut the power.
>>>
>>> Is that a client interface command or a command for the command line
>>> interface? On my pegasos I have the shut-down command on the command
>>> line interface. The power-off command does not exist.
>>
>> IIRC, power-off is used on Sparc, and shut-down on PowerPC. I don't
>> know
>> why they are inconsistent, though.
>
> Unfortunately, neither are listed in IEEE1275.
Right. But I don't think this should not be a reason not to add this
feature. It works on both the apple and bplan firmware.
Calling the functions after each other won't work on the bplan
firmware, IIRC because it crashes.
> Further, "interpret" is an optional client interface command, and will
> not exist on systems without the Forth user interface (like PIBS,
> IBM's firmware for embedded PPC). I think the flow will need to go
> something like this:
You are right. Personally I don't want to add something like this
until GRUB works on such box. Perhaps the interpret call makes the
box crash or so. So I want to keep it this way until we can get
access to such box.
Is that ok for you?
Thanks,
Marco
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: reboot and halt commands for the PPC
2005-01-30 15:07 ` Marco Gerards
@ 2005-01-30 17:05 ` Hollis Blanchard
0 siblings, 0 replies; 7+ messages in thread
From: Hollis Blanchard @ 2005-01-30 17:05 UTC (permalink / raw)
To: The development of GRUB 2
On Jan 30, 2005, at 9:07 AM, Marco Gerards wrote:
> Hollis Blanchard <hollis@penguinppc.org> writes:
>
>> On Jan 28, 2005, at 7:10 PM, Yoshinori K. Okuji wrote:
>>
>>> On Friday 28 January 2005 22:08, Marco Gerards wrote:
>>>>> Isn't it "power-off" ?
>>>>> afaik, my sparc only understand power-off to cut the power.
>>>>
>>>> Is that a client interface command or a command for the command line
>>>> interface? On my pegasos I have the shut-down command on the
>>>> command
>>>> line interface. The power-off command does not exist.
>>>
>>> IIRC, power-off is used on Sparc, and shut-down on PowerPC. I don't
>>> know why they are inconsistent, though.
>>
>> Unfortunately, neither are listed in IEEE1275.
>
> Right. But I don't think this should not be a reason not to add this
> feature. It works on both the apple and bplan firmware.
>
> Calling the functions after each other won't work on the bplan
> firmware, IIRC because it crashes.
Ugh, really? I think we could use the "test-method" call in that case?
Or just reverse the ordering of the calls, assuming Apple/IBM OF
doesn't crash.
>> Further, "interpret" is an optional client interface command, and will
>> not exist on systems without the Forth user interface (like PIBS,
>> IBM's firmware for embedded PPC). I think the flow will need to go
>> something like this:
>
> You are right. Personally I don't want to add something like this
> until GRUB works on such box. Perhaps the interpret call makes the
> box crash or so. So I want to keep it this way until we can get
> access to such box.
>
> Is that ok for you?
Yes.
-Hollis
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-01-30 17:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-28 20:09 reboot and halt commands for the PPC Marco Gerards
2005-01-28 20:43 ` Vincent Pelletier
2005-01-28 21:08 ` Marco Gerards
2005-01-29 1:10 ` Yoshinori K. Okuji
2005-01-29 18:40 ` Hollis Blanchard
2005-01-30 15:07 ` Marco Gerards
2005-01-30 17:05 ` Hollis Blanchard
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.