* [PATCH 1/3] Implement grub-mkrescue for PowerMac and CHRP
@ 2008-01-26 23:28 Pavel Roskin
2008-01-26 23:28 ` [PATCH 2/3] Provide fallback if /memory/available is missing Pavel Roskin
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Pavel Roskin @ 2008-01-26 23:28 UTC (permalink / raw)
To: grub-devel
* DISTLIST: Add util/powerpc/ieee1275/grub-mkrescue.in.
* conf/powerpc-ieee1275.mk: Add grub-mkrescue support.
* conf/powerpc-ieee1275.mk: Regenerate.
* util/powerpc/ieee1275/grub-mkrescue.in: Implement
grub-mkrescue for PowerMac and CHRP.
---
DISTLIST | 1
conf/powerpc-ieee1275.mk | 10 +++
conf/powerpc-ieee1275.rmk | 4 +
util/powerpc/ieee1275/grub-mkrescue.in | 116 ++++++++++++++++++++++++++++++++
4 files changed, 131 insertions(+), 0 deletions(-)
create mode 100644 util/powerpc/ieee1275/grub-mkrescue.in
diff --git a/DISTLIST b/DISTLIST
index 6388257..6b527c7 100644
--- a/DISTLIST
+++ b/DISTLIST
@@ -330,6 +330,7 @@ util/i386/pc/misc.c
util/i386/pc/grub-mkrescue.in
util/ieee1275/get_disk_name.c
util/powerpc/ieee1275/grub-install.in
+util/powerpc/ieee1275/grub-mkrescue.in
util/powerpc/ieee1275/misc.c
video/bitmap.c
video/video.c
diff --git a/conf/powerpc-ieee1275.mk b/conf/powerpc-ieee1275.mk
index 8869f5b..925027f 100644
--- a/conf/powerpc-ieee1275.mk
+++ b/conf/powerpc-ieee1275.mk
@@ -686,6 +686,7 @@ kernel_elf_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \
# Scripts.
sbin_SCRIPTS = grub-install
+bin_SCRIPTS = grub-mkrescue
# For grub-install.
grub_install_SOURCES = util/powerpc/ieee1275/grub-install.in
@@ -696,6 +697,15 @@ grub-install: util/powerpc/ieee1275/grub-install.in config.status
chmod +x $@
+# For grub-mkrescue.
+grub_mkrescue_SOURCES = util/powerpc/ieee1275/grub-mkrescue.in
+CLEANFILES += grub-mkrescue
+
+grub-mkrescue: util/powerpc/ieee1275/grub-mkrescue.in config.status
+ ./config.status --file=grub-mkrescue:util/powerpc/ieee1275/grub-mkrescue.in
+ chmod +x $@
+
+
# Modules.
pkglib_MODULES = halt.mod \
_linux.mod \
diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk
index 5a43e9f..42af2c5 100644
--- a/conf/powerpc-ieee1275.rmk
+++ b/conf/powerpc-ieee1275.rmk
@@ -104,10 +104,14 @@ kernel_elf_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \
# Scripts.
sbin_SCRIPTS = grub-install
+bin_SCRIPTS = grub-mkrescue
# For grub-install.
grub_install_SOURCES = util/powerpc/ieee1275/grub-install.in
+# For grub-mkrescue.
+grub_mkrescue_SOURCES = util/powerpc/ieee1275/grub-mkrescue.in
+
# Modules.
pkglib_MODULES = halt.mod \
_linux.mod \
diff --git a/util/powerpc/ieee1275/grub-mkrescue.in b/util/powerpc/ieee1275/grub-mkrescue.in
new file mode 100644
index 0000000..61495ab
--- /dev/null
+++ b/util/powerpc/ieee1275/grub-mkrescue.in
@@ -0,0 +1,116 @@
+#! /bin/sh -e
+
+# Make GRUB rescue image
+# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008 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 3 of the License, or
+# (at your option) any later version.
+#
+# GRUB 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, see <http://www.gnu.org/licenses/>.
+
+# Initialize some variables.
+transform="@program_transform_name@"
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+bindir=@bindir@
+libdir=@libdir@
+PACKAGE_NAME=@PACKAGE_NAME@
+PACKAGE_TARNAME=@PACKAGE_TARNAME@
+PACKAGE_VERSION=@PACKAGE_VERSION@
+target_cpu=@target_cpu@
+platform=@platform@
+pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
+
+grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
+
+# Usage: usage
+# Print the usage.
+usage () {
+ cat <<EOF
+Usage: grub-mkrescue [OPTION] output_image
+Make GRUB rescue image.
+
+ -h, --help print this message and exit
+ -v, --version print the version information and exit
+ --modules=MODULES pre-load specified modules MODULES
+ --pkglibdir=DIR use images from directory DIR
+ default: ${pkglibdir}
+ --grub-mkimage=FILE use FILE as grub-mkimage
+
+grub-mkimage generates a bootable rescue CD image for PowerMac and CHRP.
+
+Report bugs to <grub-devel@gnu.org>.
+EOF
+}
+
+input_dir=${pkglibdir}
+grub_mkimage=grub-mkimage
+
+# Check the arguments.
+for option in "$@"; do
+ case "$option" in
+ -h | --help)
+ usage
+ exit 0 ;;
+ -v | --version)
+ echo "grub-install (GNU GRUB ${PACKAGE_VERSION})"
+ exit 0 ;;
+ --modules=*)
+ modules=`echo "$option" | sed 's/--modules=//'` ;;
+ --pkglibdir=*)
+ input_dir=`echo "$option" | sed 's/--pkglibdir=//'` ;;
+ --grub-mkimage=*)
+ grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
+ -*)
+ echo "Unrecognized option \`$option'" 1>&2
+ usage
+ exit 1
+ ;;
+ *)
+ if test "x$output_image" != x; then
+ echo "Unrecognized option \`$option'" 1>&2
+ usage
+ exit 1
+ fi
+ output_image="${option}" ;;
+ esac
+done
+
+if test "x$output_image" = x; then
+ usage
+ exit 1
+fi
+
+if [ "x${modules}" = "x" ] ; then
+ modules=`cd ${input_dir}/ && ls *.mod`
+fi
+
+map_file=`mktemp`
+cat >${map_file} <<EOF
+# EXTN XLate CREATOR TYPE Comment
+grub.img Raw 'UNIX' 'tbxi' "bootstrap"
+EOF
+
+iso_dir=`mktemp -d`
+boot_dir=${iso_dir}/boot/grub
+mkdir ${iso_dir}/boot
+mkdir ${boot_dir}
+core_img=${boot_dir}/grub.img
+${grub_mkimage} -n -d ${input_dir}/ -o ${core_img} ${modules}
+genisoimage -hfs -part -no-desktop -r -J -o ${output_image} \
+ -map ${map_file} -hfs-bless ${boot_dir} -chrp-boot -sysid PPC \
+ ${iso_dir}
+
+rm -rf ${iso_dir}
+rm -f ${map_file}
+
+exit 0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/3] Provide fallback if /memory/available is missing
2008-01-26 23:28 [PATCH 1/3] Implement grub-mkrescue for PowerMac and CHRP Pavel Roskin
@ 2008-01-26 23:28 ` Pavel Roskin
2008-01-26 23:28 ` [PATCH 3/3] Work around "CLAIM failed" on PowerMac Pavel Roskin
2008-01-29 8:55 ` [PATCH 1/3] Implement grub-mkrescue for PowerMac and CHRP Marco Gerards
2 siblings, 0 replies; 8+ messages in thread
From: Pavel Roskin @ 2008-01-26 23:28 UTC (permalink / raw)
To: grub-devel
* kern/powerpc/ieee1275/openfw.c (grub_available_iterate):
Provide fallback if /memory/available is missing - try claiming
memory between 3Mb and 4Mb. That's what yaboot does.
---
kern/powerpc/ieee1275/openfw.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/kern/powerpc/ieee1275/openfw.c b/kern/powerpc/ieee1275/openfw.c
index 26ff3d5..c8b30e5 100644
--- a/kern/powerpc/ieee1275/openfw.c
+++ b/kern/powerpc/ieee1275/openfw.c
@@ -170,8 +170,13 @@ grub_err_t grub_available_iterate (int (*hook) (grub_uint64_t, grub_uint64_t))
"Couldn't find /memory node");
if (grub_ieee1275_get_integer_property (memory, "available", available,
sizeof available, &available_size))
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
- "Couldn't examine /memory/available property");
+ {
+ /* Fallback for Open Hack'Ware - try claiming memory between 3Mb
+ and 4Mb, just like yaboot would do. */
+ hook (0x300000, 0x100000);
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ "Couldn't examine /memory/available property");
+ }
/* Decode each entry and call `hook'. */
i = 0;
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 3/3] Work around "CLAIM failed" on PowerMac
2008-01-26 23:28 [PATCH 1/3] Implement grub-mkrescue for PowerMac and CHRP Pavel Roskin
2008-01-26 23:28 ` [PATCH 2/3] Provide fallback if /memory/available is missing Pavel Roskin
@ 2008-01-26 23:28 ` Pavel Roskin
2008-01-27 9:02 ` Robert Millan
2008-01-29 8:55 ` [PATCH 1/3] Implement grub-mkrescue for PowerMac and CHRP Marco Gerards
2 siblings, 1 reply; 8+ messages in thread
From: Pavel Roskin @ 2008-01-26 23:28 UTC (permalink / raw)
To: grub-devel
* include/grub/powerpc/ieee1275/kernel.h: Introduce GRUB_MOD_GAP
to create a gap between _end and the modules added to the image
with grub-mkrescue. That fixes "CLAIM failed" on PowerMAC.
* kern/powerpc/ieee1275/init.c: Use GRUB_MOD_GAP.
* util/elf/grub-mkimage.c (add_segments): Likewise.
---
include/grub/powerpc/ieee1275/kernel.h | 5 +++++
kern/powerpc/ieee1275/init.c | 2 +-
util/elf/grub-mkimage.c | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/grub/powerpc/ieee1275/kernel.h b/include/grub/powerpc/ieee1275/kernel.h
index 107b928..129ee20 100644
--- a/include/grub/powerpc/ieee1275/kernel.h
+++ b/include/grub/powerpc/ieee1275/kernel.h
@@ -23,6 +23,11 @@
#define GRUB_MOD_ALIGN 0x1000
+/* Minimal gap between _end and the start of the modules. It's a hack
+ for PowerMac to prevent "CLAIM failed" error. The real fix is to
+ rewrite grub-mkimage to generate valid ELF files. */
+#define GRUB_MOD_GAP 0x8000
+
void EXPORT_FUNC (grub_reboot) (void);
void EXPORT_FUNC (grub_halt) (void);
diff --git a/kern/powerpc/ieee1275/init.c b/kern/powerpc/ieee1275/init.c
index b38f017..6d08140 100644
--- a/kern/powerpc/ieee1275/init.c
+++ b/kern/powerpc/ieee1275/init.c
@@ -242,5 +242,5 @@ grub_get_rtc (void)
grub_addr_t
grub_arch_modules_addr (void)
{
- return ALIGN_UP(_end, GRUB_MOD_ALIGN);
+ return ALIGN_UP(_end + GRUB_MOD_GAP, GRUB_MOD_ALIGN);
}
diff --git a/util/elf/grub-mkimage.c b/util/elf/grub-mkimage.c
index 9e44af1..316169f 100644
--- a/util/elf/grub-mkimage.c
+++ b/util/elf/grub-mkimage.c
@@ -218,7 +218,7 @@ add_segments (char *dir, FILE *out, int chrp, char *mods[])
grub_addr_t modbase;
/* Place modules just after grub segment. */
- modbase = ALIGN_UP(grub_end, GRUB_MOD_ALIGN);
+ modbase = ALIGN_UP(grub_end + GRUB_MOD_GAP, GRUB_MOD_ALIGN);
/* Construct new segment header for modules. */
phdr = phdrs + grub_target_to_host16 (ehdr.e_phnum);
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 3/3] Work around "CLAIM failed" on PowerMac
2008-01-26 23:28 ` [PATCH 3/3] Work around "CLAIM failed" on PowerMac Pavel Roskin
@ 2008-01-27 9:02 ` Robert Millan
2008-01-27 9:27 ` Pavel Roskin
0 siblings, 1 reply; 8+ messages in thread
From: Robert Millan @ 2008-01-27 9:02 UTC (permalink / raw)
To: The development of GRUB 2
On Sat, Jan 26, 2008 at 06:28:23PM -0500, Pavel Roskin wrote:
> - return ALIGN_UP(_end, GRUB_MOD_ALIGN);
> + return ALIGN_UP(_end + GRUB_MOD_GAP, GRUB_MOD_ALIGN);
Did you check if the requirement is just a bigger alignment rather than
a gap?
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] Work around "CLAIM failed" on PowerMac
2008-01-27 9:02 ` Robert Millan
@ 2008-01-27 9:27 ` Pavel Roskin
2008-01-27 10:13 ` Robert Millan
0 siblings, 1 reply; 8+ messages in thread
From: Pavel Roskin @ 2008-01-27 9:27 UTC (permalink / raw)
To: The development of GRUB 2, Robert Millan
Quoting Robert Millan <rmh@aybabtu.com>:
> On Sat, Jan 26, 2008 at 06:28:23PM -0500, Pavel Roskin wrote:
>> - return ALIGN_UP(_end, GRUB_MOD_ALIGN);
>> + return ALIGN_UP(_end + GRUB_MOD_GAP, GRUB_MOD_ALIGN);
>
> Did you check if the requirement is just a bigger alignment rather than
> a gap?
Yes, I checked that. I wish it would be bigger alignment, but it's not.
_end is 0x29NNN, so the module base 0x32000 is OK, but 0x31000 or
0x30000 is not OK. 0x30000 is better aligned than 0x32000.
I also tried adding more code to the core image, and the 0x8000 gap
was still OK.
We could increase GRUB_MOD_ALIGN, say, to 0x40000 (256k), but we could
eventually hit the limit for the code and have this problem again.
I'll rather add a couple of lines and avoid a problem that could
re-appear suddenly and for no obvious reason.
Of course, we would be very unlikely to hit a higher limit, like
0x100000 (1Mb). After all, 640k should be enough for everyone ;-)
It's your call.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] Work around "CLAIM failed" on PowerMac
2008-01-27 9:27 ` Pavel Roskin
@ 2008-01-27 10:13 ` Robert Millan
2008-01-27 20:36 ` Pavel Roskin
0 siblings, 1 reply; 8+ messages in thread
From: Robert Millan @ 2008-01-27 10:13 UTC (permalink / raw)
To: Pavel Roskin; +Cc: The development of GRUB 2
On Sun, Jan 27, 2008 at 04:27:31AM -0500, Pavel Roskin wrote:
> Quoting Robert Millan <rmh@aybabtu.com>:
>
> >On Sat, Jan 26, 2008 at 06:28:23PM -0500, Pavel Roskin wrote:
> >>- return ALIGN_UP(_end, GRUB_MOD_ALIGN);
> >>+ return ALIGN_UP(_end + GRUB_MOD_GAP, GRUB_MOD_ALIGN);
> >
> >Did you check if the requirement is just a bigger alignment rather than
> >a gap?
>
> Yes, I checked that. I wish it would be bigger alignment, but it's not.
Ah, ok.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] Work around "CLAIM failed" on PowerMac
2008-01-27 10:13 ` Robert Millan
@ 2008-01-27 20:36 ` Pavel Roskin
0 siblings, 0 replies; 8+ messages in thread
From: Pavel Roskin @ 2008-01-27 20:36 UTC (permalink / raw)
To: Robert Millan; +Cc: The development of GRUB 2
On Sun, 2008-01-27 at 11:13 +0100, Robert Millan wrote:
> On Sun, Jan 27, 2008 at 04:27:31AM -0500, Pavel Roskin wrote:
> > Quoting Robert Millan <rmh@aybabtu.com>:
> >
> > >On Sat, Jan 26, 2008 at 06:28:23PM -0500, Pavel Roskin wrote:
> > >>- return ALIGN_UP(_end, GRUB_MOD_ALIGN);
> > >>+ return ALIGN_UP(_end + GRUB_MOD_GAP, GRUB_MOD_ALIGN);
> > >
> > >Did you check if the requirement is just a bigger alignment rather than
> > >a gap?
> >
> > Yes, I checked that. I wish it would be bigger alignment, but it's not.
>
> Ah, ok.
Applied.
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] Implement grub-mkrescue for PowerMac and CHRP
2008-01-26 23:28 [PATCH 1/3] Implement grub-mkrescue for PowerMac and CHRP Pavel Roskin
2008-01-26 23:28 ` [PATCH 2/3] Provide fallback if /memory/available is missing Pavel Roskin
2008-01-26 23:28 ` [PATCH 3/3] Work around "CLAIM failed" on PowerMac Pavel Roskin
@ 2008-01-29 8:55 ` Marco Gerards
2 siblings, 0 replies; 8+ messages in thread
From: Marco Gerards @ 2008-01-29 8:55 UTC (permalink / raw)
To: The development of GRUB 2
Pavel Roskin <proski@gnu.org> writes:
> * DISTLIST: Add util/powerpc/ieee1275/grub-mkrescue.in.
> * conf/powerpc-ieee1275.mk: Add grub-mkrescue support.
I guess you mean .rmk? Please mention the changes you made.
> * conf/powerpc-ieee1275.mk: Regenerate.
No need to mention regenerated files.
> * util/powerpc/ieee1275/grub-mkrescue.in: Implement
> grub-mkrescue for PowerMac and CHRP.
This is a new file? In that case please say that.
Can you please include a proper changelog entry including its header
and tabs? It's important that you describe what you change, not what
it is supposed to do.
--
Marco
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-01-29 8:54 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-26 23:28 [PATCH 1/3] Implement grub-mkrescue for PowerMac and CHRP Pavel Roskin
2008-01-26 23:28 ` [PATCH 2/3] Provide fallback if /memory/available is missing Pavel Roskin
2008-01-26 23:28 ` [PATCH 3/3] Work around "CLAIM failed" on PowerMac Pavel Roskin
2008-01-27 9:02 ` Robert Millan
2008-01-27 9:27 ` Pavel Roskin
2008-01-27 10:13 ` Robert Millan
2008-01-27 20:36 ` Pavel Roskin
2008-01-29 8:55 ` [PATCH 1/3] Implement grub-mkrescue for PowerMac and CHRP 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.