From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Subject: [PATCH] grub-install on coreboot
Date: Sat, 22 Nov 2008 16:53:14 +0100 [thread overview]
Message-ID: <20081122155314.GA1091@thorin> (raw)
[-- Attachment #1: Type: text/plain, Size: 754 bytes --]
Hi,
This patch implements grub-install on coreboot. Since there's no pre-defined
boot protocol on this platform, we simply generate a usable Multiboot image
and dump it to /boot. User can afterwards load it to flash to make the board
boot using this disk, or load it from elsewhere (even from a BIOS rescue disk).
I hope it's not too intrusive to reuse i386-pc's grub-install; I think it's
much better than duplicating the whole script.
Note: indentation changes intentionally ommitted to improve readability.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
[-- Attachment #2: grub-install.diff --]
[-- Type: text/x-diff, Size: 4639 bytes --]
2008-11-22 Robert Millan <rmh@aybabtu.com>
* conf/i386-coreboot.rmk (sbin_SCRIPTS): Add `grub-install'.
(grub_install_SOURCES): New variable.
* util/i386/pc/grub-install.in: Add a few condition checks to make it
usable on coreboot.
Index: conf/i386-coreboot.rmk
===================================================================
--- conf/i386-coreboot.rmk (revision 1926)
+++ conf/i386-coreboot.rmk (working copy)
@@ -90,6 +90,9 @@ grub_emu_SOURCES = commands/boot.c comma
grub_emu_LDFLAGS = $(LIBCURSES)
+sbin_SCRIPTS += grub-install
+grub_install_SOURCES = util/i386/pc/grub-install.in
+
# Modules.
pkglib_MODULES = _linux.mod linux.mod normal.mod \
_multiboot.mod multiboot.mod aout.mod \
Index: util/i386/pc/grub-install.in
===================================================================
--- util/i386/pc/grub-install.in (revision 1926)
+++ util/i386/pc/grub-install.in (working copy)
@@ -32,7 +32,11 @@ platform=@platform@
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
grub_setup=${sbindir}/`echo grub-setup | sed ${transform}`
+if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
+else
+grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}`
+fi
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
rootdir=
@@ -152,6 +156,7 @@ device_map=${grubdir}/device.map
grub_probe="${grub_probe} --device-map=${device_map}"
+if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
# Check if GRUB is installed.
set $grub_setup dummy
if test -f "$1"; then
@@ -160,6 +165,7 @@ else
echo "$1: Not found." 1>&2
exit 1
fi
+fi
set $grub_mkimage dummy
if test -f "$1"; then
@@ -210,9 +216,14 @@ for file in ${grubdir}/*.mod ${grubdir}/
rm -f $file || exit 1
fi
done
-for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst ${pkglibdir}/*.img; do
+for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do
+ cp -f $file ${grubdir} || exit 1
+done
+if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
+for file in ${pkglibdir}/*.img; do
cp -f $file ${grubdir} || exit 1
done
+fi
# Write device to a variable so we don't have to traverse /dev every time.
grub_device=`$grub_probe --target=device ${grubdir}`
@@ -234,7 +245,12 @@ partmap_module=`$grub_probe --target=par
devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}`
# The order in this list is critical. Be careful when modifying it.
-modules="$modules $fs_module $partmap_module biosdisk $devabstraction_module"
+if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
+ modules="$modules biosdisk"
+else
+ modules="$modules ata"
+fi
+modules="$modules $fs_module $partmap_module $devabstraction_module"
prefix_drive=
if [ "x${devabstraction_module}" = "x" ] ; then
@@ -248,7 +264,16 @@ if [ "x${devabstraction_module}" = "x" ]
# Strip partition number
install_drive="`echo ${install_drive} | sed -e s/,[0-9]*//g`"
grub_drive="`echo ${grub_drive} | sed -e s/,[0-9]*//g`"
- if [ "x${grub_drive}" != "x${install_drive}" ] ; then
+ if [ "${target_cpu}-${platform}" != "i386-pc" ] ; then
+ # generic method (used on coreboot)
+ uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`"
+ if [ "x${uuid}" = "x" ] ; then
+ echo "UUID needed on this platform, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
+ exit 1
+ fi
+ prefix_drive="(UUID=${uuid})"
+ modules="$modules fs_uuid"
+ elif [ "x${grub_drive}" != "x${install_drive}" ] ; then
uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`"
if [ "x${uuid}" = "x" ] ; then
echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
@@ -266,12 +291,20 @@ if [ "x${relative_grubdir}" = "x" ] ; th
relative_grubdir=/
fi
+if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
+
$grub_mkimage --output=${grubdir}/core.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
# Now perform the installation.
$grub_setup ${setup_verbose} --directory=${grubdir} --device-map=${device_map} \
${install_device} || exit 1
+else
+
+$grub_mkimage -d ${pkglibdir} --output=/boot/multiboot.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
+
+fi
+
# Prompt the user to check if the device map is correct.
echo "Installation finished. No error reported."
echo "This is the contents of the device map $device_map."
next reply other threads:[~2008-11-22 15:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-22 15:53 Robert Millan [this message]
2008-11-28 20:06 ` [PATCH] grub-install on coreboot Robert Millan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081122155314.GA1091@thorin \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.