merge mainline into zfs
This commit is contained in:
commit
11e50e923a
553 changed files with 42706 additions and 8566 deletions
|
@ -402,7 +402,7 @@ unset __grub_mkimage_program
|
|||
#
|
||||
# grub-mkpasswd-pbkdf2
|
||||
#
|
||||
_grub_mkpasswd-pbkdf2 () {
|
||||
_grub_mkpasswd_pbkdf2 () {
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
|
@ -417,7 +417,7 @@ _grub_mkpasswd-pbkdf2 () {
|
|||
}
|
||||
__grub_mkpasswd_pbkdf2_program=$( echo grub-mkpasswd-pbkdf2 | sed "@program_transform_name@" )
|
||||
have ${__grub_mkpasswd_pbkdf2_program} && \
|
||||
complete -F _grub_mkpasswd-pbkdf2 -o filenames ${__grub_mkpasswd_pbkdf2_program}
|
||||
complete -F _grub_mkpasswd_pbkdf2 -o filenames ${__grub_mkpasswd_pbkdf2_program}
|
||||
unset __grub_mkpasswd_pbkdf2_program
|
||||
|
||||
|
||||
|
@ -462,7 +462,7 @@ unset __grub_probe_program
|
|||
#
|
||||
# grub-script-check
|
||||
#
|
||||
_grub_script-check () {
|
||||
_grub_script_check () {
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
|
@ -477,7 +477,7 @@ _grub_script-check () {
|
|||
}
|
||||
__grub_script_check_program=$( echo grub-script-check | sed "@program_transform_name@" )
|
||||
have ${__grub_script_check_program} && \
|
||||
complete -F _grub_script-check -o filenames ${__grub_script_check_program}
|
||||
complete -F _grub_script_check -o filenames ${__grub_script_check_program}
|
||||
|
||||
|
||||
# Local variables:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* deviceiter.c - iterate over system devices */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008,2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -286,6 +286,26 @@ get_scsi_disk_name (char *name, int unit)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD_kernel__
|
||||
static void
|
||||
get_ada_disk_name (char *name, int unit)
|
||||
{
|
||||
sprintf (name, "/dev/ada%d", unit);
|
||||
}
|
||||
|
||||
static void
|
||||
get_ataraid_disk_name (char *name, int unit)
|
||||
{
|
||||
sprintf (name, "/dev/ar%d", unit);
|
||||
}
|
||||
|
||||
static void
|
||||
get_mfi_disk_name (char *name, int unit)
|
||||
{
|
||||
sprintf (name, "/dev/mfid%d", unit);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
static void
|
||||
get_virtio_disk_name (char *name, int unit)
|
||||
|
@ -620,6 +640,48 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD_kernel__
|
||||
/* IDE disks using ATA Direct Access driver. */
|
||||
if (get_kfreebsd_version () >= 800000)
|
||||
for (i = 0; i < 96; i++)
|
||||
{
|
||||
char name[16];
|
||||
|
||||
get_ada_disk_name (name, i);
|
||||
if (check_device_readable_unique (name))
|
||||
{
|
||||
if (hook (name, 0))
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* ATARAID disks. */
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
char name[20];
|
||||
|
||||
get_ataraid_disk_name (name, i);
|
||||
if (check_device_readable_unique (name))
|
||||
{
|
||||
if (hook (name, 0))
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* LSI MegaRAID SAS. */
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
char name[20];
|
||||
|
||||
get_mfi_disk_name (name, i);
|
||||
if (check_device_readable_unique (name))
|
||||
{
|
||||
if (hook (name, 0))
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
/* Virtio disks. */
|
||||
for (i = 0; i < 26; i++)
|
||||
|
|
1605
util/getroot.c
Normal file
1605
util/getroot.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -54,17 +54,21 @@ 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
|
||||
#define CMD_ZFSINFO 8
|
||||
|
||||
enum {
|
||||
CMD_LS = 1,
|
||||
CMD_CP,
|
||||
CMD_CAT,
|
||||
CMD_CMP,
|
||||
CMD_HEX,
|
||||
CMD_CRC,
|
||||
CMD_BLOCKLIST,
|
||||
CMD_TESTLOAD,
|
||||
CMD_ZFSINFO
|
||||
};
|
||||
#define BUF_SIZE 32256
|
||||
|
||||
static grub_disk_addr_t skip, leng;
|
||||
static int uncompress = 0;
|
||||
|
||||
static void
|
||||
read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
|
||||
|
@ -108,11 +112,13 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len))
|
|||
return;
|
||||
}
|
||||
|
||||
grub_file_filter_disable_compression ();
|
||||
if (uncompress == 0)
|
||||
grub_file_filter_disable_compression ();
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -182,6 +188,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)
|
||||
{
|
||||
|
@ -222,6 +248,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);
|
||||
}
|
||||
|
||||
|
@ -267,6 +301,7 @@ static char **images = NULL;
|
|||
static int cmd = 0;
|
||||
static char *debug_str = NULL;
|
||||
static char **args = NULL;
|
||||
static int mount_crypt = 0;
|
||||
|
||||
static void
|
||||
fstest (int n, char **args)
|
||||
|
@ -296,6 +331,15 @@ fstest (int n, char **args)
|
|||
grub_free (host_file);
|
||||
}
|
||||
|
||||
{
|
||||
char *argv[2] = { "-a", NULL};
|
||||
if (mount_crypt)
|
||||
{
|
||||
if (execute_command ("cryptomount", 1, argv))
|
||||
grub_util_error (_("cryptomount command fails: %s"), grub_errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
grub_lvm_fini ();
|
||||
grub_mdraid09_fini ();
|
||||
grub_mdraid1x_fini ();
|
||||
|
@ -316,6 +360,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;
|
||||
|
@ -328,6 +375,9 @@ fstest (int n, char **args)
|
|||
case CMD_BLOCKLIST:
|
||||
execute_command ("blocklist", n, args);
|
||||
grub_printf ("\n");
|
||||
case CMD_TESTLOAD:
|
||||
execute_command ("testload", n, args);
|
||||
grub_printf ("\n");
|
||||
}
|
||||
|
||||
for (i = 0; i < num_disks; i++)
|
||||
|
@ -351,6 +401,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},
|
||||
|
@ -361,7 +412,9 @@ static struct argp_option options[] = {
|
|||
{"length", 'n', "N", 0, N_("Handle N bytes in output file."), 2},
|
||||
{"diskcount", 'c', "N", 0, N_("N input files."), 2},
|
||||
{"debug", 'd', "S", 0, N_("Set debug environment variable."), 2},
|
||||
{"crypto", 'C', NULL, OPTION_ARG_OPTIONAL, N_("Mount crypto devices."), 2},
|
||||
{"verbose", 'v', NULL, OPTION_ARG_OPTIONAL, N_("Print verbose messages."), 2},
|
||||
{"uncompress", 'u', NULL, OPTION_ARG_OPTIONAL, N_("Uncompress data."), 2},
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -384,6 +437,10 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
|||
root = arg;
|
||||
return 0;
|
||||
|
||||
case 'C':
|
||||
mount_crypt = 1;
|
||||
return 0;
|
||||
|
||||
case 's':
|
||||
skip = grub_strtoul (arg, &p, 0);
|
||||
if (*p == 's')
|
||||
|
@ -418,6 +475,10 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
|||
verbosity++;
|
||||
return 0;
|
||||
|
||||
case 'u':
|
||||
uncompress = 1;
|
||||
return 0;
|
||||
|
||||
case ARGP_KEY_END:
|
||||
if (args_count < num_disks)
|
||||
{
|
||||
|
@ -467,6 +528,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;
|
||||
|
@ -487,6 +553,11 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
|||
cmd = CMD_BLOCKLIST;
|
||||
nparm = 1;
|
||||
}
|
||||
else if (!grub_strcmp (arg, "testload"))
|
||||
{
|
||||
cmd = CMD_TESTLOAD;
|
||||
nparm = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, _("Invalid command %s.\n"), arg);
|
||||
|
@ -522,6 +593,7 @@ main (int argc, char *argv[])
|
|||
|
||||
/* Initialize all modules. */
|
||||
grub_init_all ();
|
||||
grub_gcry_init_all ();
|
||||
|
||||
if (debug_str)
|
||||
grub_env_set ("debug", debug_str);
|
||||
|
@ -550,6 +622,7 @@ main (int argc, char *argv[])
|
|||
fstest (args_count - 1 - num_disks, args);
|
||||
|
||||
/* Free resources. */
|
||||
grub_gcry_fini_all ();
|
||||
grub_fini_all ();
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -31,6 +31,7 @@ PACKAGE_VERSION=@PACKAGE_VERSION@
|
|||
target_cpu=@target_cpu@
|
||||
platform=@platform@
|
||||
host_os=@host_os@
|
||||
datarootdir=@datarootdir@
|
||||
pkglibdir="${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`"
|
||||
localedir="@datadir@/locale"
|
||||
|
||||
|
@ -56,9 +57,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 +65,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
|
||||
|
@ -77,7 +75,7 @@ if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
|||
elif [ "${platform}" = "ieee1275" ] || [ "${platform}" = "efi" ] ; then
|
||||
disk_module=
|
||||
else
|
||||
disk_module=ata
|
||||
disk_module=native
|
||||
fi
|
||||
|
||||
# Usage: usage
|
||||
|
@ -114,7 +112,7 @@ Install GRUB on your drive.
|
|||
EOF
|
||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
||||
cat <<EOF
|
||||
--disk-module=MODULE disk module to use
|
||||
--disk-module=MODULE disk module to use (biosdisk or native)
|
||||
EOF
|
||||
fi
|
||||
if [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ] ; then
|
||||
|
@ -266,6 +264,8 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
|
||||
|
||||
if test "x$install_device" = x && ([ "${target_cpu}-${platform}" = "i386-pc" ] \
|
||||
|| [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]); then
|
||||
echo "install_device not specified." 1>&2
|
||||
|
@ -273,6 +273,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
|
||||
|
@ -331,6 +336,12 @@ if [ x"$platform" = xefi ]; then
|
|||
if test "x$install_device" != "x`"$grub_mkdevicemap" --device-map=/dev/stdout | "$grub_probe" --target=device --device-map=/dev/stdin "${bootdir}"`"; then
|
||||
efidir="${bootdir}/efi"
|
||||
fi
|
||||
elif test -d "${bootdir}/EFI"; then
|
||||
install_device="`"$grub_mkdevicemap" --device-map=/dev/stdout | "$grub_probe" --target=device --device-map=/dev/stdin "${bootdir}/EFI"`"
|
||||
# Is it a mount point?
|
||||
if test "x$install_device" != "x`"$grub_mkdevicemap" --device-map=/dev/stdout | "$grub_probe" --target=device --device-map=/dev/stdin "${bootdir}"`"; then
|
||||
efidir="${bootdir}/EFI"
|
||||
fi
|
||||
elif test -n "$rootdir" && test "x$rootdir" != "x/"; then
|
||||
# The EFI System Partition may have been given directly using
|
||||
# --root-directory.
|
||||
|
@ -365,7 +376,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 +390,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
|
||||
|
@ -454,6 +465,8 @@ for dir in "${localedir}"/*; do
|
|||
fi
|
||||
done
|
||||
|
||||
is_path_readable_by_grub "${grubdir}" || (echo "${grubdir}" not readable 1>&2 ; exit 1)
|
||||
|
||||
# Write device to a variable so we don't have to traverse /dev every time.
|
||||
grub_device="`"$grub_probe" --device-map="${device_map}" --target=device "${grubdir}"`" || exit 1
|
||||
|
||||
|
@ -465,7 +478,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
|
||||
|
||||
|
@ -486,6 +500,18 @@ done
|
|||
# Device abstraction module, if any (lvm, raid).
|
||||
devabstraction_module="`"$grub_probe" --device-map="${device_map}" --target=abstraction --device "${grub_device}"`"
|
||||
|
||||
if [ "x$disk_module" = xata ]; then
|
||||
disk_module=pata
|
||||
fi
|
||||
|
||||
if [ "x$disk_module" = xnative ]; then
|
||||
disk_module="pata ahci ohci"
|
||||
if [ "x$target_cpu" = "xi386" ] || [ "x$target_cpu" = "xx86_64" ]; then
|
||||
disk_module="$disk_module uhci"
|
||||
fi
|
||||
disk_module="$disk_module usbms"
|
||||
fi
|
||||
|
||||
# The order in this list is critical. Be careful when modifying it.
|
||||
modules="$modules $disk_module"
|
||||
modules="$modules $fs_module $partmap_module $devabstraction_module"
|
||||
|
@ -519,28 +545,26 @@ 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 ([ "x$disk_module" != x ] && [ "x$disk_module" != xbiosdisk ]) || [ "x${grub_drive}" != "x${install_drive}" ] || ([ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${platform}" != x"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"${platform}" != x"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
|
||||
elif [ "x$platform" = xefi ] || [ "x$platform" = xpc ] || [ "x$platform" = xieee1275 ]; then
|
||||
# we need to hardcode the partition number in the core image's prefix.
|
||||
if [ x"$grub_partition" = x ]; then
|
||||
prefix_drive="()"
|
||||
|
@ -549,18 +573,26 @@ if [ "x${devabstraction_module}" = "x" ] ; then
|
|||
fi
|
||||
fi
|
||||
else
|
||||
if [ x$GRUB_CRYPTODISK_ENABLE = xy ]; then
|
||||
for uuid in "`"${grub_probe}" --device "${grub_device}" --target=cryptodisk_uuid`"; do
|
||||
echo "cryptomount -u $uuid" >> "${grubdir}/load.cfg"
|
||||
done
|
||||
fi
|
||||
|
||||
config_opt="-c ${grubdir}/load.cfg "
|
||||
|
||||
prefix_drive=`"$grub_probe" --device-map="${device_map}" --target=drive --device "${grub_device}"` || exit 1
|
||||
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 +601,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 +617,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 +651,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 +690,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);
|
||||
|
|
|
@ -95,7 +95,7 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
|
||||
|
||||
if [ "x$EUID" = "x" ] ; then
|
||||
EUID=`id -u`
|
||||
|
@ -239,6 +239,8 @@ export GRUB_DEFAULT \
|
|||
GRUB_CMDLINE_LINUX_DEFAULT \
|
||||
GRUB_CMDLINE_XEN \
|
||||
GRUB_CMDLINE_XEN_DEFAULT \
|
||||
GRUB_CMDLINE_LINUX_XEN_REPLACE \
|
||||
GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT \
|
||||
GRUB_CMDLINE_NETBSD \
|
||||
GRUB_CMDLINE_NETBSD_DEFAULT \
|
||||
GRUB_TERMINAL_INPUT \
|
||||
|
@ -254,6 +256,7 @@ export GRUB_DEFAULT \
|
|||
GRUB_DISABLE_OS_PROBER \
|
||||
GRUB_INIT_TUNE \
|
||||
GRUB_SAVEDEFAULT \
|
||||
GRUB_ENABLE_CRYPTODISK \
|
||||
GRUB_BADRAM
|
||||
|
||||
if test "x${grub_cfg}" != "x"; then
|
||||
|
@ -280,6 +283,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,46 +44,64 @@ 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 abstractions="`"${grub_probe}" -t abstraction "$path"`" 2>&1 ; then
|
||||
:
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ x$GRUB_CRYPTODISK_ENABLE = xy ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
for abstraction in $abstractions; do
|
||||
if [ "x$abstraction" = xcryptodisk ]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
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 +115,39 @@ EOF
|
|||
|
||||
prepare_grub_to_access_device ()
|
||||
{
|
||||
device=$1
|
||||
device="$1"
|
||||
|
||||
partmap="`"${grub_probe}" --device "${device}" --target=partmap`"
|
||||
for module in ${partmap} ; do
|
||||
case "${module}" in
|
||||
netbsd | openbsd)
|
||||
echo "insmod part_bsd";;
|
||||
*)
|
||||
echo "insmod part_${module}";;
|
||||
esac
|
||||
done
|
||||
|
||||
# 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`"
|
||||
for module in ${partmap} ; do
|
||||
echo "insmod part_${module}"
|
||||
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 [ x$GRUB_CRYPTODISK_ENABLE = xy ]; then
|
||||
for uuid in "`"${grub_probe}" --device "${device}" --target=cryptodisk_uuid`"; do
|
||||
echo "cryptomount -u $uuid"
|
||||
done
|
||||
fi
|
||||
|
||||
# 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
|
||||
}
|
||||
|
@ -128,7 +157,7 @@ grub_file_is_not_garbage ()
|
|||
if test -f "$1" ; then
|
||||
case "$1" in
|
||||
*.dpkg-*) return 1 ;; # debian dpkg
|
||||
README*) return 1 ;; # documentation
|
||||
README*|*/README*) return 1 ;; # documentation
|
||||
esac
|
||||
else
|
||||
return 1
|
||||
|
@ -138,21 +167,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 +190,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
|
||||
|
@ -187,14 +216,26 @@ version_find_latest ()
|
|||
echo "$a"
|
||||
}
|
||||
|
||||
# One layer of quotation is eaten by "", the second by sed, and the third by
|
||||
# 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
|
||||
# remaining arguments to printf. This is a useful abbreviation and tends to
|
||||
# be easier to type.
|
||||
gettext_printf () {
|
||||
local format="$1"
|
||||
shift
|
||||
printf "$(gettext_quoted "$format")" "$@"
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1170,7 +1180,8 @@ main (int argc, char *argv[])
|
|||
font_info.style = ft_face->style_flags;
|
||||
font_info.size = size;
|
||||
|
||||
FT_Set_Pixel_Sizes (ft_face, size, size);
|
||||
if (FT_Set_Pixel_Sizes (ft_face, size, size))
|
||||
grub_util_error ("can't set %dx%d font size", size, size);
|
||||
add_font (&font_info, ft_face, file_format != PF2);
|
||||
FT_Done_Face (ft_face);
|
||||
}
|
||||
|
|
|
@ -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,26 +59,26 @@ 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_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC,
|
||||
IMAGE_QEMU_MIPS_FLASH
|
||||
} 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;
|
||||
unsigned raw_size;
|
||||
unsigned total_module_size;
|
||||
unsigned kernel_image_size;
|
||||
unsigned compressed_size;
|
||||
unsigned link_align;
|
||||
grub_uint16_t elf_target;
|
||||
|
@ -86,21 +88,27 @@ 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,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.prefix = GRUB_KERNEL_I386_COREBOOT_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_I386_COREBOOT_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
|
@ -113,16 +121,14 @@ 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,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.prefix = GRUB_KERNEL_I386_MULTIBOOT_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_I386_MULTIBOOT_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
|
@ -135,16 +141,14 @@ 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,
|
||||
.flags = PLATFORM_FLAGS_LZMA,
|
||||
.prefix = GRUB_KERNEL_I386_PC_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_I386_PC_PREFIX_END,
|
||||
.raw_size = GRUB_KERNEL_I386_PC_RAW_SIZE,
|
||||
.total_module_size = GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE,
|
||||
.kernel_image_size = GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE,
|
||||
.compressed_size = GRUB_KERNEL_I386_PC_COMPRESSED_SIZE,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
|
@ -153,16 +157,14 @@ 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,
|
||||
.flags = PLATFORM_FLAGS_LZMA,
|
||||
.prefix = GRUB_KERNEL_I386_PC_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_I386_PC_PREFIX_END,
|
||||
.raw_size = GRUB_KERNEL_I386_PC_RAW_SIZE,
|
||||
.total_module_size = GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE,
|
||||
.kernel_image_size = GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE,
|
||||
.compressed_size = GRUB_KERNEL_I386_PC_COMPRESSED_SIZE,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
|
@ -171,16 +173,14 @@ 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,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.prefix = GRUB_KERNEL_I386_EFI_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_I386_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 = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
||||
|
@ -191,18 +191,18 @@ 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,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.prefix = GRUB_KERNEL_I386_IEEE1275_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_I386_IEEE1275_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
|
@ -215,17 +215,15 @@ 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,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.prefix = GRUB_KERNEL_I386_QEMU_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_I386_QEMU_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = TARGET_NO_FIELD,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = GRUB_KERNEL_I386_QEMU_KERNEL_IMAGE_SIZE,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
|
@ -233,80 +231,90 @@ 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,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.prefix = GRUB_KERNEL_X86_64_EFI_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_X86_64_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 = 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,
|
||||
.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-fuloong2f-flash", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_YEELOONG_ELF,
|
||||
.id = IMAGE_FULOONG2F_FLASH,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.prefix = GRUB_KERNEL_MIPS_YEELOONG_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_MIPS_YEELOONG_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-fuloong2f-elf", "mipsel-fuloong2e-elf",
|
||||
"mipsel-fuloong-elf", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_LOONGSON_ELF,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE,
|
||||
.compressed_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,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.prefix = GRUB_KERNEL_POWERPC_IEEE1275_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_POWERPC_IEEE1275_PREFIX_END,
|
||||
.raw_size = 0,
|
||||
.total_module_size = TARGET_NO_FIELD,
|
||||
.kernel_image_size = TARGET_NO_FIELD,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
|
@ -319,17 +327,15 @@ 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,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.prefix = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END,
|
||||
.raw_size = GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE,
|
||||
.total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
|
||||
.kernel_image_size = GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE,
|
||||
.compressed_size = GRUB_KERNEL_SPARC64_IEEE1275_COMPRESSED_SIZE,
|
||||
.compressed_size = TARGET_NO_FIELD,
|
||||
.section_align = 1,
|
||||
.vaddr_offset = 0,
|
||||
.install_dos_part = TARGET_NO_FIELD,
|
||||
|
@ -337,23 +343,134 @@ 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,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.prefix = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX,
|
||||
.prefix_end = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END,
|
||||
.raw_size = GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE,
|
||||
.total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
|
||||
.kernel_image_size = GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE,
|
||||
.compressed_size = GRUB_KERNEL_SPARC64_IEEE1275_COMPRESSED_SIZE,
|
||||
.compressed_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_SPARC64_IEEE1275_LINK_ADDR
|
||||
},
|
||||
{
|
||||
.dirname = "ia64-efi",
|
||||
.names = {"ia64-efi", NULL},
|
||||
.voidp_sizeof = 8,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_EFI,
|
||||
.flags = PLATFORM_FLAGS_NONE,
|
||||
.raw_size = 0,
|
||||
.total_module_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),
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE,
|
||||
.compressed_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,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
|
||||
.compressed_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-flash", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 1,
|
||||
.id = IMAGE_QEMU_MIPS_FLASH,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
|
||||
.compressed_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 = "mipsel-qemu_mips",
|
||||
.names = { "mipsel-qemu_mips-flash", NULL },
|
||||
.voidp_sizeof = 4,
|
||||
.bigendian = 0,
|
||||
.id = IMAGE_QEMU_MIPS_FLASH,
|
||||
.flags = PLATFORM_FLAGS_DECOMPRESSORS,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
|
||||
.compressed_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,
|
||||
.raw_size = 0,
|
||||
.total_module_size = GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE,
|
||||
.compressed_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)))
|
||||
|
@ -617,6 +734,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
char *kernel_img, *core_img;
|
||||
size_t kernel_size, total_module_size, core_size, exec_size;
|
||||
size_t memdisk_size = 0, config_size = 0, config_size_pure = 0;
|
||||
size_t prefix_size = 0;
|
||||
char *kernel_path;
|
||||
size_t offset;
|
||||
struct grub_util_path_list *path_list, *p, *next;
|
||||
|
@ -624,6 +742,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;
|
||||
|
@ -652,6 +771,12 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
total_module_size += config_size + sizeof (struct grub_module_header);
|
||||
}
|
||||
|
||||
if (prefix)
|
||||
{
|
||||
prefix_size = ALIGN_ADDR (strlen (prefix) + 1);
|
||||
total_module_size += prefix_size + sizeof (struct grub_module_header);
|
||||
}
|
||||
|
||||
for (p = path_list; p; p = p->next)
|
||||
total_module_size += (ALIGN_ADDR (grub_util_get_image_size (p->name))
|
||||
+ sizeof (struct grub_module_header));
|
||||
|
@ -667,31 +792,47 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
total_module_size, &start_address, &rel_section,
|
||||
&reloc_size, &align, image_target);
|
||||
|
||||
if (image_target->prefix + strlen (prefix) + 1 > image_target->prefix_end)
|
||||
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 +883,39 @@ 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);
|
||||
if (prefix)
|
||||
{
|
||||
struct grub_module_header *header;
|
||||
|
||||
header = (struct grub_module_header *) (kernel_img + offset);
|
||||
memset (header, 0, sizeof (struct grub_module_header));
|
||||
header->type = grub_host_to_target32 (OBJ_TYPE_PREFIX);
|
||||
header->size = grub_host_to_target32 (prefix_size + sizeof (*header));
|
||||
offset += sizeof (*header);
|
||||
|
||||
grub_memset (kernel_img + offset, 0, prefix_size);
|
||||
grub_strcpy (kernel_img + offset, prefix);
|
||||
offset += prefix_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_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 +923,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 +934,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 +952,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 +1061,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 +1082,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 +1249,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);
|
||||
|
@ -1124,6 +1276,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
aout_size = core_size + sizeof (*aout_head);
|
||||
aout_img = xmalloc (aout_size);
|
||||
aout_head = aout_img;
|
||||
grub_memset (aout_head, 0, sizeof (*aout_head));
|
||||
aout_head->a_midmag = grub_host_to_target32 ((AOUT_MID_SUN << 16)
|
||||
| AOUT32_OMAGIC);
|
||||
aout_head->a_text = grub_host_to_target32 (core_size);
|
||||
|
@ -1162,17 +1315,63 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
}
|
||||
break;
|
||||
case IMAGE_YEELOONG_FLASH:
|
||||
case IMAGE_FULOONG2F_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 fuloong2f_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_FULOONG2F_FLASH)
|
||||
{
|
||||
fwstart_good_hash = fuloong2f_fwstart_good_hash;
|
||||
boot_path = grub_util_get_path (dir, "fwstart_fuloong2f.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 +1388,104 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
|||
core_size = rom_size;
|
||||
}
|
||||
break;
|
||||
case IMAGE_YEELOONG_ELF:
|
||||
case IMAGE_QEMU_MIPS_FLASH:
|
||||
{
|
||||
char *rom_img;
|
||||
size_t rom_size;
|
||||
|
||||
if (core_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);
|
||||
|
||||
memcpy (rom_img, core_img, core_size);
|
||||
|
||||
memset (rom_img + core_size, 0,
|
||||
rom_size - core_size);
|
||||
|
||||
free (core_img);
|
||||
core_img = rom_img;
|
||||
core_size = rom_size;
|
||||
}
|
||||
break;
|
||||
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 +1498,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 +1533,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 +1546,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 +1636,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 +1679,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 +1754,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 +1854,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,9 @@ 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@
|
||||
datarootdir=@datarootdir@
|
||||
pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst"
|
||||
|
||||
self=`basename $0`
|
||||
|
@ -49,6 +46,12 @@ debug=no
|
|||
debug_image=
|
||||
subdir=`echo /boot/grub | sed ${transform}`
|
||||
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-pc
|
||||
ppc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/powerpc-ieee1275
|
||||
sparc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/sparc64-ieee1275
|
||||
i386_ieee1275_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-ieee1275
|
||||
efi32_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-efi
|
||||
efi64_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/x86_64-efi
|
||||
itanium_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/ia64-efi
|
||||
|
||||
# Usage: usage
|
||||
# Print the usage.
|
||||
|
@ -64,7 +67,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
|
||||
|
@ -200,11 +203,20 @@ process_input_dir ()
|
|||
config_opt="-c ${grubdir}/load.cfg "
|
||||
fi
|
||||
|
||||
prefix="/${subdir}/${platform}";
|
||||
case "${platform}" in
|
||||
i386-pc) mkimage_target=i386-pc-pxe;
|
||||
netmodules="pxe";
|
||||
prefix="(pxe)/${subdir}/${platform}";
|
||||
ext=0 ;;
|
||||
sparc64-ieee1275) mkimage_target=sparc64-ieee1275-aout;
|
||||
netmodules="ofnet";
|
||||
ext=img ;;
|
||||
*-ieee1275) mkimage_target="${platform}";
|
||||
netmodules="ofnet";
|
||||
ext=elf ;;
|
||||
*-efi) mkimage_target="${platform}";
|
||||
netmodules="efinet";
|
||||
ext=efi ;;
|
||||
*) echo Unsupported platform ${platform};
|
||||
exit 1;;
|
||||
esac
|
||||
|
@ -213,16 +225,35 @@ process_input_dir ()
|
|||
source ${subdir}/grub.cfg
|
||||
EOF
|
||||
|
||||
$grub_mkimage ${config_opt} -d "${input_dir}" -O ${mkimage_target} --output=${grubdir}/core.$ext --prefix=$prefix $modules $netmodules || exit 1
|
||||
$grub_mkimage ${config_opt} -d "${input_dir}" -O ${mkimage_target} --output=${grubdir}/core.$ext --prefix=$prefix $modules $netmodules tftp || exit 1
|
||||
echo "Netboot directory for ${platform} created. Configure your DHCP server to point to ${subdir}/${platform}/core.$ext"
|
||||
}
|
||||
|
||||
if [ "${override_dir}" = "" ] ; then
|
||||
if test -e "${pc_dir}" ; then
|
||||
process_input_dir ${pc_dir} i386-pc
|
||||
process_input_dir "${pc_dir}" i386-pc
|
||||
fi
|
||||
if test -e "${ppc_dir}" ; then
|
||||
process_input_dir "${ppc_dir}" powerpc-ieee1275
|
||||
fi
|
||||
if test -e "${sparc_dir}" ; then
|
||||
process_input_dir ${sparc_dir} sparc64-ieee1275
|
||||
fi
|
||||
if test -e "${i386_ieee1275_dir}" ; then
|
||||
process_input_dir "${i386_ieee1275_dir}" i386-ieee1275
|
||||
fi
|
||||
if test -e "${efi32_dir}" ; then
|
||||
process_input_dir "${efi32_dir}" i386-efi
|
||||
fi
|
||||
if test -e "${efi64_dir}" ; then
|
||||
process_input_dir "${efi64_dir}" x86_64-efi
|
||||
fi
|
||||
if test -e "${itanium_dir}" ; then
|
||||
process_input_dir "${itanium_dir}" ia64-efi
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <grub/types.h>
|
||||
#include <grub/crypto.h>
|
||||
#include <grub/auth.h>
|
||||
#include <grub/emu/misc.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/i18n.h>
|
||||
|
@ -29,7 +30,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include "progname.h"
|
||||
|
||||
|
@ -85,14 +85,12 @@ int
|
|||
main (int argc, char *argv[])
|
||||
{
|
||||
unsigned int count = 10000, buflen = 64, saltlen = 64;
|
||||
char *pass1, *pass2;
|
||||
char *bufhex, *salthex;
|
||||
gcry_err_code_t gcry_err;
|
||||
grub_uint8_t *buf, *salt;
|
||||
ssize_t nr;
|
||||
FILE *in, *out;
|
||||
struct termios s, t;
|
||||
int tty_changed;
|
||||
char pass1[GRUB_AUTH_MAX_PASSLEN];
|
||||
char pass2[GRUB_AUTH_MAX_PASSLEN];
|
||||
|
||||
set_program_name (argv[0]);
|
||||
|
||||
|
@ -160,86 +158,37 @@ main (int argc, char *argv[])
|
|||
free (buf);
|
||||
grub_util_error ("out of memory");
|
||||
}
|
||||
|
||||
/* Disable echoing. Based on glibc. */
|
||||
in = fopen ("/dev/tty", "w+c");
|
||||
if (in == NULL)
|
||||
{
|
||||
in = stdin;
|
||||
out = stderr;
|
||||
}
|
||||
else
|
||||
out = in;
|
||||
|
||||
if (tcgetattr (fileno (in), &t) == 0)
|
||||
{
|
||||
/* Save the old one. */
|
||||
s = t;
|
||||
/* Tricky, tricky. */
|
||||
t.c_lflag &= ~(ECHO|ISIG);
|
||||
tty_changed = (tcsetattr (fileno (in), TCSAFLUSH, &t) == 0);
|
||||
}
|
||||
else
|
||||
tty_changed = 0;
|
||||
|
||||
printf ("Enter password: ");
|
||||
pass1 = NULL;
|
||||
{
|
||||
grub_size_t n;
|
||||
nr = getline (&pass1, &n, stdin);
|
||||
}
|
||||
if (nr < 0 || !pass1)
|
||||
if (!grub_password_get (pass1, GRUB_AUTH_MAX_PASSLEN))
|
||||
{
|
||||
free (buf);
|
||||
free (bufhex);
|
||||
free (salthex);
|
||||
free (salt);
|
||||
/* Restore the original setting. */
|
||||
if (tty_changed)
|
||||
(void) tcsetattr (fileno (in), TCSAFLUSH, &s);
|
||||
grub_util_error ("failure to read password");
|
||||
}
|
||||
if (nr >= 1 && pass1[nr-1] == '\n')
|
||||
pass1[nr-1] = 0;
|
||||
|
||||
printf ("\nReenter password: ");
|
||||
pass2 = NULL;
|
||||
{
|
||||
grub_size_t n;
|
||||
nr = getline (&pass2, &n, stdin);
|
||||
}
|
||||
/* Restore the original setting. */
|
||||
if (tty_changed)
|
||||
(void) tcsetattr (fileno (in), TCSAFLUSH, &s);
|
||||
printf ("\n");
|
||||
|
||||
if (nr < 0 || !pass2)
|
||||
if (!grub_password_get (pass2, GRUB_AUTH_MAX_PASSLEN))
|
||||
{
|
||||
memset (pass1, 0, strlen (pass1));
|
||||
free (pass1);
|
||||
free (buf);
|
||||
free (bufhex);
|
||||
free (salthex);
|
||||
free (salt);
|
||||
grub_util_error ("failure to read password");
|
||||
}
|
||||
if (nr >= 1 && pass2[nr-1] == '\n')
|
||||
pass2[nr-1] = 0;
|
||||
|
||||
if (strcmp (pass1, pass2) != 0)
|
||||
{
|
||||
memset (pass1, 0, strlen (pass1));
|
||||
memset (pass2, 0, strlen (pass2));
|
||||
free (pass1);
|
||||
free (pass2);
|
||||
memset (pass1, 0, sizeof (pass1));
|
||||
memset (pass2, 0, sizeof (pass2));
|
||||
free (buf);
|
||||
free (bufhex);
|
||||
free (salthex);
|
||||
free (salt);
|
||||
grub_util_error ("passwords don't match");
|
||||
}
|
||||
memset (pass2, 0, strlen (pass2));
|
||||
free (pass2);
|
||||
memset (pass2, 0, sizeof (pass2));
|
||||
|
||||
#if ! defined (__linux__) && ! defined (__FreeBSD__)
|
||||
printf ("WARNING: your random generator isn't known to be secure\n");
|
||||
|
@ -248,11 +197,10 @@ 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));
|
||||
free (pass1);
|
||||
memset (pass1, 0, sizeof (pass1));
|
||||
free (buf);
|
||||
free (bufhex);
|
||||
free (salthex);
|
||||
|
@ -264,13 +212,11 @@ main (int argc, char *argv[])
|
|||
if (rd != saltlen)
|
||||
{
|
||||
fclose (f);
|
||||
memset (pass1, 0, strlen (pass1));
|
||||
free (pass1);
|
||||
memset (pass1, 0, sizeof (pass1));
|
||||
free (buf);
|
||||
free (bufhex);
|
||||
free (salthex);
|
||||
free (salt);
|
||||
fclose (f);
|
||||
grub_util_error ("couldn't retrieve random data for salt");
|
||||
}
|
||||
fclose (f);
|
||||
|
@ -280,8 +226,7 @@ main (int argc, char *argv[])
|
|||
(grub_uint8_t *) pass1, strlen (pass1),
|
||||
salt, saltlen,
|
||||
count, buf, buflen);
|
||||
memset (pass1, 0, strlen (pass1));
|
||||
free (pass1);
|
||||
memset (pass1, 0, sizeof (pass1));
|
||||
|
||||
if (gcry_err)
|
||||
{
|
||||
|
|
|
@ -27,21 +27,19 @@ 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`
|
||||
|
||||
multiboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-multiboot
|
||||
coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-coreboot
|
||||
qemu_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-qemu
|
||||
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-pc
|
||||
efi32_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-efi
|
||||
efi64_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/x86_64-efi
|
||||
multiboot_dir="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-multiboot"
|
||||
coreboot_dir="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-coreboot"
|
||||
qemu_dir="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-qemu"
|
||||
pc_dir="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-pc"
|
||||
efi32_dir="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-efi"
|
||||
efi64_dir="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/x86_64-efi"
|
||||
rom_directory=
|
||||
override_dir=
|
||||
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
|
||||
grub_mkimage="${bindir}/`echo grub-mkimage | sed ${transform}`"
|
||||
|
||||
xorriso=xorriso
|
||||
|
||||
|
@ -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} ;;
|
||||
|
@ -276,7 +275,7 @@ if test -e "${pc_dir}" ; then
|
|||
fi
|
||||
|
||||
# build multiboot core.img
|
||||
make_image "${multiboot_dir}" i386-multiboot "${iso9660_dir}/boot/multiboot.img" "ata at_keyboard"
|
||||
make_image "${multiboot_dir}" i386-multiboot "${iso9660_dir}/boot/multiboot.img" "pata ahci at_keyboard"
|
||||
|
||||
if test -e "${efi64_dir}" || test -e "${efi32_dir}"; then
|
||||
efi_dir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
|
@ -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 ::/
|
||||
|
@ -293,11 +296,11 @@ if test -e "${efi64_dir}" || test -e "${efi32_dir}"; then
|
|||
grub_mkisofs_arguments="${grub_mkisofs_arguments} --efi-boot efi.img"
|
||||
fi
|
||||
|
||||
make_image "${qemu_dir}" i386-qemu "${iso9660_dir}/boot/qemu.img" "ata at_keyboard"
|
||||
make_image "${qemu_dir}" i386-qemu "${iso9660_dir}/boot/qemu.img" "pata at_keyboard"
|
||||
if [ -e "${iso9660_dir}/boot/qemu.img" ] && [ -d "${rom_directory}" ]; then
|
||||
cp "${iso9660_dir}/boot/qemu.img" "${rom_directory}/qemu.img"
|
||||
fi
|
||||
make_image "${coreboot_dir}" i386-coreboot "${iso9660_dir}/boot/coreboot.elf" "ata at_keyboard"
|
||||
make_image "${coreboot_dir}" i386-coreboot "${iso9660_dir}/boot/coreboot.elf" "pata ahci at_keyboard"
|
||||
if [ -e "${iso9660_dir}/boot/coreboot.elf" ] && [ -d "${rom_directory}" ]; then
|
||||
cp "${iso9660_dir}/boot/coreboot.elf" "${rom_directory}/coreboot.elf"
|
||||
fi
|
||||
|
|
189
util/grub-mkstandalone.in
Normal file
189
util/grub-mkstandalone.in
Normal file
|
@ -0,0 +1,189 @@
|
|||
#! /bin/sh
|
||||
set -e
|
||||
|
||||
# Make GRUB rescue image
|
||||
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# GRUB is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# GRUB is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Initialize some variables.
|
||||
transform="@program_transform_name@"
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
bindir=@bindir@
|
||||
libdir=@libdir@
|
||||
PACKAGE_NAME=@PACKAGE_NAME@
|
||||
PACKAGE_TARNAME=@PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION=@PACKAGE_VERSION@
|
||||
pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst"
|
||||
|
||||
self=`basename $0`
|
||||
|
||||
source_dirrectory=
|
||||
compression=auto
|
||||
format=
|
||||
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
|
||||
source=
|
||||
|
||||
# Usage: usage
|
||||
# Print the usage.
|
||||
usage () {
|
||||
cat <<EOF
|
||||
Usage: $self [OPTION] SOURCE...
|
||||
Make GRUB rescue image.
|
||||
|
||||
-h, --help print this message and exit
|
||||
-v, --version print the version information and exit
|
||||
-o, --output=FILE save output in FILE [required]
|
||||
-d, --directory=DIR use images and modules under DIR [default=%s/@platform@]
|
||||
-O, --format=FORMAT generate an image in format
|
||||
available formats: %s
|
||||
-C, --compression=(xz|none|auto) choose the compression to use
|
||||
--modules=MODULES pre-load specified modules MODULES
|
||||
--grub-mkimage=FILE use FILE as grub-mkimage
|
||||
|
||||
$self generates a standalone image (containing all modules) in the selected format
|
||||
|
||||
Report bugs to <bug-grub@gnu.org>.
|
||||
EOF
|
||||
}
|
||||
|
||||
argument () {
|
||||
opt=$1
|
||||
shift
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo "$0: option requires an argument -- '$opt'" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
echo $1
|
||||
}
|
||||
|
||||
# Check the arguments.
|
||||
while test $# -gt 0
|
||||
do
|
||||
option=$1
|
||||
shift
|
||||
|
||||
case "$option" in
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0 ;;
|
||||
-v | --version)
|
||||
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
|
||||
exit 0 ;;
|
||||
|
||||
--modules)
|
||||
modules=`argument $option "$@"`; shift ;;
|
||||
--modules=*)
|
||||
modules=`echo "$option" | sed 's/--modules=//'` ;;
|
||||
|
||||
-o | --output)
|
||||
output_image=`argument $option "$@"`; shift ;;
|
||||
--output=*)
|
||||
output_image=`echo "$option" | sed 's/--output=//'` ;;
|
||||
|
||||
--directory | -d)
|
||||
source_directory=`argument $option "$@"`; shift ;;
|
||||
--directory=*)
|
||||
source_directory=`echo "$option" | sed 's/--rom-directory=//'` ;;
|
||||
|
||||
--grub-mkimage)
|
||||
grub_mkimage=`argument $option "$@"`; shift ;;
|
||||
--grub-mkimage=*)
|
||||
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
|
||||
|
||||
--compression | -C)
|
||||
compression=`argument $option "$@"`; shift ;;
|
||||
--compression=*)
|
||||
compression=`echo "${option}/" | sed 's/--xorriso=//'` ;;
|
||||
|
||||
--format | -O)
|
||||
format=`argument $option "$@"`; shift ;;
|
||||
--format=*)
|
||||
format=`echo "${option}/" | sed 's/--xorriso=//'` ;;
|
||||
|
||||
*)
|
||||
source="${source} ${option} $@"; break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "x${output_image}" = x ] ; then
|
||||
echo "output file must be given" >&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "x${format}" = x ] ; then
|
||||
echo "format must be given" >&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "x$source_directory" = x ] ; then
|
||||
cpu="`echo $format | awk -F - '{ print $1; }'`"
|
||||
platform="`echo $format | awk -F - '{ print $2; }'`"
|
||||
case "$platform" in
|
||||
yeeloong | fuloong | fuloong2f | fuloong2e)
|
||||
platform=loongson ;;
|
||||
esac
|
||||
case "$cpu-$platform" in
|
||||
mips-loongson)
|
||||
cpu=mipsel ;;
|
||||
esac
|
||||
source_directory="${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/$cpu-$platform"
|
||||
fi
|
||||
|
||||
set $grub_mkimage dummy
|
||||
if test -f "$1"; then
|
||||
:
|
||||
else
|
||||
echo "$1: Not found." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
memdisk_dir="`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
|
||||
mkdir -p "${memdisk_dir}"/boot/grub
|
||||
|
||||
for file in "${source_directory}/"*.mod "${source_directory}/"efiemu32.o "${source_directory}/"efiemu64.o; do
|
||||
if test -f "$file"; then
|
||||
cp -f "$file" "${memdisk_dir}"/boot/grub/
|
||||
fi
|
||||
done
|
||||
for file in ${pkglib_DATA}; do
|
||||
if test -f "${source_directory}/${file}"; then
|
||||
cp -f "${source_directory}/${file}" "${memdisk_dir}"/boot/grub/
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p "${memdisk_dir}"/boot/grub/locale
|
||||
for file in "${source_directory}"/po/*.mo; do
|
||||
if test -f "$file"; then
|
||||
cp -f "$file" "${memdisk_dir}"/boot/grub/locale/
|
||||
fi
|
||||
done
|
||||
|
||||
for file in $source; do
|
||||
cp -f "$file" "${memdisk_dir}"/"$file";
|
||||
done
|
||||
|
||||
memdisk_img=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
|
||||
(cd "${memdisk_dir}"; tar -cf - * $source) > "${memdisk_img}"
|
||||
rm -rf "${memdisk_dir}"
|
||||
$grub_mkimage -O "${format}" -C "$compression" -d "${source_directory}" -m "${memdisk_img}" -o "$output_image" --prefix='(memdisk)/boot/grub' memdisk tar $modules
|
||||
rm -rf "${memdisk_img}"
|
||||
|
||||
exit 0
|
|
@ -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;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/emu/misc.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/file.h>
|
||||
|
@ -34,6 +33,8 @@
|
|||
#include <grub/env.h>
|
||||
#include <grub/raid.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/crypto.h>
|
||||
#include <grub/cryptodisk.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
@ -54,6 +55,7 @@ enum {
|
|||
PRINT_DEVICE,
|
||||
PRINT_PARTMAP,
|
||||
PRINT_ABSTRACTION,
|
||||
PRINT_CRYPTODISK_UUID
|
||||
};
|
||||
|
||||
int print = PRINT_FS;
|
||||
|
@ -63,15 +65,49 @@ static void
|
|||
probe_partmap (grub_disk_t disk)
|
||||
{
|
||||
grub_partition_t part;
|
||||
grub_disk_memberlist_t list = NULL, tmp;
|
||||
|
||||
if (disk->partition == NULL)
|
||||
{
|
||||
grub_util_info ("no partition map found for %s", disk->name);
|
||||
return;
|
||||
}
|
||||
|
||||
for (part = disk->partition; part; part = part->parent)
|
||||
printf ("%s\n", part->partmap->name);
|
||||
printf ("%s ", part->partmap->name);
|
||||
|
||||
/* In case of LVM/RAID, check the member devices as well. */
|
||||
if (disk->dev->memberlist)
|
||||
{
|
||||
list = disk->dev->memberlist (disk);
|
||||
}
|
||||
while (list)
|
||||
{
|
||||
probe_partmap (list->disk);
|
||||
tmp = list->next;
|
||||
free (list);
|
||||
list = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
probe_cryptodisk_uuid (grub_disk_t disk)
|
||||
{
|
||||
grub_disk_memberlist_t list = NULL, tmp;
|
||||
|
||||
/* In case of LVM/RAID, check the member devices as well. */
|
||||
if (disk->dev->memberlist)
|
||||
{
|
||||
list = disk->dev->memberlist (disk);
|
||||
}
|
||||
while (list)
|
||||
{
|
||||
probe_cryptodisk_uuid (list->disk);
|
||||
tmp = list->next;
|
||||
free (list);
|
||||
list = tmp;
|
||||
}
|
||||
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
|
||||
grub_util_cryptodisk_print_uuid (disk);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -88,6 +124,42 @@ probe_raid_level (grub_disk_t disk)
|
|||
return ((struct grub_raid_array *) disk->data)->level;
|
||||
}
|
||||
|
||||
static void
|
||||
probe_abstraction (grub_disk_t disk)
|
||||
{
|
||||
grub_disk_memberlist_t list = NULL, tmp;
|
||||
int raid_level;
|
||||
|
||||
if (disk->dev->memberlist)
|
||||
list = disk->dev->memberlist (disk);
|
||||
while (list)
|
||||
{
|
||||
probe_abstraction (list->disk);
|
||||
|
||||
tmp = list->next;
|
||||
free (list);
|
||||
list = tmp;
|
||||
}
|
||||
|
||||
if (disk->dev->id == GRUB_DISK_DEVICE_LVM_ID)
|
||||
printf ("lvm ");
|
||||
|
||||
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
|
||||
grub_util_cryptodisk_print_abstraction (disk);
|
||||
|
||||
raid_level = probe_raid_level (disk);
|
||||
if (raid_level >= 0)
|
||||
{
|
||||
printf ("raid ");
|
||||
if (disk->dev->raidname)
|
||||
printf ("%s ", disk->dev->raidname (disk));
|
||||
}
|
||||
if (raid_level == 5)
|
||||
printf ("raid5rec ");
|
||||
if (raid_level == 6)
|
||||
printf ("raid6rec ");
|
||||
}
|
||||
|
||||
static void
|
||||
probe (const char *path, char *device_name)
|
||||
{
|
||||
|
@ -108,7 +180,10 @@ probe (const char *path, char *device_name)
|
|||
#endif
|
||||
}
|
||||
else
|
||||
device_name = grub_guess_root_device (path);
|
||||
{
|
||||
grub_path = canonicalize_file_name (path);
|
||||
device_name = grub_guess_root_device (grub_path);
|
||||
}
|
||||
|
||||
if (! device_name)
|
||||
grub_util_error ("cannot find a device for %s (is /dev mounted?)", path);
|
||||
|
@ -136,91 +211,23 @@ probe (const char *path, char *device_name)
|
|||
|
||||
if (print == PRINT_ABSTRACTION)
|
||||
{
|
||||
grub_disk_memberlist_t list = NULL, tmp;
|
||||
const int is_lvm = (dev->disk->dev->id == GRUB_DISK_DEVICE_LVM_ID);
|
||||
int is_raid = 0;
|
||||
int is_raid5 = 0;
|
||||
int is_raid6 = 0;
|
||||
int raid_level;
|
||||
grub_disk_t raid_disk;
|
||||
|
||||
raid_level = probe_raid_level (dev->disk);
|
||||
if (raid_level >= 0)
|
||||
{
|
||||
is_raid = 1;
|
||||
is_raid5 |= (raid_level == 5);
|
||||
is_raid6 |= (raid_level == 6);
|
||||
raid_disk = dev->disk;
|
||||
}
|
||||
|
||||
if ((is_lvm) && (dev->disk->dev->memberlist))
|
||||
list = dev->disk->dev->memberlist (dev->disk);
|
||||
while (list)
|
||||
{
|
||||
raid_level = probe_raid_level (list->disk);
|
||||
if (raid_level >= 0)
|
||||
{
|
||||
is_raid = 1;
|
||||
is_raid5 |= (raid_level == 5);
|
||||
is_raid6 |= (raid_level == 6);
|
||||
raid_disk = list->disk;
|
||||
}
|
||||
|
||||
tmp = list->next;
|
||||
free (list);
|
||||
list = tmp;
|
||||
}
|
||||
|
||||
if (is_raid)
|
||||
{
|
||||
printf ("raid ");
|
||||
if (is_raid5)
|
||||
printf ("raid5rec ");
|
||||
if (is_raid6)
|
||||
printf ("raid6rec ");
|
||||
if (raid_disk->dev->raidname)
|
||||
printf ("%s ", raid_disk->dev->raidname (raid_disk));
|
||||
}
|
||||
|
||||
if (is_lvm)
|
||||
printf ("lvm ");
|
||||
|
||||
probe_abstraction (dev->disk);
|
||||
printf ("\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (print == PRINT_CRYPTODISK_UUID)
|
||||
{
|
||||
probe_cryptodisk_uuid (dev->disk);
|
||||
printf ("\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (print == PRINT_PARTMAP)
|
||||
{
|
||||
grub_disk_memberlist_t list = NULL, tmp;
|
||||
|
||||
/* Check if dev->disk itself is contained in a partmap. */
|
||||
probe_partmap (dev->disk);
|
||||
|
||||
/* In case of LVM/RAID, check the member devices as well. */
|
||||
if (dev->disk->dev->memberlist)
|
||||
list = dev->disk->dev->memberlist (dev->disk);
|
||||
while (list)
|
||||
{
|
||||
probe_partmap (list->disk);
|
||||
/* LVM on RAID */
|
||||
if (list->disk->dev->memberlist)
|
||||
{
|
||||
grub_disk_memberlist_t sub_list;
|
||||
|
||||
sub_list = list->disk->dev->memberlist (list->disk);
|
||||
while (sub_list)
|
||||
{
|
||||
probe_partmap (sub_list->disk);
|
||||
tmp = sub_list->next;
|
||||
free (sub_list);
|
||||
sub_list = tmp;
|
||||
}
|
||||
}
|
||||
tmp = list->next;
|
||||
free (list);
|
||||
list = tmp;
|
||||
}
|
||||
printf ("\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -289,8 +296,8 @@ Probe device information for a given path (or device, if the -d option is given)
|
|||
\n\
|
||||
-d, --device given argument is a system device, not a path\n\
|
||||
-m, --device-map=FILE use FILE as the device map [default=%s]\n\
|
||||
-t, --target=(fs|fs_uuid|fs_label|drive|device|partmap|abstraction)\n\
|
||||
print filesystem module, GRUB drive, system device, partition map module or abstraction module [default=fs]\n\
|
||||
-t, --target=(fs|fs_uuid|fs_label|drive|device|partmap|abstraction|cryptodisk_uuid)\n\
|
||||
print filesystem module, GRUB drive, system device, partition map module, abstraction module or CRYPTO UUID [default=fs]\n\
|
||||
-h, --help display this message and exit\n\
|
||||
-V, --version print version information and exit\n\
|
||||
-v, --verbose print verbose messages\n\
|
||||
|
@ -348,6 +355,8 @@ main (int argc, char *argv[])
|
|||
print = PRINT_PARTMAP;
|
||||
else if (!strcmp (optarg, "abstraction"))
|
||||
print = PRINT_ABSTRACTION;
|
||||
else if (!strcmp (optarg, "cryptodisk_uuid"))
|
||||
print = PRINT_CRYPTODISK_UUID;
|
||||
else
|
||||
usage (1);
|
||||
break;
|
||||
|
@ -393,6 +402,7 @@ main (int argc, char *argv[])
|
|||
|
||||
/* Initialize all modules. */
|
||||
grub_init_all ();
|
||||
grub_gcry_init_all ();
|
||||
|
||||
grub_lvm_fini ();
|
||||
grub_mdraid09_fini ();
|
||||
|
@ -410,6 +420,7 @@ main (int argc, char *argv[])
|
|||
probe (argument, NULL);
|
||||
|
||||
/* Free resources. */
|
||||
grub_gcry_fini_all ();
|
||||
grub_fini_all ();
|
||||
grub_util_biosdisk_fini ();
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ main (int argc, char *argv[])
|
|||
{
|
||||
char *argument;
|
||||
char *input;
|
||||
int lineno = 0;
|
||||
FILE *file = 0;
|
||||
int verbose = 0;
|
||||
int found_input = 0;
|
||||
|
@ -111,6 +112,7 @@ main (int argc, char *argv[])
|
|||
cmdline[i] = '\0';
|
||||
}
|
||||
|
||||
lineno++;
|
||||
*line = grub_strdup (cmdline);
|
||||
|
||||
free (cmdline);
|
||||
|
@ -189,5 +191,11 @@ main (int argc, char *argv[])
|
|||
|
||||
if (file) fclose (file);
|
||||
|
||||
return (found_input && script == 0);
|
||||
if (found_input && script == 0)
|
||||
{
|
||||
fprintf (stderr, "error: line no: %u\n", lineno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* grub-setup.c - make GRUB usable */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -32,7 +32,6 @@
|
|||
#include <grub/machine/kernel.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/util/raid.h>
|
||||
#include <grub/util/lvm.h>
|
||||
#ifdef GRUB_MACHINE_IEEE1275
|
||||
#include <grub/util/ofpath.h>
|
||||
|
@ -49,6 +48,8 @@
|
|||
#include <grub/emu/getroot.h>
|
||||
#include "progname.h"
|
||||
#include <grub/reed_solomon.h>
|
||||
#include <grub/msdos_partition.h>
|
||||
#include <include/grub/crypto.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);
|
||||
|
@ -879,6 +894,7 @@ main (int argc, char *argv[])
|
|||
|
||||
/* Initialize all modules. */
|
||||
grub_init_all ();
|
||||
grub_gcry_init_all ();
|
||||
|
||||
grub_lvm_fini ();
|
||||
grub_mdraid09_fini ();
|
||||
|
@ -939,10 +955,12 @@ main (int argc, char *argv[])
|
|||
arguments.dir ? : DEFAULT_DIRECTORY);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
if (grub_util_lvm_isvolume (root_dev))
|
||||
must_embed = 1;
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
if (root_dev[0] == 'm' && root_dev[1] == 'd'
|
||||
&& ((root_dev[2] >= '0' && root_dev[2] <= '9') || root_dev[2] == '/'))
|
||||
{
|
||||
|
@ -956,7 +974,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, 1);
|
||||
else
|
||||
{
|
||||
char *devname;
|
||||
devname = xasprintf ("/dev/%s", dest_dev);
|
||||
devicelist = grub_util_raid_getmembers (dest_dev, 1);
|
||||
free (devname);
|
||||
}
|
||||
|
||||
for (i = 0; devicelist[i]; i++)
|
||||
{
|
||||
|
|
|
@ -23,9 +23,9 @@ prefix=@prefix@
|
|||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
locale_dir=`echo ${GRUB_PREFIX}/locale | sed ${transform}`
|
||||
grub_lang=`echo $LANG | cut -d _ -f 1`
|
||||
grub_lang=`echo $LANG | cut -d . -f 1`
|
||||
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
|
||||
|
||||
# Do this as early as possible, since other commands might depend on it.
|
||||
# (e.g. the `loadfont' command might need lvm or raid modules)
|
||||
|
@ -36,7 +36,7 @@ done
|
|||
if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
|
||||
if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
|
||||
if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
|
||||
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=640x480 ; fi
|
||||
if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=auto ; fi
|
||||
|
||||
if [ "x${GRUB_DEFAULT_BUTTON}" = "x" ] ; then GRUB_DEFAULT_BUTTON="$GRUB_DEFAULT" ; fi
|
||||
if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_entry}' ; fi
|
||||
|
@ -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
|
||||
|
|
|
@ -20,7 +20,8 @@ set -e
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
datarootdir=@datarootdir@
|
||||
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
|
||||
|
||||
CLASS="--class gnu --class os"
|
||||
|
||||
|
@ -28,7 +29,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
|
||||
|
@ -81,14 +82,16 @@ do
|
|||
menuentry "${OS} ${KERNEL}" ${CLASS} {
|
||||
EOF
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
|
||||
message="$(gettext_printf "Loading GNU Mach ...")"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading GNU Mach ...")'
|
||||
echo '$message'
|
||||
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/}
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
|
||||
message="$(gettext_printf "Loading the Hurd ...")"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading the Hurd ...")'
|
||||
echo '$message'
|
||||
module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
|
||||
--multiboot-command-line='\${kernel-command-line}' \\
|
||||
--host-priv-port='\${host-port}' \\
|
||||
|
@ -103,13 +106,15 @@ EOF
|
|||
menuentry "${OS} ${KERNEL} (recovery mode)" ${CLASS} {
|
||||
EOF
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
|
||||
message="$(gettext_printf "Loading GNU Mach ...")"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading GNU Mach ...")'
|
||||
echo '$message'
|
||||
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} -s
|
||||
EOF
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
|
||||
message="$(gettext_printf "Loading the Hurd ...")"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading the Hurd ...")'
|
||||
echo '$message'
|
||||
module /hurd/${hurd_fs}.static ${hurd_fs} \\
|
||||
--multiboot-command-line='\${kernel-command-line}' \\
|
||||
--host-priv-port='\${host-port}' \\
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
set -e
|
||||
|
||||
# grub-mkconfig helper script.
|
||||
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
|
||||
#
|
||||
# GRUB is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -21,7 +21,8 @@ prefix=@prefix@
|
|||
exec_prefix=@exec_prefix@
|
||||
bindir=@bindir@
|
||||
libdir=@libdir@
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
datarootdir=@datarootdir@
|
||||
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
|
||||
|
||||
export TEXTDOMAIN=@PACKAGE@
|
||||
export TEXTDOMAINDIR=@localedir@
|
||||
|
@ -31,7 +32,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"
|
||||
|
@ -84,8 +85,9 @@ kfreebsd_entry ()
|
|||
fi
|
||||
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
message="$(gettext_printf "Loading kernel of FreeBSD %s ..." ${version})"
|
||||
cat << EOF
|
||||
echo '$(printf "$(gettext_quoted "Loading kernel of FreeBSD %s ...")" ${version})'
|
||||
echo '$message'
|
||||
kfreebsd ${rel_dirname}/${basename} ${args}
|
||||
EOF
|
||||
|
||||
|
@ -97,6 +99,12 @@ EOF
|
|||
|
||||
load_kfreebsd_module acpi true
|
||||
|
||||
for abstraction in dummy $(grub-probe -t abstraction --device ${GRUB_DEVICE}) ; do
|
||||
case $abstraction in
|
||||
lvm) load_kfreebsd_module geom_linux_lvm false ;;
|
||||
esac
|
||||
done
|
||||
|
||||
case "${kfreebsd_fs}" in
|
||||
zfs)
|
||||
load_kfreebsd_module opensolaris false
|
||||
|
@ -109,7 +117,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}
|
||||
|
|
|
@ -21,7 +21,8 @@ prefix=@prefix@
|
|||
exec_prefix=@exec_prefix@
|
||||
bindir=@bindir@
|
||||
libdir=@libdir@
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
datarootdir=@datarootdir@
|
||||
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
|
||||
|
||||
export TEXTDOMAIN=@PACKAGE@
|
||||
export TEXTDOMAINDIR=@localedir@
|
||||
|
@ -32,7 +33,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 +52,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 +82,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,17 +99,30 @@ EOF
|
|||
EOF
|
||||
fi
|
||||
|
||||
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}"
|
||||
cat << EOF
|
||||
echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
|
||||
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
|
||||
message="$(gettext_printf "Loading Linux %s ..." ${version})"
|
||||
cat << EOF
|
||||
echo '$message'
|
||||
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
|
||||
EOF
|
||||
if test -n "${initrd}" ; then
|
||||
message="$(gettext_printf "Loading initial ramdisk ...")"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading initial ramdisk ...")'
|
||||
echo '$message'
|
||||
initrd ${rel_dirname}/${initrd}
|
||||
EOF
|
||||
fi
|
||||
|
@ -109,10 +131,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`
|
||||
|
@ -128,21 +159,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
|
||||
|
|
|
@ -21,17 +21,72 @@ prefix=@prefix@
|
|||
exec_prefix=@exec_prefix@
|
||||
bindir=@bindir@
|
||||
libdir=@libdir@
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
datarootdir=@datarootdir@
|
||||
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
|
||||
|
||||
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 +114,9 @@ netbsd_entry ()
|
|||
"${kernel}" "${kernel}" "${kroot_device}" "${GRUB_CMDLINE_NETBSD} ${args}"
|
||||
;;
|
||||
esac
|
||||
|
||||
netbsd_load_fs_module "${loader}" "${kernel}"
|
||||
|
||||
printf "}\n"
|
||||
}
|
||||
|
||||
|
@ -72,8 +130,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
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ set -e
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
datarootdir=@datarootdir@
|
||||
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
|
||||
|
||||
case "`uname 2>/dev/null`" in
|
||||
CYGWIN*) ;;
|
||||
|
|
|
@ -21,7 +21,8 @@ prefix=@prefix@
|
|||
exec_prefix=@exec_prefix@
|
||||
bindir=@bindir@
|
||||
libdir=@libdir@
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
datarootdir=@datarootdir@
|
||||
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
|
||||
|
||||
export TEXTDOMAIN=@PACKAGE@
|
||||
export TEXTDOMAINDIR=@localedir@
|
||||
|
@ -32,7 +33,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 +52,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 +77,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,14 +90,18 @@ linux_entry ()
|
|||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
|
||||
fi
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
xmessage="$(gettext_printf "Loading Xen %s ..." ${xen_version})"
|
||||
lmessage="$(gettext_printf "Loading Linux %s ..." ${version})"
|
||||
cat << EOF
|
||||
echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
|
||||
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
|
||||
message="$(gettext_printf "Loading initial ramdisk ...")"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading initial ramdisk ...")'
|
||||
echo '$message'
|
||||
module ${rel_dirname}/${initrd}
|
||||
EOF
|
||||
fi
|
||||
|
@ -89,11 +110,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`
|
||||
|
@ -120,7 +154,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
|
||||
|
|
|
@ -21,7 +21,7 @@ prefix=@prefix@
|
|||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
|
||||
|
||||
if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
|
||||
exit 0
|
||||
|
@ -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
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "progname.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *of_path;
|
||||
|
@ -32,11 +34,16 @@ int main(int argc, char **argv)
|
|||
|
||||
grub_util_init_nls ();
|
||||
|
||||
if (argc != 2)
|
||||
if (argc != 2 || strcmp (argv[1], "--help") == 0)
|
||||
{
|
||||
printf("Usage: %s DEVICE\n", program_name);
|
||||
return 1;
|
||||
}
|
||||
if (strcmp (argv[1], "--version") == 0)
|
||||
{
|
||||
printf ("%s\n", PACKAGE_STRING);
|
||||
return 1;
|
||||
}
|
||||
|
||||
of_path = grub_util_devname_to_ofpath (argv[1]);
|
||||
printf("%s\n", of_path);
|
||||
|
|
|
@ -297,6 +297,7 @@ check_sas (char *sysfs_path, int *tgt)
|
|||
|
||||
free (path);
|
||||
free (p);
|
||||
close (fd);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -377,8 +378,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 +392,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);
|
||||
|
@ -412,6 +420,7 @@ int main(int argc, char **argv)
|
|||
|
||||
of_path = grub_util_devname_to_ofpath (argv[1]);
|
||||
printf("%s\n", of_path);
|
||||
free (of_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import re
|
|||
import sys
|
||||
import os
|
||||
import datetime
|
||||
import codecs
|
||||
|
||||
if len (sys.argv) < 3:
|
||||
print ("Usage: %s SOURCE DESTINATION" % sys.argv[0])
|
||||
|
@ -40,9 +41,17 @@ except:
|
|||
print ("WARNING: %s already exists" % cipher_dir_out)
|
||||
|
||||
cipher_files = os.listdir (cipher_dir_in)
|
||||
conf = open (os.path.join ("grub-core", "Makefile.gcry.def"), "w")
|
||||
conf = codecs.open (os.path.join ("grub-core", "Makefile.gcry.def"), "w", "utf-8")
|
||||
conf.write ("AutoGen definitions Makefile.tpl;\n\n")
|
||||
confutil = codecs.open ("Makefile.utilgcry.def", "w", "utf-8")
|
||||
confutil.write ("AutoGen definitions Makefile.tpl;\n\n")
|
||||
confutil.write ("library = {\n");
|
||||
confutil.write (" name = libgrubgcry.a;\n");
|
||||
confutil.write (" cflags = '$(CFLAGS_GCRY)';\n");
|
||||
confutil.write (" cppflags = '$(CPPFLAGS_GCRY)';\n");
|
||||
confutil.write ("\n");
|
||||
chlog = ""
|
||||
modules = []
|
||||
|
||||
# Strictly speaking CRC32/CRC24 work on bytes so this value should be 1
|
||||
# But libgcrypt uses 64. Let's keep the value for compatibility. Since
|
||||
|
@ -61,7 +70,7 @@ mdblocksizes = {"_gcry_digest_spec_crc32" : 64,
|
|||
"_gcry_digest_spec_tiger" : 64,
|
||||
"_gcry_digest_spec_whirlpool" : 64}
|
||||
|
||||
cryptolist = open (os.path.join (cipher_dir_out, "crypto.lst"), "w")
|
||||
cryptolist = codecs.open (os.path.join (cipher_dir_out, "crypto.lst"), "w", "utf-8")
|
||||
|
||||
# rijndael is the only cipher using aliases. So no need for mangling, just
|
||||
# hardcode it
|
||||
|
@ -73,6 +82,8 @@ cryptolist.write ("AES-128: gcry_rijndael\n");
|
|||
cryptolist.write ("AES-192: gcry_rijndael\n");
|
||||
cryptolist.write ("AES-256: gcry_rijndael\n");
|
||||
|
||||
cryptolist.write ("ADLER32: adler32\n");
|
||||
|
||||
for cipher_file in cipher_files:
|
||||
infile = os.path.join (cipher_dir_in, cipher_file)
|
||||
outfile = os.path.join (cipher_dir_out, cipher_file)
|
||||
|
@ -88,16 +99,36 @@ for cipher_file in cipher_files:
|
|||
nch = False
|
||||
if re.match (".*\.[ch]$", cipher_file):
|
||||
isc = re.match (".*\.c$", cipher_file)
|
||||
f = open (infile, "r")
|
||||
fw = open (outfile, "w")
|
||||
f = codecs.open (infile, "r", "utf-8")
|
||||
fw = codecs.open (outfile, "w", "utf-8")
|
||||
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")
|
||||
if cipher_file == "camellia.c":
|
||||
fw.write ("#include \"camellia.h\"\n")
|
||||
if cipher_file == "camellia.h":
|
||||
fw.write ("#include <grub/misc.h>\n")
|
||||
fw.write ("void camellia_setup128(const unsigned char *key, grub_uint32_t *subkey);\n")
|
||||
fw.write ("void camellia_setup192(const unsigned char *key, grub_uint32_t *subkey);\n")
|
||||
fw.write ("void camellia_setup256(const unsigned char *key, grub_uint32_t *subkey);\n")
|
||||
fw.write ("void camellia_encrypt128(const grub_uint32_t *subkey, grub_uint32_t *io);\n")
|
||||
fw.write ("void camellia_encrypt192(const grub_uint32_t *subkey, grub_uint32_t *io);\n")
|
||||
fw.write ("void camellia_encrypt256(const grub_uint32_t *subkey, grub_uint32_t *io);\n")
|
||||
fw.write ("void camellia_decrypt128(const grub_uint32_t *subkey, grub_uint32_t *io);\n")
|
||||
fw.write ("void camellia_decrypt192(const grub_uint32_t *subkey, grub_uint32_t *io);\n")
|
||||
fw.write ("void camellia_decrypt256(const grub_uint32_t *subkey, grub_uint32_t *io);\n")
|
||||
fw.write ("#define memcpy grub_memcpy\n")
|
||||
# Whole libgcrypt is distributed under GPLv3+ or compatible
|
||||
if isc:
|
||||
fw.write ("GRUB_MOD_LICENSE (\"GPLv3+\");\n")
|
||||
|
||||
ciphernames = []
|
||||
mdnames = []
|
||||
hold = False
|
||||
skip = False
|
||||
skip2 = False
|
||||
ismd = False
|
||||
iscipher = False
|
||||
iscryptostart = False
|
||||
iscomma = False
|
||||
isglue = False
|
||||
|
@ -109,6 +140,7 @@ for cipher_file in cipher_files:
|
|||
isglue = True
|
||||
modname = "gcry_%s" % modname
|
||||
for line in f:
|
||||
line = line
|
||||
if skip_statement:
|
||||
if not re.search (";", line) is None:
|
||||
skip_statement = False
|
||||
|
@ -127,15 +159,22 @@ for cipher_file in cipher_files:
|
|||
sg = s.groups()[0]
|
||||
cryptolist.write (("%s: %s\n") % (sg, modname))
|
||||
iscryptostart = False
|
||||
if ismd:
|
||||
if ismd or iscipher:
|
||||
if not re.search (" *};", line) is None:
|
||||
if not mdblocksizes.has_key (mdname):
|
||||
print ("ERROR: Unknown digest blocksize: %s\n" % mdname)
|
||||
exit (1)
|
||||
if not iscomma:
|
||||
fw.write (" ,\n")
|
||||
fw.write (" .blocksize = %s\n" % mdblocksizes [mdname])
|
||||
fw.write ("#ifdef GRUB_UTIL\n");
|
||||
fw.write (" .modname = \"%s\",\n" % modname);
|
||||
fw.write ("#endif\n");
|
||||
if ismd:
|
||||
if not (mdname in mdblocksizes):
|
||||
print ("ERROR: Unknown digest blocksize: %s\n"
|
||||
% mdname)
|
||||
exit (1)
|
||||
fw.write (" .blocksize = %s\n"
|
||||
% mdblocksizes [mdname])
|
||||
ismd = False
|
||||
iscipher = False
|
||||
iscomma = not re.search (",$", line) is None
|
||||
# Used only for selftests.
|
||||
m = re.match ("(static byte|static unsigned char) (weak_keys_chksum)\[[0-9]*\] =", line)
|
||||
|
@ -164,10 +203,9 @@ for cipher_file in cipher_files:
|
|||
continue
|
||||
else:
|
||||
fw.write (holdline)
|
||||
m = re.match ("#include <.*>", line)
|
||||
m = re.match ("# *include <(.*)>", line)
|
||||
if not m is None:
|
||||
chmsg = "Removed including of %s" % \
|
||||
m.group () [len ("#include <"):len (m.group ()) - 1]
|
||||
chmsg = "Removed including of %s" % m.groups ()[0]
|
||||
if nch:
|
||||
chlognew = "%s\n %s" % (chlognew, chmsg)
|
||||
else:
|
||||
|
@ -176,14 +214,18 @@ for cipher_file in cipher_files:
|
|||
continue
|
||||
m = re.match ("gcry_cipher_spec_t", line)
|
||||
if isc and not m is None:
|
||||
assert (not iscryptostart)
|
||||
assert (not iscipher)
|
||||
assert (not iscryptostart)
|
||||
ciphername = line [len ("gcry_cipher_spec_t"):].strip ()
|
||||
ciphername = re.match("[a-zA-Z0-9_]*",ciphername).group ()
|
||||
ciphernames.append (ciphername)
|
||||
iscipher = True
|
||||
iscryptostart = True
|
||||
m = re.match ("gcry_md_spec_t", line)
|
||||
if isc and not m is None:
|
||||
assert (not ismd)
|
||||
assert (not iscipher)
|
||||
assert (not iscryptostart)
|
||||
mdname = line [len ("gcry_md_spec_t"):].strip ()
|
||||
mdname = re.match("[a-zA-Z0-9_]*",mdname).group ()
|
||||
|
@ -244,6 +286,7 @@ for cipher_file in cipher_files:
|
|||
% (cipher_file, cipher_file.replace ("-glue.c", ".c"))
|
||||
else:
|
||||
modfiles = "lib/libgcrypt-grub/cipher/%s" % cipher_file
|
||||
modules.append (modname)
|
||||
chmsg = "(GRUB_MOD_INIT(%s)): New function\n" % modname
|
||||
if nch:
|
||||
chlognew = "%s\n %s" % (chlognew, chmsg)
|
||||
|
@ -278,6 +321,7 @@ for cipher_file in cipher_files:
|
|||
conf.write (" name = %s;\n" % modname)
|
||||
for src in modfiles.split():
|
||||
conf.write (" common = %s;\n" % src)
|
||||
confutil.write (" common = grub-core/%s;\n" % src)
|
||||
conf.write (" cflags = '$(CFLAGS_GCRY)';\n");
|
||||
conf.write (" cppflags = '$(CPPFLAGS_GCRY)';\n");
|
||||
conf.write ("};\n\n")
|
||||
|
@ -295,28 +339,28 @@ cryptolist.close ()
|
|||
chlog = "%s * crypto.lst: New file.\n" % chlog
|
||||
|
||||
outfile = os.path.join (cipher_dir_out, "types.h")
|
||||
fw=open (outfile, "w")
|
||||
fw=codecs.open (outfile, "w", "utf-8")
|
||||
fw.write ("#include <grub/types.h>\n")
|
||||
fw.write ("#include <cipher_wrap.h>\n")
|
||||
chlog = "%s * types.h: New file.\n" % chlog
|
||||
fw.close ()
|
||||
|
||||
outfile = os.path.join (cipher_dir_out, "memory.h")
|
||||
fw=open (outfile, "w")
|
||||
fw=codecs.open (outfile, "w", "utf-8")
|
||||
fw.write ("#include <cipher_wrap.h>\n")
|
||||
chlog = "%s * memory.h: New file.\n" % chlog
|
||||
fw.close ()
|
||||
|
||||
|
||||
outfile = os.path.join (cipher_dir_out, "cipher.h")
|
||||
fw=open (outfile, "w")
|
||||
fw=codecs.open (outfile, "w", "utf-8")
|
||||
fw.write ("#include <grub/crypto.h>\n")
|
||||
fw.write ("#include <cipher_wrap.h>\n")
|
||||
chlog = "%s * cipher.h: Likewise.\n" % chlog
|
||||
fw.close ()
|
||||
|
||||
outfile = os.path.join (cipher_dir_out, "g10lib.h")
|
||||
fw=open (outfile, "w")
|
||||
fw=codecs.open (outfile, "w", "utf-8")
|
||||
fw.write ("#include <cipher_wrap.h>\n")
|
||||
chlog = "%s * g10lib.h: Likewise.\n" % chlog
|
||||
fw.close ()
|
||||
|
@ -324,9 +368,35 @@ fw.close ()
|
|||
infile = os.path.join (cipher_dir_in, "ChangeLog")
|
||||
outfile = os.path.join (cipher_dir_out, "ChangeLog")
|
||||
|
||||
conf.close ();
|
||||
|
||||
f=open (infile, "r")
|
||||
fw=open (outfile, "w")
|
||||
initfile = codecs.open (os.path.join (cipher_dir_out, "init.c"), "w", "utf-8")
|
||||
for module in modules:
|
||||
initfile.write ("extern void grub_%s_init (void);\n" % module)
|
||||
initfile.write ("extern void grub_%s_fini (void);\n" % module)
|
||||
initfile.write ("\n")
|
||||
initfile.write ("void\n")
|
||||
initfile.write ("grub_gcry_init_all (void)\n")
|
||||
initfile.write ("{\n")
|
||||
for module in modules:
|
||||
initfile.write (" grub_%s_init ();\n" % module)
|
||||
initfile.write ("}\n")
|
||||
initfile.write ("\n")
|
||||
initfile.write ("void\n")
|
||||
initfile.write ("grub_gcry_fini_all (void)\n")
|
||||
initfile.write ("{\n")
|
||||
for module in modules:
|
||||
initfile.write (" grub_%s_fini ();\n" % module)
|
||||
initfile.write ("}\n")
|
||||
initfile.close ()
|
||||
|
||||
confutil.write (" common = grub-core/lib/libgcrypt-grub/cipher/init.c;\n")
|
||||
confutil.write ("};\n");
|
||||
confutil.close ();
|
||||
|
||||
|
||||
f=codecs.open (infile, "r", "utf-8")
|
||||
fw=codecs.open (outfile, "w", "utf-8")
|
||||
dt = datetime.date.today ()
|
||||
fw.write ("%04d-%02d-%02d Automatic import tool\n" % \
|
||||
(dt.year,dt.month, dt.day))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* lvm.c - LVM support for GRUB utils. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2008,2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -17,8 +17,7 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* We only support LVM on Linux. */
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#include <grub/emu/misc.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/util/lvm.h>
|
||||
|
@ -26,8 +25,6 @@
|
|||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
|
||||
|
||||
int
|
||||
grub_util_lvm_isvolume (char *name)
|
||||
{
|
||||
|
@ -49,4 +46,4 @@ grub_util_lvm_isvolume (char *name)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ! __linux__ */
|
||||
#endif
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#ifdef __MINGW32__
|
||||
#include <windows.h>
|
||||
#include <winioctl.h>
|
||||
#include "dirname.h"
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
|
@ -316,17 +317,13 @@ int fsync (int fno __attribute__ ((unused)))
|
|||
return 0;
|
||||
}
|
||||
|
||||
void sleep (int s)
|
||||
{
|
||||
Sleep (s * 1000);
|
||||
}
|
||||
|
||||
grub_int64_t
|
||||
grub_util_get_disk_size (char *name)
|
||||
{
|
||||
HANDLE hd;
|
||||
grub_int64_t size = -1LL;
|
||||
|
||||
strip_trailing_slashes(name);
|
||||
hd = CreateFile (name, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
0, OPEN_EXISTING, 0, 0);
|
||||
|
||||
|
|
25
util/raid.c
25
util/raid.c
|
@ -21,7 +21,6 @@
|
|||
#ifdef __linux__
|
||||
#include <grub/emu/misc.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/util/raid.h>
|
||||
#include <grub/emu/getroot.h>
|
||||
|
||||
#include <string.h>
|
||||
|
@ -36,31 +35,31 @@
|
|||
#include <linux/raid/md_u.h>
|
||||
|
||||
char **
|
||||
grub_util_raid_getmembers (char *name)
|
||||
grub_util_raid_getmembers (const char *name, int bootable)
|
||||
{
|
||||
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)
|
||||
grub_util_error ("ioctl RAID_VERSION error: %s", strerror (errno));
|
||||
|
||||
if (version.major != 0 || version.minor != 90)
|
||||
if ((version.major != 0 || version.minor != 90)
|
||||
&& (version.major != 1 || version.minor != 0)
|
||||
&& (version.major != 1 || version.minor != 1)
|
||||
&& (version.major != 1 || version.minor != 2))
|
||||
grub_util_error ("unsupported RAID version: %d.%d",
|
||||
version.major, version.minor);
|
||||
|
||||
if (bootable && (version.major != 0 || version.minor != 90))
|
||||
grub_util_error ("unsupported RAID version: %d.%d",
|
||||
version.major, version.minor);
|
||||
|
||||
|
@ -87,6 +86,8 @@ grub_util_raid_getmembers (char *name)
|
|||
|
||||
devicelist[j] = NULL;
|
||||
|
||||
close (fd);
|
||||
|
||||
return devicelist;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,6 @@ prefix=@prefix@
|
|||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
. ${libdir}/@PACKAGE@/grub-mkconfig_lib
|
||||
|
||||
grub_warn "update-grub_lib is deprecated, use grub-mkconfig_lib instead"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue