[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] PPC build fixes
From: |
Hollis Blanchard |
Subject: |
[patch] PPC build fixes |
Date: |
Sat, 19 Feb 2005 17:34:40 -0600 |
User-agent: |
Mutt/1.5.6+20040907i |
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 <address@hidden>
* 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;
+}
+
+
+#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;
+}
+
+
+#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;
-}
-
-
-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;
-}
-
-
-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 ();
-}
- [patch] PPC build fixes,
Hollis Blanchard <=