reboot and halt commands for the PPC
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 <[email protected]>
* 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
powerpc/ieee1275/ieee1275.c +19 -0
@@ -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
ieee1275/halt.c new file +48 -0
48 lines not on this page · raw message
Index: commands/ieee1275/reboot.c
===================================================================
RCS file: commands/ieee1275/reboot.c
ieee1275/reboot.c new file +46 -0
46 lines not on this page · raw message
Index: commands/ieee1275/suspend.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/ieee1275/suspend.c,v retrieving revision 1.1
ieee1275/suspend.c +5 -22
@@ -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 ; } -#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
powerpc-ieee1275.rmk +9 -1
@@ -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
grub/powerpc/ieee1275/ieee1275.h +1 -0
@@ -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,
-----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-----
Quoted 11 lines · Vincent Pelletier
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;
Quoted 2 lines
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
Quoted 6 lines · Marco Gerards
Quoted 2 lines
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
Quoted 10 lines · Yoshinori K. Okuji
Quoted 6 lines · Marco Gerards
Quoted 2 lines
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
Quoted 10 lines · Hollis Blanchard
Quoted 8 lines · Yoshinori K. Okuji
Quoted 6 lines · Marco Gerards
Quoted 2 lines
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.
Quoted 5 lines
Quoted 3 lines
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.
Quoted 4 lines
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
Quoted 15 lines · Marco Gerards
Quoted 13 lines · Hollis Blanchard
Quoted 10 lines · Yoshinori K. Okuji
Quoted 6 lines · Marco Gerards
Quoted 2 lines
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.
Quoted 7 lines
Quoted 1 line
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.
Quoted 11 lines
Quoted 4 lines
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