* [patch] PPC build fixes
@ 2005-02-19 23:34 Hollis Blanchard
2005-02-20 13:39 ` Yoshinori K. Okuji
2005-02-21 18:28 ` Marco Gerards
0 siblings, 2 replies; 10+ messages in thread
From: Hollis Blanchard @ 2005-02-19 23:34 UTC (permalink / raw)
To: grub-devel
This patch fixes PowerPC build breakage from the recent grub-emu changes. Of
note:
- grub_reboot and grub_halt in util/i386/pc/misc.c are not
architecture-specific, so have been moved to util/grub-emu.c.
- commands/ieee1275/halt.c and reboot.c are no longer
architecture-specific either. This is because we now want those
commands to be loaded in grub-emu, and of course grub-emu does not
emulate Open Firmware. Accordingly, these files are moved up to the
commands directory. Since i386 needs a special argument ("no-apm"), it
still uses its version in commands/i386/pc.
- since grub_machine_fini isn't called yet, I haven't yet figured out
how to release the memory indicated in the comments.
OK?
-Hollis
2005-02-19 Hollis Blanchard <hollis@penguinppc.org>
* commands/ieee1275/halt.c (grub_cmd_halt): Call grub_halt.
Move file...
* commands/halt.c: ... to here.
* commands/ieee1275/reboot.c (grub_cmd_reboot): Call grub_reboot.
Move file...
* commands/reboot.c: ... to here.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Add
commands/halt.c and commands/reboot.c.
(reboot_mod_SOURCES): Set to commands/reboot.c.
(halt_mod_SOURCES): Set to commands/halt.c.
* disk/powerpc/ieee1275/ofdisk.c (grub_ofdisk_fini): New
function.
* include/grub/powerpc/ieee1275/ieee1275.h (grub_reboot): Add
prototype.
(grub_halt): Likewise.
* kern/powerpc/ieee1275/init.c (heap_start): Make global.
(heap_len): Likewise.
(grub_machine_fini): New function.
* kern/powerpc/ieee1275/openfw.c (grub_reboot): New function.
(grub_halt): Likewise.
* term/powerpc/ieee1275/ofconsole.c (grub_ofconsole_fini): New
function.
* util/i386/pc/misc.c: Remove file.
(grub_reboot): Move to ...
* util/grub-emu.c: ... here.
* util/i386/pc/misc.c (grub_halt): Move to ...
* util/grub-emu.c: ... here.
Index: commands/halt.c
===================================================================
RCS file: commands/halt.c
diff -N commands/halt.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ commands/halt.c 19 Feb 2005 23:37:39 -0000
@@ -0,0 +1,64 @@
+/* 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>
+#include <grub/machine/kernel.h>
+
+static grub_err_t
+grub_cmd_halt (struct grub_arg_list *state __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_halt ();
+ return 0;
+}
+
+\f
+#ifdef GRUB_UTIL
+void
+grub_halt_init (void)
+{
+ grub_register_command ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH,
+ "halt", "halts the computer. This command does not"
+ " work on all firmware.", 0);
+}
+
+void
+grub_halt_fini (void)
+{
+ grub_unregister_command ("halt");
+}
+#else /* ! GRUB_UTIL */
+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 all firmware.", 0);
+}
+
+GRUB_MOD_FINI
+{
+ grub_unregister_command ("halt");
+}
+#endif
Index: commands/reboot.c
===================================================================
RCS file: commands/reboot.c
diff -N commands/reboot.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ commands/reboot.c 19 Feb 2005 23:37:39 -0000
@@ -0,0 +1,62 @@
+/* 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>
+#include <grub/machine/kernel.h>
+
+static grub_err_t
+grub_cmd_reboot (struct grub_arg_list *state __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_reboot ();
+ return 0;
+}
+
+\f
+#ifdef GRUB_UTIL
+void
+grub_reboot_init (void)
+{
+ grub_register_command ("reboot", grub_cmd_reboot, GRUB_COMMAND_FLAG_BOTH,
+ "reboot", "Reboot the computer", 0);
+}
+
+void
+grub_reboot_fini (void)
+{
+ grub_unregister_command ("reboot");
+}
+#else /* ! GRUB_UTIL */
+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");
+}
+#endif
Index: commands/ieee1275/halt.c
===================================================================
RCS file: commands/ieee1275/halt.c
diff -N commands/ieee1275/halt.c
--- commands/ieee1275/halt.c 31 Jan 2005 21:28:34 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,48 +0,0 @@
-/* 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
--- commands/ieee1275/reboot.c 31 Jan 2005 21:28:34 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,46 +0,0 @@
-/* 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: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v
retrieving revision 1.25
diff -u -p -r1.25 powerpc-ieee1275.rmk
--- conf/powerpc-ieee1275.rmk 19 Feb 2005 20:56:06 -0000 1.25
+++ conf/powerpc-ieee1275.rmk 19 Feb 2005 23:37:41 -0000
@@ -42,7 +42,8 @@ grub_emu_SOURCES = kern/main.c kern/devi
normal/menu_entry.c normal/arg.c kern/partition.c \
util/console.c util/grub-emu.c util/misc.c util/i386/pc/getroot.c \
kern/env.c disk/loopback.c commands/ls.c commands/help.c \
- commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c
+ commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c \
+ commands/halt.c commands/reboot.c
grub_emu_LDFLAGS = -lncurses
grubof_SOURCES = boot/powerpc/ieee1275/crt0.S boot/powerpc/ieee1275/cmain.c \
@@ -163,11 +164,11 @@ suspend_mod_SOURCES = commands/ieee1275/
suspend_mod_CFLAGS = $(COMMON_CFLAGS)
# For reboot.mod
-reboot_mod_SOURCES = commands/ieee1275/reboot.c
+reboot_mod_SOURCES = commands/reboot.c
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
# For halt.mod
-halt_mod_SOURCES = commands/ieee1275/halt.c
+halt_mod_SOURCES = commands/halt.c
halt_mod_CFLAGS = $(COMMON_CFLAGS)
# For help.mod.
Index: disk/powerpc/ieee1275/ofdisk.c
===================================================================
RCS file: /cvsroot/grub/grub2/disk/powerpc/ieee1275/ofdisk.c,v
retrieving revision 1.7
diff -u -p -r1.7 ofdisk.c
--- disk/powerpc/ieee1275/ofdisk.c 22 Jan 2005 16:03:15 -0000 1.7
+++ disk/powerpc/ieee1275/ofdisk.c 19 Feb 2005 23:37:41 -0000
@@ -164,3 +164,9 @@ grub_ofdisk_init (void)
{
grub_disk_dev_register (&grub_ofdisk_dev);
}
+
+void
+grub_ofdisk_fini (void)
+{
+ grub_disk_dev_unregister (&grub_ofdisk_dev);
+}
Index: include/grub/powerpc/ieee1275/ieee1275.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v
retrieving revision 1.14
diff -u -p -r1.14 ieee1275.h
--- include/grub/powerpc/ieee1275/ieee1275.h 31 Jan 2005 21:28:34 -0000 1.14
+++ include/grub/powerpc/ieee1275/ieee1275.h 19 Feb 2005 23:37:41 -0000
@@ -132,5 +132,7 @@ int EXPORT_FUNC(grub_claimmap) (grub_add
void EXPORT_FUNC(abort) (void);
+void EXPORT_FUNC (grub_reboot) (void);
+void EXPORT_FUNC (grub_halt) (void);
#endif /* ! GRUB_IEEE1275_MACHINE_HEADER */
Index: kern/powerpc/ieee1275/init.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/init.c,v
retrieving revision 1.13
diff -u -p -r1.13 init.c
--- kern/powerpc/ieee1275/init.c 4 Jan 2005 14:01:45 -0000 1.13
+++ kern/powerpc/ieee1275/init.c 19 Feb 2005 23:37:41 -0000
@@ -33,6 +33,10 @@
#include <grub/machine/time.h>
#include <grub/machine/kernel.h>
+/* Apple OF 1.0.5 reserves 0x0 to 0x4000 for the exception handlers. */
+static const grub_addr_t heap_start = 0x4000;
+static grub_addr_t heap_len;
+
void
abort (void)
{
@@ -46,13 +50,9 @@ void
grub_machine_init (void)
{
extern char _start;
- grub_addr_t heap_start;
- grub_addr_t heap_len;
grub_console_init ();
- /* Apple OF 1.0.5 reserves 0x4000 bytes for the exception handlers. */
- heap_start = 0x4000;
/* Apple OF 3.1.1 reserves an extra 0x1000 bytes below the load address
of an ELF file. */
heap_len = (grub_addr_t) &_start - 0x1000 - heap_start;
@@ -71,6 +71,17 @@ grub_machine_init (void)
}
void
+grub_machine_fini (void)
+{
+ grub_ofdisk_fini ();
+ grub_console_fini ();
+
+ grub_ieee1275_release (heap_start, heap_len);
+ /* XXX Release memory claimed in 'linux' and 'initrd' commands. */
+ /* XXX Release memory claimed for Old World firmware. */
+}
+
+void
grub_stop (void)
{
for (;;);
Index: kern/powerpc/ieee1275/openfw.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/openfw.c,v
retrieving revision 1.7
diff -u -p -r1.7 openfw.c
--- kern/powerpc/ieee1275/openfw.c 3 Jan 2005 17:44:25 -0000 1.7
+++ kern/powerpc/ieee1275/openfw.c 19 Feb 2005 23:37:42 -0000
@@ -199,3 +199,15 @@ grub_claimmap (grub_addr_t addr, grub_si
return 0;
}
+
+void
+grub_reboot (void)
+{
+ grub_ieee1275_interpret ("reset-all", 0);
+}
+
+void
+grub_halt (void)
+{
+ grub_ieee1275_interpret ("shut-down", 0);
+}
Index: term/powerpc/ieee1275/ofconsole.c
===================================================================
RCS file: /cvsroot/grub/grub2/term/powerpc/ieee1275/ofconsole.c,v
retrieving revision 1.5
diff -u -p -r1.5 ofconsole.c
--- term/powerpc/ieee1275/ofconsole.c 3 Nov 2004 03:21:14 -0000 1.5
+++ term/powerpc/ieee1275/ofconsole.c 19 Feb 2005 23:37:42 -0000
@@ -307,3 +307,9 @@ grub_console_init (void)
grub_term_register (&grub_ofconsole_term);
grub_term_set_current (&grub_ofconsole_term);
}
+
+void
+grub_console_fini (void)
+{
+ grub_term_unregister (&grub_ofconsole_term);
+}
Index: util/grub-emu.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/grub-emu.c,v
retrieving revision 1.15
diff -u -p -r1.15 grub-emu.c
--- util/grub-emu.c 15 Feb 2005 00:07:01 -0000 1.15
+++ util/grub-emu.c 19 Feb 2005 23:37:42 -0000
@@ -73,6 +73,18 @@ grub_arch_dl_relocate_symbols (grub_dl_t
}
void
+grub_reboot (void)
+{
+ longjmp (main_env, 1);
+}
+
+void
+grub_halt (int no_apm __attribute__ ((unused)))
+{
+ grub_reboot ();
+}
+
+void
grub_machine_init (void)
{
signal (SIGINT, SIG_IGN);
Index: util/i386/pc/misc.c
===================================================================
RCS file: util/i386/pc/misc.c
diff -N util/i386/pc/misc.c
--- util/i386/pc/misc.c 15 Feb 2005 00:07:01 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,34 +0,0 @@
-/*
- * 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 <setjmp.h>
-
-#include <grub/util/misc.h>
-
-void
-grub_reboot (void)
-{
- longjmp (main_env, 1);
-}
-
-void
-grub_halt (int no_apm __attribute__ ((unused)))
-{
- grub_reboot ();
-}
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] PPC build fixes
2005-02-19 23:34 Hollis Blanchard
@ 2005-02-20 13:39 ` Yoshinori K. Okuji
2005-02-20 16:38 ` Hollis Blanchard
2005-02-21 18:28 ` Marco Gerards
1 sibling, 1 reply; 10+ messages in thread
From: Yoshinori K. Okuji @ 2005-02-20 13:39 UTC (permalink / raw)
To: The development of GRUB 2
On Sunday 20 February 2005 00:34, Hollis Blanchard wrote:
> - grub_reboot and grub_halt in util/i386/pc/misc.c are not
> architecture-specific, so have been moved to util/grub-emu.c.
grub_halt is clearly arch-specific. Look at the definition grub_halt in
PC. It takes one argument, while the PPC version does not. I expect
that the same thing might happen in grub_reboot as well.
Okuji
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] PPC build fixes
2005-02-20 13:39 ` Yoshinori K. Okuji
@ 2005-02-20 16:38 ` Hollis Blanchard
2005-02-20 18:41 ` Yoshinori K. Okuji
2005-02-21 18:30 ` Marco Gerards
0 siblings, 2 replies; 10+ messages in thread
From: Hollis Blanchard @ 2005-02-20 16:38 UTC (permalink / raw)
To: The development of GRUB 2
On Feb 20, 2005, at 7:39 AM, Yoshinori K. Okuji wrote:
> On Sunday 20 February 2005 00:34, Hollis Blanchard wrote:
>> - grub_reboot and grub_halt in util/i386/pc/misc.c are not
>> architecture-specific, so have been moved to util/grub-emu.c.
>
> grub_halt is clearly arch-specific. Look at the definition grub_halt in
> PC. It takes one argument, while the PPC version does not. I expect
> that the same thing might happen in grub_reboot as well.
Oops, I meant to convert that into using a more generic "flags"
argument, and then "no_apm" becomes one bit in it. How would that be?
--- util/grub-emu.c 15 Feb 2005 00:07:01 -0000 1.15
+++ util/grub-emu.c 20 Feb 2005 16:36:49 -0000
@@ -73,6 +73,18 @@ grub_arch_dl_relocate_symbols (grub_dl_t
}
void
+grub_reboot (void)
+{
+ longjmp (main_env, 1);
+}
+
+void
+grub_halt (grub_uint32_t flags __attribute__ ((unused)))
+{
+ grub_reboot ();
+}
+
+void
grub_machine_init (void)
{
signal (SIGINT, SIG_IGN);
-Hollis
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] PPC build fixes
2005-02-20 16:38 ` Hollis Blanchard
@ 2005-02-20 18:41 ` Yoshinori K. Okuji
2005-02-21 18:30 ` Marco Gerards
1 sibling, 0 replies; 10+ messages in thread
From: Yoshinori K. Okuji @ 2005-02-20 18:41 UTC (permalink / raw)
To: The development of GRUB 2
On Sunday 20 February 2005 17:38, Hollis Blanchard wrote:
> Oops, I meant to convert that into using a more generic "flags"
> argument, and then "no_apm" becomes one bit in it. How would that be?
Not bad.
Okuji
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] PPC build fixes
2005-02-19 23:34 Hollis Blanchard
2005-02-20 13:39 ` Yoshinori K. Okuji
@ 2005-02-21 18:28 ` Marco Gerards
1 sibling, 0 replies; 10+ messages in thread
From: Marco Gerards @ 2005-02-21 18:28 UTC (permalink / raw)
To: The development of GRUB 2
Hollis Blanchard <hollis@penguinppc.org> writes:
> This patch fixes PowerPC build breakage from the recent grub-emu changes. Of
> note:
>
> - grub_reboot and grub_halt in util/i386/pc/misc.c are not
> architecture-specific, so have been moved to util/grub-emu.c.
>
> - commands/ieee1275/halt.c and reboot.c are no longer
> architecture-specific either. This is because we now want those
> commands to be loaded in grub-emu, and of course grub-emu does not
> emulate Open Firmware. Accordingly, these files are moved up to the
> commands directory. Since i386 needs a special argument ("no-apm"), it
> still uses its version in commands/i386/pc.
>
> - since grub_machine_fini isn't called yet, I haven't yet figured out
> how to release the memory indicated in the comments.
>
> OK?
>
> -Hollis
>
> 2005-02-19 Hollis Blanchard <hollis@penguinppc.org>
>
> * commands/ieee1275/halt.c (grub_cmd_halt): Call grub_halt.
> Move file...
> * commands/halt.c: ... to here.
> * commands/ieee1275/reboot.c (grub_cmd_reboot): Call grub_reboot.
> Move file...
> * commands/reboot.c: ... to here.
If you do this, you could delete the PC specific reboot and halt
commands. Personally I like separate reboot and halt commands. If
you do it like this it will become hard/ugly to make platform specific
changes, I think.
> * disk/powerpc/ieee1275/ofdisk.c (grub_ofdisk_fini): New
> function.
> * include/grub/powerpc/ieee1275/ieee1275.h (grub_reboot): Add
> prototype.
Better put this in `include/grub/powerpc/ieee1275/init.h', just like
it is done for the PC. Perhaps it would be even better to have a new
header file for such things.
> (grub_halt): Likewise.
> * kern/powerpc/ieee1275/init.c (heap_start): Make global.
> (heap_len): Likewise.
`New variable.' would be more appropriate, I think. Can you put a
prefix before the function name?
> (grub_machine_fini): New function.
It's really nice that we have this now. :)
> * kern/powerpc/ieee1275/openfw.c (grub_reboot): New function.
> (grub_halt): Likewise.
> * term/powerpc/ieee1275/ofconsole.c (grub_ofconsole_fini): New
> function.
You have added grub_console_fini, not grub_ofconsole_fini.
> void
> +grub_machine_fini (void)
> +{
> + grub_ofdisk_fini ();
> + grub_console_fini ();
> +
> + grub_ieee1275_release (heap_start, heap_len);
> + /* XXX Release memory claimed in 'linux' and 'initrd' commands. */
> + /* XXX Release memory claimed for Old World firmware. */
> +}
Why would you release the memory for linux and initrd? IIRC there is
a callback function.
I think it should work like this:
In case someone quits GRUB:
- longjump (?)
- Release the memory for the loader (use grub_loader_unset).
- Call grub_console_fini.
- Call grub_ofdisk_fini.
- Release the heap.
In case someone starts a loader the same should be done, except
calling grub_loader_unset. After that the OS should be loaded. I
wonder what should happen when the OS can not be loaded. Perhaps GRUB
just has to fail or so.
Thanks,
Marco
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] PPC build fixes
2005-02-20 16:38 ` Hollis Blanchard
2005-02-20 18:41 ` Yoshinori K. Okuji
@ 2005-02-21 18:30 ` Marco Gerards
1 sibling, 0 replies; 10+ messages in thread
From: Marco Gerards @ 2005-02-21 18:30 UTC (permalink / raw)
To: The development of GRUB 2
Hollis Blanchard <hollis@penguinppc.org> writes:
> On Feb 20, 2005, at 7:39 AM, Yoshinori K. Okuji wrote:
>
>> On Sunday 20 February 2005 00:34, Hollis Blanchard wrote:
>>> - grub_reboot and grub_halt in util/i386/pc/misc.c are not
>>> architecture-specific, so have been moved to util/grub-emu.c.
>>
>> grub_halt is clearly arch-specific. Look at the definition grub_halt in
>> PC. It takes one argument, while the PPC version does not. I expect
>> that the same thing might happen in grub_reboot as well.
>
> Oops, I meant to convert that into using a more generic "flags"
> argument, and then "no_apm" becomes one bit in it. How would that be?
And how would the parser work? What if more options have to be added
for other archs? I do not have a strong objection against using
flags, I am just afraid it might be inadequate and that the current
code is easier to maintain.
Thanks,
Marco
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] PPC build fixes
@ 2005-03-24 3:00 Hollis Blanchard
2005-03-24 21:41 ` Marco Gerards
0 siblings, 1 reply; 10+ messages in thread
From: Hollis Blanchard @ 2005-03-24 3:00 UTC (permalink / raw)
To: grub-devel
5 weeks later...
Here I did not combine i386 and PPC halt/reboot as I did in my original
patch.
-Hollis
2005-03-23 Hollis Blanchard <hollis@penguinppc.org>
* commands/ieee1275/halt.c (grub_cmd_halt): Call grub_halt
instead of grub_ieee1275_interpret.
(grub_halt_init): New function.
(grub_halt_fini): Likewise.
(GRUB_MOD_INIT): Correct message grammar.
* commands/ieee1275/reboot.c (grub_cmd_reboot): Call grub_reboot
instead of grub_ieee1275_interpret.
(grub_reboot_init): New function.
(grub_reboot_fini): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Replace
commands/i386/pc/halt.c, commands/i386/pc/reboot.c, and
util/i386/pc/misc.c with
commands/ieee1275/halt.c, commands/ieee1275/reboot.c, and
util/powerpc/ieee1275/misc.c.
* disk/powerpc/ieee1275/ofdisk.c (grub_ofdisk_fini): New
function.
* include/grub/powerpc/ieee1275/console.h (grub_console_fini):
Add prototype.
* include/grub/powerpc/ieee1275/ieee1275.h (grub_reboot): Add
prototype.
(grub_halt): Likewise.
* include/grub/powerpc/ieee1275/init.h: Remove inaccurate comment.
(cmain): Remove __attribute__((unused)).
* kern/powerpc/ieee1275/init.c (grub_heap_start): New variable.
(grub_heap_len): Likewise.
(grub_machine_fini): New function.
* kern/powerpc/ieee1275/openfw.c (grub_reboot): New function.
(grub_halt): Likewise.
* term/powerpc/ieee1275/ofconsole.c (grub_console_fini): New
function.
* util/powerpc/ieee1275/misc.c (grub_reboot): New function.
(grub_halt): Likewise.
Index: commands/ieee1275/halt.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/ieee1275/halt.c,v
retrieving revision 1.1
diff -u -p -r1.1 halt.c
--- commands/ieee1275/halt.c 31 Jan 2005 21:28:34 -0000 1.1
+++ commands/ieee1275/halt.c 24 Mar 2005 03:01:57 -0000
@@ -28,21 +28,36 @@ grub_cmd_halt (struct grub_arg_list *sta
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
- grub_ieee1275_interpret ("shut-down", 0);
+ grub_halt ();
return 0;
}
\f
+#ifdef GRUB_UTIL
+void
+grub_halt_init (void)
+{
+ grub_register_command ("halt", grub_cmd_halt, GRUB_COMMAND_FLAG_BOTH,
+ "halt", "halts the computer. This command does not"
+ " work on all firmware.", 0);
+}
+
+void
+grub_halt_fini (void)
+{
+ grub_unregister_command ("halt");
+}
+#else /* ! GRUB_UTIL */
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);
+ " work on all firmware.", 0);
}
GRUB_MOD_FINI
{
grub_unregister_command ("halt");
}
-
+#endif
Index: commands/ieee1275/reboot.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/ieee1275/reboot.c,v
retrieving revision 1.1
diff -u -p -r1.1 reboot.c
--- commands/ieee1275/reboot.c 31 Jan 2005 21:28:34 -0000 1.1
+++ commands/ieee1275/reboot.c 24 Mar 2005 03:01:57 -0000
@@ -28,11 +28,25 @@ grub_cmd_reboot (struct grub_arg_list *s
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
- grub_ieee1275_interpret ("reset-all", 0);
+ grub_reboot ();
return 0;
}
\f
+#ifdef GRUB_UTIL
+void
+grub_reboot_init (void)
+{
+ grub_register_command ("reboot", grub_cmd_reboot, GRUB_COMMAND_FLAG_BOTH,
+ "reboot", "Reboot the computer", 0);
+}
+
+void
+grub_reboot_fini (void)
+{
+ grub_unregister_command ("reboot");
+}
+#else /* ! GRUB_UTIL */
GRUB_MOD_INIT
{
(void)mod; /* To stop warning. */
@@ -44,3 +58,4 @@ GRUB_MOD_FINI
{
grub_unregister_command ("reboot");
}
+#endif
Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v
retrieving revision 1.28
diff -u -p -r1.28 powerpc-ieee1275.rmk
--- conf/powerpc-ieee1275.rmk 2 Mar 2005 20:12:46 -0000 1.28
+++ conf/powerpc-ieee1275.rmk 24 Mar 2005 03:02:03 -0000
@@ -35,7 +35,7 @@ grub_mkimage_SOURCES = util/powerpc/ieee
grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
commands/configfile.c commands/default.c commands/help.c \
commands/terminal.c commands/ls.c commands/timeout.c \
- commands/i386/pc/halt.c commands/i386/pc/reboot.c \
+ commands/ieee1275/halt.c commands/ieee1275/reboot.c \
disk/loopback.c \
fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.c fs/jfs.c \
fs/minix.c fs/ufs.c \
@@ -47,7 +47,7 @@ grub_emu_SOURCES = commands/boot.c comma
partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \
util/console.c util/grub-emu.c util/misc.c \
util/i386/pc/biosdisk.c util/i386/pc/getroot.c \
- util/i386/pc/misc.c
+ util/powerpc/ieee1275/misc.c
grub_emu_LDFLAGS = -lncurses
Index: disk/powerpc/ieee1275/ofdisk.c
===================================================================
RCS file: /cvsroot/grub/grub2/disk/powerpc/ieee1275/ofdisk.c,v
retrieving revision 1.7
diff -u -p -r1.7 ofdisk.c
--- disk/powerpc/ieee1275/ofdisk.c 22 Jan 2005 16:03:15 -0000 1.7
+++ disk/powerpc/ieee1275/ofdisk.c 24 Mar 2005 03:02:03 -0000
@@ -164,3 +164,9 @@ grub_ofdisk_init (void)
{
grub_disk_dev_register (&grub_ofdisk_dev);
}
+
+void
+grub_ofdisk_fini (void)
+{
+ grub_disk_dev_unregister (&grub_ofdisk_dev);
+}
Index: include/grub/powerpc/ieee1275/console.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/console.h,v
retrieving revision 1.2
diff -u -p -r1.2 console.h
--- include/grub/powerpc/ieee1275/console.h 4 Apr 2004 13:46:01 -0000 1.2
+++ include/grub/powerpc/ieee1275/console.h 24 Mar 2005 03:02:03 -0000
@@ -51,6 +51,9 @@ void grub_console_setcursor (int on);
/* Initialize the console system. */
void grub_console_init (void);
+/* Finish the console system. */
+void grub_console_fini (void);
+
#endif
#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */
Index: include/grub/powerpc/ieee1275/ieee1275.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/ieee1275.h,v
retrieving revision 1.14
diff -u -p -r1.14 ieee1275.h
--- include/grub/powerpc/ieee1275/ieee1275.h 31 Jan 2005 21:28:34 -0000 1.14
+++ include/grub/powerpc/ieee1275/ieee1275.h 24 Mar 2005 03:02:03 -0000
@@ -131,6 +131,8 @@ grub_err_t EXPORT_FUNC(grub_children_ite
int EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
void EXPORT_FUNC(abort) (void);
+void EXPORT_FUNC (grub_reboot) (void);
+void EXPORT_FUNC (grub_halt) (void);
#endif /* ! GRUB_IEEE1275_MACHINE_HEADER */
Index: include/grub/powerpc/ieee1275/init.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/powerpc/ieee1275/init.h,v
retrieving revision 1.1
diff -u -p -r1.1 init.h
--- include/grub/powerpc/ieee1275/init.h 27 Dec 2004 13:46:20 -0000 1.1
+++ include/grub/powerpc/ieee1275/init.h 24 Mar 2005 03:02:03 -0000
@@ -1,4 +1,3 @@
-/* ieee1275.h - Access the Open Firmware client interface. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2004 Free Software Foundation, Inc.
@@ -21,7 +20,7 @@
#ifndef GRUB_INIT_MACHINE_HEADER
#define GRUB_INIT_MACHINE_HEADER 1
-void cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5);
+void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
void grub_ofdisk_init (void);
void grub_console_init (void);
Index: kern/powerpc/ieee1275/init.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/init.c,v
retrieving revision 1.13
diff -u -p -r1.13 init.c
--- kern/powerpc/ieee1275/init.c 4 Jan 2005 14:01:45 -0000 1.13
+++ kern/powerpc/ieee1275/init.c 24 Mar 2005 03:02:03 -0000
@@ -33,6 +33,10 @@
#include <grub/machine/time.h>
#include <grub/machine/kernel.h>
+/* Apple OF 1.0.5 reserves 0x0 to 0x4000 for the exception handlers. */
+static const grub_addr_t grub_heap_start = 0x4000;
+static grub_addr_t grub_heap_len;
+
void
abort (void)
{
@@ -46,24 +50,20 @@ void
grub_machine_init (void)
{
extern char _start;
- grub_addr_t heap_start;
- grub_addr_t heap_len;
grub_console_init ();
- /* Apple OF 1.0.5 reserves 0x4000 bytes for the exception handlers. */
- heap_start = 0x4000;
/* Apple OF 3.1.1 reserves an extra 0x1000 bytes below the load address
of an ELF file. */
- heap_len = (grub_addr_t) &_start - 0x1000 - heap_start;
+ grub_heap_len = (grub_addr_t) &_start - 0x1000 - grub_heap_start;
- if (grub_ieee1275_claim (heap_start, heap_len, 0, 0))
+ if (grub_ieee1275_claim (grub_heap_start, grub_heap_len, 0, 0))
{
- grub_printf ("Failed to claim heap at 0x%x, len 0x%x\n", heap_start,
- heap_len);
+ grub_printf ("Failed to claim heap at 0x%x, len 0x%x\n", grub_heap_start,
+ grub_heap_len);
abort ();
}
- grub_mm_init_region ((void *) heap_start, heap_len);
+ grub_mm_init_region ((void *) grub_heap_start, grub_heap_len);
grub_env_set ("prefix", "");
@@ -71,6 +71,18 @@ grub_machine_init (void)
}
void
+grub_machine_fini (void)
+{
+ grub_loader_unset ();
+
+ grub_ofdisk_fini ();
+ grub_console_fini ();
+
+ grub_ieee1275_release (grub_heap_start, grub_heap_len);
+ /* XXX Release memory claimed for Old World firmware. */
+}
+
+void
grub_stop (void)
{
for (;;);
Index: kern/powerpc/ieee1275/openfw.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/openfw.c,v
retrieving revision 1.7
diff -u -p -r1.7 openfw.c
--- kern/powerpc/ieee1275/openfw.c 3 Jan 2005 17:44:25 -0000 1.7
+++ kern/powerpc/ieee1275/openfw.c 24 Mar 2005 03:02:03 -0000
@@ -199,3 +199,15 @@ grub_claimmap (grub_addr_t addr, grub_si
return 0;
}
+
+void
+grub_reboot (void)
+{
+ grub_ieee1275_interpret ("reset-all", 0);
+}
+
+void
+grub_halt (void)
+{
+ grub_ieee1275_interpret ("shut-down", 0);
+}
Index: term/powerpc/ieee1275/ofconsole.c
===================================================================
RCS file: /cvsroot/grub/grub2/term/powerpc/ieee1275/ofconsole.c,v
retrieving revision 1.5
diff -u -p -r1.5 ofconsole.c
--- term/powerpc/ieee1275/ofconsole.c 3 Nov 2004 03:21:14 -0000 1.5
+++ term/powerpc/ieee1275/ofconsole.c 24 Mar 2005 03:02:03 -0000
@@ -307,3 +307,9 @@ grub_console_init (void)
grub_term_register (&grub_ofconsole_term);
grub_term_set_current (&grub_ofconsole_term);
}
+
+void
+grub_console_fini (void)
+{
+ grub_term_unregister (&grub_ofconsole_term);
+}
Index: util/powerpc/ieee1275/misc.c
===================================================================
RCS file: util/powerpc/ieee1275/misc.c
diff -N util/powerpc/ieee1275/misc.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ util/powerpc/ieee1275/misc.c 24 Mar 2005 03:02:03 -0000
@@ -0,0 +1,34 @@
+/*
+ * 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 <setjmp.h>
+
+#include <grub/util/misc.h>
+
+void
+grub_reboot (void)
+{
+ longjmp (main_env, 1);
+}
+
+void
+grub_halt (void)
+{
+ grub_reboot ();
+}
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] PPC build fixes
2005-03-24 3:00 [patch] PPC build fixes Hollis Blanchard
@ 2005-03-24 21:41 ` Marco Gerards
2005-03-25 14:58 ` Hollis Blanchard
0 siblings, 1 reply; 10+ messages in thread
From: Marco Gerards @ 2005-03-24 21:41 UTC (permalink / raw)
To: The development of GRUB 2
Hollis Blanchard <hollis@penguinppc.org> writes:
> 5 weeks later...
np.
> Here I did not combine i386 and PPC halt/reboot as I did in my original
> patch.
Cool!
> (grub_halt_init): New function.
> (grub_halt_fini): Likewise.
Why do you need this?
> (grub_reboot_init): New function.
> (grub_reboot_fini): Likewise.
Same here.
> * include/grub/powerpc/ieee1275/init.h: Remove inaccurate
> comment.
Can you change the comment to something sane?
> * util/powerpc/ieee1275/misc.c (grub_reboot): New function.
> (grub_halt): Likewise.
Isn't this just a completely new file?
Thanks,
Marco
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] PPC build fixes
2005-03-24 21:41 ` Marco Gerards
@ 2005-03-25 14:58 ` Hollis Blanchard
2005-03-25 17:40 ` Marco Gerards
0 siblings, 1 reply; 10+ messages in thread
From: Hollis Blanchard @ 2005-03-25 14:58 UTC (permalink / raw)
To: The development of GRUB 2
On Mar 24, 2005, at 3:41 PM, Marco Gerards wrote:
> Hollis Blanchard <hollis@penguinppc.org> writes:
>> (grub_halt_init): New function.
>> (grub_halt_fini): Likewise.
>
> Why do you need this?
>
>> (grub_reboot_init): New function.
>> (grub_reboot_fini): Likewise.
>
> Same here.
Because these commands need to be accessible from grub-emu (that is how
you quit).
>> * include/grub/powerpc/ieee1275/init.h: Remove inaccurate
>> comment.
>
> Can you change the comment to something sane?
include/grub/i386/pc/init.h has no comment, and I don't know how to
describe this anyways:
void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
void grub_ofdisk_init (void);
void grub_console_init (void);
"A tiny bit of miscellaneous stuff"? "Things related to booting"?
>> * util/powerpc/ieee1275/misc.c (grub_reboot): New function.
>> (grub_halt): Likewise.
>
> Isn't this just a completely new file?
Er, yes, sorry. :)
-Hollis
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [patch] PPC build fixes
2005-03-25 14:58 ` Hollis Blanchard
@ 2005-03-25 17:40 ` Marco Gerards
0 siblings, 0 replies; 10+ messages in thread
From: Marco Gerards @ 2005-03-25 17:40 UTC (permalink / raw)
To: The development of GRUB 2
Hollis Blanchard <hollis@penguinppc.org> writes:
[...]
> Because these commands need to be accessible from grub-emu (that is
> how you quit).
Oh, right.
>>> * include/grub/powerpc/ieee1275/init.h: Remove inaccurate
>>> comment.
>>
>> Can you change the comment to something sane?
>
> include/grub/i386/pc/init.h has no comment, and I don't know how to
> describe this anyways:
> void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
> void grub_ofdisk_init (void);
> void grub_console_init (void);
> "A tiny bit of miscellaneous stuff"? "Things related to booting"?
Ok, just remove it. You are right again. :)
>>> * util/powerpc/ieee1275/misc.c (grub_reboot): New function.
>>> (grub_halt): Likewise.
>>
>> Isn't this just a completely new file?
>
> Er, yes, sorry. :)
Can you change these two lines to this:
* util/powerpc/ieee1275/misc.c: New file
If you do this, you could commit the patch. I can also do it if you
want. After this we can concentrate on getting that boot-path patch
committed. I will fix the initrd problem this weekend.
Thanks,
Marco
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2005-03-25 17:57 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-24 3:00 [patch] PPC build fixes Hollis Blanchard
2005-03-24 21:41 ` Marco Gerards
2005-03-25 14:58 ` Hollis Blanchard
2005-03-25 17:40 ` Marco Gerards
-- strict thread matches above, loose matches on Subject: below --
2005-02-19 23:34 Hollis Blanchard
2005-02-20 13:39 ` Yoshinori K. Okuji
2005-02-20 16:38 ` Hollis Blanchard
2005-02-20 18:41 ` Yoshinori K. Okuji
2005-02-21 18:30 ` Marco Gerards
2005-02-21 18:28 ` Marco Gerards
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.