merge trunk
This commit is contained in:
commit
e806ce60ee
431 changed files with 17605 additions and 2568 deletions
|
@ -54,12 +54,15 @@ execute_command (char *name, int n, char **args)
|
|||
return (cmd->func) (cmd, n, args);
|
||||
}
|
||||
|
||||
#define CMD_LS 1
|
||||
#define CMD_CP 2
|
||||
#define CMD_CMP 3
|
||||
#define CMD_HEX 4
|
||||
#define CMD_CRC 6
|
||||
#define CMD_BLOCKLIST 7
|
||||
enum {
|
||||
CMD_LS = 1,
|
||||
CMD_CP,
|
||||
CMD_CAT,
|
||||
CMD_CMP,
|
||||
CMD_HEX,
|
||||
CMD_CRC,
|
||||
CMD_BLOCKLIST
|
||||
};
|
||||
|
||||
#define BUF_SIZE 32256
|
||||
|
||||
|
@ -111,7 +114,8 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
|
|||
file = grub_file_open (pathname);
|
||||
if (!file)
|
||||
{
|
||||
grub_util_error (_("cannot open file %s"), pathname);
|
||||
grub_util_error (_("cannot open file %s:%s"), pathname,
|
||||
grub_errmsg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -181,6 +185,26 @@ cmd_cp (char *src, char *dest)
|
|||
fclose (ff);
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_cat (char *src)
|
||||
{
|
||||
auto int cat_hook (grub_off_t ofs, char *buf, int len);
|
||||
int cat_hook (grub_off_t ofs, char *buf, int len)
|
||||
{
|
||||
(void) ofs;
|
||||
|
||||
if ((int) fwrite (buf, 1, len, stdout) != len)
|
||||
{
|
||||
grub_util_error (_("write error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
read_file (src, cat_hook);
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_cmp (char *src, char *dest)
|
||||
{
|
||||
|
@ -221,6 +245,14 @@ cmd_cmp (char *src, char *dest)
|
|||
grub_util_error (_("seek error"));
|
||||
|
||||
read_file (src, cmp_hook);
|
||||
|
||||
{
|
||||
grub_uint64_t pre;
|
||||
pre = ftell (ff);
|
||||
fseek (ff, 0, SEEK_END);
|
||||
if (pre != ftell (ff))
|
||||
grub_util_error (_("unexpected end of file"));
|
||||
}
|
||||
fclose (ff);
|
||||
}
|
||||
|
||||
|
@ -312,6 +344,9 @@ fstest (int n, char **args)
|
|||
case CMD_CP:
|
||||
cmd_cp (args[0], args[1]);
|
||||
break;
|
||||
case CMD_CAT:
|
||||
cmd_cat (args[0]);
|
||||
break;
|
||||
case CMD_CMP:
|
||||
cmd_cmp (args[0], args[1]);
|
||||
break;
|
||||
|
@ -347,6 +382,7 @@ static struct argp_option options[] = {
|
|||
{0, 0, 0 , OPTION_DOC, N_("Commands:"), 1},
|
||||
{N_("ls PATH"), 0, 0 , OPTION_DOC, N_("List files in PATH."), 1},
|
||||
{N_("cp FILE LOCAL"), 0, 0, OPTION_DOC, N_("Copy FILE to local file LOCAL."), 1},
|
||||
{N_("cat FILE"), 0, 0 , OPTION_DOC, N_("Copy FILE to standard output."), 1},
|
||||
{N_("cmp FILE LOCAL"), 0, 0, OPTION_DOC, N_("Compare FILE with local file LOCAL."), 1},
|
||||
{N_("hex FILE"), 0, 0 , OPTION_DOC, N_("Hex dump FILE."), 1},
|
||||
{N_("crc FILE"), 0, 0 , OPTION_DOC, N_("Get crc32 checksum of FILE."), 1},
|
||||
|
@ -459,6 +495,11 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
|||
cmd = CMD_CP;
|
||||
nparm = 2;
|
||||
}
|
||||
else if (!grub_strcmp (arg, "cat"))
|
||||
{
|
||||
cmd = CMD_CAT;
|
||||
nparm = 1;
|
||||
}
|
||||
else if (!grub_strcmp (arg, "cmp"))
|
||||
{
|
||||
cmd = CMD_CMP;
|
||||
|
|
|
@ -56,9 +56,6 @@ debug_image=
|
|||
|
||||
update_nvram=yes
|
||||
|
||||
ofpathname="`which ofpathname`"
|
||||
nvsetenv="`which nvsetenv`"
|
||||
efibootmgr="`which efibootmgr 2>/dev/null || true`"
|
||||
removable=no
|
||||
efi_quiet=
|
||||
|
||||
|
@ -67,7 +64,7 @@ if test -f "${sysconfdir}/default/grub" ; then
|
|||
. "${sysconfdir}/default/grub"
|
||||
fi
|
||||
|
||||
bootloader_id="$(echo "$GRUB_DISTRIBUTOR" | tr '[A-Z]' '[a-z]' | cut -d' ' -f1)"
|
||||
bootloader_id="$(echo "$GRUB_DISTRIBUTOR" | tr 'A-Z' 'a-z' | cut -d' ' -f1)"
|
||||
if test -z "$bootloader_id"; then
|
||||
bootloader_id=grub
|
||||
fi
|
||||
|
@ -273,6 +270,11 @@ if test "x$install_device" = x && ([ "${target_cpu}-${platform}" = "i386-pc" ] \
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if ! ([ "${target_cpu}-${platform}" = "i386-pc" ] \
|
||||
|| [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]); then
|
||||
install_device=
|
||||
fi
|
||||
|
||||
# If the debugging feature is enabled, print commands.
|
||||
setup_verbose=
|
||||
if test x"$debug" = xyes; then
|
||||
|
@ -365,7 +367,7 @@ if [ x"$platform" = xefi ]; then
|
|||
case "$target_cpu" in
|
||||
i386)
|
||||
efi_file=BOOTIA32.EFI ;;
|
||||
x86-64)
|
||||
x86_64)
|
||||
efi_file=BOOTX64.EFI ;;
|
||||
# GRUB does not yet support these architectures, but they're defined
|
||||
# by the specification so we include them here to ease future
|
||||
|
@ -379,7 +381,7 @@ if [ x"$platform" = xefi ]; then
|
|||
case "$target_cpu" in
|
||||
i386)
|
||||
efi_file=grubia32.efi ;;
|
||||
x86-64)
|
||||
x86_64)
|
||||
efi_file=grubx64.efi ;;
|
||||
# GRUB does not yet support these architectures, but they're defined
|
||||
# by the specification so we include them here to ease future
|
||||
|
@ -465,7 +467,8 @@ fi
|
|||
fs_module="`"$grub_probe" --device-map="${device_map}" --target=fs --device "${grub_device}"`"
|
||||
if test "x$fs_module" = x ; then
|
||||
echo "Auto-detection of a filesystem of ${grub_device} failed." 1>&2
|
||||
echo "Please report this together with the output of \"$grub_probe --device-map=\"${device_map}\" --target=fs -v ${grubdir}\" to <bug-grub@gnu.org>" 1>&2
|
||||
echo "Try with --recheck." 1>&2
|
||||
echo "If the problem persists please report this together with the output of \"$grub_probe --device-map=\"${device_map}\" --target=fs -v ${grubdir}\" to <bug-grub@gnu.org>" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -519,27 +522,24 @@ if [ "x${devabstraction_module}" = "x" ] ; then
|
|||
# Strip partition number
|
||||
grub_partition="`echo "${grub_drive}" | sed -e 's/^[^,]*[,)]//; s/)$//'`"
|
||||
grub_drive="`echo "${grub_drive}" | sed -e s/,[a-z0-9,]*//g`"
|
||||
if [ "$disk_module" = ata ] ; then
|
||||
if [ "$disk_module" = ata ] || [ "x${grub_drive}" != "x${install_drive}" ] || ([ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${target_cpu}-${platform}" != x"sparc64-ieee1275" ]) ; then
|
||||
# generic method (used on coreboot and ata mod)
|
||||
uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`"
|
||||
if [ "x${uuid}" = "x" ] ; then
|
||||
echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
|
||||
if [ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${target_cpu}-${platform}" != x"sparc64-ieee1275" ]; then
|
||||
echo "UUID needed with $platform, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
|
||||
elif [ "$disk_module" = ata ]; then
|
||||
echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
|
||||
else
|
||||
echo "UUID needed with cross-disk installs, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
|
||||
fi
|
||||
|
||||
exit 1
|
||||
fi
|
||||
echo "search.fs_uuid ${uuid} root " >> "${grubdir}/load.cfg"
|
||||
echo 'set prefix=($root)'"${relative_grubdir}" >> "${grubdir}/load.cfg"
|
||||
config_opt="-c ${grubdir}/load.cfg "
|
||||
modules="$modules search_fs_uuid"
|
||||
elif [ "x${grub_drive}" != "x${install_drive}" ] ; then
|
||||
uuid="`"$grub_probe" --device-map="${device_map}" --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
|
||||
exit 1
|
||||
fi
|
||||
echo "search.fs_uuid ${uuid} root " >> ${grubdir}/load.cfg
|
||||
echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg
|
||||
config_opt="-c ${grubdir}/load.cfg "
|
||||
modules="$modules search_fs_uuid"
|
||||
elif [ "x$platform" = xefi ] || [ "x$platform" = xpc ]; then
|
||||
# we need to hardcode the partition number in the core image's prefix.
|
||||
if [ x"$grub_partition" = x ]; then
|
||||
|
@ -554,13 +554,13 @@ fi
|
|||
|
||||
case "${target_cpu}-${platform}" in
|
||||
sparc64-ieee1275) mkimage_target=sparc64-ieee1275-raw ;;
|
||||
mips-yeeloong) mkimage_target=mipsel-yeeloong-elf ;;
|
||||
mipsel-loongson) mkimage_target=mipsel-loongson-elf ;;
|
||||
*) mkimage_target="${target_cpu}-${platform}" ;;
|
||||
esac
|
||||
|
||||
case "${target_cpu}-${platform}" in
|
||||
i386-efi | x86_64-efi) imgext=efi ;;
|
||||
mips-yeeloong | i386-coreboot | i386-multiboot | i386-ieee1275 \
|
||||
mipsel-loongson | i386-coreboot | i386-multiboot | i386-ieee1275 \
|
||||
| powerpc-ieee1275) imgext=elf ;;
|
||||
*) imgext=img ;;
|
||||
esac
|
||||
|
@ -569,7 +569,7 @@ esac
|
|||
"$grub_mkimage" ${config_opt} -d "${pkglibdir}" -O ${mkimage_target} --output="${grubdir}/core.${imgext}" --prefix="${prefix_drive}${relative_grubdir}" $modules || exit 1
|
||||
|
||||
# Backward-compatibility kludges
|
||||
if [ "${target_cpu}-${platform}" = "mips-yeeloong" ]; then
|
||||
if [ "${target_cpu}-${platform}" = "mipsel-loongson" ]; then
|
||||
cp "${grubdir}/core.${imgext}" "${bootdir}"/grub.elf
|
||||
elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ]; then
|
||||
cp "${grubdir}/core.${imgext}" "${grubdir}/grub"
|
||||
|
@ -585,6 +585,8 @@ if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}"
|
|||
--device-map="${device_map}" "${install_device}" || exit 1
|
||||
elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ]; then
|
||||
if [ x"$update_nvram" = xyes ]; then
|
||||
ofpathname="`which ofpathname`"
|
||||
nvsetenv="`which nvsetenv`"
|
||||
set "$ofpathname" dummy
|
||||
if test -f "$1"; then
|
||||
:
|
||||
|
@ -617,10 +619,18 @@ elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${pla
|
|||
exit 1
|
||||
}
|
||||
fi
|
||||
elif [ x"${target_cpu}-${platform}" = xmips-arc ]; then
|
||||
dvhtool -d "${install_device}" --unix-to-vh "{grubdir}/core.${imgext}" grub
|
||||
echo "You will have to set SystemPartition and OSLoader manually."
|
||||
elif [ x"$platform" = xefi ]; then
|
||||
cp "${grubdir}/core.${imgext}" "${efidir}/${efi_file}"
|
||||
# For old macs. Suggested by Peter Jones.
|
||||
if [ x$target_cpu = xi386 ]; then
|
||||
cp "${grubdir}/core.${imgext}" "${efidir}/boot.efi"
|
||||
fi
|
||||
|
||||
# Try to make this image bootable using the EFI Boot Manager, if available.
|
||||
efibootmgr="`which efibootmgr`"
|
||||
if test "$removable" = no && test -n "$efi_distributor" && \
|
||||
test -n "$efibootmgr"; then
|
||||
# On Linux, we need the efivars kernel modules.
|
||||
|
@ -648,7 +658,7 @@ elif [ x"$platform" = xefi ]; then
|
|||
efidir_disk="$(echo "$clean_devmap" | grep "^$(echo "$efidir_drive" | sed 's/,[^)]*//')" | cut -f2)"
|
||||
efidir_part="$(echo "$efidir_drive" | sed 's/^([^,]*,[^0-9]*//; s/[^0-9].*//')"
|
||||
efibootmgr $efi_quiet -c -d "$efidir_disk" -p "$efidir_part" -w \
|
||||
-L "$GRUB_DISTRIBUTOR" -l "\\EFI\\$efi_distributor\\$efi_file"
|
||||
-L "$bootloader_id" -l "\\EFI\\$efi_distributor\\$efi_file"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
transform="@program_transform_name@"
|
||||
|
||||
prefix="@prefix@"
|
||||
exec_prefix="@exec_prefix@"
|
||||
bindir="@bindir@"
|
||||
|
||||
grub_mklayout=${bindir}/`echo grub-mklayout | sed ${transform}`
|
||||
|
||||
ckbcomp "$@" | $grub_mklayout -o "$1".gkb
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
|
@ -78,9 +79,12 @@ main (int argc, char **argv)
|
|||
{
|
||||
char *oldname = NULL;
|
||||
char *newsuffix;
|
||||
char *ptr;
|
||||
|
||||
for (ptr = buf; *ptr && grub_isspace (*ptr); ptr++);
|
||||
|
||||
oldname = entryname;
|
||||
parsed = grub_legacy_parse (buf, &entryname, &newsuffix);
|
||||
parsed = grub_legacy_parse (ptr, &entryname, &newsuffix);
|
||||
if (newsuffix)
|
||||
{
|
||||
suffixlen += strlen (newsuffix);
|
||||
|
|
|
@ -280,6 +280,8 @@ for i in ${grub_mkconfig_dir}/* ; do
|
|||
case "$i" in
|
||||
# emacsen backup files. FIXME: support other editors
|
||||
*~) ;;
|
||||
# emacsen autosave files. FIXME: support other editors
|
||||
\#*\#) ;;
|
||||
*)
|
||||
if grub_file_is_not_garbage "$i" && test -x "$i" ; then
|
||||
echo
|
||||
|
|
|
@ -16,19 +16,19 @@
|
|||
|
||||
transform="@program_transform_name@"
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
datarootdir=@datarootdir@
|
||||
datadir=@datadir@
|
||||
bindir=@bindir@
|
||||
sbindir=@sbindir@
|
||||
pkgdatadir=${datadir}/`echo @PACKAGE_TARNAME@ | sed "${transform}"`
|
||||
prefix="@prefix@"
|
||||
exec_prefix="@exec_prefix@"
|
||||
datarootdir="@datarootdir@"
|
||||
datadir="@datadir@"
|
||||
bindir="@bindir@"
|
||||
sbindir="@sbindir@"
|
||||
pkgdatadir="${datadir}/`echo "@PACKAGE_TARNAME@" | sed "${transform}"`"
|
||||
|
||||
if test "x$grub_probe" = x; then
|
||||
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
|
||||
grub_probe="${sbindir}/`echo grub-probe | sed "${transform}"`"
|
||||
fi
|
||||
if test "x$grub_mkrelpath" = x; then
|
||||
grub_mkrelpath=${bindir}/`echo grub-mkrelpath | sed ${transform}`
|
||||
grub_mkrelpath="${bindir}/`echo grub-mkrelpath | sed "${transform}"`"
|
||||
fi
|
||||
|
||||
if $(which gettext >/dev/null 2>/dev/null) ; then
|
||||
|
@ -44,20 +44,26 @@ grub_warn ()
|
|||
|
||||
make_system_path_relative_to_its_root ()
|
||||
{
|
||||
${grub_mkrelpath} $1
|
||||
"${grub_mkrelpath}" "$1"
|
||||
}
|
||||
|
||||
is_path_readable_by_grub ()
|
||||
{
|
||||
path=$1
|
||||
path="$1"
|
||||
|
||||
# abort if path doesn't exist
|
||||
if test -e $path ; then : ;else
|
||||
if test -e "$path" ; then : ;else
|
||||
return 1
|
||||
fi
|
||||
|
||||
# abort if file is in a filesystem we can't read
|
||||
if ${grub_probe} -t fs $path > /dev/null 2>&1 ; then : ; else
|
||||
if "${grub_probe}" -t fs "$path" > /dev/null 2>&1 ; then : ; else
|
||||
return 1
|
||||
fi
|
||||
|
||||
# ... or if we can't figure out the abstraction module, for example if
|
||||
# memberlist fails on an LVM volume group.
|
||||
if ${grub_probe} -t abstraction $path > /dev/null 2>&1 ; then : ; else
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -66,24 +72,24 @@ is_path_readable_by_grub ()
|
|||
|
||||
convert_system_path_to_grub_path ()
|
||||
{
|
||||
path=$1
|
||||
path="$1"
|
||||
|
||||
grub_warn "convert_system_path_to_grub_path() is deprecated. Use prepare_grub_to_access_device() instead."
|
||||
|
||||
# abort if GRUB can't access the path
|
||||
if is_path_readable_by_grub ${path} ; then : ; else
|
||||
if is_path_readable_by_grub "${path}" ; then : ; else
|
||||
return 1
|
||||
fi
|
||||
|
||||
if drive=`${grub_probe} -t drive $path` ; then : ; else
|
||||
if drive="`"${grub_probe}" -t drive "$path"`" ; then : ; else
|
||||
return 1
|
||||
fi
|
||||
|
||||
if relative_path=`make_system_path_relative_to_its_root $path` ; then : ; else
|
||||
if relative_path="`make_system_path_relative_to_its_root "$path"`" ; then : ; else
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo ${drive}${relative_path}
|
||||
echo "${drive}${relative_path}"
|
||||
}
|
||||
|
||||
save_default_entry ()
|
||||
|
@ -97,28 +103,33 @@ EOF
|
|||
|
||||
prepare_grub_to_access_device ()
|
||||
{
|
||||
device=$1
|
||||
device="$1"
|
||||
|
||||
# Abstraction modules aren't auto-loaded.
|
||||
abstraction="`${grub_probe} --device ${device} --target=abstraction`"
|
||||
abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`"
|
||||
for module in ${abstraction} ; do
|
||||
echo "insmod ${module}"
|
||||
done
|
||||
|
||||
partmap="`${grub_probe} --device ${device} --target=partmap`"
|
||||
partmap="`"${grub_probe}" --device "${device}" --target=partmap`"
|
||||
for module in ${partmap} ; do
|
||||
echo "insmod part_${module}"
|
||||
case "${module}" in
|
||||
netbsd | openbsd)
|
||||
echo "insmod part_bsd";;
|
||||
*)
|
||||
echo "insmod part_${module}";;
|
||||
esac
|
||||
done
|
||||
|
||||
fs="`${grub_probe} --device ${device} --target=fs`"
|
||||
fs="`"${grub_probe}" --device "${device}" --target=fs`"
|
||||
for module in ${fs} ; do
|
||||
echo "insmod ${module}"
|
||||
done
|
||||
|
||||
# If there's a filesystem UUID that GRUB is capable of identifying, use it;
|
||||
# otherwise set root as per value in device.map.
|
||||
echo "set root='`${grub_probe} --device ${device} --target=drive`'"
|
||||
if fs_uuid="`${grub_probe} --device ${device} --target=fs_uuid 2> /dev/null`" ; then
|
||||
echo "set root='`"${grub_probe}" --device "${device}" --target=drive`'"
|
||||
if fs_uuid="`"${grub_probe}" --device "${device}" --target=fs_uuid 2> /dev/null`" ; then
|
||||
echo "search --no-floppy --fs-uuid --set=root ${fs_uuid}"
|
||||
fi
|
||||
}
|
||||
|
@ -138,21 +149,21 @@ grub_file_is_not_garbage ()
|
|||
|
||||
version_test_numeric ()
|
||||
{
|
||||
local a=$1
|
||||
local cmp=$2
|
||||
local b=$3
|
||||
local a="$1"
|
||||
local cmp="$2"
|
||||
local b="$3"
|
||||
if [ "$a" = "$b" ] ; then
|
||||
case $cmp in
|
||||
case "$cmp" in
|
||||
ge|eq|le) return 0 ;;
|
||||
gt|lt) return 1 ;;
|
||||
esac
|
||||
fi
|
||||
if [ "$cmp" = "lt" ] ; then
|
||||
c=$a
|
||||
a=$b
|
||||
b=$c
|
||||
c="$a"
|
||||
a="$b"
|
||||
b="$c"
|
||||
fi
|
||||
if (echo $a ; echo $b) | sort -n | head -n 1 | grep -qx $b ; then
|
||||
if (echo "$a" ; echo "$b") | sort -n | head -n 1 | grep -qx "$b" ; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
|
@ -161,25 +172,25 @@ version_test_numeric ()
|
|||
|
||||
version_test_gt ()
|
||||
{
|
||||
local a=`echo $1 | sed -e "s/[^-]*-//"`
|
||||
local b=`echo $2 | sed -e "s/[^-]*-//"`
|
||||
local a="`echo "$1" | sed -e "s/[^-]*-//"`"
|
||||
local b="`echo "$2" | sed -e "s/[^-]*-//"`"
|
||||
local cmp=gt
|
||||
if [ "x$b" = "x" ] ; then
|
||||
return 0
|
||||
fi
|
||||
case $a:$b in
|
||||
case "$a:$b" in
|
||||
*.old:*.old) ;;
|
||||
*.old:*) a=`echo -n $a | sed -e s/\.old$//` ; cmp=gt ;;
|
||||
*:*.old) b=`echo -n $b | sed -e s/\.old$//` ; cmp=ge ;;
|
||||
*.old:*) a="`echo -n "$a" | sed -e 's/\.old$//'`" ; cmp=gt ;;
|
||||
*:*.old) b="`echo -n "$b" | sed -e 's/\.old$//'`" ; cmp=ge ;;
|
||||
esac
|
||||
version_test_numeric $a $cmp $b
|
||||
return $?
|
||||
version_test_numeric "$a" "$cmp" "$b"
|
||||
return "$?"
|
||||
}
|
||||
|
||||
version_find_latest ()
|
||||
{
|
||||
local a=""
|
||||
for i in $@ ; do
|
||||
for i in "$@" ; do
|
||||
if version_test_gt "$i" "$a" ; then
|
||||
a="$i"
|
||||
fi
|
||||
|
@ -191,7 +202,7 @@ version_find_latest ()
|
|||
# printf; so this turns ' into \'. Note that you must use the output of
|
||||
# this function in a printf format string.
|
||||
gettext_quoted () {
|
||||
$gettext "$@" | sed "s/'/'\\\\\\\\''/g"
|
||||
"$gettext" "$@" | sed "s/'/'\\\\\\\\''/g"
|
||||
}
|
||||
|
||||
# Run the first argument through gettext_quoted, and then pass that and all
|
||||
|
@ -204,9 +215,9 @@ gettext_printf () {
|
|||
}
|
||||
|
||||
uses_abstraction () {
|
||||
device=$1
|
||||
device="$1"
|
||||
|
||||
abstraction="`${grub_probe} --device ${device} --target=abstraction`"
|
||||
abstraction="`"${grub_probe}" --device "${device}" --target=abstraction`"
|
||||
for module in ${abstraction}; do
|
||||
if test "x${module}" = "x$2"; then
|
||||
return 0
|
||||
|
|
|
@ -859,7 +859,7 @@ void
|
|||
write_font_pf2 (struct grub_font_info *font_info, char *output_file)
|
||||
{
|
||||
FILE *file;
|
||||
grub_uint32_t leng, data;
|
||||
grub_uint32_t leng;
|
||||
char style_name[20], *font_name;
|
||||
int offset;
|
||||
struct grub_glyph_info *cur;
|
||||
|
@ -959,12 +959,14 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
|
|||
for (cur = font_info->glyphs_sorted;
|
||||
cur < font_info->glyphs_sorted + font_info->num_glyphs; cur++)
|
||||
{
|
||||
data = grub_cpu_to_be32 (cur->char_code);
|
||||
grub_util_write_image ((char *) &data, 4, file);
|
||||
data = 0;
|
||||
grub_util_write_image ((char *) &data, 1, file);
|
||||
data = grub_cpu_to_be32 (offset);
|
||||
grub_util_write_image ((char *) &data, 4, file);
|
||||
grub_uint32_t data32;
|
||||
grub_uint8_t data8;
|
||||
data32 = grub_cpu_to_be32 (cur->char_code);
|
||||
grub_util_write_image ((char *) &data32, 4, file);
|
||||
data8 = 0;
|
||||
grub_util_write_image ((char *) &data8, 1, file);
|
||||
data32 = grub_cpu_to_be32 (offset);
|
||||
grub_util_write_image ((char *) &data32, 4, file);
|
||||
offset += 10 + cur->bitmap_size;
|
||||
}
|
||||
|
||||
|
@ -976,6 +978,7 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
|
|||
for (cur = font_info->glyphs_sorted;
|
||||
cur < font_info->glyphs_sorted + font_info->num_glyphs; cur++)
|
||||
{
|
||||
grub_uint16_t data;
|
||||
data = grub_cpu_to_be16 (cur->width);
|
||||
grub_util_write_image ((char *) &data, 2, file);
|
||||
data = grub_cpu_to_be16 (cur->height);
|
||||
|
@ -1146,11 +1149,18 @@ main (int argc, char *argv[])
|
|||
{
|
||||
FT_Face ft_face;
|
||||
int size;
|
||||
FT_Error err;
|
||||
|
||||
if (FT_New_Face (ft_lib, argv[optind], font_index, &ft_face))
|
||||
err = FT_New_Face (ft_lib, argv[optind], font_index, &ft_face);
|
||||
if (err)
|
||||
{
|
||||
grub_util_info ("can't open file %s, index %d", argv[optind],
|
||||
font_index);
|
||||
grub_printf ("can't open file %s, index %d: error %d", argv[optind],
|
||||
font_index, err);
|
||||
if (err > 0 && err < (signed) ARRAY_SIZE (ft_errmsgs))
|
||||
printf (": %s\n", ft_errmsgs[err]);
|
||||
else
|
||||
printf ("\n");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <grub/util/resolve.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/offsets.h>
|
||||
#include <grub/crypto.h>
|
||||
#include <grub/dl.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -57,20 +59,22 @@ typedef enum {
|
|||
|
||||
struct image_target_desc
|
||||
{
|
||||
const char *name;
|
||||
const char *dirname;
|
||||
const char *names[6];
|
||||
grub_size_t voidp_sizeof;
|
||||
int bigendian;
|
||||
enum {
|
||||
IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT,
|
||||
IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_I386_IEEE1275,
|
||||
IMAGE_YEELOONG_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH,
|
||||
IMAGE_I386_PC_PXE
|
||||
IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH,
|
||||
IMAGE_FULOONG_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC
|
||||
} id;
|
||||
enum
|
||||
{
|
||||
PLATFORM_FLAGS_NONE = 0,
|
||||
PLATFORM_FLAGS_LZMA = 1,
|
||||
PLATFORM_FLAGS_DECOMPRESSORS = 2
|
||||
PLATFORM_FLAGS_DECOMPRESSORS = 2,
|
||||
PLATFORM_FLAGS_MODULES_BEFORE_KERNEL = 4,
|
||||
} flags;
|
||||
unsigned prefix;
|
||||
unsigned prefix_end;
|
||||
|
@ -86,12 +90,21 @@ struct image_target_desc
|
|||
grub_uint64_t link_addr;
|
||||
unsigned mod_gap, mod_align;
|
||||
grub_compression_t default_compression;
|
||||
grub_uint16_t pe_target;
|
||||
};
|
||||
|
||||
#define EFI64_HEADER_SIZE ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE \
|
||||
+ GRUB_PE32_SIGNATURE_SIZE \
|
||||
+ sizeof (struct grub_pe32_coff_header) \
|
||||
+ sizeof (struct grub_pe64_optional_header) \
|
||||
+ 4 * sizeof (struct grub_pe32_section_table), \
|
||||
GRUB_PE32_SECTION_ALIGNMENT)
|
||||
|
||||
struct image_target_desc image_targets[] =
|
||||
{
|
||||
{
|
||||
.name = "i386-coreboot",
|
||||
.dirname = "i386-coreboot",
|
||||
.names = { "i386-coreboot", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_COREBOOT,
|
||||
|
@ -113,7 +126,8 @@ struct image_target_desc image_targets[] =
|
|||
.mod_align = GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN
|
||||
},
|
||||
{
|
||||
.name = "i386-multiboot",
|
||||
.dirname = "i386-multiboot",
|
||||
.names = { "i386-multiboot", NULL},
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_COREBOOT,
|
||||
|
@ -135,7 +149,8 @@ struct image_target_desc image_targets[] =
|
|||
.mod_align = GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN
|
||||
},
|
||||
{
|
||||
.name = "i386-pc",
|
||||
.dirname = "i386-pc",
|
||||
.names = { "i386-pc", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_I386_PC,
|
||||
|
@ -153,7 +168,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_addr = GRUB_KERNEL_I386_PC_LINK_ADDR
|
||||
},
|
||||
{
|
||||
.name = "i386-pc-pxe",
|
||||
.dirname = "i386-pc",
|
||||
.names = { "i386-pc-pxe", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_I386_PC_PXE,
|
||||
|
@ -171,7 +187,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_addr = GRUB_KERNEL_I386_PC_LINK_ADDR
|
||||
},
|
||||
{
|
||||
.name = "i386-efi",
|
||||
.dirname = "i386-efi",
|
||||
.names = { "i386-efi", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_EFI,
|
||||
|
@ -191,9 +208,12 @@ struct image_target_desc image_targets[] =
|
|||
GRUB_PE32_SECTION_ALIGNMENT),
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.pe_target = GRUB_PE32_MACHINE_I386,
|
||||
.elf_target = EM_386,
|
||||
},
|
||||
{
|
||||
.name = "i386-ieee1275",
|
||||
.dirname = "i386-ieee1275",
|
||||
.names = { "i386-ieee1275", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_I386_IEEE1275,
|
||||
|
@ -215,7 +235,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_align = 4,
|
||||
},
|
||||
{
|
||||
.name = "i386-qemu",
|
||||
.dirname = "i386-qemu",
|
||||
.names = { "i386-qemu", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_QEMU,
|
||||
|
@ -233,7 +254,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_addr = GRUB_KERNEL_I386_QEMU_LINK_ADDR
|
||||
},
|
||||
{
|
||||
.name = "x86_64-efi",
|
||||
.dirname = "x86_64-efi",
|
||||
.names = { "x86_64-efi", NULL },
|
||||
.voidp_sizeof = 8,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_EFI,
|
||||
|
@ -245,59 +267,82 @@ struct image_target_desc image_targets[] =
|
|||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
||||
.vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
||||
+ GRUB_PE32_SIGNATURE_SIZE
|
||||
+ sizeof (struct grub_pe32_coff_header)
|
||||
+ sizeof (struct grub_pe64_optional_header)
|
||||
+ 4 * sizeof (struct grub_pe32_section_table),
|
||||
GRUB_PE32_SECTION_ALIGNMENT),
|
||||
.vaddr_offset = EFI64_HEADER_SIZE,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.pe_target = GRUB_PE32_MACHINE_X86_64,
|
||||
.elf_target = EM_X86_64,
|
||||
},
|
||||
{
|
||||
.name = "mipsel-yeeloong-flash",
|
||||
.dirname = "mipsel-loongson",
|
||||
.names = { "mipsel-yeeloong-flash", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_YEELOONG_FLASH,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.prefix = GRUB_KERNEL_MIPS_YEELOONG_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END,
|
||||
.prefix = GRUB_KERNEL_MIPS_LOONGSON_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.link_addr = GRUB_KERNEL_MIPS_YEELOONG_LINK_ADDR,
|
||||
.link_addr = GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR,
|
||||
.elf_target = EM_MIPS,
|
||||
.link_align = GRUB_KERNEL_MIPS_YEELOONG_LINK_ALIGN,
|
||||
.link_align = GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN,
|
||||
.default_compression = COMPRESSION_NONE
|
||||
},
|
||||
{
|
||||
.name = "mipsel-yeeloong-elf",
|
||||
.dirname = "mipsel-loongson",
|
||||
.names = { "mipsel-fuloong-flash", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_YEELOONG_ELF,
|
||||
.id = IMAGE_FULOONG_FLASH,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.prefix = GRUB_KERNEL_MIPS_YEELOONG_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END,
|
||||
.prefix = GRUB_KERNEL_MIPS_LOONGSON_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.link_addr = GRUB_KERNEL_MIPS_YEELOONG_LINK_ADDR,
|
||||
.link_addr = GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR,
|
||||
.elf_target = EM_MIPS,
|
||||
.link_align = GRUB_KERNEL_MIPS_YEELOONG_LINK_ALIGN,
|
||||
.link_align = GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN,
|
||||
.default_compression = COMPRESSION_NONE
|
||||
},
|
||||
{
|
||||
.name = "powerpc-ieee1275",
|
||||
.dirname = "mipsel-loongson",
|
||||
.names = { "mipsel-loongson-elf", "mipsel-yeeloong-elf",
|
||||
"mipsel-fuloong-elf", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_LOONGSON_ELF,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.prefix = GRUB_KERNEL_MIPS_LOONGSON_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.link_addr = GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR,
|
||||
.elf_target = EM_MIPS,
|
||||
.link_align = GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN,
|
||||
.default_compression = COMPRESSION_NONE
|
||||
},
|
||||
{
|
||||
.dirname = "powerpc-ieee1275",
|
||||
.names = { "powerpc-ieee1275", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 1,
|
||||
.id = IMAGE_PPC,
|
||||
|
@ -319,7 +364,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_align = 4
|
||||
},
|
||||
{
|
||||
.name = "sparc64-ieee1275-raw",
|
||||
.dirname = "sparc64-ieee1275",
|
||||
.names = { "sparc64-ieee1275-raw", NULL },
|
||||
.voidp_sizeof = 8,
|
||||
.bigendian = 1,
|
||||
.id = IMAGE_SPARC64_RAW,
|
||||
|
@ -337,7 +383,8 @@ struct image_target_desc image_targets[] =
|
|||
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
|
||||
},
|
||||
{
|
||||
.name = "sparc64-ieee1275-aout",
|
||||
.dirname = "sparc64-ieee1275",
|
||||
.names = { "sparc64-ieee1275-aout", NULL },
|
||||
.voidp_sizeof = 8,
|
||||
.bigendian = 1,
|
||||
.id = IMAGE_SPARC64_AOUT,
|
||||
|
@ -354,6 +401,93 @@ struct image_target_desc image_targets[] =
|
|||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
|
||||
},
|
||||
{
|
||||
.dirname = "ia64-efi",
|
||||
.names = {"ia64-efi", NULL},
|
||||
.voidp_sizeof = 8,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_EFI,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.prefix = GRUB_KERNEL_IA64_EFI_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_IA64_EFI_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
||||
.vaddr_offset = EFI64_HEADER_SIZE,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.pe_target = GRUB_PE32_MACHINE_IA64,
|
||||
.elf_target = EM_IA_64,
|
||||
},
|
||||
{
|
||||
.dirname = "mips-arc",
|
||||
.names = {"mips-arc", NULL},
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 1,
|
||||
.id = IMAGE_MIPS_ARC,
|
||||
.flags = (PLATFORM_FLAGS_DECOMPRESSORS
|
||||
| PLATFORM_FLAGS_MODULES_BEFORE_KERNEL),
|
||||
.prefix = GRUB_KERNEL_MIPS_ARC_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_ARC_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.link_addr = GRUB_KERNEL_MIPS_ARC_LINK_ADDR,
|
||||
.elf_target = EM_MIPS,
|
||||
.link_align = GRUB_KERNEL_MIPS_ARC_LINK_ALIGN,
|
||||
.default_compression = COMPRESSION_NONE
|
||||
},
|
||||
{
|
||||
.dirname = "mipsel-qemu_mips",
|
||||
.names = { "mipsel-qemu_mips-elf", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_LOONGSON_ELF,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.prefix = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
|
||||
.elf_target = EM_MIPS,
|
||||
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
|
||||
.default_compression = COMPRESSION_NONE
|
||||
},
|
||||
{
|
||||
.dirname = "mips-qemu_mips",
|
||||
.names = { "mips-qemu_mips-elf", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 1,
|
||||
.id = IMAGE_LOONGSON_ELF,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.prefix = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
.install_bsd_part = TARGET_NO_FIELD,
|
||||
.link_addr = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR,
|
||||
.elf_target = EM_MIPS,
|
||||
.link_align = GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN,
|
||||
.default_compression = COMPRESSION_NONE
|
||||
},
|
||||
};
|
||||
|
||||
#define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x)))
|
||||
|
@ -624,6 +758,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
grub_uint64_t start_address;
|
||||
void *rel_section;
|
||||
grub_size_t reloc_size, align;
|
||||
size_t decompress_size;
|
||||
|
||||
if (comp == COMPRESSION_AUTO)
|
||||
comp = image_target->default_compression;
|
||||
|
@ -671,27 +806,47 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
grub_util_error (_("prefix is too long"));
|
||||
strcpy (kernel_img + image_target->prefix, prefix);
|
||||
|
||||
if ((image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS)
|
||||
&& (image_target->total_module_size != TARGET_NO_FIELD))
|
||||
*((grub_uint32_t *) (kernel_img + image_target->total_module_size))
|
||||
= grub_host_to_target32 (total_module_size);
|
||||
|
||||
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
|
||||
memmove (kernel_img + total_module_size, kernel_img, kernel_size);
|
||||
|
||||
if (image_target->voidp_sizeof == 8)
|
||||
{
|
||||
/* Fill in the grub_module_info structure. */
|
||||
struct grub_module_info64 *modinfo;
|
||||
modinfo = (struct grub_module_info64 *) (kernel_img + kernel_size);
|
||||
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
|
||||
modinfo = (struct grub_module_info64 *) kernel_img;
|
||||
else
|
||||
modinfo = (struct grub_module_info64 *) (kernel_img + kernel_size);
|
||||
memset (modinfo, 0, sizeof (struct grub_module_info64));
|
||||
modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC);
|
||||
modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info64));
|
||||
modinfo->size = grub_host_to_target_addr (total_module_size);
|
||||
offset = kernel_size + sizeof (struct grub_module_info64);
|
||||
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
|
||||
offset = sizeof (struct grub_module_info64);
|
||||
else
|
||||
offset = kernel_size + sizeof (struct grub_module_info64);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Fill in the grub_module_info structure. */
|
||||
struct grub_module_info32 *modinfo;
|
||||
modinfo = (struct grub_module_info32 *) (kernel_img + kernel_size);
|
||||
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
|
||||
modinfo = (struct grub_module_info32 *) kernel_img;
|
||||
else
|
||||
modinfo = (struct grub_module_info32 *) (kernel_img + kernel_size);
|
||||
memset (modinfo, 0, sizeof (struct grub_module_info32));
|
||||
modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC);
|
||||
modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info32));
|
||||
modinfo->size = grub_host_to_target_addr (total_module_size);
|
||||
offset = kernel_size + sizeof (struct grub_module_info32);
|
||||
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
|
||||
offset = sizeof (struct grub_module_info32);
|
||||
else
|
||||
offset = kernel_size + sizeof (struct grub_module_info32);
|
||||
}
|
||||
|
||||
for (p = path_list; p; p = p->next)
|
||||
|
@ -742,26 +897,27 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
offset += config_size;
|
||||
}
|
||||
|
||||
if ((image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS)
|
||||
&& (image_target->total_module_size != TARGET_NO_FIELD))
|
||||
*((grub_uint32_t *) (kernel_img + image_target->total_module_size))
|
||||
= grub_host_to_target32 (total_module_size);
|
||||
|
||||
grub_util_info ("kernel_img=%p, kernel_size=0x%x", kernel_img, kernel_size);
|
||||
compress_kernel (image_target, kernel_img, kernel_size + total_module_size,
|
||||
&core_img, &core_size, comp);
|
||||
free (kernel_img);
|
||||
|
||||
if (image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS)
|
||||
kernel_img = core_img + total_module_size;
|
||||
else
|
||||
kernel_img = core_img;
|
||||
|
||||
grub_util_info ("the core size is 0x%x", core_size);
|
||||
|
||||
if (!(image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS)
|
||||
&& image_target->total_module_size != TARGET_NO_FIELD)
|
||||
*((grub_uint32_t *) (core_img + image_target->total_module_size))
|
||||
*((grub_uint32_t *) (kernel_img + image_target->total_module_size))
|
||||
= grub_host_to_target32 (total_module_size);
|
||||
if (image_target->kernel_image_size != TARGET_NO_FIELD)
|
||||
*((grub_uint32_t *) (core_img + image_target->kernel_image_size))
|
||||
*((grub_uint32_t *) (kernel_img + image_target->kernel_image_size))
|
||||
= grub_host_to_target32 (kernel_size);
|
||||
if (image_target->compressed_size != TARGET_NO_FIELD)
|
||||
*((grub_uint32_t *) (core_img + image_target->compressed_size))
|
||||
*((grub_uint32_t *) (kernel_img + image_target->compressed_size))
|
||||
= grub_host_to_target32 (core_size - image_target->raw_size);
|
||||
|
||||
/* If we included a drive in our prefix, let GRUB know it doesn't have to
|
||||
|
@ -769,9 +925,9 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
if (image_target->install_dos_part != TARGET_NO_FIELD
|
||||
&& image_target->install_bsd_part != TARGET_NO_FIELD && prefix[0] == '(')
|
||||
{
|
||||
*((grub_int32_t *) (core_img + image_target->install_dos_part))
|
||||
*((grub_int32_t *) (kernel_img + image_target->install_dos_part))
|
||||
= grub_host_to_target32 (-2);
|
||||
*((grub_int32_t *) (core_img + image_target->install_bsd_part))
|
||||
*((grub_int32_t *) (kernel_img + image_target->install_bsd_part))
|
||||
= grub_host_to_target32 (-2);
|
||||
}
|
||||
|
||||
|
@ -780,7 +936,6 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
char *full_img;
|
||||
size_t full_size;
|
||||
char *decompress_path, *decompress_img;
|
||||
size_t decompress_size;
|
||||
const char *name;
|
||||
|
||||
switch (comp)
|
||||
|
@ -799,12 +954,19 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
decompress_size = grub_util_get_image_size (decompress_path);
|
||||
decompress_img = grub_util_read_image (decompress_path);
|
||||
|
||||
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_YEELOONG_COMPRESSED_SIZE))
|
||||
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_LOONGSON_COMPRESSED_SIZE))
|
||||
= grub_host_to_target32 (core_size);
|
||||
|
||||
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_YEELOONG_UNCOMPRESSED_SIZE))
|
||||
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_SIZE))
|
||||
= grub_host_to_target32 (kernel_size + total_module_size);
|
||||
|
||||
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
|
||||
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR))
|
||||
= grub_host_to_target_addr (image_target->link_addr - total_module_size);
|
||||
else
|
||||
*((grub_uint32_t *) (decompress_img + GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR))
|
||||
= grub_host_to_target_addr (image_target->link_addr);
|
||||
|
||||
full_size = core_size + decompress_size;
|
||||
|
||||
full_img = xmalloc (full_size);
|
||||
|
@ -901,12 +1063,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
+ 4 * sizeof (struct grub_pe32_section_table),
|
||||
GRUB_PE32_SECTION_ALIGNMENT);
|
||||
else
|
||||
header_size = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
||||
+ GRUB_PE32_SIGNATURE_SIZE
|
||||
+ sizeof (struct grub_pe32_coff_header)
|
||||
+ sizeof (struct grub_pe64_optional_header)
|
||||
+ 4 * sizeof (struct grub_pe32_section_table),
|
||||
GRUB_PE32_SECTION_ALIGNMENT);
|
||||
header_size = EFI64_HEADER_SIZE;
|
||||
|
||||
reloc_addr = ALIGN_UP (header_size + core_size,
|
||||
image_target->section_align);
|
||||
|
@ -927,10 +1084,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
/* The COFF file header. */
|
||||
c = (struct grub_pe32_coff_header *) (header + GRUB_PE32_MSDOS_STUB_SIZE
|
||||
+ GRUB_PE32_SIGNATURE_SIZE);
|
||||
if (image_target->voidp_sizeof == 4)
|
||||
c->machine = grub_host_to_target16 (GRUB_PE32_MACHINE_I386);
|
||||
else
|
||||
c->machine = grub_host_to_target16 (GRUB_PE32_MACHINE_X86_64);
|
||||
c->machine = grub_host_to_target16 (image_target->pe_target);
|
||||
|
||||
c->num_sections = grub_host_to_target16 (4);
|
||||
c->time = grub_host_to_target32 (time (0));
|
||||
|
@ -1097,7 +1251,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
rom_img = xmalloc (rom_size);
|
||||
memset (rom_img, 0, rom_size);
|
||||
|
||||
*((grub_int32_t *) (core_img + GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR))
|
||||
*((grub_int32_t *) (kernel_img + GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR))
|
||||
= grub_host_to_target32 ((grub_uint32_t) -rom_size);
|
||||
|
||||
memcpy (rom_img, core_img, core_size);
|
||||
|
@ -1162,17 +1316,63 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
}
|
||||
break;
|
||||
case IMAGE_YEELOONG_FLASH:
|
||||
case IMAGE_FULOONG_FLASH:
|
||||
{
|
||||
char *rom_img;
|
||||
size_t rom_size;
|
||||
char *boot_path, *boot_img;
|
||||
size_t boot_size;
|
||||
|
||||
boot_path = grub_util_get_path (dir, "fwstart.img");
|
||||
grub_uint8_t context[GRUB_MD_SHA512->contextsize];
|
||||
/* fwstart.img is the only part which can't be tested by using *-elf
|
||||
target. Check it against the checksum. */
|
||||
const grub_uint8_t yeeloong_fwstart_good_hash[512 / 8] =
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
/* None yet. */
|
||||
const grub_uint8_t fuloong_fwstart_good_hash[512 / 8] =
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
const grub_uint8_t *fwstart_good_hash;
|
||||
|
||||
if (image_target->id == IMAGE_FULOONG_FLASH)
|
||||
{
|
||||
fwstart_good_hash = fuloong_fwstart_good_hash;
|
||||
boot_path = grub_util_get_path (dir, "fwstart_fuloong.img");
|
||||
}
|
||||
else
|
||||
{
|
||||
fwstart_good_hash = yeeloong_fwstart_good_hash;
|
||||
boot_path = grub_util_get_path (dir, "fwstart.img");
|
||||
}
|
||||
|
||||
boot_size = grub_util_get_image_size (boot_path);
|
||||
boot_img = grub_util_read_image (boot_path);
|
||||
|
||||
rom_size = ALIGN_UP (core_size + boot_size, 512 * 1024);
|
||||
grub_memset (context, 0, sizeof (context));
|
||||
GRUB_MD_SHA512->init (context);
|
||||
GRUB_MD_SHA512->write (context, boot_img, boot_size);
|
||||
GRUB_MD_SHA512->final (context);
|
||||
if (grub_memcmp (GRUB_MD_SHA512->read (context), fwstart_good_hash,
|
||||
GRUB_MD_SHA512->mdlen) != 0)
|
||||
grub_util_warn ("fwstart.img doesn't match the known good version. "
|
||||
"Proceed at your own risk");
|
||||
|
||||
if (core_size + boot_size > 512 * 1024)
|
||||
grub_util_error ("firmware image is too big");
|
||||
rom_size = 512 * 1024;
|
||||
|
||||
rom_img = xmalloc (rom_size);
|
||||
memset (rom_img, 0, rom_size);
|
||||
|
@ -1189,7 +1389,82 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
core_size = rom_size;
|
||||
}
|
||||
break;
|
||||
case IMAGE_YEELOONG_ELF:
|
||||
case IMAGE_MIPS_ARC:
|
||||
{
|
||||
char *ecoff_img;
|
||||
struct ecoff_header {
|
||||
grub_uint16_t magic;
|
||||
grub_uint16_t nsec;
|
||||
grub_uint32_t time;
|
||||
grub_uint32_t syms;
|
||||
grub_uint32_t nsyms;
|
||||
grub_uint16_t opt;
|
||||
grub_uint16_t flags;
|
||||
grub_uint16_t magic2;
|
||||
grub_uint16_t version;
|
||||
grub_uint32_t textsize;
|
||||
grub_uint32_t datasize;
|
||||
grub_uint32_t bsssize;
|
||||
grub_uint32_t entry;
|
||||
grub_uint32_t text_start;
|
||||
grub_uint32_t data_start;
|
||||
grub_uint32_t bss_start;
|
||||
grub_uint32_t gprmask;
|
||||
grub_uint32_t cprmask[4];
|
||||
grub_uint32_t gp_value;
|
||||
};
|
||||
struct ecoff_section
|
||||
{
|
||||
char name[8];
|
||||
grub_uint32_t paddr;
|
||||
grub_uint32_t vaddr;
|
||||
grub_uint32_t size;
|
||||
grub_uint32_t file_offset;
|
||||
grub_uint32_t reloc;
|
||||
grub_uint32_t gp;
|
||||
grub_uint16_t nreloc;
|
||||
grub_uint16_t ngp;
|
||||
grub_uint32_t flags;
|
||||
};
|
||||
struct ecoff_header *head;
|
||||
struct ecoff_section *section;
|
||||
grub_uint32_t target_addr;
|
||||
size_t program_size;
|
||||
|
||||
program_size = ALIGN_ADDR (core_size);
|
||||
if (comp == COMPRESSION_NONE)
|
||||
target_addr = (image_target->link_addr
|
||||
- total_module_size - decompress_size);
|
||||
else
|
||||
target_addr = (image_target->link_addr
|
||||
- ALIGN_UP(total_module_size + core_size, 1048576)
|
||||
- (1 << 20));
|
||||
|
||||
ecoff_img = xmalloc (program_size + sizeof (*head) + sizeof (*section));
|
||||
grub_memset (ecoff_img, 0, program_size + sizeof (*head) + sizeof (*section));
|
||||
head = (void *) ecoff_img;
|
||||
section = (void *) (head + 1);
|
||||
head->magic = grub_host_to_target16 (0x160);
|
||||
head->nsec = grub_host_to_target16 (1);
|
||||
head->time = grub_host_to_target32 (0);
|
||||
head->opt = grub_host_to_target16 (0x38);
|
||||
head->flags = grub_host_to_target16 (0x207);
|
||||
head->magic2 = grub_host_to_target16 (0x107);
|
||||
head->textsize = grub_host_to_target32 (program_size);
|
||||
head->entry = grub_host_to_target32 (target_addr);
|
||||
head->text_start = grub_host_to_target32 (target_addr);
|
||||
head->data_start = grub_host_to_target32 (target_addr + program_size);
|
||||
grub_memcpy (section->name, ".text", sizeof (".text") - 1);
|
||||
section->vaddr = grub_host_to_target32 (target_addr);
|
||||
section->size = grub_host_to_target32 (program_size);
|
||||
section->file_offset = grub_host_to_target32 (sizeof (*head) + sizeof (*section));
|
||||
memcpy (section + 1, core_img, core_size);
|
||||
free (core_img);
|
||||
core_img = ecoff_img;
|
||||
core_size = program_size + sizeof (*head) + sizeof (*section);
|
||||
}
|
||||
break;
|
||||
case IMAGE_LOONGSON_ELF:
|
||||
case IMAGE_PPC:
|
||||
case IMAGE_COREBOOT:
|
||||
case IMAGE_I386_IEEE1275:
|
||||
|
@ -1202,7 +1477,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
int header_size, footer_size = 0;
|
||||
int phnum = 1;
|
||||
|
||||
if (image_target->id != IMAGE_YEELOONG_ELF)
|
||||
if (image_target->id != IMAGE_LOONGSON_ELF)
|
||||
phnum += 2;
|
||||
|
||||
if (note)
|
||||
|
@ -1237,7 +1512,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
|
||||
/* No section headers. */
|
||||
ehdr->e_shoff = grub_host_to_target32 (0);
|
||||
if (image_target->id == IMAGE_YEELOONG_ELF)
|
||||
if (image_target->id == IMAGE_LOONGSON_ELF)
|
||||
ehdr->e_shentsize = grub_host_to_target16 (0);
|
||||
else
|
||||
ehdr->e_shentsize = grub_host_to_target16 (sizeof (Elf32_Shdr));
|
||||
|
@ -1250,21 +1525,26 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
phdr->p_offset = grub_host_to_target32 (header_size);
|
||||
phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
|
||||
|
||||
if (image_target->id == IMAGE_YEELOONG_ELF)
|
||||
target_addr = ALIGN_UP (image_target->link_addr
|
||||
+ kernel_size + total_module_size, 32);
|
||||
if (image_target->id == IMAGE_LOONGSON_ELF)
|
||||
{
|
||||
if (comp == COMPRESSION_NONE)
|
||||
target_addr = (image_target->link_addr - decompress_size);
|
||||
else
|
||||
target_addr = ALIGN_UP (image_target->link_addr
|
||||
+ kernel_size + total_module_size, 32);
|
||||
}
|
||||
else
|
||||
target_addr = image_target->link_addr;
|
||||
ehdr->e_entry = grub_host_to_target32 (target_addr);
|
||||
phdr->p_vaddr = grub_host_to_target32 (target_addr);
|
||||
phdr->p_paddr = grub_host_to_target32 (target_addr);
|
||||
phdr->p_align = grub_host_to_target32 (align > image_target->link_align ? align : image_target->link_align);
|
||||
if (image_target->id == IMAGE_YEELOONG_ELF)
|
||||
if (image_target->id == IMAGE_LOONGSON_ELF)
|
||||
ehdr->e_flags = grub_host_to_target32 (0x1000 | EF_MIPS_NOREORDER
|
||||
| EF_MIPS_PIC | EF_MIPS_CPIC);
|
||||
else
|
||||
ehdr->e_flags = 0;
|
||||
if (image_target->id == IMAGE_YEELOONG_ELF)
|
||||
if (image_target->id == IMAGE_LOONGSON_ELF)
|
||||
{
|
||||
phdr->p_filesz = grub_host_to_target32 (core_size);
|
||||
phdr->p_memsz = grub_host_to_target32 (core_size);
|
||||
|
@ -1335,7 +1615,6 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
}
|
||||
|
||||
grub_util_write_image (core_img, core_size, out);
|
||||
free (kernel_img);
|
||||
free (core_img);
|
||||
free (kernel_path);
|
||||
|
||||
|
@ -1379,12 +1658,12 @@ usage (int status)
|
|||
char *ptr;
|
||||
unsigned i;
|
||||
for (i = 0; i < ARRAY_SIZE (image_targets); i++)
|
||||
format_len += strlen (image_targets[i].name) + 2;
|
||||
format_len += strlen (image_targets[i].names[0]) + 2;
|
||||
ptr = formats = xmalloc (format_len);
|
||||
for (i = 0; i < ARRAY_SIZE (image_targets); i++)
|
||||
{
|
||||
strcpy (ptr, image_targets[i].name);
|
||||
ptr += strlen (image_targets[i].name);
|
||||
strcpy (ptr, image_targets[i].names[0]);
|
||||
ptr += strlen (image_targets[i].names[0]);
|
||||
*ptr++ = ',';
|
||||
*ptr++ = ' ';
|
||||
}
|
||||
|
@ -1454,10 +1733,12 @@ main (int argc, char *argv[])
|
|||
|
||||
case 'O':
|
||||
{
|
||||
unsigned i;
|
||||
unsigned i, j;
|
||||
for (i = 0; i < ARRAY_SIZE (image_targets); i++)
|
||||
if (strcmp (optarg, image_targets[i].name) == 0)
|
||||
image_target = &image_targets[i];
|
||||
for (j = 0; image_targets[i].names[j]
|
||||
&& j < ARRAY_SIZE (image_targets[i].names); j++)
|
||||
if (strcmp (optarg, image_targets[i].names[j]) == 0)
|
||||
image_target = &image_targets[i];
|
||||
if (!image_target)
|
||||
{
|
||||
printf ("unknown target format %s\n", optarg);
|
||||
|
@ -1552,25 +1833,19 @@ main (int argc, char *argv[])
|
|||
|
||||
if (!dir)
|
||||
{
|
||||
const char *last;
|
||||
last = strchr (image_target->name, '-');
|
||||
if (last)
|
||||
last = strchr (last + 1, '-');
|
||||
if (!last)
|
||||
last = image_target->name + strlen (image_target->name);
|
||||
dir = xmalloc (sizeof (GRUB_PKGLIBROOTDIR) + (last - image_target->name)
|
||||
+ 1);
|
||||
dir = xmalloc (sizeof (GRUB_PKGLIBROOTDIR)
|
||||
+ grub_strlen (image_target->dirname) + 1);
|
||||
memcpy (dir, GRUB_PKGLIBROOTDIR, sizeof (GRUB_PKGLIBROOTDIR) - 1);
|
||||
*(dir + sizeof (GRUB_PKGLIBROOTDIR) - 1) = '/';
|
||||
memcpy (dir + sizeof (GRUB_PKGLIBROOTDIR), image_target->name,
|
||||
last - image_target->name);
|
||||
*(dir + sizeof (GRUB_PKGLIBROOTDIR) + (last - image_target->name)) = 0;
|
||||
strcpy (dir + sizeof (GRUB_PKGLIBROOTDIR), image_target->dirname);
|
||||
}
|
||||
|
||||
generate_image (dir, prefix ? : DEFAULT_DIRECTORY, fp,
|
||||
argv + optind, memdisk, config,
|
||||
image_target, note, comp);
|
||||
|
||||
fflush (fp);
|
||||
fsync (fileno (fp));
|
||||
fclose (fp);
|
||||
|
||||
if (dir)
|
||||
|
|
|
@ -56,6 +56,7 @@ static Elf_Addr
|
|||
SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections,
|
||||
Elf_Shdr *symtab_section, Elf_Addr *section_addresses,
|
||||
Elf_Half section_entsize, Elf_Half num_sections,
|
||||
void *jumpers, Elf_Addr jumpers_addr,
|
||||
struct image_target_desc *image_target)
|
||||
{
|
||||
Elf_Word symtab_size, sym_size, num_syms;
|
||||
|
@ -65,6 +66,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections,
|
|||
Elf_Word i;
|
||||
Elf_Shdr *strtab_section;
|
||||
const char *strtab;
|
||||
grub_uint64_t *jptr = jumpers;
|
||||
|
||||
strtab_section
|
||||
= (Elf_Shdr *) ((char *) sections
|
||||
|
@ -101,9 +103,19 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections,
|
|||
else if (index >= num_sections)
|
||||
grub_util_error ("section %d does not exist", index);
|
||||
|
||||
sym->st_value = (grub_target_to_host32 (sym->st_value)
|
||||
sym->st_value = (grub_target_to_host (sym->st_value)
|
||||
+ section_addresses[index]);
|
||||
grub_util_info ("locating %s at 0x%x", name, sym->st_value);
|
||||
|
||||
if (image_target->elf_target == EM_IA_64 && ELF_ST_TYPE (sym->st_info)
|
||||
== STT_FUNC)
|
||||
{
|
||||
*jptr = sym->st_value;
|
||||
sym->st_value = (char *) jptr - (char *) jumpers + jumpers_addr;
|
||||
jptr++;
|
||||
*jptr = 0;
|
||||
jptr++;
|
||||
}
|
||||
grub_util_info ("locating %s at 0x%x", name, sym->st_value, section_addresses[index]);
|
||||
|
||||
if (! start_address)
|
||||
if (strcmp (name, "_start") == 0 || strcmp (name, "start") == 0)
|
||||
|
@ -134,6 +146,152 @@ SUFFIX (get_target_address) (Elf_Ehdr *e, Elf_Shdr *s, Elf_Addr offset,
|
|||
return (Elf_Addr *) ((char *) e + grub_target_to_host32 (s->sh_offset) + offset);
|
||||
}
|
||||
|
||||
static Elf_Addr
|
||||
SUFFIX (count_funcs) (Elf_Ehdr *e, Elf_Shdr *symtab_section,
|
||||
struct image_target_desc *image_target)
|
||||
{
|
||||
Elf_Word symtab_size, sym_size, num_syms;
|
||||
Elf_Off symtab_offset;
|
||||
Elf_Addr start_address = 0;
|
||||
Elf_Sym *sym;
|
||||
Elf_Word i;
|
||||
int ret = 0;
|
||||
|
||||
symtab_size = grub_target_to_host (symtab_section->sh_size);
|
||||
sym_size = grub_target_to_host (symtab_section->sh_entsize);
|
||||
symtab_offset = grub_target_to_host (symtab_section->sh_offset);
|
||||
num_syms = symtab_size / sym_size;
|
||||
|
||||
for (i = 0, sym = (Elf_Sym *) ((char *) e + symtab_offset);
|
||||
i < num_syms;
|
||||
i++, sym = (Elf_Sym *) ((char *) sym + sym_size))
|
||||
if (ELF_ST_TYPE (sym->st_info) == STT_FUNC)
|
||||
ret++;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef MKIMAGE_ELF64
|
||||
struct unaligned_uint32
|
||||
{
|
||||
grub_uint32_t val;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define MASK20 ((1 << 20) - 1)
|
||||
#define MASK19 ((1 << 19) - 1)
|
||||
|
||||
static void
|
||||
add_value_to_slot_20b (grub_addr_t addr, grub_uint32_t value)
|
||||
{
|
||||
struct unaligned_uint32 *p;
|
||||
switch (addr & 3)
|
||||
{
|
||||
case 0:
|
||||
p = (struct unaligned_uint32 *) ((addr & ~3ULL) + 2);
|
||||
p->val = ((((((p->val >> 2) & MASK20) + value) & MASK20) << 2)
|
||||
| (p->val & ~(MASK20 << 2)));
|
||||
break;
|
||||
case 1:
|
||||
p = (struct unaligned_uint32 *) ((grub_uint8_t *) (addr & ~3ULL) + 7);
|
||||
p->val = ((((((p->val >> 3) & MASK20) + value) & MASK20) << 3)
|
||||
| (p->val & ~(MASK20 << 3)));
|
||||
break;
|
||||
case 2:
|
||||
p = (struct unaligned_uint32 *) ((grub_uint8_t *) (addr & ~3ULL) + 12);
|
||||
p->val = ((((((p->val >> 4) & MASK20) + value) & MASK20) << 4)
|
||||
| (p->val & ~(MASK20 << 4)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define MASKF21 ( ((1 << 23) - 1) & ~((1 << 7) | (1 << 8)) )
|
||||
|
||||
static grub_uint32_t
|
||||
add_value_to_slot_21_real (grub_uint32_t a, grub_uint32_t value)
|
||||
{
|
||||
grub_uint32_t high, mid, low, c;
|
||||
low = (a & 0x00007f);
|
||||
mid = (a & 0x7fc000) >> 7;
|
||||
high = (a & 0x003e00) << 7;
|
||||
c = (low | mid | high) + value;
|
||||
return (c & 0x7f) | ((c << 7) & 0x7fc000) | ((c >> 7) & 0x0003e00); //0x003e00
|
||||
}
|
||||
|
||||
static void
|
||||
add_value_to_slot_21 (grub_addr_t addr, grub_uint32_t value)
|
||||
{
|
||||
struct unaligned_uint32 *p;
|
||||
switch (addr & 3)
|
||||
{
|
||||
case 0:
|
||||
p = (struct unaligned_uint32 *) ((addr & ~3ULL) + 2);
|
||||
p->val = ((add_value_to_slot_21_real (((p->val >> 2) & MASKF21), value) & MASKF21) << 2) | (p->val & ~(MASKF21 << 2));
|
||||
break;
|
||||
case 1:
|
||||
p = (struct unaligned_uint32 *) ((grub_uint8_t *) (addr & ~3ULL) + 7);
|
||||
p->val = ((add_value_to_slot_21_real (((p->val >> 3) & MASKF21), value) & MASKF21) << 3) | (p->val & ~(MASKF21 << 3));
|
||||
break;
|
||||
case 2:
|
||||
p = (struct unaligned_uint32 *) ((grub_uint8_t *) (addr & ~3ULL) + 12);
|
||||
p->val = ((add_value_to_slot_21_real (((p->val >> 4) & MASKF21), value) & MASKF21) << 4) | (p->val & ~(MASKF21 << 4));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct ia64_kernel_trampoline
|
||||
{
|
||||
/* nop.m */
|
||||
grub_uint8_t nop[5];
|
||||
/* movl r15 = addr*/
|
||||
grub_uint8_t addr_hi[6];
|
||||
grub_uint8_t e0;
|
||||
grub_uint8_t addr_lo[4];
|
||||
grub_uint8_t jump[0x20];
|
||||
};
|
||||
|
||||
static grub_uint8_t nopm[5] =
|
||||
{
|
||||
/* [MLX] nop.m 0x0 */
|
||||
0x05, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
|
||||
static grub_uint8_t jump[0x20] =
|
||||
{
|
||||
/* [MMI] add r15=r15,r1;; */
|
||||
0x0b, 0x78, 0x3c, 0x02, 0x00, 0x20,
|
||||
/* ld8 r16=[r15],8 */
|
||||
0x00, 0x41, 0x3c, 0x30, 0x28, 0xc0,
|
||||
/* mov r14=r1;; */
|
||||
0x01, 0x08, 0x00, 0x84,
|
||||
/* [MIB] ld8 r1=[r15] */
|
||||
0x11, 0x08, 0x00, 0x1e, 0x18, 0x10,
|
||||
/* mov b6=r16 */
|
||||
0x60, 0x80, 0x04, 0x80, 0x03, 0x00,
|
||||
/* br.few b6;; */
|
||||
0x60, 0x00, 0x80, 0x00
|
||||
};
|
||||
|
||||
static void
|
||||
make_trampoline (struct ia64_kernel_trampoline *tr, grub_uint64_t addr)
|
||||
{
|
||||
grub_memcpy (tr->nop, nopm, sizeof (tr->nop));
|
||||
tr->addr_hi[0] = ((addr & 0xc00000) >> 16);
|
||||
tr->addr_hi[1] = (addr >> 24) & 0xff;
|
||||
tr->addr_hi[2] = (addr >> 32) & 0xff;
|
||||
tr->addr_hi[3] = (addr >> 40) & 0xff;
|
||||
tr->addr_hi[4] = (addr >> 48) & 0xff;
|
||||
tr->addr_hi[5] = (addr >> 56) & 0xff;
|
||||
tr->e0 = 0xe0;
|
||||
tr->addr_lo[0] = ((addr & 0x000f) << 4) | 0x01;
|
||||
tr->addr_lo[1] = (((addr & 0x0070) >> 4) | ((addr & 0x070000) >> 11)
|
||||
| ((addr & 0x200000) >> 17));
|
||||
tr->addr_lo[2] = ((addr & 0x1f80) >> 5) | ((addr & 0x180000) >> 19);
|
||||
tr->addr_lo[3] = ((addr & 0xe000) >> 13) | 0x60;
|
||||
grub_memcpy (tr->jump, jump, sizeof (tr->jump));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Deal with relocation information. This function relocates addresses
|
||||
within the virtual address space starting from 0. So only relative
|
||||
addresses can be fully resolved. Absolute addresses must be relocated
|
||||
|
@ -142,10 +300,15 @@ static void
|
|||
SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
|
||||
Elf_Addr *section_addresses,
|
||||
Elf_Half section_entsize, Elf_Half num_sections,
|
||||
const char *strtab, struct image_target_desc *image_target)
|
||||
const char *strtab,
|
||||
char *pe_target, Elf_Addr tramp_off,
|
||||
Elf_Addr got_off,
|
||||
struct image_target_desc *image_target)
|
||||
{
|
||||
Elf_Half i;
|
||||
Elf_Shdr *s;
|
||||
struct ia64_kernel_trampoline *tr = (void *) (pe_target + tramp_off);
|
||||
grub_uint64_t *gpptr = (void *) (pe_target + got_off);
|
||||
|
||||
for (i = 0, s = sections;
|
||||
i < num_sections;
|
||||
|
@ -200,7 +363,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
|
|||
addend = (s->sh_type == grub_target_to_host32 (SHT_RELA)) ?
|
||||
r->r_addend : 0;
|
||||
|
||||
if (image_target->voidp_sizeof == 4)
|
||||
switch (image_target->elf_target)
|
||||
{
|
||||
case EM_386:
|
||||
switch (ELF_R_TYPE (info))
|
||||
{
|
||||
case R_386_NONE:
|
||||
|
@ -224,11 +389,12 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
|
|||
*target, offset);
|
||||
break;
|
||||
default:
|
||||
grub_util_error ("unknown relocation type %d",
|
||||
grub_util_error ("unknown relocation type 0x%x",
|
||||
ELF_R_TYPE (info));
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
case EM_X86_64:
|
||||
switch (ELF_R_TYPE (info))
|
||||
{
|
||||
|
||||
|
@ -270,6 +436,85 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
|
|||
ELF_R_TYPE (info));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#ifdef MKIMAGE_ELF64
|
||||
case EM_IA_64:
|
||||
switch (ELF_R_TYPE (info))
|
||||
{
|
||||
case R_IA64_PCREL21B:
|
||||
{
|
||||
grub_uint64_t noff;
|
||||
make_trampoline (tr, addend + sym_addr);
|
||||
noff = ((char *) tr - (char *) pe_target
|
||||
- target_section_addr - (offset & ~3)) >> 4;
|
||||
tr++;
|
||||
if (noff & ~MASK19)
|
||||
grub_util_error ("trampoline offset too big (%lx)",
|
||||
noff);
|
||||
add_value_to_slot_20b ((grub_addr_t) target, noff);
|
||||
}
|
||||
break;
|
||||
|
||||
case R_IA64_LTOFF22X:
|
||||
case R_IA64_LTOFF22:
|
||||
{
|
||||
Elf_Sym *sym;
|
||||
|
||||
sym = (Elf_Sym *) ((char *) e
|
||||
+ grub_target_to_host32 (symtab_section->sh_offset)
|
||||
+ ELF_R_SYM (info) * grub_target_to_host32 (symtab_section->sh_entsize));
|
||||
if (ELF_ST_TYPE (sym->st_info) == STT_FUNC)
|
||||
sym_addr = grub_target_to_host64 (*(grub_uint64_t *) (pe_target
|
||||
+ sym->st_value
|
||||
- image_target->vaddr_offset));
|
||||
}
|
||||
case R_IA64_LTOFF_FPTR22:
|
||||
*gpptr = grub_host_to_target64 (addend + sym_addr);
|
||||
add_value_to_slot_21 ((grub_addr_t) target,
|
||||
(char *) gpptr - (char *) pe_target
|
||||
+ image_target->vaddr_offset);
|
||||
gpptr++;
|
||||
break;
|
||||
|
||||
case R_IA64_GPREL22:
|
||||
add_value_to_slot_21 ((grub_addr_t) target,
|
||||
addend + sym_addr);
|
||||
break;
|
||||
case R_IA64_PCREL64LSB:
|
||||
*target = grub_host_to_target64 (grub_target_to_host64 (*target)
|
||||
+ addend + sym_addr
|
||||
- target_section_addr - offset
|
||||
- image_target->vaddr_offset);
|
||||
break;
|
||||
|
||||
case R_IA64_SEGREL64LSB:
|
||||
*target = grub_host_to_target64 (grub_target_to_host64 (*target)
|
||||
+ addend + sym_addr - target_section_addr);
|
||||
break;
|
||||
case R_IA64_DIR64LSB:
|
||||
case R_IA64_FPTR64LSB:
|
||||
*target = grub_host_to_target64 (grub_target_to_host64 (*target)
|
||||
+ addend + sym_addr);
|
||||
grub_util_info ("relocating a direct entry to 0x%"
|
||||
PRIxGRUB_UINT64_T " at the offset 0x%x",
|
||||
*target, offset);
|
||||
break;
|
||||
|
||||
/* We treat LTOFF22X as LTOFF22, so we can ignore LDXMOV. */
|
||||
case R_IA64_LDXMOV:
|
||||
break;
|
||||
|
||||
default:
|
||||
grub_util_error ("unknown relocation type 0x%x",
|
||||
ELF_R_TYPE (info));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
grub_util_error ("unknown architecture type %d",
|
||||
image_target->elf_target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +557,7 @@ SUFFIX (add_fixup_entry) (struct fixup_block_list **cblock, grub_uint16_t type,
|
|||
b->block_size += 2;
|
||||
}
|
||||
}
|
||||
else if (b->block_size & (8 - 1))
|
||||
else while (b->block_size & (8 - 1))
|
||||
{
|
||||
/* If not aligned with a 32-bit boundary, add
|
||||
a padding entry. */
|
||||
|
@ -374,9 +619,11 @@ static Elf_Addr
|
|||
SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
|
||||
Elf_Addr *section_addresses, Elf_Shdr *sections,
|
||||
Elf_Half section_entsize, Elf_Half num_sections,
|
||||
const char *strtab, struct image_target_desc *image_target)
|
||||
const char *strtab,
|
||||
Elf_Addr jumpers, grub_size_t njumpers,
|
||||
struct image_target_desc *image_target)
|
||||
{
|
||||
Elf_Half i;
|
||||
unsigned i;
|
||||
Elf_Shdr *s;
|
||||
struct fixup_block_list *lst, *lst0;
|
||||
Elf_Addr current_address = 0;
|
||||
|
@ -384,8 +631,7 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
|
|||
lst = lst0 = xmalloc (sizeof (*lst) + 2 * 0x1000);
|
||||
memset (lst, 0, sizeof (*lst) + 2 * 0x1000);
|
||||
|
||||
for (i = 0, s = sections;
|
||||
i < num_sections;
|
||||
for (i = 0, s = sections; i < num_sections;
|
||||
i++, s = (Elf_Shdr *) ((char *) s + section_entsize))
|
||||
if ((s->sh_type == grub_cpu_to_le32 (SHT_REL)) ||
|
||||
(s->sh_type == grub_cpu_to_le32 (SHT_RELA)))
|
||||
|
@ -417,8 +663,9 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
|
|||
info = grub_le_to_cpu32 (r->r_info);
|
||||
|
||||
/* Necessary to relocate only absolute addresses. */
|
||||
if (image_target->voidp_sizeof == 4)
|
||||
switch (image_target->elf_target)
|
||||
{
|
||||
case EM_386:
|
||||
if (ELF_R_TYPE (info) == R_386_32)
|
||||
{
|
||||
Elf_Addr addr;
|
||||
|
@ -431,9 +678,8 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
|
|||
addr, 0, current_address,
|
||||
image_target);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
case EM_X86_64:
|
||||
if ((ELF_R_TYPE (info) == R_X86_64_32) ||
|
||||
(ELF_R_TYPE (info) == R_X86_64_32S))
|
||||
{
|
||||
|
@ -452,10 +698,57 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
|
|||
0, current_address,
|
||||
image_target);
|
||||
}
|
||||
break;
|
||||
case EM_IA_64:
|
||||
switch (ELF_R_TYPE (info))
|
||||
{
|
||||
case R_IA64_PCREL64LSB:
|
||||
case R_IA64_LDXMOV:
|
||||
case R_IA64_PCREL21B:
|
||||
case R_IA64_LTOFF_FPTR22:
|
||||
case R_IA64_LTOFF22X:
|
||||
case R_IA64_LTOFF22:
|
||||
case R_IA64_GPREL22:
|
||||
case R_IA64_SEGREL64LSB:
|
||||
break;
|
||||
|
||||
case R_IA64_FPTR64LSB:
|
||||
case R_IA64_DIR64LSB:
|
||||
#if 1
|
||||
{
|
||||
Elf_Addr addr;
|
||||
|
||||
addr = section_address + offset;
|
||||
grub_util_info ("adding a relocation entry for 0x%llx", addr);
|
||||
current_address
|
||||
= SUFFIX (add_fixup_entry) (&lst,
|
||||
GRUB_PE32_REL_BASED_DIR64,
|
||||
addr,
|
||||
0, current_address,
|
||||
image_target);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
grub_util_error ("unknown relocation type 0x%x",
|
||||
ELF_R_TYPE (info));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
grub_util_error ("unknown machine type 0x%x", image_target->elf_target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (image_target->elf_target == EM_IA_64)
|
||||
for (i = 0; i < njumpers; i++)
|
||||
current_address = SUFFIX (add_fixup_entry) (&lst,
|
||||
GRUB_PE32_REL_BASED_DIR64,
|
||||
jumpers + 8 * i,
|
||||
0, current_address,
|
||||
image_target);
|
||||
|
||||
current_address = SUFFIX (add_fixup_entry) (&lst, 0, 0, 1, current_address, image_target);
|
||||
|
||||
{
|
||||
|
@ -617,7 +910,10 @@ SUFFIX (load_image) (const char *kernel_path, grub_size_t *exec_size,
|
|||
Elf_Off section_offset;
|
||||
Elf_Half section_entsize;
|
||||
grub_size_t kernel_size;
|
||||
grub_size_t ia64jmp_off = 0, ia64_toff = 0, ia64_got_off = 0;
|
||||
unsigned ia64jmpnum = 0;
|
||||
Elf_Shdr *symtab_section;
|
||||
grub_size_t got = 0;
|
||||
|
||||
*start = 0;
|
||||
|
||||
|
@ -696,23 +992,31 @@ SUFFIX (load_image) (const char *kernel_path, grub_size_t *exec_size,
|
|||
break;
|
||||
}
|
||||
|
||||
#ifdef MKIMAGE_ELF64
|
||||
if (image_target->elf_target == EM_IA_64)
|
||||
{
|
||||
grub_size_t tramp;
|
||||
|
||||
*kernel_sz = ALIGN_UP (*kernel_sz, 16);
|
||||
|
||||
grub_ia64_dl_get_tramp_got_size (e, &tramp, &got);
|
||||
tramp *= sizeof (struct ia64_kernel_trampoline);
|
||||
|
||||
ia64_toff = *kernel_sz;
|
||||
*kernel_sz += ALIGN_UP (tramp, 16);
|
||||
|
||||
ia64jmp_off = *kernel_sz;
|
||||
ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section,
|
||||
image_target);
|
||||
*kernel_sz += 16 * ia64jmpnum;
|
||||
|
||||
ia64_got_off = *kernel_sz;
|
||||
*kernel_sz += ALIGN_UP (got * sizeof (grub_uint64_t), 16);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! symtab_section)
|
||||
grub_util_error ("no symbol table");
|
||||
|
||||
*start = SUFFIX (relocate_symbols) (e, sections, symtab_section,
|
||||
section_vaddresses, section_entsize,
|
||||
num_sections, image_target);
|
||||
if (*start == 0)
|
||||
grub_util_error ("start symbol is not defined");
|
||||
|
||||
/* Resolve addresses in the virtual address space. */
|
||||
SUFFIX (relocate_addresses) (e, sections, section_addresses, section_entsize,
|
||||
num_sections, strtab, image_target);
|
||||
|
||||
*reloc_size = SUFFIX (make_reloc_section) (e, reloc_section,
|
||||
section_vaddresses, sections,
|
||||
section_entsize, num_sections,
|
||||
strtab, image_target);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -722,6 +1026,34 @@ SUFFIX (load_image) (const char *kernel_path, grub_size_t *exec_size,
|
|||
|
||||
out_img = xmalloc (*kernel_sz + total_module_size);
|
||||
|
||||
if (image_target->id == IMAGE_EFI)
|
||||
{
|
||||
*start = SUFFIX (relocate_symbols) (e, sections, symtab_section,
|
||||
section_vaddresses, section_entsize,
|
||||
num_sections,
|
||||
(char *) out_img + ia64jmp_off,
|
||||
ia64jmp_off
|
||||
+ image_target->vaddr_offset,
|
||||
image_target);
|
||||
if (*start == 0)
|
||||
grub_util_error ("start symbol is not defined");
|
||||
|
||||
/* Resolve addresses in the virtual address space. */
|
||||
SUFFIX (relocate_addresses) (e, sections, section_addresses,
|
||||
section_entsize,
|
||||
num_sections, strtab,
|
||||
out_img, ia64_toff, ia64_got_off,
|
||||
image_target);
|
||||
|
||||
*reloc_size = SUFFIX (make_reloc_section) (e, reloc_section,
|
||||
section_vaddresses, sections,
|
||||
section_entsize, num_sections,
|
||||
strtab, ia64jmp_off
|
||||
+ image_target->vaddr_offset,
|
||||
2 * ia64jmpnum + got,
|
||||
image_target);
|
||||
}
|
||||
|
||||
for (i = 0, s = sections;
|
||||
i < num_sections;
|
||||
i++, s = (Elf_Shdr *) ((char *) s + section_entsize))
|
||||
|
|
|
@ -60,6 +60,8 @@ static struct console_grub_equivalence console_grub_equivalences_shift[] = {
|
|||
{"KP_8", '8'},
|
||||
{"KP_9", '9'},
|
||||
{"KP_Period", '.'},
|
||||
|
||||
{NULL, '\0'}
|
||||
};
|
||||
|
||||
static struct console_grub_equivalence console_grub_equivalences_unshift[] = {
|
||||
|
@ -74,6 +76,8 @@ static struct console_grub_equivalence console_grub_equivalences_unshift[] = {
|
|||
{"KP_8", GRUB_TERM_KEY_UP},
|
||||
{"KP_9", GRUB_TERM_KEY_PPAGE},
|
||||
{"KP_Period", GRUB_TERM_KEY_DC},
|
||||
|
||||
{NULL, '\0'}
|
||||
};
|
||||
|
||||
static struct console_grub_equivalence console_grub_equivalences_common[] = {
|
||||
|
@ -259,8 +263,9 @@ usage (int status)
|
|||
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
|
||||
else
|
||||
printf ("\
|
||||
Usage: %s [OPTIONS] LAYOUT\n\
|
||||
-o, --output set output base name file. Default is LAYOUT.gkb\n\
|
||||
Usage: %s [OPTIONS]\n\
|
||||
-i, --input set input filename. Default is STDIN\n\
|
||||
-o, --output set output filename. Default is STDOUT\n\
|
||||
-h, --help display this message and exit.\n\
|
||||
-V, --version print version information and exit.\n\
|
||||
-v, --verbose print verbose messages.\n\
|
||||
|
|
|
@ -27,12 +27,8 @@ libdir=@libdir@
|
|||
PACKAGE_NAME=@PACKAGE_NAME@
|
||||
PACKAGE_TARNAME=@PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION=@PACKAGE_VERSION@
|
||||
target_cpu=@target_cpu@
|
||||
platform=@platform@
|
||||
host_os=@host_os@
|
||||
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
|
||||
localedir=@datadir@/locale
|
||||
native_platform=@platform@
|
||||
pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst"
|
||||
|
||||
self=`basename $0`
|
||||
|
@ -64,7 +60,7 @@ Install GRUB on your drive.
|
|||
--subdir=DIR relative subdirectory on network server
|
||||
--grub-mkimage=FILE use FILE as grub-mkimage
|
||||
|
||||
$self copies GRUB images into net_directory/subdir/${target_cpu}-${platform}
|
||||
$self copies GRUB images into net_directory/subdir/target_cpu-platform
|
||||
|
||||
Report bugs to <bug-grub@gnu.org>.
|
||||
EOF
|
||||
|
@ -222,7 +218,8 @@ if [ "${override_dir}" = "" ] ; then
|
|||
process_input_dir ${pc_dir} i386-pc
|
||||
fi
|
||||
else
|
||||
process_input_dir ${override_dir} ${target_cpu}-${native_platform}
|
||||
source "${override_dir}"/modinfo.sh
|
||||
process_input_dir "${override_dir}" ${grub_modinfo_target_cpu}-${grub_modinfo_platform}
|
||||
fi
|
||||
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ main (int argc, char *argv[])
|
|||
{
|
||||
FILE *f;
|
||||
size_t rd;
|
||||
f = fopen ("/dev/random", "rb");
|
||||
f = fopen ("/dev/urandom", "rb");
|
||||
if (!f)
|
||||
{
|
||||
memset (pass1, 0, strlen (pass1));
|
||||
|
|
|
@ -27,8 +27,6 @@ libdir=@libdir@
|
|||
PACKAGE_NAME=@PACKAGE_NAME@
|
||||
PACKAGE_TARNAME=@PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION=@PACKAGE_VERSION@
|
||||
target_cpu=@target_cpu@
|
||||
native_platform=@platform@
|
||||
pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst"
|
||||
|
||||
self=`basename $0`
|
||||
|
@ -160,7 +158,7 @@ process_input_dir ()
|
|||
input_dir="$1"
|
||||
platform="$2"
|
||||
mkdir -p ${iso9660_dir}/boot/grub/${platform}
|
||||
for file in ${input_dir}/*.mod; do
|
||||
for file in "${input_dir}/"*.mod "${input_dir}/"efiemu32.o "${input_dir}/"efiemu64.o; do
|
||||
if test -f "$file"; then
|
||||
cp -f "$file" ${iso9660_dir}/boot/grub/${platform}/
|
||||
fi
|
||||
|
@ -231,14 +229,15 @@ if [ "${override_dir}" = "" ] ; then
|
|||
process_input_dir ${efi64_dir} x86_64-efi
|
||||
fi
|
||||
else
|
||||
process_input_dir ${override_dir} ${target_cpu}-${native_platform}
|
||||
. "${override_dir}"/modinfo.sh
|
||||
process_input_dir "${override_dir}" ${grub_modinfo_target_cpu}-${grub_modinfo_platform}
|
||||
multiboot_dir=
|
||||
pc_dir=
|
||||
efi32_dir=
|
||||
efi64_dir=
|
||||
coreboot_dir=
|
||||
qemu_dir=
|
||||
case "${target_cpu}-${native_platform}" in
|
||||
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
|
||||
i386-multiboot) multiboot_dir=${override_dir} ;;
|
||||
i386-coreboot) coreboot_dir=${override_dir} ;;
|
||||
i386-qemu) qemu_dir=${override_dir} ;;
|
||||
|
@ -286,6 +285,10 @@ if test -e "${efi64_dir}" || test -e "${efi32_dir}"; then
|
|||
make_image "${efi64_dir}" x86_64-efi "${efi_dir}"/efi/boot/bootx64.efi ""
|
||||
# build bootia32.efi
|
||||
make_image "${efi32_dir}" i386-efi "${efi_dir}"/efi/boot/bootia32.efi ""
|
||||
if [ -e "${efi_dir}"/efi/boot/bootia32.efi ]; then
|
||||
# For old macs. Suggested by Peter Jones.
|
||||
cp "${efi_dir}"/efi/boot/bootia32.efi "${efi_dir}"/efi/boot/boot.efi
|
||||
fi
|
||||
|
||||
mformat -C -f 2880 -L 16 -i "${iso9660_dir}"/efi.img ::
|
||||
mcopy -s -i "${iso9660_dir}"/efi.img ${efi_dir}/efi ::/
|
||||
|
|
|
@ -79,11 +79,12 @@ Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
|
|||
#define BSS_SECTION 4
|
||||
#define MODNAME_SECTION 5
|
||||
#define MODDEPS_SECTION 6
|
||||
#define SYMTAB_SECTION 7
|
||||
#define STRTAB_SECTION 8
|
||||
#define MODLICENSE_SECTION 7
|
||||
#define SYMTAB_SECTION 8
|
||||
#define STRTAB_SECTION 9
|
||||
|
||||
#define REL_SECTION 9
|
||||
#define MAX_SECTIONS 12
|
||||
#define REL_SECTION 10
|
||||
#define MAX_SECTIONS 16
|
||||
|
||||
#define STRTAB_BLOCK 256
|
||||
|
||||
|
@ -96,7 +97,7 @@ int num_sections;
|
|||
grub_uint32_t offset;
|
||||
|
||||
static int
|
||||
insert_string (char *name)
|
||||
insert_string (const char *name)
|
||||
{
|
||||
int len, result;
|
||||
|
||||
|
@ -124,6 +125,8 @@ write_section_data (FILE* fp, char *image,
|
|||
{
|
||||
int *section_map;
|
||||
int i;
|
||||
char *pe_strtab = (image + pe_chdr->symtab_offset
|
||||
+ pe_chdr->num_symbols * sizeof (struct grub_pe32_symbol));
|
||||
|
||||
section_map = xmalloc ((pe_chdr->num_sections + 1) * sizeof (int));
|
||||
section_map[0] = 0;
|
||||
|
@ -131,31 +134,42 @@ write_section_data (FILE* fp, char *image,
|
|||
for (i = 0; i < pe_chdr->num_sections; i++, pe_shdr++)
|
||||
{
|
||||
grub_uint32_t idx;
|
||||
const char *name = pe_shdr->name;
|
||||
|
||||
if (! strcmp (pe_shdr->name, ".text"))
|
||||
if (name[0] == '/' && isdigit (name[1]))
|
||||
{
|
||||
char t[sizeof (pe_shdr->name) + 1];
|
||||
memcpy (t, name, sizeof (pe_shdr->name));
|
||||
t[sizeof (pe_shdr->name)] = 0;
|
||||
name = pe_strtab + atoi (t + 1);
|
||||
}
|
||||
|
||||
if (! strcmp (name, ".text"))
|
||||
{
|
||||
idx = TEXT_SECTION;
|
||||
shdr[idx].sh_flags = SHF_ALLOC | SHF_EXECINSTR;
|
||||
}
|
||||
else if (! strcmp (pe_shdr->name, ".rdata"))
|
||||
else if (! strcmp (name, ".rdata"))
|
||||
{
|
||||
idx = RDATA_SECTION;
|
||||
shdr[idx].sh_flags = SHF_ALLOC;
|
||||
}
|
||||
else if (! strcmp (pe_shdr->name, ".data"))
|
||||
else if (! strcmp (name, ".data"))
|
||||
{
|
||||
idx = DATA_SECTION;
|
||||
shdr[idx].sh_flags = SHF_ALLOC | SHF_WRITE;
|
||||
}
|
||||
else if (! strcmp (pe_shdr->name, ".bss"))
|
||||
else if (! strcmp (name, ".bss"))
|
||||
{
|
||||
idx = BSS_SECTION;
|
||||
shdr[idx].sh_flags = SHF_ALLOC | SHF_WRITE;
|
||||
}
|
||||
else if (! strcmp (pe_shdr->name, ".modname"))
|
||||
else if (! strcmp (name, ".modname"))
|
||||
idx = MODNAME_SECTION;
|
||||
else if (! strcmp (pe_shdr->name, ".moddeps"))
|
||||
else if (! strcmp (name, ".moddeps"))
|
||||
idx = MODDEPS_SECTION;
|
||||
else if (strcmp (name, ".module_license") == 0)
|
||||
idx = MODLICENSE_SECTION;
|
||||
else
|
||||
{
|
||||
section_map[i + 1] = -1;
|
||||
|
@ -181,14 +195,14 @@ write_section_data (FILE* fp, char *image,
|
|||
|
||||
if (pe_shdr->relocations_offset)
|
||||
{
|
||||
char name[5 + strlen (pe_shdr->name)];
|
||||
char relname[5 + strlen (name)];
|
||||
|
||||
if (num_sections >= MAX_SECTIONS)
|
||||
grub_util_error ("too many sections");
|
||||
|
||||
sprintf (name, ".rel%s", pe_shdr->name);
|
||||
sprintf (relname, ".rel%s", name);
|
||||
|
||||
shdr[num_sections].sh_name = insert_string (name);
|
||||
shdr[num_sections].sh_name = insert_string (relname);
|
||||
shdr[num_sections].sh_link = i;
|
||||
shdr[num_sections].sh_info = idx;
|
||||
|
||||
|
@ -197,7 +211,7 @@ write_section_data (FILE* fp, char *image,
|
|||
num_sections++;
|
||||
}
|
||||
else
|
||||
shdr[idx].sh_name = insert_string (pe_shdr->name);
|
||||
shdr[idx].sh_name = insert_string (name);
|
||||
}
|
||||
|
||||
return section_map;
|
||||
|
@ -337,7 +351,7 @@ write_symbol_table (FILE* fp, char *image,
|
|||
else
|
||||
bind = STB_LOCAL;
|
||||
|
||||
if ((type != STT_FUNC) && (pe_symtab->num_aux))
|
||||
if ((pe_symtab->type != GRUB_PE32_DT_FUNCTION) && (pe_symtab->num_aux))
|
||||
{
|
||||
if (! pe_symtab->value)
|
||||
type = STT_SECTION;
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include <grub/emu/getroot.h>
|
||||
#include "progname.h"
|
||||
#include <grub/reed_solomon.h>
|
||||
#include <grub/msdos_partition.h>
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
#include <argp.h>
|
||||
|
@ -339,6 +340,12 @@ setup (const char *dir,
|
|||
{
|
||||
if (p->parent != container)
|
||||
return 0;
|
||||
/* NetBSD and OpenBSD subpartitions have metadata inside a partition,
|
||||
so they are safe to ignore.
|
||||
*/
|
||||
if (grub_strcmp (p->partmap->name, "netbsd") == 0
|
||||
|| grub_strcmp (p->partmap->name, "openbsd") == 0)
|
||||
return 0;
|
||||
if (dest_partmap == NULL)
|
||||
{
|
||||
dest_partmap = p->partmap;
|
||||
|
@ -352,6 +359,15 @@ setup (const char *dir,
|
|||
|
||||
grub_partition_iterate (dest_dev->disk, identify_partmap);
|
||||
|
||||
if (container && grub_strcmp (container->partmap->name, "msdos") == 0
|
||||
&& dest_partmap
|
||||
&& (container->msdostype == GRUB_PC_PARTITION_TYPE_NETBSD
|
||||
|| container->msdostype == GRUB_PC_PARTITION_TYPE_OPENBSD))
|
||||
{
|
||||
grub_util_warn (_("Attempting to install GRUB to a disk with multiple partition labels or both partition label and filesystem. This is not supported yet."));
|
||||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
fs = grub_fs_probe (dest_dev);
|
||||
if (!fs)
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
@ -383,6 +399,15 @@ setup (const char *dir,
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Copy the partition table. */
|
||||
if (dest_partmap ||
|
||||
(!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk)))
|
||||
memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
|
||||
tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
|
||||
GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC);
|
||||
|
||||
free (tmp_img);
|
||||
|
||||
if (! dest_partmap)
|
||||
{
|
||||
grub_util_warn (_("Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea."));
|
||||
|
@ -394,14 +419,6 @@ setup (const char *dir,
|
|||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
/* Copy the partition table. */
|
||||
if (dest_partmap)
|
||||
memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
|
||||
tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
|
||||
GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC);
|
||||
|
||||
free (tmp_img);
|
||||
|
||||
if (!dest_partmap->embed)
|
||||
{
|
||||
grub_util_warn ("Partition style '%s' doesn't support embeding",
|
||||
|
@ -503,9 +520,7 @@ unable_to_embed:
|
|||
core_path_dev = grub_make_system_path_relative_to_its_root (core_path_dev_full);
|
||||
free (core_path_dev_full);
|
||||
|
||||
/* It is a Good Thing to sync two times. */
|
||||
sync ();
|
||||
sync ();
|
||||
grub_util_biosdisk_flush (root_dev->disk);
|
||||
|
||||
#define MAX_TRIES 5
|
||||
|
||||
|
@ -566,7 +581,7 @@ unable_to_embed:
|
|||
grub_util_info ("error message = %s", grub_errmsg);
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
sync ();
|
||||
grub_util_biosdisk_flush (root_dev->disk);
|
||||
sleep (1);
|
||||
}
|
||||
|
||||
|
@ -657,8 +672,8 @@ unable_to_embed:
|
|||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
|
||||
/* Sync is a Good Thing. */
|
||||
sync ();
|
||||
grub_util_biosdisk_flush (root_dev->disk);
|
||||
grub_util_biosdisk_flush (dest_dev->disk);
|
||||
|
||||
free (core_path);
|
||||
free (core_img);
|
||||
|
@ -956,7 +971,15 @@ main (int argc, char *argv[])
|
|||
char **devicelist;
|
||||
int i;
|
||||
|
||||
devicelist = grub_util_raid_getmembers (dest_dev);
|
||||
if (arguments.device[0] == '/')
|
||||
devicelist = grub_util_raid_getmembers (arguments.device);
|
||||
else
|
||||
{
|
||||
char *devname;
|
||||
devname = xasprintf ("/dev/%s", dest_dev);
|
||||
devicelist = grub_util_raid_getmembers (dest_dev);
|
||||
free (devname);
|
||||
}
|
||||
|
||||
for (i = 0; devicelist[i]; i++)
|
||||
{
|
||||
|
|
|
@ -84,11 +84,16 @@ if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
|
|||
EOF
|
||||
else
|
||||
# Insert all available backends; GRUB will use the most appropriate.
|
||||
have_video=0;
|
||||
for backend in $(cat "${GRUB_PREFIX}/video.lst"); do
|
||||
have_video=1;
|
||||
cat <<EOF
|
||||
insmod ${backend}
|
||||
EOF
|
||||
done
|
||||
if [ x$have_video = x0 ]; then
|
||||
echo "true"
|
||||
fi
|
||||
fi
|
||||
cat <<EOF
|
||||
}
|
||||
|
@ -127,6 +132,19 @@ if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then
|
|||
set gfxmode=${GRUB_GFXMODE}
|
||||
load_video
|
||||
insmod gfxterm
|
||||
EOF
|
||||
|
||||
# Gettext variables and module
|
||||
if [ "x${LANG}" != "xC" ] && [ -d "${locale_dir}" ] ; then
|
||||
prepare_grub_to_access_device $(${grub_probe} --target=device ${locale_dir}) | sed -e "s/^/ /"
|
||||
cat << EOF
|
||||
set locale_dir=(\$root)$(make_system_path_relative_to_its_root ${locale_dir})
|
||||
set lang=${grub_lang}
|
||||
insmod gettext
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
|
@ -205,16 +223,6 @@ EOF
|
|||
fi
|
||||
fi
|
||||
|
||||
# Gettext variables and module
|
||||
if [ "x${LANG}" != "xC" ] && [ -d "${locale_dir}" ] ; then
|
||||
prepare_grub_to_access_device $(${grub_probe} --target=device ${locale_dir})
|
||||
cat << EOF
|
||||
set locale_dir=(\$root)$(make_system_path_relative_to_its_root ${locale_dir})
|
||||
set lang=${grub_lang}
|
||||
insmod gettext
|
||||
EOF
|
||||
fi
|
||||
|
||||
make_timeout ()
|
||||
{
|
||||
if [ "x${1}" != "x" ] ; then
|
||||
|
|
|
@ -28,7 +28,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
|||
OS=GNU
|
||||
else
|
||||
OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
|
||||
fi
|
||||
|
||||
at_least_one=false
|
||||
|
|
|
@ -31,7 +31,7 @@ CLASS="--class os"
|
|||
case "${GRUB_DISTRIBUTOR}" in
|
||||
Debian)
|
||||
OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}"
|
||||
;;
|
||||
*)
|
||||
OS="FreeBSD"
|
||||
|
@ -110,7 +110,11 @@ EOF
|
|||
;;
|
||||
esac
|
||||
|
||||
load_kfreebsd_module ${kfreebsd_fs} false
|
||||
if [ x${kfreebsd_fs} = xufs ]; then
|
||||
load_kfreebsd_module ${kfreebsd_fs} true
|
||||
else
|
||||
load_kfreebsd_module ${kfreebsd_fs} false
|
||||
fi
|
||||
|
||||
cat << EOF
|
||||
set kFreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${kfreebsd_device}
|
||||
|
|
|
@ -32,7 +32,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
|||
OS=GNU/Linux
|
||||
else
|
||||
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
|
||||
fi
|
||||
|
||||
# loop-AES arranges things so that /dev/loop/X can be our root device, but
|
||||
|
@ -51,6 +51,14 @@ else
|
|||
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
|
||||
fi
|
||||
|
||||
if [ "x`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null || true`" = xbtrfs ]; then
|
||||
rootsubvol="`make_system_path_relative_to_its_root /`"
|
||||
rootsubvol="${rootsubvol#/}"
|
||||
if [ "x${rootsubvol}" != x ]; then
|
||||
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
|
||||
fi
|
||||
fi
|
||||
|
||||
linux_entry ()
|
||||
{
|
||||
os="$1"
|
||||
|
@ -73,8 +81,8 @@ linux_entry ()
|
|||
cat << EOF
|
||||
load_video
|
||||
EOF
|
||||
if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null \
|
||||
&& grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" /boot/config-${version} 2> /dev/null; then
|
||||
if grep -qx "CONFIG_FB_EFI=y" "${config}" 2> /dev/null \
|
||||
&& grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" "${config}" 2> /dev/null; then
|
||||
cat << EOF
|
||||
set gfxpayload=keep
|
||||
EOF
|
||||
|
@ -90,10 +98,21 @@ EOF
|
|||
EOF
|
||||
fi
|
||||
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
|
||||
cat << EOF
|
||||
insmod gzio
|
||||
EOF
|
||||
|
||||
if [ x$dirname = x/ ]; then
|
||||
if [ -z "${prepare_root_cache}" ]; then
|
||||
prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/")"
|
||||
fi
|
||||
printf '%s\n' "${prepare_root_cache}"
|
||||
else
|
||||
if [ -z "${prepare_boot_cache}" ]; then
|
||||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
|
||||
fi
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
fi
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
message="$(gettext_printf "Loading Linux %s ..." ${version})"
|
||||
cat << EOF
|
||||
echo '$message'
|
||||
|
@ -111,10 +130,19 @@ EOF
|
|||
EOF
|
||||
}
|
||||
|
||||
list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* ; do
|
||||
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
|
||||
done`
|
||||
case x`uname -m` in
|
||||
xi?86 | xx86_64)
|
||||
list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
|
||||
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
|
||||
done` ;;
|
||||
*)
|
||||
list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
|
||||
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
|
||||
done` ;;
|
||||
esac
|
||||
|
||||
prepare_boot_cache=
|
||||
prepare_root_cache=
|
||||
|
||||
while [ "x$list" != "x" ] ; do
|
||||
linux=`version_find_latest $list`
|
||||
|
@ -130,21 +158,28 @@ while [ "x$list" != "x" ] ; do
|
|||
for i in "initrd.img-${version}" "initrd-${version}.img" \
|
||||
"initrd-${version}" "initramfs-${version}.img" \
|
||||
"initrd.img-${alt_version}" "initrd-${alt_version}.img" \
|
||||
"initrd-${alt_version}" "initramfs-${alt_version}.img"; do
|
||||
"initrd-${alt_version}" "initramfs-${alt_version}.img" \
|
||||
"initramfs-genkernel-${version}" \
|
||||
"initramfs-genkernel-${alt_version}"; do
|
||||
if test -e "${dirname}/${i}" ; then
|
||||
initrd="$i"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
initramfs=
|
||||
for i in "config-${version}" "config-${alt_version}"; do
|
||||
if test -e "${dirname}/${i}" ; then
|
||||
initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${dirname}/${i}" | cut -f2 -d= | tr -d \"`
|
||||
config=
|
||||
for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
|
||||
if test -e "${i}" ; then
|
||||
config="${i}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
initramfs=
|
||||
if test -n "${config}" ; then
|
||||
initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"`
|
||||
fi
|
||||
|
||||
if test -n "${initrd}" ; then
|
||||
echo "Found initrd image: ${dirname}/${initrd}" >&2
|
||||
elif test -z "${initramfs}" ; then
|
||||
|
|
|
@ -27,11 +27,65 @@ export TEXTDOMAIN=@PACKAGE@
|
|||
export TEXTDOMAINDIR=@localedir@
|
||||
|
||||
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
||||
OS=NetBSD
|
||||
OS="NetBSD"
|
||||
else
|
||||
OS="${GRUB_DISTRIBUTOR} NetBSD"
|
||||
fi
|
||||
|
||||
netbsd_load_fs_module ()
|
||||
{
|
||||
loader="$1" # "knetbsd" or "multiboot"
|
||||
kernel="$2" # absolute path to the kernel file
|
||||
|
||||
case $(zcat -f "${kernel}" | file -bL - | cut -d , -f 2 | tr -d ' ') in
|
||||
Intel80386)
|
||||
karch="i386"
|
||||
;;
|
||||
x86-64)
|
||||
karch="amd64"
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case $(${grub_probe} --target=fs -d ${GRUB_DEVICE}) in
|
||||
ext2)
|
||||
kmod="ext2fs"
|
||||
;;
|
||||
fat)
|
||||
kmod="msdosfs"
|
||||
;;
|
||||
ntfs)
|
||||
kmod="ntfs"
|
||||
;;
|
||||
ufs*)
|
||||
kmod="ffs"
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }')
|
||||
kmodule="/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod"
|
||||
|
||||
if test -z "$karch" -o -z "$kversion" -o ! -f "${kmodule}"; then
|
||||
return
|
||||
fi
|
||||
|
||||
kmodule_rel=$(make_system_path_relative_to_its_root "$kmodule") || return
|
||||
prepare_grub_to_access_device $(${grub_probe} -t device "${kmodule}") | sed -e 's,^, ,'
|
||||
case "${loader}" in
|
||||
knetbsd)
|
||||
printf "\tknetbsd_module_elf %s\n" "${kmodule_rel}"
|
||||
;;
|
||||
multiboot)
|
||||
printf "\tmodule %s\n" "${kmodule_rel}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
netbsd_entry ()
|
||||
{
|
||||
loader="$1" # "knetbsd" or "multiboot"
|
||||
|
@ -59,6 +113,9 @@ netbsd_entry ()
|
|||
"${kernel}" "${kernel}" "${kroot_device}" "${GRUB_CMDLINE_NETBSD} ${args}"
|
||||
;;
|
||||
esac
|
||||
|
||||
netbsd_load_fs_module "${loader}" "${kernel}"
|
||||
|
||||
printf "}\n"
|
||||
}
|
||||
|
||||
|
@ -72,8 +129,7 @@ for k in $(ls -t /netbsd*) ; do
|
|||
if ! grub_file_is_not_garbage "$k" ; then
|
||||
continue
|
||||
fi
|
||||
if ! ((file -bL "$k" | grep -q "${pattern}") ||
|
||||
(zcat "$k" | file -bL - | grep -q "${pattern}")) 2>/dev/null ; then
|
||||
if ! (zcat -f "$k" | file -bL - | grep -q "${pattern}") 2>/dev/null ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
|||
OS=GNU/Linux
|
||||
else
|
||||
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
|
||||
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
|
||||
fi
|
||||
|
||||
# loop-AES arranges things so that /dev/loop/X can be our root device, but
|
||||
|
@ -51,6 +51,22 @@ else
|
|||
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
|
||||
fi
|
||||
|
||||
# Allow overriding GRUB_CMDLINE_LINUX and GRUB_CMDLINE_LINUX_DEFAULT.
|
||||
if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE}" ]; then
|
||||
GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX_XEN_REPLACE}"
|
||||
fi
|
||||
if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}" ]; then
|
||||
GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}"
|
||||
fi
|
||||
|
||||
if [ "x`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2>/dev/null || true`" = xbtrfs ]; then
|
||||
rootsubvol="`make_system_path_relative_to_its_root /`"
|
||||
rootsubvol="${rootsubvol#/}"
|
||||
if [ "x${rootsubvol}" != x ]; then
|
||||
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
|
||||
fi
|
||||
fi
|
||||
|
||||
linux_entry ()
|
||||
{
|
||||
os="$1"
|
||||
|
@ -60,11 +76,11 @@ linux_entry ()
|
|||
args="$5"
|
||||
xen_args="$6"
|
||||
if ${recovery} ; then
|
||||
title="$(gettext_quoted "%s, with Linux %s and XEN %s (recovery mode)")"
|
||||
title="$(gettext_quoted "%s, with Xen %s and Linux %s (recovery mode)")"
|
||||
else
|
||||
title="$(gettext_quoted "%s, with Linux %s and XEN %s")"
|
||||
title="$(gettext_quoted "%s, with Xen %s and Linux %s")"
|
||||
fi
|
||||
printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}" "${xen_version}"
|
||||
printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${xen_version}" "${version}"
|
||||
if ! ${recovery} ; then
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
fi
|
||||
|
@ -73,10 +89,12 @@ linux_entry ()
|
|||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
|
||||
fi
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
message="$(gettext_printf "Loading Linux %s ..." ${version})"
|
||||
xmessage="$(gettext_printf "Loading Xen %s ..." ${xen_version})"
|
||||
lmessage="$(gettext_printf "Loading Linux %s ..." ${version})"
|
||||
cat << EOF
|
||||
echo '$message'
|
||||
echo '$xmessage'
|
||||
multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args}
|
||||
echo '$lmessage'
|
||||
module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
|
||||
EOF
|
||||
if test -n "${initrd}" ; then
|
||||
|
@ -91,11 +109,24 @@ EOF
|
|||
EOF
|
||||
}
|
||||
|
||||
linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
|
||||
linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do
|
||||
if grub_file_is_not_garbage "$i"; then
|
||||
basename=$(basename $i)
|
||||
version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
|
||||
if grub_file_is_not_garbage "$i" && grep -qx "CONFIG_XEN_DOM0=y" /boot/config-${version} 2> /dev/null ; then echo -n "$i " ; fi
|
||||
done`
|
||||
dirname=$(dirname $i)
|
||||
config=
|
||||
for j in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
|
||||
if test -e "${j}" ; then
|
||||
config="${j}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if (grep -qx "CONFIG_XEN_DOM0=y" "${config}" 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" "${config}" 2> /dev/null); then echo -n "$i " ; fi
|
||||
fi
|
||||
done`
|
||||
if [ "x${linux_list}" = "x" ] ; then
|
||||
exit 0
|
||||
fi
|
||||
xen_list=`for i in /boot/xen*; do
|
||||
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
|
||||
done`
|
||||
|
@ -122,7 +153,9 @@ while [ "x${xen_list}" != "x" ] ; do
|
|||
initrd=
|
||||
for i in "initrd.img-${version}" "initrd-${version}.img" \
|
||||
"initrd-${version}" "initrd.img-${alt_version}" \
|
||||
"initrd-${alt_version}.img" "initrd-${alt_version}"; do
|
||||
"initrd-${alt_version}.img" "initrd-${alt_version}" \
|
||||
"initramfs-genkernel-${version}" \
|
||||
"initramfs-genkernel-${alt_version}" ; do
|
||||
if test -e "${dirname}/${i}" ; then
|
||||
initrd="$i"
|
||||
break
|
||||
|
|
|
@ -111,7 +111,7 @@ EOF
|
|||
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
|
||||
|
||||
case ${LONGNAME} in
|
||||
Windows\ Vista*|Windows\ 7*)
|
||||
Windows\ Vista*|Windows\ 7*|Windows\ Server\ 2008*)
|
||||
;;
|
||||
*)
|
||||
cat << EOF
|
||||
|
|
|
@ -377,8 +377,8 @@ grub_util_devname_to_ofpath (const char *devname)
|
|||
if (! name_buf)
|
||||
grub_util_error ("cannot get the real path of `%s'", devname);
|
||||
|
||||
device = get_basename (devname);
|
||||
devnode = strip_trailing_digits (devname);
|
||||
device = get_basename (name_buf);
|
||||
devnode = strip_trailing_digits (name_buf);
|
||||
devicenode = strip_trailing_digits (device);
|
||||
|
||||
ofpath = xmalloc (OF_PATH_MAX);
|
||||
|
@ -391,6 +391,13 @@ grub_util_devname_to_ofpath (const char *devname)
|
|||
else if (device[0] == 'v' && device[1] == 'd' && device[2] == 'i'
|
||||
&& device[3] == 's' && device[4] == 'k')
|
||||
of_path_of_vdisk(ofpath, name_buf, device, devnode, devicenode);
|
||||
else if (device[0] == 'f' && device[1] == 'd'
|
||||
&& device[2] == '0' && device[3] == '\0')
|
||||
/* All the models I've seen have a devalias "floppy".
|
||||
New models have no floppy at all. */
|
||||
strcpy (ofpath, "floppy");
|
||||
else
|
||||
grub_util_error ("unknown device type %s\n", device);
|
||||
|
||||
free (devnode);
|
||||
free (devicenode);
|
||||
|
|
|
@ -91,7 +91,12 @@ for cipher_file in cipher_files:
|
|||
f = open (infile, "r")
|
||||
fw = open (outfile, "w")
|
||||
fw.write ("/* This file was automatically imported with \n")
|
||||
fw.write (" import_gcry.py. Please don't modify it */\n");
|
||||
fw.write (" import_gcry.py. Please don't modify it */\n")
|
||||
fw.write ("#include <grub/dl.h>\n")
|
||||
# Whole libgcrypt is distributed under GPLv3+ or compatible
|
||||
if isc:
|
||||
fw.write ("GRUB_MOD_LICENSE (\"GPLv3+\");\n")
|
||||
|
||||
ciphernames = []
|
||||
mdnames = []
|
||||
hold = False
|
||||
|
|
13
util/raid.c
13
util/raid.c
|
@ -36,25 +36,18 @@
|
|||
#include <linux/raid/md_u.h>
|
||||
|
||||
char **
|
||||
grub_util_raid_getmembers (char *name)
|
||||
grub_util_raid_getmembers (const char *name)
|
||||
{
|
||||
int fd, ret, i, j;
|
||||
char *devname;
|
||||
char **devicelist;
|
||||
mdu_version_t version;
|
||||
mdu_array_info_t info;
|
||||
mdu_disk_info_t disk;
|
||||
|
||||
devname = xmalloc (strlen (name) + 6);
|
||||
strcpy (devname, "/dev/");
|
||||
strcpy (devname+5, name);
|
||||
|
||||
fd = open (devname, O_RDONLY);
|
||||
fd = open (name, O_RDONLY);
|
||||
|
||||
if (fd == -1)
|
||||
grub_util_error ("can't open %s: %s", devname, strerror (errno));
|
||||
|
||||
free (devname);
|
||||
grub_util_error ("can't open %s: %s", name, strerror (errno));
|
||||
|
||||
ret = ioctl (fd, RAID_VERSION, &version);
|
||||
if (ret != 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue