mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-28 01:59:49 +00:00
Compare commits
36
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8f07821cc | ||
|
|
dc3286ade4 | ||
|
|
46f8d358ef | ||
|
|
09c479006c | ||
|
|
4d6c69536e | ||
|
|
faf4a65e1e | ||
|
|
e5fa26e573 | ||
|
|
569766e49b | ||
|
|
4127206896 | ||
|
|
f7c7c4d4ad | ||
|
|
57bc5d431b | ||
|
|
6a7957f9f5 | ||
|
|
e88f0420b9 | ||
|
|
da98622662 | ||
|
|
fba31b5f69 | ||
|
|
72f099578e | ||
|
|
808e97c4e7 | ||
|
|
e388db904c | ||
|
|
cef394032d | ||
|
|
a4d610026f | ||
|
|
0c930a841e | ||
|
|
3d369a01ac | ||
|
|
5b83ef97e5 | ||
|
|
16f7455b04 | ||
|
|
74fa9ac1a6 | ||
|
|
62956fe7b9 | ||
|
|
260632161f | ||
|
|
4cd0b55fd0 | ||
|
|
95b56e3a97 | ||
|
|
bbc52c228f | ||
|
|
943981ff65 | ||
|
|
adabfb5418 | ||
|
|
77ec462a56 | ||
|
|
3bf2db8959 | ||
|
|
30a9ab952f | ||
|
|
c415eaa98f |
No files matched your search
@@ -1,3 +1,172 @@
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* configure.ac: Set version to 2.02~beta2.
|
||||
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/efi/efidisk.c (name_devices): Skip Apple ghosts.
|
||||
|
||||
2013-12-24 Andrey Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* util/grub-probe.c: Improve help message and simplify list handling.
|
||||
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Fix buffer overflow in grub_efi_print_device_path.
|
||||
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Show SATA device path.
|
||||
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Revert grub-file usage in grub-mkconfig.
|
||||
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Make newly-created files other than grub.cfg world-readable.
|
||||
|
||||
2013-12-24 Andrey Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* util/grub.d/00_header.in: Improve compatibility with old config.
|
||||
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Make rijndael.c respect aliasing rules.
|
||||
|
||||
Trivial backport of dfb4673da8ee52d95e0a62c9f49ca8599943f22e.
|
||||
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Make grub_util_device_is_mapped_stat available in grub-emu core.
|
||||
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Add -Qn to TARGET_CFLAGS if it's supported.
|
||||
Fixes compilation on cygwin.
|
||||
|
||||
Reported by: Andrey Borzenkov.
|
||||
Suggested by: Andrey Borzenkov.
|
||||
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Save TARGET_CC version in modinfo.sh.
|
||||
|
||||
Suggested by: Andrey Borzenkov.
|
||||
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Make grub_util_devmapper_part_to_disk and grub_util_find_partition_start
|
||||
follow the same algorithm to avoid method mismatch. Don't assume
|
||||
DMRAID- UUID to mean full disk but instead check that mapping is linear.
|
||||
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Declare GRUB_EFI_VENDOR_APPLE_GUID.
|
||||
|
||||
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Dump type and vendor specific data when printing device path.
|
||||
|
||||
2013-12-23 Colin Watson <cjwatson@debian.org>
|
||||
|
||||
Update some documentation to refer to Git rather than Bazaar.
|
||||
|
||||
* docs/grub.texi (Obtaining and Building GRUB): Refer to Git rather
|
||||
than Bazaar.
|
||||
* po/README: Likewise. Fix spelling mistake.
|
||||
|
||||
2013-12-23 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
Don't distribute config.h.
|
||||
|
||||
* Makefile.am (platform_HEADERS): Move to ...
|
||||
(nodist_platform_HEADERS): ... here. Fixes gettext_strings_test
|
||||
failure when building from a distributed tarball.
|
||||
|
||||
2013-12-23 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* configure.ac: Fix spelling.
|
||||
* grub-core/commands/parttool.c: Fix grammar.
|
||||
* grub-core/disk/ldm.c: Use consistent capitalisation for "LDM
|
||||
Embedding Partition".
|
||||
|
||||
2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
ARM64 support for grub-mkrescue.
|
||||
|
||||
2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Install modinfo.sh to keep build information around.
|
||||
|
||||
2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/modinfo.sh.in: Add build config information.
|
||||
|
||||
2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
ARM64 grub-file and grub-mkconfig support.
|
||||
|
||||
2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Remove leftover options defines.
|
||||
|
||||
2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* include/grub/arm64/linux.h: Remove leftovers. Add missing prefixes.
|
||||
|
||||
2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/loader/arm64/linux.c: Add missing bracket.
|
||||
|
||||
2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Add arm64-efi recognition to grub-file.
|
||||
|
||||
2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Fix ia64-efi recognition in grub-file.
|
||||
|
||||
2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Recognize raspberry pi kernel in grub-file.
|
||||
|
||||
2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Enable cache on ARM U-Boot port.
|
||||
|
||||
Without it the port is reidiculously slow.
|
||||
|
||||
2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Fix ARM cache maintainance.
|
||||
|
||||
More code was converted from ASM to C for easier handling.
|
||||
|
||||
2013-12-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/arm/cache.c (grub_arm_disable_caches_mmu): Use v6
|
||||
algorithm on v5.
|
||||
|
||||
Suggested by: Leif Lindholm.
|
||||
|
||||
2013-12-22 Andrey Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* util/grub-mkconfig.in: Fix Xen platform conditions.
|
||||
|
||||
2013-12-22 Andrey Borzenkov <arvidjaar@gmail.com>
|
||||
|
||||
* util/grub-mkrescue.c: Split single help message string in several
|
||||
strings used in previous shell version.
|
||||
|
||||
2013-12-22 Leif Lindholm <leif.lindholm@linaro.org>
|
||||
|
||||
Add arm64 Linux loader.
|
||||
|
||||
2013-12-22 Leif Lindholm <leif.lindholm@linaro.org>
|
||||
|
||||
Add grub_fdt_create_empty_tree() and grub_fdt_set_prop64().
|
||||
|
||||
2013-12-22 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Add module loading and parsing boot time checkpoints.
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec
|
||||
CLEANFILES += widthspec.h
|
||||
|
||||
# Install config.h into platformdir
|
||||
platform_HEADERS = config.h
|
||||
nodist_platform_HEADERS = config.h
|
||||
|
||||
pkgdata_DATA += grub-mkconfig_lib
|
||||
|
||||
|
||||
+7
-1
@@ -119,7 +119,6 @@ library = {
|
||||
common = grub-core/fs/sfs.c;
|
||||
common = grub-core/fs/squash4.c;
|
||||
common = grub-core/fs/tar.c;
|
||||
common = grub-core/fs/greffs.c;
|
||||
common = grub-core/fs/udf.c;
|
||||
common = grub-core/fs/ufs2.c;
|
||||
common = grub-core/fs/ufs.c;
|
||||
@@ -440,42 +439,49 @@ script = {
|
||||
name = '10_hurd';
|
||||
common = util/grub.d/10_hurd.in;
|
||||
installdir = grubconf;
|
||||
condition = COND_HOST_HURD;
|
||||
};
|
||||
|
||||
script = {
|
||||
name = '10_kfreebsd';
|
||||
common = util/grub.d/10_kfreebsd.in;
|
||||
installdir = grubconf;
|
||||
condition = COND_HOST_KFREEBSD;
|
||||
};
|
||||
|
||||
script = {
|
||||
name = '10_illumos';
|
||||
common = util/grub.d/10_illumos.in;
|
||||
installdir = grubconf;
|
||||
condition = COND_HOST_ILLUMOS;
|
||||
};
|
||||
|
||||
script = {
|
||||
name = '10_netbsd';
|
||||
common = util/grub.d/10_netbsd.in;
|
||||
installdir = grubconf;
|
||||
condition = COND_HOST_NETBSD;
|
||||
};
|
||||
|
||||
script = {
|
||||
name = '10_linux';
|
||||
common = util/grub.d/10_linux.in;
|
||||
installdir = grubconf;
|
||||
condition = COND_HOST_LINUX;
|
||||
};
|
||||
|
||||
script = {
|
||||
name = '10_xnu';
|
||||
common = util/grub.d/10_xnu.in;
|
||||
installdir = grubconf;
|
||||
condition = COND_HOST_XNU;
|
||||
};
|
||||
|
||||
script = {
|
||||
name = '20_linux_xen';
|
||||
common = util/grub.d/20_linux_xen.in;
|
||||
installdir = grubconf;
|
||||
condition = COND_HOST_LINUX;
|
||||
};
|
||||
|
||||
script = {
|
||||
|
||||
@@ -51,12 +51,6 @@
|
||||
#define PACKAGE_NAME "@PACKAGE_NAME@"
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||
/* Default boot directory name" */
|
||||
#define GRUB_BOOT_DIR_NAME "@bootdirname@"
|
||||
/* Default grub directory name */
|
||||
#define GRUB_DIR_NAME "@grubdirname@"
|
||||
/* Define to 1 if GCC generates calls to __register_frame_info(). */
|
||||
#define NEED_REGISTER_FRAME_INFO @NEED_REGISTER_FRAME_INFO@
|
||||
|
||||
#define GRUB_TARGET_CPU "@GRUB_TARGET_CPU@"
|
||||
#define GRUB_PLATFORM "@GRUB_PLATFORM@"
|
||||
|
||||
+24
-13
@@ -32,7 +32,7 @@ dnl type, so there is no conflict. Variables with the prefix "TARGET_"
|
||||
dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
|
||||
dnl type.
|
||||
|
||||
AC_INIT([GRUB],[2.02~beta1],[bug-grub@gnu.org])
|
||||
AC_INIT([GRUB],[2.02~beta2],[bug-grub@gnu.org])
|
||||
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
|
||||
@@ -214,20 +214,14 @@ case "$platform" in
|
||||
qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
|
||||
pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
|
||||
emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
|
||||
loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||
qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||
loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1" ;;
|
||||
qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1" ;;
|
||||
arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
|
||||
esac
|
||||
case "$target_cpu" in
|
||||
arm) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM=1" ;;
|
||||
arm64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM64=1" ;;
|
||||
mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
|
||||
sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
|
||||
esac
|
||||
if test x${target_cpu} = xmipsel ; then
|
||||
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
|
||||
else
|
||||
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,` -DGRUB_TARGET_CPU_`echo ${target_cpu} | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`=1"
|
||||
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
|
||||
fi
|
||||
|
||||
case "${target_cpu}-$platform" in
|
||||
@@ -509,6 +503,8 @@ if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
|
||||
fi
|
||||
|
||||
TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)"
|
||||
|
||||
AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
|
||||
LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
|
||||
|
||||
@@ -917,6 +913,15 @@ if test "x$target_cpu" = xarm; then
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [
|
||||
CFLAGS="$TARGET_CFLAGS -Qn -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||
[grub_cv_target_cc_qn=yes],
|
||||
[grub_cv_target_cc_qn=no])])
|
||||
if test "x$grub_cv_target_cc_qn" = xyes; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -Qn"
|
||||
fi
|
||||
|
||||
#
|
||||
# Compiler features.
|
||||
#
|
||||
@@ -1174,7 +1179,7 @@ enable_grub_emu_usb=no
|
||||
fi
|
||||
|
||||
if test x"$enable_grub_emu_sdl" = xno ; then
|
||||
grub_emu_sdl_excuse="explicitely disabled"
|
||||
grub_emu_sdl_excuse="explicitly disabled"
|
||||
fi
|
||||
[if [ x"$grub_emu_sdl_excuse" = x ]; then
|
||||
# Check for libSDL libraries.]
|
||||
@@ -1190,7 +1195,7 @@ AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
|
||||
[fi]
|
||||
|
||||
if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
|
||||
AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled ($grub_emu_sdl_excuse)])
|
||||
AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)])
|
||||
fi
|
||||
if test x"$grub_emu_sdl_excuse" = x ; then
|
||||
enable_grub_emu_sdl=yes
|
||||
@@ -1580,7 +1585,6 @@ AC_SUBST(BSS_START_SYMBOL)
|
||||
AC_SUBST(END_SYMBOL)
|
||||
AC_SUBST(PACKAGE)
|
||||
AC_SUBST(VERSION)
|
||||
AC_SUBST(NEED_REGISTER_FRAME_INFO)
|
||||
|
||||
AC_ARG_ENABLE([werror],
|
||||
[AS_HELP_STRING([--disable-werror],
|
||||
@@ -1612,6 +1616,7 @@ AC_SUBST(TARGET_CPP)
|
||||
AC_SUBST(TARGET_CCAS)
|
||||
AC_SUBST(TARGET_OBJ2ELF)
|
||||
AC_SUBST(TARGET_MODULE_FORMAT)
|
||||
AC_SUBST(TARGET_CC_VERSION)
|
||||
|
||||
AC_SUBST(TARGET_CFLAGS)
|
||||
AC_SUBST(TARGET_LDFLAGS)
|
||||
@@ -1661,7 +1666,13 @@ AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
|
||||
AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
|
||||
AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
|
||||
|
||||
AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
|
||||
AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
|
||||
AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
|
||||
AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
|
||||
AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
|
||||
AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
|
||||
AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
|
||||
|
||||
AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
|
||||
AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
|
||||
|
||||
+1
-1
@@ -6385,7 +6385,7 @@ just do:
|
||||
@end group
|
||||
@end example
|
||||
|
||||
Also, the latest version is available using Bazaar. See
|
||||
Also, the latest version is available using Git. See
|
||||
@uref{http://www.gnu.org/software/grub/grub-download.html} for more
|
||||
information.
|
||||
|
||||
|
||||
@@ -221,12 +221,14 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/uboot/uboot.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/uboot/disk.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h
|
||||
endif
|
||||
|
||||
if COND_arm_efi
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h
|
||||
endif
|
||||
|
||||
if COND_arm64_efi
|
||||
|
||||
@@ -1399,11 +1399,6 @@ module = {
|
||||
common = fs/tar.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = greffs;
|
||||
common = fs/greffs.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = udf;
|
||||
common = fs/udf.c;
|
||||
@@ -1677,7 +1672,8 @@ module = {
|
||||
sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c;
|
||||
ia64_efi = loader/ia64/efi/linux.c;
|
||||
arm = loader/arm/linux.c;
|
||||
arm = lib/fdt.c;
|
||||
arm64 = loader/arm64/linux.c;
|
||||
fdt = lib/fdt.c;
|
||||
common = loader/linux.c;
|
||||
common = lib/cmdline.c;
|
||||
enable = noemu;
|
||||
|
||||
@@ -48,6 +48,8 @@ static const struct grub_arg_option options[] = {
|
||||
N_("Check if FILE can be used as x86 multiboot2 kernel"), 0, 0},
|
||||
{"is-arm-linux", 0, 0,
|
||||
N_("Check if FILE is ARM Linux"), 0, 0},
|
||||
{"is-arm64-linux", 0, 0,
|
||||
N_("Check if FILE is ARM64 Linux"), 0, 0},
|
||||
{"is-ia64-linux", 0, 0,
|
||||
N_("Check if FILE is IA64 Linux"), 0, 0},
|
||||
{"is-mips-linux", 0, 0,
|
||||
@@ -82,6 +84,8 @@ static const struct grub_arg_option options[] = {
|
||||
N_("Check if FILE is x86_64 EFI file"), 0, 0},
|
||||
{"is-ia64-efi", 0, 0,
|
||||
N_("Check if FILE is IA64 EFI file"), 0, 0},
|
||||
{"is-arm64-efi", 0, 0,
|
||||
N_("Check if FILE is ARM64 EFI file"), 0, 0},
|
||||
{"is-arm-efi", 0, 0,
|
||||
N_("Check if FILE is ARM EFI file"), 0, 0},
|
||||
{"is-hibernated-hiberfil", 0, 0,
|
||||
@@ -105,6 +109,7 @@ enum
|
||||
IS_MULTIBOOT,
|
||||
IS_MULTIBOOT2,
|
||||
IS_ARM_LINUX,
|
||||
IS_ARM64_LINUX,
|
||||
IS_IA64_LINUX,
|
||||
IS_MIPS_LINUX,
|
||||
IS_MIPSEL_LINUX,
|
||||
@@ -121,6 +126,7 @@ enum
|
||||
IS_32_EFI,
|
||||
IS_64_EFI,
|
||||
IS_IA_EFI,
|
||||
IS_ARM64_EFI,
|
||||
IS_ARM_EFI,
|
||||
IS_HIBERNATED,
|
||||
IS_XNU64,
|
||||
@@ -377,14 +383,40 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
}
|
||||
case IS_ARM_LINUX:
|
||||
{
|
||||
grub_uint32_t sig;
|
||||
grub_uint32_t sig, sig_pi;
|
||||
if (grub_file_read (file, &sig_pi, 4) != 4)
|
||||
break;
|
||||
/* Raspberry pi. */
|
||||
if (sig_pi == grub_cpu_to_le32_compile_time (0xea000006))
|
||||
{
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (grub_file_seek (file, 0x24) == (grub_size_t) -1)
|
||||
break;
|
||||
if (grub_file_read (file, &sig, 4) != 4)
|
||||
break;
|
||||
if (sig != grub_cpu_to_le32_compile_time (0x016f2818))
|
||||
if (sig == grub_cpu_to_le32_compile_time (0x016f2818))
|
||||
{
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IS_ARM64_LINUX:
|
||||
{
|
||||
grub_uint32_t sig;
|
||||
|
||||
if (grub_file_seek (file, 0x38) == (grub_size_t) -1)
|
||||
break;
|
||||
ret = 1;
|
||||
if (grub_file_read (file, &sig, 4) != 4)
|
||||
break;
|
||||
if (sig == grub_cpu_to_le32_compile_time (0x644d5241))
|
||||
{
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IS_PAE_DOMU ... IS_DOM0:
|
||||
@@ -535,6 +567,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
case IS_32_EFI:
|
||||
case IS_64_EFI:
|
||||
case IS_IA_EFI:
|
||||
case IS_ARM64_EFI:
|
||||
case IS_ARM_EFI:
|
||||
{
|
||||
char signature[4];
|
||||
@@ -573,11 +606,15 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
&& coff_head.machine !=
|
||||
grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_IA64))
|
||||
break;
|
||||
if (type == IS_ARM64_EFI
|
||||
&& coff_head.machine !=
|
||||
grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_ARM64))
|
||||
break;
|
||||
if (type == IS_ARM_EFI
|
||||
&& coff_head.machine !=
|
||||
grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_ARMTHUMB_MIXED))
|
||||
break;
|
||||
if (type == IS_64_EFI || type == IS_64_EFI)
|
||||
if (type == IS_IA_EFI || type == IS_64_EFI || type == IS_ARM64_EFI)
|
||||
{
|
||||
struct grub_pe64_optional_header o64;
|
||||
if (grub_file_read (file, &o64, sizeof (o64)) != sizeof (o64))
|
||||
|
||||
@@ -133,7 +133,7 @@ show_help (grub_device_t dev)
|
||||
}
|
||||
}
|
||||
if (! found)
|
||||
grub_printf_ (N_("Sorry no parttool is available for %s\n"),
|
||||
grub_printf_ (N_("Sorry, no parttool is available for %s\n"),
|
||||
dev->disk->partition->partmap->name);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -333,6 +333,21 @@ name_devices (struct grub_efidisk_data *devices)
|
||||
if (! dp)
|
||||
continue;
|
||||
|
||||
/* Ghosts proudly presented by Apple. */
|
||||
if (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
|
||||
&& GRUB_EFI_DEVICE_PATH_SUBTYPE (dp)
|
||||
== GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE)
|
||||
{
|
||||
grub_efi_vendor_device_path_t *vendor = (grub_efi_vendor_device_path_t *) dp;
|
||||
const struct grub_efi_guid apple = GRUB_EFI_VENDOR_APPLE_GUID;
|
||||
|
||||
if (vendor->header.length == sizeof (*vendor)
|
||||
&& grub_memcmp (&vendor->vendor_guid, &apple,
|
||||
sizeof (vendor->vendor_guid)) == 0
|
||||
&& find_parent_device (devices, d))
|
||||
continue;
|
||||
}
|
||||
|
||||
m = d->block_io->media;
|
||||
if (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_ACPI_DEVICE_PATH_TYPE
|
||||
&& GRUB_EFI_DEVICE_PATH_SUBTYPE (dp)
|
||||
|
||||
@@ -1012,7 +1012,7 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
|
||||
usable for bootloaders (called generically
|
||||
"embedding zone") and this operation is
|
||||
called "embedding". */
|
||||
N_("your LDM embedding Partition is too small;"
|
||||
N_("your LDM Embedding Partition is too small;"
|
||||
" embedding won't be possible"));
|
||||
*nsectors = lv->size;
|
||||
if (*nsectors > max_nsectors)
|
||||
|
||||
@@ -1,314 +0,0 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/misc.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/archelp.h>
|
||||
|
||||
#include <grub/file.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/greffs.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
struct grub_greffs_data
|
||||
{
|
||||
grub_uint32_t dofs;
|
||||
};
|
||||
|
||||
static grub_err_t
|
||||
get_string (grub_disk_t disk,
|
||||
const struct grub_greffs_header *head,
|
||||
grub_uint32_t fn,
|
||||
char **buf, grub_size_t *size)
|
||||
{
|
||||
grub_uint32_t desc[2];
|
||||
grub_size_t read_size;
|
||||
|
||||
if (grub_disk_read (disk, 0,
|
||||
grub_cpu_to_le32 (head->string_ptrs_offset)
|
||||
+ fn * sizeof (desc[0]), sizeof (desc), &desc))
|
||||
return grub_errno;
|
||||
read_size = desc[1] - desc[0];
|
||||
if (*size < read_size + 1)
|
||||
{
|
||||
grub_free (*buf);
|
||||
*size = (read_size + 4) * 2;
|
||||
*buf = grub_malloc (*size);
|
||||
if (!*buf)
|
||||
{
|
||||
*size = 0;
|
||||
return grub_errno;
|
||||
}
|
||||
}
|
||||
if (grub_disk_read (disk, 0, desc[0], read_size, *buf))
|
||||
return grub_errno;
|
||||
(*buf)[read_size] = '\0';
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
find_file (grub_disk_t disk,
|
||||
struct grub_greffs_header *head,
|
||||
const char *name_in, grub_uint32_t *f, int exact)
|
||||
{
|
||||
grub_uint32_t num_files, cur_file = 0;
|
||||
int i;
|
||||
char *buf = NULL;
|
||||
grub_size_t buf_size = 0;
|
||||
grub_err_t err;
|
||||
|
||||
num_files = grub_le_to_cpu32 (head->nfiles);
|
||||
|
||||
for (i = 31; i >= 0; i--)
|
||||
{
|
||||
int cmp;
|
||||
if ((cur_file | (1 << i)) > num_files)
|
||||
continue;
|
||||
err = get_string (disk, head, (cur_file | (1 << i)) - 1, &buf, &buf_size);
|
||||
if (err)
|
||||
{
|
||||
grub_free (buf);
|
||||
return err;
|
||||
}
|
||||
cmp = grub_strcmp (buf, name_in);
|
||||
if (cmp <= 0)
|
||||
cur_file |= (1 << i);
|
||||
if (cmp == 0)
|
||||
{
|
||||
grub_free (buf);
|
||||
*f = cur_file - 1;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
grub_free (buf);
|
||||
if (!exact)
|
||||
{
|
||||
*f = cur_file;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"),
|
||||
name_in);
|
||||
}
|
||||
|
||||
static char *
|
||||
canonicalize (const char *name_in, int make_dir)
|
||||
{
|
||||
const char *iptr;
|
||||
char *out, *optr;
|
||||
out = grub_malloc (grub_strlen (name_in) + 2);
|
||||
if (!out)
|
||||
return NULL;
|
||||
for (iptr = name_in, optr = out; *iptr; )
|
||||
{
|
||||
while (*iptr == '/')
|
||||
iptr++;
|
||||
if (iptr[0] == '.' && (iptr[1] == '/' || iptr[1] == 0))
|
||||
{
|
||||
iptr += 2;
|
||||
continue;
|
||||
}
|
||||
if (iptr[0] == '.' && iptr[1] == '.' && (iptr[2] == '/' || iptr[2] == 0))
|
||||
{
|
||||
iptr += 3;
|
||||
if (optr == out)
|
||||
continue;
|
||||
for (optr -= 2; optr >= out && *optr != '/'; optr--);
|
||||
optr++;
|
||||
continue;
|
||||
}
|
||||
while (*iptr && *iptr != '/')
|
||||
*optr++ = *iptr++;
|
||||
if (*iptr)
|
||||
*optr++ = *iptr++;
|
||||
else if (make_dir && optr != out)
|
||||
*optr++ = '/';
|
||||
}
|
||||
*optr = 0;
|
||||
return out;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_greffs_dir (grub_device_t device, const char *path_in,
|
||||
grub_fs_dir_hook_t hook, void *hook_data)
|
||||
{
|
||||
grub_err_t err;
|
||||
grub_uint32_t cur_file, num_files;
|
||||
char *buf = 0;
|
||||
grub_size_t buf_size = 0;
|
||||
char *can;
|
||||
grub_size_t len;
|
||||
struct grub_greffs_header head;
|
||||
|
||||
if (grub_disk_read (device->disk, 0, 0, sizeof (head), &head))
|
||||
return grub_error (GRUB_ERR_BAD_FS, "not a greffs filesystem");
|
||||
|
||||
if (grub_memcmp (head.magic, GRUB_GREFFS_MAGIC, sizeof (head.magic)) != 0)
|
||||
return grub_error (GRUB_ERR_BAD_FS, "not a greffs filesystem");
|
||||
|
||||
can = canonicalize (path_in, 1);
|
||||
if (!can)
|
||||
return grub_errno;
|
||||
|
||||
if (can[0] == '\0')
|
||||
cur_file = 0;
|
||||
else
|
||||
{
|
||||
err = find_file (device->disk, &head, can, &cur_file, 0);
|
||||
if (err)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
num_files = grub_le_to_cpu32 (head.nfiles);
|
||||
|
||||
len = grub_strlen (can);
|
||||
|
||||
while (cur_file < num_files)
|
||||
{
|
||||
char *p, *n;
|
||||
struct grub_dirhook_info info;
|
||||
|
||||
err = get_string (device->disk, &head, cur_file, &buf, &buf_size);
|
||||
if (err)
|
||||
goto fail;
|
||||
if (grub_memcmp (can, buf, len) != 0)
|
||||
break;
|
||||
grub_memset (&info, 0, sizeof (info));
|
||||
|
||||
n = buf + len;
|
||||
while (*n == '/')
|
||||
n++;
|
||||
|
||||
p = grub_strchr (n, '/');
|
||||
if (p)
|
||||
*p = 0;
|
||||
info.dir = (p != NULL);
|
||||
if (hook (n, &info, hook_data))
|
||||
goto fail;
|
||||
if (!p)
|
||||
cur_file++;
|
||||
else
|
||||
{
|
||||
*p = '/' + 1;
|
||||
p[1] = '\0';
|
||||
err = find_file (device->disk, &head, buf, &cur_file, 0);
|
||||
if (err)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
fail:
|
||||
grub_free (buf);
|
||||
grub_free (can);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
static grub_err_t
|
||||
grub_greffs_open (grub_file_t file, const char *name_in)
|
||||
{
|
||||
struct grub_greffs_header head;
|
||||
struct grub_greffs_data *data;
|
||||
struct grub_greffs_inode inode;
|
||||
grub_err_t err;
|
||||
grub_uint32_t cur_file;
|
||||
char *can;
|
||||
|
||||
if (grub_disk_read (file->device->disk, 0, 0, sizeof (head), &head))
|
||||
return grub_error (GRUB_ERR_BAD_FS, "not a greffs filesystem");
|
||||
|
||||
if (grub_memcmp (head.magic, GRUB_GREFFS_MAGIC, sizeof (head.magic)) != 0)
|
||||
return grub_error (GRUB_ERR_BAD_FS, "not a greffs filesystem");
|
||||
|
||||
can = canonicalize (name_in, 0);
|
||||
if (!can)
|
||||
return grub_errno;
|
||||
|
||||
err = find_file (file->device->disk, &head, can, &cur_file, 1);
|
||||
grub_free (can);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
data = grub_malloc (sizeof (*data));
|
||||
if (!data)
|
||||
return grub_errno;
|
||||
if (grub_disk_read (file->device->disk,
|
||||
0, grub_le_to_cpu32 (head.inodes_offset)
|
||||
+ sizeof (inode) * cur_file, sizeof (inode), &inode))
|
||||
return grub_error (GRUB_ERR_BAD_FS, "not a greffs filesystem");
|
||||
|
||||
data->dofs = grub_cpu_to_le32 (inode.start);
|
||||
file->size = grub_cpu_to_le32 (inode.size);
|
||||
|
||||
file->data = data;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_ssize_t
|
||||
grub_greffs_read (grub_file_t file, char *buf, grub_size_t len)
|
||||
{
|
||||
struct grub_greffs_data *data;
|
||||
grub_ssize_t ret;
|
||||
|
||||
data = file->data;
|
||||
|
||||
file->device->disk->read_hook = file->read_hook;
|
||||
file->device->disk->read_hook_data = file->read_hook_data;
|
||||
ret = (grub_disk_read (file->device->disk, 0, data->dofs + file->offset,
|
||||
len, buf)) ? -1 : (grub_ssize_t) len;
|
||||
file->device->disk->read_hook = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_greffs_close (grub_file_t file)
|
||||
{
|
||||
struct grub_greffs_data *data;
|
||||
|
||||
data = file->data;
|
||||
grub_free (data);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static struct grub_fs grub_greffs_fs = {
|
||||
.name = "greffs",
|
||||
.dir = grub_greffs_dir,
|
||||
.open = grub_greffs_open,
|
||||
.read = grub_greffs_read,
|
||||
.close = grub_greffs_close,
|
||||
#ifdef GRUB_UTIL
|
||||
.reserved_first_sector = 0,
|
||||
.blocklist_install = 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT (greffs)
|
||||
{
|
||||
grub_fs_register (&grub_greffs_fs);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (greffs)
|
||||
{
|
||||
grub_fs_unregister (&grub_greffs_fs);
|
||||
}
|
||||
+12
-32
@@ -37,20 +37,16 @@
|
||||
* Simple cache maintenance functions
|
||||
*/
|
||||
|
||||
dlinesz_addr:
|
||||
.long EXT_C(grub_arch_cache_dlinesz)
|
||||
ilinesz_addr:
|
||||
.long EXT_C(grub_arch_cache_ilinesz)
|
||||
|
||||
@ r0 - *beg (inclusive)
|
||||
@ r1 - *end (exclusive)
|
||||
clean_dcache_range:
|
||||
@void grub_arm_clean_dcache_range (grub_addr_t start, grub_addr_t end, grub_addr_t dlinesz)
|
||||
#ifdef ARMV6
|
||||
FUNCTION(grub_arm_clean_dcache_range_armv6)
|
||||
#else
|
||||
FUNCTION(grub_arm_clean_dcache_range_armv7)
|
||||
#endif
|
||||
DSB
|
||||
@ Clean data cache for range to point-of-unification
|
||||
ldr r2, dlinesz_addr
|
||||
ldr r2, [r2]
|
||||
sub r3, r2, #1 @ align "beg" to start of line
|
||||
mvn r3, r3
|
||||
and r0, r0, r3
|
||||
1: cmp r0, r1
|
||||
bge 2f
|
||||
#ifdef ARMV6
|
||||
@@ -65,13 +61,12 @@ clean_dcache_range:
|
||||
|
||||
@ r0 - *beg (inclusive)
|
||||
@ r1 - *end (exclusive)
|
||||
invalidate_icache_range:
|
||||
#ifdef ARMV6
|
||||
FUNCTION(grub_arm_invalidate_icache_range_armv6)
|
||||
#else
|
||||
FUNCTION(grub_arm_invalidate_icache_range_armv7)
|
||||
#endif
|
||||
@ Invalidate instruction cache for range to point-of-unification
|
||||
ldr r2, ilinesz_addr
|
||||
ldr r2, [r2]
|
||||
sub r3, r2, #1 @ align "beg" to start of line
|
||||
mvn r3, r3
|
||||
and r0, r0, r3
|
||||
1: cmp r0, r1
|
||||
bge 2f
|
||||
mcr p15, 0, r0, c7, c5, 1 @ ICIMVAU
|
||||
@@ -83,21 +78,6 @@ invalidate_icache_range:
|
||||
ISB
|
||||
bx lr
|
||||
|
||||
@void grub_arch_sync_caches (void *address, grub_size_t len)
|
||||
#ifdef ARMV6
|
||||
FUNCTION(grub_arch_sync_caches_armv6)
|
||||
#else
|
||||
FUNCTION(grub_arch_sync_caches_armv7)
|
||||
#endif
|
||||
DSB
|
||||
add r1, r0, r1
|
||||
push {r0-r2, lr}
|
||||
bl clean_dcache_range
|
||||
pop {r0, r1}
|
||||
bl invalidate_icache_range
|
||||
pop {r2, lr}
|
||||
bx lr
|
||||
|
||||
#ifdef ARMV6
|
||||
FUNCTION(grub_arm_disable_caches_mmu_armv6)
|
||||
#else
|
||||
|
||||
+152
-9
@@ -1,6 +1,11 @@
|
||||
#include <grub/dl.h>
|
||||
#include <grub/cache.h>
|
||||
#include <grub/arm/system.h>
|
||||
#ifdef GRUB_MACHINE_UBOOT
|
||||
#include <grub/uboot/uboot.h>
|
||||
#include <grub/uboot/api_public.h>
|
||||
#include <grub/mm.h>
|
||||
#endif
|
||||
|
||||
/* This is only about cache architecture. It doesn't imply
|
||||
the CPU architecture. */
|
||||
@@ -13,12 +18,21 @@ static enum
|
||||
ARCH_ARMV7
|
||||
} type = ARCH_UNKNOWN;
|
||||
|
||||
grub_uint32_t grub_arch_cache_dlinesz;
|
||||
grub_uint32_t grub_arch_cache_ilinesz;
|
||||
static int is_v6_mmu;
|
||||
|
||||
static grub_uint32_t grub_arch_cache_dlinesz;
|
||||
static grub_uint32_t grub_arch_cache_ilinesz;
|
||||
static grub_uint32_t grub_arch_cache_max_linesz;
|
||||
|
||||
/* Prototypes for asm functions. */
|
||||
void grub_arch_sync_caches_armv6 (void *address, grub_size_t len);
|
||||
void grub_arch_sync_caches_armv7 (void *address, grub_size_t len);
|
||||
void grub_arm_clean_dcache_range_armv6 (grub_addr_t start, grub_addr_t end,
|
||||
grub_addr_t dlinesz);
|
||||
void grub_arm_clean_dcache_range_armv7 (grub_addr_t start, grub_addr_t end,
|
||||
grub_addr_t dlinesz);
|
||||
void grub_arm_invalidate_icache_range_armv6 (grub_addr_t start, grub_addr_t end,
|
||||
grub_addr_t dlinesz);
|
||||
void grub_arm_invalidate_icache_range_armv7 (grub_addr_t start, grub_addr_t end,
|
||||
grub_addr_t dlinesz);
|
||||
void grub_arm_disable_caches_mmu_armv6 (void);
|
||||
void grub_arm_disable_caches_mmu_armv7 (void);
|
||||
grub_uint32_t grub_arm_main_id (void);
|
||||
@@ -38,8 +52,11 @@ probe_caches (void)
|
||||
case 0x4:
|
||||
case 0x5:
|
||||
case 0x6:
|
||||
is_v6_mmu = 0;
|
||||
break;
|
||||
case 0x7:
|
||||
case 0xf:
|
||||
is_v6_mmu = 1;
|
||||
break;
|
||||
default:
|
||||
grub_fatal ("Unsupported ARM ID 0x%x", main_id);
|
||||
@@ -82,20 +99,148 @@ probe_caches (void)
|
||||
default:
|
||||
grub_fatal ("Unsupported cache type 0x%x", cache_type);
|
||||
}
|
||||
if (grub_arch_cache_dlinesz > grub_arch_cache_ilinesz)
|
||||
grub_arch_cache_max_linesz = grub_arch_cache_dlinesz;
|
||||
else
|
||||
grub_arch_cache_max_linesz = grub_arch_cache_ilinesz;
|
||||
}
|
||||
|
||||
#ifdef GRUB_MACHINE_UBOOT
|
||||
|
||||
static void subdivide (grub_uint32_t *table, grub_uint32_t *subtable,
|
||||
grub_uint32_t addr)
|
||||
{
|
||||
grub_uint32_t j;
|
||||
addr = addr >> 20 << 20;
|
||||
table[addr >> 20] = (grub_addr_t) subtable | 1;
|
||||
for (j = 0; j < 256; j++)
|
||||
subtable[j] = addr | (j << 12)
|
||||
| (3 << 4) | (3 << 6) | (3 << 8) | (3 << 10)
|
||||
| (0 << 3) | (1 << 2) | 2;
|
||||
}
|
||||
|
||||
void
|
||||
grub_arm_enable_caches_mmu (void)
|
||||
{
|
||||
grub_uint32_t *table;
|
||||
grub_uint32_t i;
|
||||
grub_uint32_t border_crossing = 0;
|
||||
grub_uint32_t *subtable;
|
||||
struct sys_info *si = grub_uboot_get_sys_info ();
|
||||
|
||||
if (!si || (si->mr_no == 0))
|
||||
{
|
||||
grub_printf ("couldn't get memory map, not enabling caches");
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == ARCH_UNKNOWN)
|
||||
probe_caches ();
|
||||
|
||||
for (i = 0; (signed) i < si->mr_no; i++)
|
||||
{
|
||||
if (si->mr[i].start & ((1 << 20) - 1))
|
||||
border_crossing++;
|
||||
if ((si->mr[i].start + si->mr[i].size) & ((1 << 20) - 1))
|
||||
border_crossing++;
|
||||
}
|
||||
|
||||
grub_printf ("%d crossers\n", border_crossing);
|
||||
|
||||
table = grub_memalign (1 << 14, (1 << 14) + (border_crossing << 10));
|
||||
if (!table)
|
||||
{
|
||||
grub_printf ("couldn't allocate place for MMU table, not enabling caches");
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
subtable = table + (1 << 12);
|
||||
/* Map all unknown as device. */
|
||||
for (i = 0; i < (1 << 12); i++)
|
||||
table[i] = (i << 20) | (3 << 10) | (0 << 3) | (1 << 2) | 2;
|
||||
/*
|
||||
Device: TEX= 0, C=0, B=1
|
||||
normal: TEX= 0, C=1, B=1
|
||||
AP = 3
|
||||
IMP = 0
|
||||
Domain = 0
|
||||
*/
|
||||
|
||||
for (i = 0; (signed) i < si->mr_no; i++)
|
||||
{
|
||||
if (si->mr[i].start & ((1 << 20) - 1))
|
||||
{
|
||||
subdivide (table, subtable, si->mr[i].start);
|
||||
subtable += (1 << 8);
|
||||
}
|
||||
if ((si->mr[i].start + si->mr[i].size) & ((1 << 20) - 1))
|
||||
{
|
||||
subdivide (table, subtable, si->mr[i].start + si->mr[i].size);
|
||||
subtable += (1 << 8);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; (signed) i < si->mr_no; i++)
|
||||
if ((si->mr[i].flags & MR_ATTR_MASK) == MR_ATTR_DRAM
|
||||
|| (si->mr[i].flags & MR_ATTR_MASK) == MR_ATTR_SRAM
|
||||
|| (si->mr[i].flags & MR_ATTR_MASK) == MR_ATTR_FLASH)
|
||||
{
|
||||
grub_uint32_t cur, end;
|
||||
cur = si->mr[i].start;
|
||||
end = si->mr[i].start + si->mr[i].size;
|
||||
while (cur < end)
|
||||
{
|
||||
grub_uint32_t *st;
|
||||
if ((table[cur >> 20] & 3) == 2)
|
||||
{
|
||||
cur = cur >> 20 << 20;
|
||||
table[cur >> 20] = cur | (3 << 10) | (1 << 3) | (1 << 2) | 2;
|
||||
cur += (1 << 20);
|
||||
continue;
|
||||
}
|
||||
cur = cur >> 12 << 12;
|
||||
st = (grub_uint32_t *) (table[cur >> 20] & ~0x3ff);
|
||||
st[(cur >> 12) & 0xff] = cur | (3 << 4) | (3 << 6)
|
||||
| (3 << 8) | (3 << 10)
|
||||
| (1 << 3) | (1 << 2) | 2;
|
||||
cur += (1 << 12);
|
||||
}
|
||||
}
|
||||
|
||||
grub_printf ("MMU tables generated\n");
|
||||
if (is_v6_mmu)
|
||||
grub_arm_clear_mmu_v6 ();
|
||||
|
||||
grub_printf ("enabling MMU\n");
|
||||
grub_arm_enable_mmu (table);
|
||||
grub_printf ("MMU enabled\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
grub_arch_sync_caches (void *address, grub_size_t len)
|
||||
{
|
||||
grub_addr_t start = (grub_addr_t) address;
|
||||
grub_addr_t end = start + len;
|
||||
|
||||
if (type == ARCH_UNKNOWN)
|
||||
probe_caches ();
|
||||
start = ALIGN_DOWN (start, grub_arch_cache_max_linesz);
|
||||
end = ALIGN_UP (end, grub_arch_cache_max_linesz);
|
||||
switch (type)
|
||||
{
|
||||
case ARCH_ARMV6:
|
||||
grub_arch_sync_caches_armv6 (address, len);
|
||||
grub_arm_clean_dcache_range_armv6 (start, end, grub_arch_cache_dlinesz);
|
||||
grub_arm_invalidate_icache_range_armv6 (start, end,
|
||||
grub_arch_cache_ilinesz);
|
||||
break;
|
||||
case ARCH_ARMV7:
|
||||
grub_arch_sync_caches_armv7 (address, len);
|
||||
grub_arm_clean_dcache_range_armv7 (start, end, grub_arch_cache_dlinesz);
|
||||
grub_arm_invalidate_icache_range_armv7 (start, end,
|
||||
grub_arch_cache_ilinesz);
|
||||
break;
|
||||
/* Nothing to do. */
|
||||
case ARCH_ARMV5_WRITE_THROUGH:
|
||||
@@ -114,15 +259,13 @@ grub_arm_disable_caches_mmu (void)
|
||||
probe_caches ();
|
||||
switch (type)
|
||||
{
|
||||
case ARCH_ARMV5_WRITE_THROUGH:
|
||||
case ARCH_ARMV6_UNIFIED:
|
||||
case ARCH_ARMV6:
|
||||
grub_arm_disable_caches_mmu_armv6 ();
|
||||
break;
|
||||
case ARCH_ARMV7:
|
||||
grub_arm_disable_caches_mmu_armv7 ();
|
||||
break;
|
||||
/* Nothing to do. */
|
||||
case ARCH_ARMV5_WRITE_THROUGH:
|
||||
break;
|
||||
/* Pacify GCC. */
|
||||
case ARCH_UNKNOWN:
|
||||
|
||||
@@ -41,4 +41,33 @@ FUNCTION(grub_arm_main_id)
|
||||
|
||||
FUNCTION(grub_arm_cache_type)
|
||||
mrc p15, 0, r0, c0, c0, 1
|
||||
bx lr
|
||||
bx lr
|
||||
|
||||
FUNCTION(grub_arm_clear_mmu_v6)
|
||||
mov r0, #0
|
||||
mcr p15, 0, r0, c2, c0, 2
|
||||
bx lr
|
||||
|
||||
FUNCTION(grub_arm_enable_mmu)
|
||||
mcr p15, 0, r0, c2, c0, 0
|
||||
|
||||
mvn r0, #0
|
||||
mcr p15, 0, r0, c3, c0, 0
|
||||
|
||||
mrc p15, 0, r0, c1, c0, 0
|
||||
bic r0, r0, #(1 << 23)
|
||||
mcr p15, 0, r0, c1, c0, 0
|
||||
|
||||
mrc p15, 0, r0, c1, c0, 0
|
||||
orr r0, r0, #(1 << 0)
|
||||
mcr p15, 0, r0, c1, c0, 0
|
||||
|
||||
mrc p15, 0, r0, c1, c0, 0
|
||||
orr r0, r0, #(1 << 2)
|
||||
mcr p15, 0, r0, c1, c0, 0
|
||||
|
||||
mrc p15, 0, r0, c1, c0, 0
|
||||
orr r0, r0, #(1 << 12)
|
||||
mcr p15, 0, r0, c1, c0, 0
|
||||
|
||||
bx lr
|
||||
@@ -198,6 +198,5 @@ grub_efi_prepare_platform (void)
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
grub_arm_disable_caches_mmu();
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
+177
-178
@@ -385,6 +385,34 @@ grub_efi_get_device_path (grub_efi_handle_t handle)
|
||||
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||
}
|
||||
|
||||
static void
|
||||
dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor)
|
||||
{
|
||||
grub_uint32_t vendor_data_len = vendor->header.length - sizeof (*vendor);
|
||||
grub_printf ("/%sVendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)[%x: ",
|
||||
type,
|
||||
(unsigned) vendor->vendor_guid.data1,
|
||||
(unsigned) vendor->vendor_guid.data2,
|
||||
(unsigned) vendor->vendor_guid.data3,
|
||||
(unsigned) vendor->vendor_guid.data4[0],
|
||||
(unsigned) vendor->vendor_guid.data4[1],
|
||||
(unsigned) vendor->vendor_guid.data4[2],
|
||||
(unsigned) vendor->vendor_guid.data4[3],
|
||||
(unsigned) vendor->vendor_guid.data4[4],
|
||||
(unsigned) vendor->vendor_guid.data4[5],
|
||||
(unsigned) vendor->vendor_guid.data4[6],
|
||||
(unsigned) vendor->vendor_guid.data4[7],
|
||||
vendor_data_len);
|
||||
if (vendor->header.length > sizeof (*vendor))
|
||||
{
|
||||
grub_uint32_t i;
|
||||
for (i = 0; i < vendor_data_len; i++)
|
||||
grub_printf ("%02x ", vendor->vendor_defined_data[i]);
|
||||
}
|
||||
grub_printf ("]");
|
||||
}
|
||||
|
||||
|
||||
/* Print the chain of Device Path nodes. This is mainly for debugging. */
|
||||
void
|
||||
grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||
@@ -419,53 +447,40 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||
{
|
||||
case GRUB_EFI_PCI_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_pci_device_path_t pci;
|
||||
grub_memcpy (&pci, dp, len);
|
||||
grub_efi_pci_device_path_t *pci
|
||||
= (grub_efi_pci_device_path_t *) dp;
|
||||
grub_printf ("/PCI(%x,%x)",
|
||||
(unsigned) pci.function, (unsigned) pci.device);
|
||||
(unsigned) pci->function, (unsigned) pci->device);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_PCCARD_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_pccard_device_path_t pccard;
|
||||
grub_memcpy (&pccard, dp, len);
|
||||
grub_efi_pccard_device_path_t *pccard
|
||||
= (grub_efi_pccard_device_path_t *) dp;
|
||||
grub_printf ("/PCCARD(%x)",
|
||||
(unsigned) pccard.function);
|
||||
(unsigned) pccard->function);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_memory_mapped_device_path_t mmapped;
|
||||
grub_memcpy (&mmapped, dp, len);
|
||||
grub_efi_memory_mapped_device_path_t *mmapped
|
||||
= (grub_efi_memory_mapped_device_path_t *) dp;
|
||||
grub_printf ("/MMap(%x,%llx,%llx)",
|
||||
(unsigned) mmapped.memory_type,
|
||||
(unsigned long long) mmapped.start_address,
|
||||
(unsigned long long) mmapped.end_address);
|
||||
(unsigned) mmapped->memory_type,
|
||||
(unsigned long long) mmapped->start_address,
|
||||
(unsigned long long) mmapped->end_address);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_vendor_device_path_t *vendor = (grub_efi_vendor_device_path_t *) dp;
|
||||
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
|
||||
(unsigned) vendor->vendor_guid.data1,
|
||||
(unsigned) vendor->vendor_guid.data2,
|
||||
(unsigned) vendor->vendor_guid.data3,
|
||||
(unsigned) vendor->vendor_guid.data4[0],
|
||||
(unsigned) vendor->vendor_guid.data4[1],
|
||||
(unsigned) vendor->vendor_guid.data4[2],
|
||||
(unsigned) vendor->vendor_guid.data4[3],
|
||||
(unsigned) vendor->vendor_guid.data4[4],
|
||||
(unsigned) vendor->vendor_guid.data4[5],
|
||||
(unsigned) vendor->vendor_guid.data4[6],
|
||||
(unsigned) vendor->vendor_guid.data4[7]);
|
||||
}
|
||||
dump_vendor_path ("Hardware",
|
||||
(grub_efi_vendor_device_path_t *) dp);
|
||||
break;
|
||||
case GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_controller_device_path_t controller;
|
||||
grub_memcpy (&controller, dp, len);
|
||||
grub_efi_controller_device_path_t *controller
|
||||
= (grub_efi_controller_device_path_t *) dp;
|
||||
grub_printf ("/Ctrl(%x)",
|
||||
(unsigned) controller.controller_number);
|
||||
(unsigned) controller->controller_number);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -479,31 +494,31 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||
{
|
||||
case GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_acpi_device_path_t acpi;
|
||||
grub_memcpy (&acpi, dp, len);
|
||||
grub_efi_acpi_device_path_t *acpi
|
||||
= (grub_efi_acpi_device_path_t *) dp;
|
||||
grub_printf ("/ACPI(%x,%x)",
|
||||
(unsigned) acpi.hid,
|
||||
(unsigned) acpi.uid);
|
||||
(unsigned) acpi->hid,
|
||||
(unsigned) acpi->uid);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_expanded_acpi_device_path_t eacpi;
|
||||
grub_memcpy (&eacpi, dp, sizeof (eacpi));
|
||||
grub_efi_expanded_acpi_device_path_t *eacpi
|
||||
= (grub_efi_expanded_acpi_device_path_t *) dp;
|
||||
grub_printf ("/ACPI(");
|
||||
|
||||
if (GRUB_EFI_EXPANDED_ACPI_HIDSTR (dp)[0] == '\0')
|
||||
grub_printf ("%x,", (unsigned) eacpi.hid);
|
||||
grub_printf ("%x,", (unsigned) eacpi->hid);
|
||||
else
|
||||
grub_printf ("%s,", GRUB_EFI_EXPANDED_ACPI_HIDSTR (dp));
|
||||
|
||||
if (GRUB_EFI_EXPANDED_ACPI_UIDSTR (dp)[0] == '\0')
|
||||
grub_printf ("%x,", (unsigned) eacpi.uid);
|
||||
grub_printf ("%x,", (unsigned) eacpi->uid);
|
||||
else
|
||||
grub_printf ("%s,", GRUB_EFI_EXPANDED_ACPI_UIDSTR (dp));
|
||||
|
||||
if (GRUB_EFI_EXPANDED_ACPI_CIDSTR (dp)[0] == '\0')
|
||||
grub_printf ("%x)", (unsigned) eacpi.cid);
|
||||
grub_printf ("%x)", (unsigned) eacpi->cid);
|
||||
else
|
||||
grub_printf ("%s)", GRUB_EFI_EXPANDED_ACPI_CIDSTR (dp));
|
||||
}
|
||||
@@ -519,167 +534,165 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||
{
|
||||
case GRUB_EFI_ATAPI_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_atapi_device_path_t atapi;
|
||||
grub_memcpy (&atapi, dp, len);
|
||||
grub_efi_atapi_device_path_t *atapi
|
||||
= (grub_efi_atapi_device_path_t *) dp;
|
||||
grub_printf ("/ATAPI(%x,%x,%x)",
|
||||
(unsigned) atapi.primary_secondary,
|
||||
(unsigned) atapi.slave_master,
|
||||
(unsigned) atapi.lun);
|
||||
(unsigned) atapi->primary_secondary,
|
||||
(unsigned) atapi->slave_master,
|
||||
(unsigned) atapi->lun);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_SCSI_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_scsi_device_path_t scsi;
|
||||
grub_memcpy (&scsi, dp, len);
|
||||
grub_efi_scsi_device_path_t *scsi
|
||||
= (grub_efi_scsi_device_path_t *) dp;
|
||||
grub_printf ("/SCSI(%x,%x)",
|
||||
(unsigned) scsi.pun,
|
||||
(unsigned) scsi.lun);
|
||||
(unsigned) scsi->pun,
|
||||
(unsigned) scsi->lun);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_FIBRE_CHANNEL_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_fibre_channel_device_path_t fc;
|
||||
grub_memcpy (&fc, dp, len);
|
||||
grub_efi_fibre_channel_device_path_t *fc
|
||||
= (grub_efi_fibre_channel_device_path_t *) dp;
|
||||
grub_printf ("/FibreChannel(%llx,%llx)",
|
||||
(unsigned long long) fc.wwn,
|
||||
(unsigned long long) fc.lun);
|
||||
(unsigned long long) fc->wwn,
|
||||
(unsigned long long) fc->lun);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_1394_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_1394_device_path_t firewire;
|
||||
grub_memcpy (&firewire, dp, len);
|
||||
grub_printf ("/1394(%llx)", (unsigned long long) firewire.guid);
|
||||
grub_efi_1394_device_path_t *firewire
|
||||
= (grub_efi_1394_device_path_t *) dp;
|
||||
grub_printf ("/1394(%llx)",
|
||||
(unsigned long long) firewire->guid);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_USB_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_usb_device_path_t usb;
|
||||
grub_memcpy (&usb, dp, len);
|
||||
grub_efi_usb_device_path_t *usb
|
||||
= (grub_efi_usb_device_path_t *) dp;
|
||||
grub_printf ("/USB(%x,%x)",
|
||||
(unsigned) usb.parent_port_number,
|
||||
(unsigned) usb.usb_interface);
|
||||
(unsigned) usb->parent_port_number,
|
||||
(unsigned) usb->usb_interface);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_USB_CLASS_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_usb_class_device_path_t usb_class;
|
||||
grub_memcpy (&usb_class, dp, len);
|
||||
grub_efi_usb_class_device_path_t *usb_class
|
||||
= (grub_efi_usb_class_device_path_t *) dp;
|
||||
grub_printf ("/USBClass(%x,%x,%x,%x,%x)",
|
||||
(unsigned) usb_class.vendor_id,
|
||||
(unsigned) usb_class.product_id,
|
||||
(unsigned) usb_class.device_class,
|
||||
(unsigned) usb_class.device_subclass,
|
||||
(unsigned) usb_class.device_protocol);
|
||||
(unsigned) usb_class->vendor_id,
|
||||
(unsigned) usb_class->product_id,
|
||||
(unsigned) usb_class->device_class,
|
||||
(unsigned) usb_class->device_subclass,
|
||||
(unsigned) usb_class->device_protocol);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_I2O_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_i2o_device_path_t i2o;
|
||||
grub_memcpy (&i2o, dp, len);
|
||||
grub_printf ("/I2O(%x)", (unsigned) i2o.tid);
|
||||
grub_efi_i2o_device_path_t *i2o
|
||||
= (grub_efi_i2o_device_path_t *) dp;
|
||||
grub_printf ("/I2O(%x)", (unsigned) i2o->tid);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_mac_address_device_path_t mac;
|
||||
grub_memcpy (&mac, dp, len);
|
||||
grub_efi_mac_address_device_path_t *mac
|
||||
= (grub_efi_mac_address_device_path_t *) dp;
|
||||
grub_printf ("/MacAddr(%02x:%02x:%02x:%02x:%02x:%02x,%x)",
|
||||
(unsigned) mac.mac_address[0],
|
||||
(unsigned) mac.mac_address[1],
|
||||
(unsigned) mac.mac_address[2],
|
||||
(unsigned) mac.mac_address[3],
|
||||
(unsigned) mac.mac_address[4],
|
||||
(unsigned) mac.mac_address[5],
|
||||
(unsigned) mac.if_type);
|
||||
(unsigned) mac->mac_address[0],
|
||||
(unsigned) mac->mac_address[1],
|
||||
(unsigned) mac->mac_address[2],
|
||||
(unsigned) mac->mac_address[3],
|
||||
(unsigned) mac->mac_address[4],
|
||||
(unsigned) mac->mac_address[5],
|
||||
(unsigned) mac->if_type);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_ipv4_device_path_t ipv4;
|
||||
grub_memcpy (&ipv4, dp, len);
|
||||
grub_efi_ipv4_device_path_t *ipv4
|
||||
= (grub_efi_ipv4_device_path_t *) dp;
|
||||
grub_printf ("/IPv4(%u.%u.%u.%u,%u.%u.%u.%u,%u,%u,%x,%x)",
|
||||
(unsigned) ipv4.local_ip_address[0],
|
||||
(unsigned) ipv4.local_ip_address[1],
|
||||
(unsigned) ipv4.local_ip_address[2],
|
||||
(unsigned) ipv4.local_ip_address[3],
|
||||
(unsigned) ipv4.remote_ip_address[0],
|
||||
(unsigned) ipv4.remote_ip_address[1],
|
||||
(unsigned) ipv4.remote_ip_address[2],
|
||||
(unsigned) ipv4.remote_ip_address[3],
|
||||
(unsigned) ipv4.local_port,
|
||||
(unsigned) ipv4.remote_port,
|
||||
(unsigned) ipv4.protocol,
|
||||
(unsigned) ipv4.static_ip_address);
|
||||
(unsigned) ipv4->local_ip_address[0],
|
||||
(unsigned) ipv4->local_ip_address[1],
|
||||
(unsigned) ipv4->local_ip_address[2],
|
||||
(unsigned) ipv4->local_ip_address[3],
|
||||
(unsigned) ipv4->remote_ip_address[0],
|
||||
(unsigned) ipv4->remote_ip_address[1],
|
||||
(unsigned) ipv4->remote_ip_address[2],
|
||||
(unsigned) ipv4->remote_ip_address[3],
|
||||
(unsigned) ipv4->local_port,
|
||||
(unsigned) ipv4->remote_port,
|
||||
(unsigned) ipv4->protocol,
|
||||
(unsigned) ipv4->static_ip_address);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_ipv6_device_path_t ipv6;
|
||||
grub_memcpy (&ipv6, dp, len);
|
||||
grub_efi_ipv6_device_path_t *ipv6
|
||||
= (grub_efi_ipv6_device_path_t *) dp;
|
||||
grub_printf ("/IPv6(%x:%x:%x:%x:%x:%x:%x:%x,%x:%x:%x:%x:%x:%x:%x:%x,%u,%u,%x,%x)",
|
||||
(unsigned) ipv6.local_ip_address[0],
|
||||
(unsigned) ipv6.local_ip_address[1],
|
||||
(unsigned) ipv6.local_ip_address[2],
|
||||
(unsigned) ipv6.local_ip_address[3],
|
||||
(unsigned) ipv6.local_ip_address[4],
|
||||
(unsigned) ipv6.local_ip_address[5],
|
||||
(unsigned) ipv6.local_ip_address[6],
|
||||
(unsigned) ipv6.local_ip_address[7],
|
||||
(unsigned) ipv6.remote_ip_address[0],
|
||||
(unsigned) ipv6.remote_ip_address[1],
|
||||
(unsigned) ipv6.remote_ip_address[2],
|
||||
(unsigned) ipv6.remote_ip_address[3],
|
||||
(unsigned) ipv6.remote_ip_address[4],
|
||||
(unsigned) ipv6.remote_ip_address[5],
|
||||
(unsigned) ipv6.remote_ip_address[6],
|
||||
(unsigned) ipv6.remote_ip_address[7],
|
||||
(unsigned) ipv6.local_port,
|
||||
(unsigned) ipv6.remote_port,
|
||||
(unsigned) ipv6.protocol,
|
||||
(unsigned) ipv6.static_ip_address);
|
||||
(unsigned) ipv6->local_ip_address[0],
|
||||
(unsigned) ipv6->local_ip_address[1],
|
||||
(unsigned) ipv6->local_ip_address[2],
|
||||
(unsigned) ipv6->local_ip_address[3],
|
||||
(unsigned) ipv6->local_ip_address[4],
|
||||
(unsigned) ipv6->local_ip_address[5],
|
||||
(unsigned) ipv6->local_ip_address[6],
|
||||
(unsigned) ipv6->local_ip_address[7],
|
||||
(unsigned) ipv6->remote_ip_address[0],
|
||||
(unsigned) ipv6->remote_ip_address[1],
|
||||
(unsigned) ipv6->remote_ip_address[2],
|
||||
(unsigned) ipv6->remote_ip_address[3],
|
||||
(unsigned) ipv6->remote_ip_address[4],
|
||||
(unsigned) ipv6->remote_ip_address[5],
|
||||
(unsigned) ipv6->remote_ip_address[6],
|
||||
(unsigned) ipv6->remote_ip_address[7],
|
||||
(unsigned) ipv6->local_port,
|
||||
(unsigned) ipv6->remote_port,
|
||||
(unsigned) ipv6->protocol,
|
||||
(unsigned) ipv6->static_ip_address);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_infiniband_device_path_t ib;
|
||||
grub_memcpy (&ib, dp, len);
|
||||
grub_efi_infiniband_device_path_t *ib
|
||||
= (grub_efi_infiniband_device_path_t *) dp;
|
||||
grub_printf ("/InfiniBand(%x,%llx,%llx,%llx)",
|
||||
(unsigned) ib.port_gid[0], /* XXX */
|
||||
(unsigned long long) ib.remote_id,
|
||||
(unsigned long long) ib.target_port_id,
|
||||
(unsigned long long) ib.device_id);
|
||||
(unsigned) ib->port_gid[0], /* XXX */
|
||||
(unsigned long long) ib->remote_id,
|
||||
(unsigned long long) ib->target_port_id,
|
||||
(unsigned long long) ib->device_id);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_UART_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_uart_device_path_t uart;
|
||||
grub_memcpy (&uart, dp, len);
|
||||
grub_efi_uart_device_path_t *uart
|
||||
= (grub_efi_uart_device_path_t *) dp;
|
||||
grub_printf ("/UART(%llu,%u,%x,%x)",
|
||||
(unsigned long long) uart.baud_rate,
|
||||
uart.data_bits,
|
||||
uart.parity,
|
||||
uart.stop_bits);
|
||||
(unsigned long long) uart->baud_rate,
|
||||
uart->data_bits,
|
||||
uart->parity,
|
||||
uart->stop_bits);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE:
|
||||
case GRUB_EFI_SATA_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_vendor_messaging_device_path_t *vendor
|
||||
= (grub_efi_vendor_messaging_device_path_t *) dp;
|
||||
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
|
||||
(unsigned) vendor->vendor_guid.data1,
|
||||
(unsigned) vendor->vendor_guid.data2,
|
||||
(unsigned) vendor->vendor_guid.data3,
|
||||
(unsigned) vendor->vendor_guid.data4[0],
|
||||
(unsigned) vendor->vendor_guid.data4[1],
|
||||
(unsigned) vendor->vendor_guid.data4[2],
|
||||
(unsigned) vendor->vendor_guid.data4[3],
|
||||
(unsigned) vendor->vendor_guid.data4[4],
|
||||
(unsigned) vendor->vendor_guid.data4[5],
|
||||
(unsigned) vendor->vendor_guid.data4[6],
|
||||
(unsigned) vendor->vendor_guid.data4[7]);
|
||||
grub_efi_sata_device_path_t *sata;
|
||||
sata = (grub_efi_sata_device_path_t *) dp;
|
||||
grub_printf ("/Sata(%x,%x,%x)",
|
||||
sata->hba_port,
|
||||
sata->multiplier_port,
|
||||
sata->lun);
|
||||
}
|
||||
break;
|
||||
|
||||
case GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE:
|
||||
dump_vendor_path ("Messaging",
|
||||
(grub_efi_vendor_device_path_t *) dp);
|
||||
break;
|
||||
default:
|
||||
grub_printf ("/UnknownMessaging(%x)", (unsigned) subtype);
|
||||
break;
|
||||
@@ -710,31 +723,17 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||
break;
|
||||
case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_cdrom_device_path_t cd;
|
||||
grub_memcpy (&cd, dp, len);
|
||||
grub_efi_cdrom_device_path_t *cd
|
||||
= (grub_efi_cdrom_device_path_t *) dp;
|
||||
grub_printf ("/CD(%u,%llx,%llx)",
|
||||
cd.boot_entry,
|
||||
(unsigned long long) cd.partition_start,
|
||||
(unsigned long long) cd.partition_size);
|
||||
cd->boot_entry,
|
||||
(unsigned long long) cd->partition_start,
|
||||
(unsigned long long) cd->partition_size);
|
||||
}
|
||||
break;
|
||||
case GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_vendor_device_path_t *vendor = (grub_efi_vendor_device_path_t *) dp;
|
||||
|
||||
grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
|
||||
(unsigned) vendor->vendor_guid.data1,
|
||||
(unsigned) vendor->vendor_guid.data2,
|
||||
(unsigned) vendor->vendor_guid.data3,
|
||||
(unsigned) vendor->vendor_guid.data4[0],
|
||||
(unsigned) vendor->vendor_guid.data4[1],
|
||||
(unsigned) vendor->vendor_guid.data4[2],
|
||||
(unsigned) vendor->vendor_guid.data4[3],
|
||||
(unsigned) vendor->vendor_guid.data4[4],
|
||||
(unsigned) vendor->vendor_guid.data4[5],
|
||||
(unsigned) vendor->vendor_guid.data4[6],
|
||||
(unsigned) vendor->vendor_guid.data4[7]);
|
||||
}
|
||||
dump_vendor_path ("Media",
|
||||
(grub_efi_vendor_device_path_t *) dp);
|
||||
break;
|
||||
case GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
@@ -754,20 +753,20 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||
break;
|
||||
case GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_protocol_device_path_t proto;
|
||||
grub_memcpy (&proto, dp, sizeof (proto));
|
||||
grub_efi_protocol_device_path_t *proto
|
||||
= (grub_efi_protocol_device_path_t *) dp;
|
||||
grub_printf ("/Protocol(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
|
||||
(unsigned) proto.guid.data1,
|
||||
(unsigned) proto.guid.data2,
|
||||
(unsigned) proto.guid.data3,
|
||||
(unsigned) proto.guid.data4[0],
|
||||
(unsigned) proto.guid.data4[1],
|
||||
(unsigned) proto.guid.data4[2],
|
||||
(unsigned) proto.guid.data4[3],
|
||||
(unsigned) proto.guid.data4[4],
|
||||
(unsigned) proto.guid.data4[5],
|
||||
(unsigned) proto.guid.data4[6],
|
||||
(unsigned) proto.guid.data4[7]);
|
||||
(unsigned) proto->guid.data1,
|
||||
(unsigned) proto->guid.data2,
|
||||
(unsigned) proto->guid.data3,
|
||||
(unsigned) proto->guid.data4[0],
|
||||
(unsigned) proto->guid.data4[1],
|
||||
(unsigned) proto->guid.data4[2],
|
||||
(unsigned) proto->guid.data4[3],
|
||||
(unsigned) proto->guid.data4[4],
|
||||
(unsigned) proto->guid.data4[5],
|
||||
(unsigned) proto->guid.data4[6],
|
||||
(unsigned) proto->guid.data4[7]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -781,11 +780,11 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
|
||||
{
|
||||
case GRUB_EFI_BIOS_DEVICE_PATH_SUBTYPE:
|
||||
{
|
||||
grub_efi_bios_device_path_t bios;
|
||||
grub_memcpy (&bios, dp, sizeof (bios));
|
||||
grub_efi_bios_device_path_t *bios
|
||||
= (grub_efi_bios_device_path_t *) dp;
|
||||
grub_printf ("/BIOS(%x,%x,%s)",
|
||||
(unsigned) bios.device_type,
|
||||
(unsigned) bios.status_flags,
|
||||
(unsigned) bios->device_type,
|
||||
(unsigned) bios->status_flags,
|
||||
(char *) (dp + 1));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -271,7 +271,7 @@ grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
|
||||
grub_ieee1275_cell_t mode;
|
||||
grub_ieee1275_cell_t size;
|
||||
grub_ieee1275_cell_t virt;
|
||||
#ifdef GRUB_MACHINE_SPARC64
|
||||
#ifdef __sparc__
|
||||
grub_ieee1275_cell_t phys_high;
|
||||
#endif
|
||||
grub_ieee1275_cell_t phys_low;
|
||||
@@ -279,7 +279,7 @@ grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method",
|
||||
#ifdef GRUB_MACHINE_SPARC64
|
||||
#ifdef __sparc__
|
||||
7,
|
||||
#else
|
||||
6,
|
||||
@@ -287,7 +287,7 @@ grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
|
||||
1);
|
||||
args.method = (grub_ieee1275_cell_t) "map";
|
||||
args.ihandle = grub_ieee1275_mmu;
|
||||
#ifdef GRUB_MACHINE_SPARC64
|
||||
#ifdef __sparc__
|
||||
args.phys_high = 0;
|
||||
#endif
|
||||
args.phys_low = phys;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <grub/uboot/uboot.h>
|
||||
#include <grub/uboot/api_public.h>
|
||||
#include <grub/cpu/system.h>
|
||||
#include <grub/cache.h>
|
||||
|
||||
extern char __bss_start[];
|
||||
extern char _end[];
|
||||
@@ -107,6 +108,11 @@ grub_machine_init (void)
|
||||
/* Enumerate memory and initialize the memory management system. */
|
||||
grub_uboot_mm_init ();
|
||||
|
||||
/* Should be earlier but it needs memalign. */
|
||||
#ifdef __arm__
|
||||
grub_arm_enable_caches_mmu ();
|
||||
#endif
|
||||
|
||||
grub_dprintf ("init", "__bss_start: %p\n", __bss_start);
|
||||
grub_dprintf ("init", "_end: %p\n", _end);
|
||||
grub_dprintf ("init", "grub_modbase: %p\n", (void *) grub_modbase);
|
||||
|
||||
@@ -431,3 +431,32 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
|
||||
grub_memcpy (prop + 3, val, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_fdt_create_empty_tree (void *fdt, unsigned int size)
|
||||
{
|
||||
struct grub_fdt_empty_tree *et;
|
||||
|
||||
if (size < GRUB_FDT_EMPTY_TREE_SZ)
|
||||
return -1;
|
||||
|
||||
grub_memset (fdt, 0, size);
|
||||
et = fdt;
|
||||
|
||||
et->empty_node.tree_end = grub_cpu_to_be32_compile_time (FDT_END);
|
||||
et->empty_node.node_end = grub_cpu_to_be32_compile_time (FDT_END_NODE);
|
||||
et->empty_node.node_start = grub_cpu_to_be32_compile_time (FDT_BEGIN_NODE);
|
||||
((struct grub_fdt_empty_tree *) fdt)->header.off_mem_rsvmap =
|
||||
grub_cpu_to_be32 (ALIGN_UP (sizeof (grub_fdt_header_t), 8));
|
||||
|
||||
grub_fdt_set_off_dt_strings (fdt, sizeof (*et));
|
||||
grub_fdt_set_off_dt_struct (fdt,
|
||||
sizeof (et->header) + sizeof (et->empty_rsvmap));
|
||||
grub_fdt_set_version (fdt, FDT_SUPPORTED_VERSION);
|
||||
grub_fdt_set_last_comp_version (fdt, FDT_SUPPORTED_VERSION);
|
||||
grub_fdt_set_size_dt_struct (fdt, sizeof (et->empty_node));
|
||||
grub_fdt_set_totalsize (fdt, size);
|
||||
grub_fdt_set_magic (fdt, FDT_MAGIC);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -357,7 +357,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
|
||||
|
||||
for (j = KC-1; j >= 0; j--)
|
||||
{
|
||||
*((u32*)tk[j]) = *((u32*)k[j]);
|
||||
*((u32_a_t*)tk[j]) = *((u32_a_t*)k[j]);
|
||||
}
|
||||
r = 0;
|
||||
t = 0;
|
||||
@@ -366,7 +366,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
|
||||
{
|
||||
for (; (j < KC) && (t < 4); j++, t++)
|
||||
{
|
||||
*((u32*)W[r][t]) = *((u32*)tk[j]);
|
||||
*((u32_a_t*)W[r][t]) = *((u32_a_t*)tk[j]);
|
||||
}
|
||||
if (t == 4)
|
||||
{
|
||||
@@ -389,14 +389,14 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
|
||||
{
|
||||
for (j = 1; j < KC; j++)
|
||||
{
|
||||
*((u32*)tk[j]) ^= *((u32*)tk[j-1]);
|
||||
*((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 1; j < KC/2; j++)
|
||||
{
|
||||
*((u32*)tk[j]) ^= *((u32*)tk[j-1]);
|
||||
*((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
|
||||
}
|
||||
tk[KC/2][0] ^= S[tk[KC/2 - 1][0]];
|
||||
tk[KC/2][1] ^= S[tk[KC/2 - 1][1]];
|
||||
@@ -404,7 +404,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
|
||||
tk[KC/2][3] ^= S[tk[KC/2 - 1][3]];
|
||||
for (j = KC/2 + 1; j < KC; j++)
|
||||
{
|
||||
*((u32*)tk[j]) ^= *((u32*)tk[j-1]);
|
||||
*((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
|
||||
{
|
||||
for (; (j < KC) && (t < 4); j++, t++)
|
||||
{
|
||||
*((u32*)W[r][t]) = *((u32*)tk[j]);
|
||||
*((u32_a_t*)W[r][t]) = *((u32_a_t*)tk[j]);
|
||||
}
|
||||
if (t == 4)
|
||||
{
|
||||
@@ -483,29 +483,29 @@ prepare_decryption( RIJNDAEL_context *ctx )
|
||||
|
||||
for (r=0; r < MAXROUNDS+1; r++ )
|
||||
{
|
||||
*((u32*)ctx->keyschdec[r][0]) = *((u32*)ctx->keyschenc[r][0]);
|
||||
*((u32*)ctx->keyschdec[r][1]) = *((u32*)ctx->keyschenc[r][1]);
|
||||
*((u32*)ctx->keyschdec[r][2]) = *((u32*)ctx->keyschenc[r][2]);
|
||||
*((u32*)ctx->keyschdec[r][3]) = *((u32*)ctx->keyschenc[r][3]);
|
||||
*((u32_a_t*)ctx->keyschdec[r][0]) = *((u32_a_t*)ctx->keyschenc[r][0]);
|
||||
*((u32_a_t*)ctx->keyschdec[r][1]) = *((u32_a_t*)ctx->keyschenc[r][1]);
|
||||
*((u32_a_t*)ctx->keyschdec[r][2]) = *((u32_a_t*)ctx->keyschenc[r][2]);
|
||||
*((u32_a_t*)ctx->keyschdec[r][3]) = *((u32_a_t*)ctx->keyschenc[r][3]);
|
||||
}
|
||||
#define W (ctx->keyschdec)
|
||||
for (r = 1; r < ctx->rounds; r++)
|
||||
{
|
||||
w = W[r][0];
|
||||
*((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
|
||||
^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
|
||||
*((u32_a_t*)w) = *((u32_a_t*)U1[w[0]]) ^ *((u32_a_t*)U2[w[1]])
|
||||
^ *((u32_a_t*)U3[w[2]]) ^ *((u32_a_t*)U4[w[3]]);
|
||||
|
||||
w = W[r][1];
|
||||
*((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
|
||||
^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
|
||||
*((u32_a_t*)w) = *((u32_a_t*)U1[w[0]]) ^ *((u32_a_t*)U2[w[1]])
|
||||
^ *((u32_a_t*)U3[w[2]]) ^ *((u32_a_t*)U4[w[3]]);
|
||||
|
||||
w = W[r][2];
|
||||
*((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
|
||||
^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
|
||||
*((u32_a_t*)w) = *((u32_a_t*)U1[w[0]]) ^ *((u32_a_t*)U2[w[1]])
|
||||
^ *((u32_a_t*)U3[w[2]]) ^ *((u32_a_t*)U4[w[3]]);
|
||||
|
||||
w = W[r][3];
|
||||
*((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
|
||||
^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
|
||||
*((u32_a_t*)w) = *((u32_a_t*)U1[w[0]]) ^ *((u32_a_t*)U2[w[1]])
|
||||
^ *((u32_a_t*)U3[w[2]]) ^ *((u32_a_t*)U4[w[3]]);
|
||||
}
|
||||
#undef W
|
||||
#undef w
|
||||
|
||||
@@ -283,6 +283,8 @@ linux_boot (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
grub_arm_disable_caches_mmu ();
|
||||
|
||||
linuxmain (0, machine_type, fdt_addr);
|
||||
|
||||
return grub_error (GRUB_ERR_BAD_OS, "Linux call returned");
|
||||
|
||||
@@ -0,0 +1,487 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2013 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/>.
|
||||
*/
|
||||
|
||||
#include <grub/charset.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/fdt.h>
|
||||
#include <grub/linux.h>
|
||||
#include <grub/loader.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/cpu/linux.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/pe32.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/lib/cmdline.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#define GRUB_EFI_PAGE_SHIFT 12
|
||||
#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT)
|
||||
#define GRUB_EFI_PE_MAGIC 0x5A4D
|
||||
|
||||
static grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
|
||||
|
||||
static grub_dl_t my_mod;
|
||||
static int loaded;
|
||||
|
||||
static void *kernel_addr;
|
||||
static grub_uint64_t kernel_size;
|
||||
|
||||
static char *linux_args;
|
||||
static grub_uint32_t cmdline_size;
|
||||
|
||||
static grub_addr_t initrd_start;
|
||||
static grub_addr_t initrd_end;
|
||||
|
||||
static void *loaded_fdt;
|
||||
static void *fdt;
|
||||
|
||||
static void *
|
||||
get_firmware_fdt (void)
|
||||
{
|
||||
grub_efi_configuration_table_t *tables;
|
||||
void *firmware_fdt = NULL;
|
||||
unsigned int i;
|
||||
|
||||
/* Look for FDT in UEFI config tables. */
|
||||
tables = grub_efi_system_table->configuration_table;
|
||||
|
||||
for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
|
||||
if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0)
|
||||
{
|
||||
firmware_fdt = tables[i].vendor_table;
|
||||
grub_dprintf ("linux", "found registered FDT @ 0x%p\n", firmware_fdt);
|
||||
break;
|
||||
}
|
||||
|
||||
return firmware_fdt;
|
||||
}
|
||||
|
||||
static void
|
||||
get_fdt (void)
|
||||
{
|
||||
void *raw_fdt;
|
||||
grub_size_t size;
|
||||
|
||||
if (fdt)
|
||||
{
|
||||
size = BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt));
|
||||
grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size);
|
||||
}
|
||||
|
||||
if (loaded_fdt)
|
||||
raw_fdt = loaded_fdt;
|
||||
else
|
||||
raw_fdt = get_firmware_fdt();
|
||||
|
||||
size =
|
||||
raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ;
|
||||
size += 0x400;
|
||||
|
||||
grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size);
|
||||
fdt = grub_efi_allocate_pages (0, BYTES_TO_PAGES (size));
|
||||
if (!fdt)
|
||||
return;
|
||||
|
||||
if (raw_fdt)
|
||||
{
|
||||
grub_memmove (fdt, raw_fdt, size);
|
||||
grub_fdt_set_totalsize (fdt, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_fdt_create_empty_tree (fdt, size);
|
||||
}
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
check_kernel (struct grub_arm64_linux_kernel_header *lh)
|
||||
{
|
||||
if (lh->magic != GRUB_ARM64_LINUX_MAGIC)
|
||||
return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
|
||||
|
||||
if ((lh->code0 & 0xffff) != GRUB_EFI_PE_MAGIC)
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
N_("plain Image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled"));
|
||||
|
||||
grub_dprintf ("linux", "UEFI stub kernel:\n");
|
||||
grub_dprintf ("linux", "text_offset = 0x%012llx\n",
|
||||
(long long unsigned) lh->text_offset);
|
||||
grub_dprintf ("linux", "PE/COFF header @ %08x\n", lh->hdr_offset);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
finalize_params (void)
|
||||
{
|
||||
grub_efi_boot_services_t *b;
|
||||
grub_efi_status_t status;
|
||||
int node, retval;
|
||||
|
||||
get_fdt ();
|
||||
if (!fdt)
|
||||
goto failure;
|
||||
|
||||
node = grub_fdt_find_subnode (fdt, 0, "chosen");
|
||||
if (node < 0)
|
||||
node = grub_fdt_add_subnode (fdt, 0, "chosen");
|
||||
|
||||
if (node < 1)
|
||||
goto failure;
|
||||
|
||||
/* Set initrd info */
|
||||
if (initrd_start && initrd_end > initrd_start)
|
||||
{
|
||||
grub_dprintf ("linux", "Initrd @ 0x%012lx-0x%012lx\n",
|
||||
initrd_start, initrd_end);
|
||||
|
||||
retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-start",
|
||||
initrd_start);
|
||||
if (retval)
|
||||
goto failure;
|
||||
retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-end",
|
||||
initrd_end);
|
||||
if (retval)
|
||||
goto failure;
|
||||
}
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
status = b->install_configuration_table (&fdt_guid, fdt);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
goto failure;
|
||||
|
||||
grub_dprintf ("linux", "Installed/updated FDT configuration table @ %p\n",
|
||||
fdt);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
failure:
|
||||
grub_efi_free_pages ((grub_efi_physical_address_t) fdt,
|
||||
BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)));
|
||||
fdt = NULL;
|
||||
return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT");
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
{
|
||||
grub_file_t dtb;
|
||||
void *blob = NULL;
|
||||
int size;
|
||||
|
||||
if (!loaded)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
N_("you need to load the kernel first"));
|
||||
return GRUB_ERR_BAD_OS;
|
||||
}
|
||||
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
|
||||
|
||||
if (loaded_fdt)
|
||||
grub_free (loaded_fdt);
|
||||
loaded_fdt = NULL;
|
||||
|
||||
dtb = grub_file_open (argv[0]);
|
||||
if (!dtb)
|
||||
goto out;
|
||||
|
||||
size = grub_file_size (dtb);
|
||||
blob = grub_malloc (size);
|
||||
if (!blob)
|
||||
goto out;
|
||||
|
||||
if (grub_file_read (dtb, blob, size) < size)
|
||||
{
|
||||
if (!grub_errno)
|
||||
grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (grub_fdt_check_header (blob, size) != 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_OS, N_("invalid device tree"));
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
if (dtb)
|
||||
grub_file_close (dtb);
|
||||
|
||||
if (blob)
|
||||
{
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
loaded_fdt = blob;
|
||||
else
|
||||
grub_free (blob);
|
||||
}
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_linux_boot (void)
|
||||
{
|
||||
grub_efi_memory_mapped_device_path_t *mempath;
|
||||
grub_efi_handle_t image_handle;
|
||||
grub_efi_boot_services_t *b;
|
||||
grub_efi_status_t status;
|
||||
grub_err_t retval;
|
||||
grub_efi_loaded_image_t *loaded_image;
|
||||
int len;
|
||||
|
||||
retval = finalize_params();
|
||||
if (retval != GRUB_ERR_NONE)
|
||||
return retval;
|
||||
|
||||
mempath = grub_malloc (2 * sizeof (grub_efi_memory_mapped_device_path_t));
|
||||
if (!mempath)
|
||||
return grub_errno;
|
||||
|
||||
mempath[0].header.type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE;
|
||||
mempath[0].header.subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE;
|
||||
mempath[0].header.length = grub_cpu_to_le16_compile_time (sizeof (*mempath));
|
||||
mempath[0].memory_type = GRUB_EFI_LOADER_DATA;
|
||||
mempath[0].start_address = (grub_addr_t) kernel_addr;
|
||||
mempath[0].end_address = (grub_addr_t) kernel_addr + kernel_size;
|
||||
|
||||
mempath[1].header.type = GRUB_EFI_END_DEVICE_PATH_TYPE;
|
||||
mempath[1].header.subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
|
||||
mempath[1].header.length = 0;
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
status = b->load_image (0, grub_efi_image_handle,
|
||||
(grub_efi_device_path_t *) mempath,
|
||||
kernel_addr, kernel_size, &image_handle);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
return grub_error (GRUB_ERR_BAD_OS, "cannot load image");
|
||||
|
||||
grub_dprintf ("linux", "linux command line: '%s'\n", linux_args);
|
||||
|
||||
/* Convert command line to UCS-2 */
|
||||
loaded_image = grub_efi_get_loaded_image (image_handle);
|
||||
loaded_image->load_options_size = len =
|
||||
(grub_strlen (linux_args) + 1) * sizeof (grub_efi_char16_t);
|
||||
loaded_image->load_options =
|
||||
grub_efi_allocate_pages (0,
|
||||
BYTES_TO_PAGES (loaded_image->load_options_size));
|
||||
if (!loaded_image->load_options)
|
||||
return grub_errno;
|
||||
|
||||
loaded_image->load_options_size =
|
||||
2 * grub_utf8_to_utf16 (loaded_image->load_options, len,
|
||||
(grub_uint8_t *) linux_args, len, NULL);
|
||||
|
||||
grub_dprintf("linux", "starting image %p\n", image_handle);
|
||||
status = b->start_image (image_handle, 0, NULL);
|
||||
|
||||
/* When successful, not reached */
|
||||
b->unload_image (image_handle);
|
||||
grub_efi_free_pages ((grub_efi_physical_address_t) loaded_image->load_options,
|
||||
BYTES_TO_PAGES (loaded_image->load_options_size));
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_linux_unload (void)
|
||||
{
|
||||
grub_dl_unref (my_mod);
|
||||
loaded = 0;
|
||||
if (initrd_start)
|
||||
grub_efi_free_pages ((grub_efi_physical_address_t) initrd_start,
|
||||
BYTES_TO_PAGES (initrd_end - initrd_start));
|
||||
initrd_start = initrd_end = 0;
|
||||
grub_free (linux_args);
|
||||
if (kernel_addr)
|
||||
grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr,
|
||||
BYTES_TO_PAGES (kernel_size));
|
||||
if (fdt)
|
||||
grub_efi_free_pages ((grub_efi_physical_address_t) fdt,
|
||||
BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)));
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
{
|
||||
struct grub_linux_initrd_context initrd_ctx;
|
||||
int initrd_size, initrd_pages;
|
||||
void *initrd_mem = NULL;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!loaded)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
N_("you need to load the kernel first"));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (grub_initrd_init (argc, argv, &initrd_ctx))
|
||||
goto fail;
|
||||
|
||||
initrd_size = grub_get_initrd_size (&initrd_ctx);
|
||||
grub_dprintf ("linux", "Loading initrd\n");
|
||||
|
||||
initrd_pages = (BYTES_TO_PAGES (initrd_size));
|
||||
initrd_mem = grub_efi_allocate_pages (0, initrd_pages);
|
||||
if (!initrd_mem)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (grub_initrd_load (&initrd_ctx, argv, initrd_mem))
|
||||
goto fail;
|
||||
|
||||
initrd_start = (grub_addr_t) initrd_mem;
|
||||
initrd_end = initrd_start + initrd_size;
|
||||
grub_dprintf ("linux", "[addr=%p, size=0x%x]\n",
|
||||
(void *) initrd_start, initrd_size);
|
||||
|
||||
fail:
|
||||
grub_initrd_close (&initrd_ctx);
|
||||
if (initrd_mem && !initrd_start)
|
||||
grub_efi_free_pages ((grub_efi_physical_address_t) initrd_mem,
|
||||
initrd_pages);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
{
|
||||
grub_file_t file = 0;
|
||||
struct grub_arm64_linux_kernel_header lh;
|
||||
|
||||
grub_dl_ref (my_mod);
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
file = grub_file_open (argv[0]);
|
||||
if (!file)
|
||||
goto fail;
|
||||
|
||||
kernel_size = grub_file_size (file);
|
||||
|
||||
if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh))
|
||||
return grub_errno;
|
||||
|
||||
if (check_kernel (&lh) != GRUB_ERR_NONE)
|
||||
goto fail;
|
||||
|
||||
grub_loader_unset();
|
||||
|
||||
grub_dprintf ("linux", "kernel file size: %lld\n", (long long) kernel_size);
|
||||
kernel_addr = grub_efi_allocate_pages (0, BYTES_TO_PAGES (kernel_size));
|
||||
grub_dprintf ("linux", "kernel numpages: %lld\n",
|
||||
(long long) BYTES_TO_PAGES (kernel_size));
|
||||
if (!kernel_addr)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
grub_file_seek (file, 0);
|
||||
if (grub_file_read (file, kernel_addr, kernel_size)
|
||||
< (grub_int64_t) kernel_size)
|
||||
{
|
||||
if (!grub_errno)
|
||||
grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
grub_dprintf ("linux", "kernel @ %p\n", kernel_addr);
|
||||
|
||||
cmdline_size = grub_loader_cmdline_size (argc, argv) + sizeof (LINUX_IMAGE);
|
||||
linux_args = grub_malloc (cmdline_size);
|
||||
if (!linux_args)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
|
||||
goto fail;
|
||||
}
|
||||
grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE));
|
||||
grub_create_loader_cmdline (argc, argv,
|
||||
linux_args + sizeof (LINUX_IMAGE) - 1,
|
||||
cmdline_size);
|
||||
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
{
|
||||
grub_loader_set (grub_linux_boot, grub_linux_unload, 0);
|
||||
loaded = 1;
|
||||
}
|
||||
|
||||
fail:
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_dl_unref (my_mod);
|
||||
loaded = 0;
|
||||
}
|
||||
|
||||
if (linux_args && !loaded)
|
||||
grub_free (linux_args);
|
||||
|
||||
if (kernel_addr && !loaded)
|
||||
grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr,
|
||||
BYTES_TO_PAGES (kernel_size));
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
|
||||
static grub_command_t cmd_linux, cmd_initrd, cmd_devicetree;
|
||||
|
||||
GRUB_MOD_INIT (linux)
|
||||
{
|
||||
cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0,
|
||||
N_("Load Linux."));
|
||||
cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0,
|
||||
N_("Load initrd."));
|
||||
cmd_devicetree =
|
||||
grub_register_command ("devicetree", grub_cmd_devicetree, 0,
|
||||
N_("Load DTB file."));
|
||||
my_mod = mod;
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (linux)
|
||||
{
|
||||
grub_unregister_command (cmd_linux);
|
||||
grub_unregister_command (cmd_initrd);
|
||||
grub_unregister_command (cmd_devicetree);
|
||||
}
|
||||
@@ -89,8 +89,7 @@ struct piwg_full_device_path
|
||||
.subtype = GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE, \
|
||||
.length = sizeof (struct grub_efi_piwg_device_path) \
|
||||
}, \
|
||||
.guid = {0x2B0585EB, 0xD8B8, 0x49A9, {0x8B, 0x8C, 0xE2, 0x1B, \
|
||||
0x01, 0xAE, 0xF2, 0xB7}} \
|
||||
.guid = GRUB_EFI_VENDOR_APPLE_GUID \
|
||||
}, \
|
||||
.end = \
|
||||
{ \
|
||||
|
||||
@@ -1,4 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
# User-controllable options
|
||||
grub_modinfo_target_cpu=@target_cpu@
|
||||
grub_modinfo_platform=@platform@
|
||||
grub_disk_cache_stats=@DISK_CACHE_STATS@
|
||||
grub_boot_time_stats=@BOOT_TIME_STATS@
|
||||
grub_have_font_source=@HAVE_FONT_SOURCE@
|
||||
|
||||
# Autodetected config
|
||||
grub_have_asm_uscore=@HAVE_ASM_USCORE@
|
||||
grub_i8086_addr32="@ADDR32@"
|
||||
grub_i8086_data32="@DATA32@"
|
||||
grub_bss_start_symbol="@BSS_START_SYMBOL@"
|
||||
grub_end_symbol="@END_SYMBOL@"
|
||||
|
||||
# Build environment
|
||||
grub_target_cc='@TARGET_CC@'
|
||||
grub_target_cc_version='@TARGET_CC_VERSION@'
|
||||
grub_target_cflags='@TARGET_CFLAGS@'
|
||||
grub_target_cppflags='@TARGET_CPPFLAGS@'
|
||||
grub_target_ccasflags='@TARGET_CCASFLAGS@'
|
||||
grub_target_ldflags='@TARGET_LDFLAGS@'
|
||||
grub_target_strip='@TARGET_STRIP@'
|
||||
grub_target_nm='@TARGET_NM@'
|
||||
grub_target_ranlib='@TARGET_RANLIB@'
|
||||
grub_target_objconf='@TARGET_OBJCONV@'
|
||||
grub_target_obj2elf='@TARGET_OBJ2ELF@'
|
||||
|
||||
# Version
|
||||
grub_version="@VERSION@"
|
||||
grub_package="@PACKAGE@"
|
||||
grub_package_string="@PACKAGE_STRING@"
|
||||
grub_package_version="@PACKAGE_VERSION@"
|
||||
grub_package_name="@PACKAGE_NAME@"
|
||||
grub_package_bugreport="@PACKAGE_BUGREPORT@"
|
||||
@@ -80,11 +80,11 @@ grub_util_fd_open (const char *os_dev, int flags)
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
|
||||
ret = open (os_dev, flags, S_IRUSR | S_IWUSR);
|
||||
ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
|
||||
|
||||
/* If we can't have exclusive access, try shared access */
|
||||
if (ret < 0)
|
||||
ret = open (os_dev, flags | O_SHLOCK, S_IRUSR | S_IWUSR);
|
||||
ret = open (os_dev, flags | O_SHLOCK, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ grub_util_fd_open (const char *dev, int flg)
|
||||
if (dev[0] != '/' || dev[1] != '/' || dev[2] != ':')
|
||||
{
|
||||
ret->type = GRUB_UTIL_FD_FILE;
|
||||
ret->fd = open (dev, flg, S_IRUSR | S_IWUSR);
|
||||
ret->fd = open (dev, flg, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
|
||||
if (ret->fd < 0)
|
||||
{
|
||||
free (ret);
|
||||
|
||||
@@ -90,7 +90,7 @@ grub_util_fd_open (const char *os_dev, int flags)
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
|
||||
ret = open (os_dev, flags, S_IRUSR | S_IWUSR);
|
||||
ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
|
||||
if (ret >= 0)
|
||||
configure_device_driver (fd);
|
||||
return ret;
|
||||
|
||||
@@ -198,140 +198,17 @@ char *
|
||||
grub_util_devmapper_part_to_disk (struct stat *st,
|
||||
int *is_part, const char *path)
|
||||
{
|
||||
struct dm_tree *tree;
|
||||
uint32_t maj, min;
|
||||
struct dm_tree_node *node = NULL, *child;
|
||||
void *handle;
|
||||
const char *node_uuid, *mapper_name = NULL, *child_uuid, *child_name;
|
||||
int major, minor;
|
||||
|
||||
tree = dm_tree_create ();
|
||||
if (! tree)
|
||||
if (grub_util_get_dm_node_linear_info (st->st_rdev,
|
||||
&major, &minor, 0))
|
||||
{
|
||||
grub_util_info ("dm_tree_create failed");
|
||||
goto devmapper_out;
|
||||
*is_part = 1;
|
||||
return grub_find_device ("/dev",
|
||||
(major << 8) | minor);
|
||||
}
|
||||
|
||||
maj = major (st->st_rdev);
|
||||
min = minor (st->st_rdev);
|
||||
if (! dm_tree_add_dev (tree, maj, min))
|
||||
{
|
||||
grub_util_info ("dm_tree_add_dev failed");
|
||||
goto devmapper_out;
|
||||
}
|
||||
|
||||
node = dm_tree_find_node (tree, maj, min);
|
||||
if (! node)
|
||||
{
|
||||
grub_util_info ("dm_tree_find_node failed");
|
||||
goto devmapper_out;
|
||||
}
|
||||
reiterate:
|
||||
node_uuid = dm_tree_node_get_uuid (node);
|
||||
if (! node_uuid)
|
||||
{
|
||||
grub_util_info ("%s has no DM uuid", path);
|
||||
goto devmapper_out;
|
||||
}
|
||||
if (strncmp (node_uuid, "LVM-", 4) == 0)
|
||||
{
|
||||
grub_util_info ("%s is an LVM", path);
|
||||
goto devmapper_out;
|
||||
}
|
||||
if (strncmp (node_uuid, "mpath-", 6) == 0)
|
||||
{
|
||||
/* Multipath partitions have partN-mpath-* UUIDs, and are
|
||||
linear mappings so are handled by
|
||||
grub_util_get_dm_node_linear_info. Multipath disks are not
|
||||
linear mappings and must be handled specially. */
|
||||
grub_util_info ("%s is a multipath disk", path);
|
||||
goto devmapper_out;
|
||||
}
|
||||
if (strncmp (node_uuid, "DMRAID-", 7) != 0)
|
||||
{
|
||||
int major, minor;
|
||||
const char *node_name;
|
||||
grub_util_info ("%s is not DM-RAID", path);
|
||||
|
||||
if ((node_name = dm_tree_node_get_name (node))
|
||||
&& grub_util_get_dm_node_linear_info (node_name,
|
||||
&major, &minor, 0))
|
||||
{
|
||||
*is_part = 1;
|
||||
if (tree)
|
||||
dm_tree_free (tree);
|
||||
char *ret = grub_find_device ("/dev",
|
||||
(major << 8) | minor);
|
||||
return ret;
|
||||
}
|
||||
|
||||
goto devmapper_out;
|
||||
}
|
||||
|
||||
handle = NULL;
|
||||
/* Counter-intuitively, device-mapper refers to the disk-like
|
||||
device containing a DM-RAID partition device as a "child" of
|
||||
the partition device. */
|
||||
child = dm_tree_next_child (&handle, node, 0);
|
||||
if (! child)
|
||||
{
|
||||
grub_util_info ("%s has no DM children", path);
|
||||
goto devmapper_out;
|
||||
}
|
||||
child_uuid = dm_tree_node_get_uuid (child);
|
||||
if (! child_uuid)
|
||||
{
|
||||
grub_util_info ("%s child has no DM uuid", path);
|
||||
goto devmapper_out;
|
||||
}
|
||||
else if (strncmp (child_uuid, "DMRAID-", 7) != 0)
|
||||
{
|
||||
grub_util_info ("%s child is not DM-RAID", path);
|
||||
goto devmapper_out;
|
||||
}
|
||||
child_name = dm_tree_node_get_name (child);
|
||||
if (! child_name)
|
||||
{
|
||||
grub_util_info ("%s child has no DM name", path);
|
||||
goto devmapper_out;
|
||||
}
|
||||
mapper_name = child_name;
|
||||
*is_part = 1;
|
||||
node = child;
|
||||
goto reiterate;
|
||||
|
||||
devmapper_out:
|
||||
if (! mapper_name && node)
|
||||
{
|
||||
/* This is a DM-RAID disk, not a partition. */
|
||||
mapper_name = dm_tree_node_get_name (node);
|
||||
if (! mapper_name)
|
||||
grub_util_info ("%s has no DM name", path);
|
||||
}
|
||||
char *ret;
|
||||
if (mapper_name)
|
||||
ret = xasprintf ("/dev/mapper/%s", mapper_name);
|
||||
else
|
||||
ret = NULL;
|
||||
|
||||
if (tree)
|
||||
dm_tree_free (tree);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
grub_util_device_is_mapped_stat (struct stat *st)
|
||||
{
|
||||
#if GRUB_DISK_DEVS_ARE_CHAR
|
||||
if (! S_ISCHR (st->st_mode))
|
||||
#else
|
||||
if (! S_ISBLK (st->st_mode))
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
if (!grub_device_mapper_supported ())
|
||||
return 0;
|
||||
|
||||
return dm_is_dm_major (major (st->st_rdev));
|
||||
*is_part = 0;
|
||||
return xstrdup (path);
|
||||
}
|
||||
|
||||
char *
|
||||
@@ -418,12 +295,6 @@ grub_util_pull_devmapper (const char *os_dev __attribute__ ((unused)))
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
grub_util_device_is_mapped_stat (struct stat *st __attribute__ ((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
grub_util_devmapper_cleanup (void)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,24 @@ grub_util_device_is_mapped (const char *dev)
|
||||
}
|
||||
|
||||
int
|
||||
grub_util_get_dm_node_linear_info (const char *dev,
|
||||
grub_util_device_is_mapped_stat (struct stat *st)
|
||||
{
|
||||
#if GRUB_DISK_DEVS_ARE_CHAR
|
||||
if (! S_ISCHR (st->st_mode))
|
||||
#else
|
||||
if (! S_ISBLK (st->st_mode))
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
if (!grub_device_mapper_supported ())
|
||||
return 0;
|
||||
|
||||
return dm_is_dm_major (major (st->st_rdev));
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
grub_util_get_dm_node_linear_info (dev_t dev,
|
||||
int *maj, int *min,
|
||||
grub_disk_addr_t *st)
|
||||
{
|
||||
@@ -97,14 +114,16 @@ grub_util_get_dm_node_linear_info (const char *dev,
|
||||
grub_disk_addr_t partstart = 0;
|
||||
const char *node_uuid;
|
||||
|
||||
major = major (dev);
|
||||
minor = minor (dev);
|
||||
|
||||
while (1)
|
||||
{
|
||||
dmt = dm_task_create(DM_DEVICE_TABLE);
|
||||
if (!dmt)
|
||||
break;
|
||||
|
||||
if (! (first ? dm_task_set_name (dmt, dev)
|
||||
: dm_task_set_major_minor (dmt, major, minor, 0)))
|
||||
if (! (dm_task_set_major_minor (dmt, major, minor, 0)))
|
||||
{
|
||||
dm_task_destroy (dmt);
|
||||
break;
|
||||
@@ -117,8 +136,7 @@ grub_util_get_dm_node_linear_info (const char *dev,
|
||||
}
|
||||
node_uuid = dm_task_get_uuid (dmt);
|
||||
if (node_uuid && (strncmp (node_uuid, "LVM-", 4) == 0
|
||||
|| strncmp (node_uuid, "mpath-", 6) == 0
|
||||
|| strncmp (node_uuid, "DMRAID-", 7) == 0))
|
||||
|| strncmp (node_uuid, "mpath-", 6) == 0))
|
||||
{
|
||||
dm_task_destroy (dmt);
|
||||
break;
|
||||
@@ -190,7 +208,7 @@ grub_util_device_is_mapped (const char *dev __attribute__ ((unused)))
|
||||
}
|
||||
|
||||
int
|
||||
grub_util_get_dm_node_linear_info (const char *dev __attribute__ ((unused)),
|
||||
grub_util_get_dm_node_linear_info (dev_t dev __attribute__ ((unused)),
|
||||
int *maj __attribute__ ((unused)),
|
||||
int *min __attribute__ ((unused)),
|
||||
grub_disk_addr_t *st __attribute__ ((unused)))
|
||||
@@ -198,4 +216,10 @@ grub_util_get_dm_node_linear_info (const char *dev __attribute__ ((unused)),
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_util_device_is_mapped_stat (struct stat *st __attribute__ ((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -106,7 +106,7 @@ grub_util_fd_open (const char *os_dev, int flags)
|
||||
return GRUB_UTIL_FD_INVALID;
|
||||
}
|
||||
|
||||
ret = open (os_dev, flags, S_IRUSR | S_IWUSR);
|
||||
ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
if (! (sysctl_oldflags & 0x10)
|
||||
|
||||
@@ -288,6 +288,7 @@ grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector)
|
||||
{
|
||||
grub_util_fd_t fd;
|
||||
grub_disk_addr_t start;
|
||||
struct stat st;
|
||||
|
||||
sprintf (p, format, i);
|
||||
|
||||
@@ -300,14 +301,16 @@ grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector)
|
||||
return 0;
|
||||
}
|
||||
missing = 0;
|
||||
close (fd);
|
||||
|
||||
if (!grub_util_device_is_mapped (real_dev)
|
||||
|| !grub_util_get_dm_node_linear_info (real_dev, 0, 0, &start))
|
||||
if (fstat (fd, &st) < 0
|
||||
|| !grub_util_device_is_mapped_stat (&st)
|
||||
|| !grub_util_get_dm_node_linear_info (st.st_rdev, 0, 0, &start))
|
||||
start = grub_util_find_partition_start_os (real_dev);
|
||||
/* We don't care about errors here. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
close (fd);
|
||||
|
||||
if (start == sector)
|
||||
{
|
||||
struct linux_partition_cache *new_cache_item;
|
||||
|
||||
@@ -181,7 +181,7 @@ grub_util_fd_open (const char *os_dev, int flags)
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
|
||||
return open (os_dev, flags, S_IRUSR | S_IWUSR);
|
||||
return open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
#ifndef GRUB_SYSTEM_CPU_HEADER
|
||||
#define GRUB_SYSTEM_CPU_HEADER
|
||||
|
||||
#include <grub/types.h>
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI = 3138,
|
||||
GRUB_ARM_MACHINE_TYPE_FDT = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
void grub_arm_disable_caches_mmu (void);
|
||||
void EXPORT_FUNC(grub_arm_disable_caches_mmu) (void);
|
||||
void grub_arm_enable_caches_mmu (void);
|
||||
void grub_arm_enable_mmu (grub_uint32_t *mmu_tables);
|
||||
void grub_arm_clear_mmu_v6 (void);
|
||||
|
||||
#endif /* ! GRUB_SYSTEM_CPU_HEADER */
|
||||
|
||||
@@ -16,40 +16,26 @@
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_GREFFS_HEADER
|
||||
#define GRUB_GREFFS_HEADER 1
|
||||
#ifndef GRUB_LINUX_CPU_HEADER
|
||||
#define GRUB_LINUX_CPU_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/efi/efi.h>
|
||||
|
||||
/*
|
||||
Layout:
|
||||
header
|
||||
grub_uint32_t[] pointers to names
|
||||
inodes
|
||||
names
|
||||
contents.
|
||||
Everything is little-endian.
|
||||
*/
|
||||
#define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */
|
||||
|
||||
struct grub_greffs_header
|
||||
/* From linux/Documentation/arm64/booting.txt */
|
||||
struct grub_arm64_linux_kernel_header
|
||||
{
|
||||
char magic[4];
|
||||
#define GRUB_GREFFS_MAGIC "gref"
|
||||
grub_uint32_t nfiles;
|
||||
/* must be divisible by 4. */
|
||||
grub_uint32_t inodes_offset;
|
||||
/* must be divisible by 4. */
|
||||
grub_uint32_t string_ptrs_offset;
|
||||
grub_uint32_t code0; /* Executable code */
|
||||
grub_uint32_t code1; /* Executable code */
|
||||
grub_uint64_t text_offset; /* Image load offset */
|
||||
grub_uint64_t res0; /* reserved */
|
||||
grub_uint64_t res1; /* reserved */
|
||||
grub_uint64_t res2; /* reserved */
|
||||
grub_uint64_t res3; /* reserved */
|
||||
grub_uint64_t res4; /* reserved */
|
||||
grub_uint32_t magic; /* Magic number, little endian, "ARM\x64" */
|
||||
grub_uint32_t hdr_offset; /* Offset of PE/COFF header */
|
||||
};
|
||||
|
||||
struct grub_greffs_inode
|
||||
{
|
||||
grub_uint32_t start;
|
||||
grub_uint32_t size;
|
||||
grub_uint32_t mtime;
|
||||
/* Currently always 0. If we ever need symlinks,
|
||||
it could be added. */
|
||||
grub_uint32_t type;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* ! GRUB_LINUX_CPU_HEADER */
|
||||
@@ -45,4 +45,9 @@ grub_arch_sync_dma_caches (void *address __attribute__ ((unused)),
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __arm__
|
||||
void
|
||||
grub_arm_cache_enable (void);
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_CACHE_HEADER */
|
||||
+18
-5
@@ -276,6 +276,16 @@
|
||||
{ 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 } \
|
||||
}
|
||||
|
||||
#define GRUB_EFI_DEVICE_TREE_GUID \
|
||||
{ 0xb1b621d5, 0xf19c, 0x41a5, \
|
||||
{ 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } \
|
||||
}
|
||||
|
||||
#define GRUB_EFI_VENDOR_APPLE_GUID \
|
||||
{ 0x2B0585EB, 0xD8B8, 0x49A9, \
|
||||
{ 0x8B, 0x8C, 0xE2, 0x1B, 0x01, 0xAE, 0xF2, 0xB7 } \
|
||||
}
|
||||
|
||||
struct grub_efi_sal_system_table
|
||||
{
|
||||
grub_uint32_t signature;
|
||||
@@ -809,15 +819,18 @@ struct grub_efi_uart_device_path
|
||||
} GRUB_PACKED;
|
||||
typedef struct grub_efi_uart_device_path grub_efi_uart_device_path_t;
|
||||
|
||||
#define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10
|
||||
#define GRUB_EFI_SATA_DEVICE_PATH_SUBTYPE 18
|
||||
|
||||
struct grub_efi_vendor_messaging_device_path
|
||||
struct grub_efi_sata_device_path
|
||||
{
|
||||
grub_efi_device_path_t header;
|
||||
grub_efi_packed_guid_t vendor_guid;
|
||||
grub_efi_uint8_t vendor_defined_data[0];
|
||||
grub_efi_uint16_t hba_port;
|
||||
grub_efi_uint16_t multiplier_port;
|
||||
grub_efi_uint16_t lun;
|
||||
} GRUB_PACKED;
|
||||
typedef struct grub_efi_vendor_messaging_device_path grub_efi_vendor_messaging_device_path_t;
|
||||
typedef struct grub_efi_sata_device_path grub_efi_sata_device_path_t;
|
||||
|
||||
#define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10
|
||||
|
||||
/* Media Device Path. */
|
||||
#define GRUB_EFI_MEDIA_DEVICE_PATH_TYPE 4
|
||||
|
||||
@@ -61,7 +61,7 @@ char *
|
||||
grub_util_get_os_disk (const char *os_dev);
|
||||
|
||||
int
|
||||
grub_util_get_dm_node_linear_info (const char *dev,
|
||||
grub_util_get_dm_node_linear_info (dev_t dev,
|
||||
int *maj, int *min,
|
||||
grub_disk_addr_t *st);
|
||||
|
||||
|
||||
@@ -36,6 +36,19 @@ typedef struct {
|
||||
grub_uint32_t size_dt_struct;
|
||||
} grub_fdt_header_t;
|
||||
|
||||
struct grub_fdt_empty_tree {
|
||||
grub_fdt_header_t header;
|
||||
grub_uint64_t empty_rsvmap[2];
|
||||
struct {
|
||||
grub_uint32_t node_start;
|
||||
grub_uint8_t name[1];
|
||||
grub_uint32_t node_end;
|
||||
grub_uint32_t tree_end;
|
||||
} empty_node;
|
||||
};
|
||||
|
||||
#define GRUB_FDT_EMPTY_TREE_SZ sizeof (struct grub_fdt_empty_tree)
|
||||
|
||||
#define grub_fdt_get_header(fdt, field) \
|
||||
grub_be_to_cpu32(((const grub_fdt_header_t *)(fdt))->field)
|
||||
#define grub_fdt_set_header(fdt, field, value) \
|
||||
@@ -82,6 +95,7 @@ typedef struct {
|
||||
#define grub_fdt_set_size_dt_struct(fdt, value) \
|
||||
grub_fdt_set_header(fdt, size_dt_struct, value)
|
||||
|
||||
int grub_fdt_create_empty_tree (void *fdt, unsigned int size);
|
||||
int grub_fdt_check_header (void *fdt, unsigned int size);
|
||||
int grub_fdt_check_header_nosize (void *fdt);
|
||||
int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset,
|
||||
@@ -97,4 +111,10 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
|
||||
grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 4); \
|
||||
})
|
||||
|
||||
#define grub_fdt_set_prop64(fdt, nodeoffset, name, val) \
|
||||
({ \
|
||||
grub_uint64_t _val = grub_cpu_to_be64(val); \
|
||||
grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 8); \
|
||||
})
|
||||
|
||||
#endif /* ! GRUB_FDT_HEADER */
|
||||
@@ -68,7 +68,7 @@ grub_util_rename (const char *from, const char *to)
|
||||
return rename (from, to);
|
||||
}
|
||||
|
||||
#define grub_util_mkdir(a) mkdir (a, 0700)
|
||||
#define grub_util_mkdir(a) mkdir ((a), 0755)
|
||||
|
||||
struct grub_util_fd
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ grub_util_rename (const char *from, const char *to)
|
||||
return rename (from, to);
|
||||
}
|
||||
|
||||
#define grub_util_mkdir(a) mkdir ((a), 0700)
|
||||
#define grub_util_mkdir(a) mkdir ((a), 0755)
|
||||
|
||||
#if defined (__NetBSD__)
|
||||
/* NetBSD uses /boot for its boot block. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
If you checked out this source tree directly from GRUB Bazaar, you might
|
||||
be wondering where are the POT and PO files. Here are some instructions
|
||||
If you checked out this source tree directly from GRUB Git, you might be
|
||||
wondering where are the POT and PO files. Here are some instructions
|
||||
that will hopefully clarify the situation.
|
||||
|
||||
- If you're a user or a distributor, simply fill the po directory by
|
||||
@@ -16,7 +16,7 @@ that will hopefully clarify the situation.
|
||||
(http://translationproject.org/). The GRUB project doesn't interact
|
||||
with translators directly (but we dearly appreciate your work!).
|
||||
|
||||
- If you're a developer adding/removing/modifiing translatable strings,
|
||||
- If you're a developer adding/removing/modifying translatable strings,
|
||||
you can check that these turn into a sane POT file by using the
|
||||
`po/grub.pot' make rule.
|
||||
|
||||
|
||||
+7
-2
@@ -77,10 +77,15 @@
|
||||
grub_disk_addr_t
|
||||
grub_util_find_partition_start (const char *dev)
|
||||
{
|
||||
#if GRUB_UTIL_FD_STAT_IS_FUNCTIONAL
|
||||
struct stat st;
|
||||
grub_disk_addr_t partition_start;
|
||||
if (grub_util_device_is_mapped (dev)
|
||||
&& grub_util_get_dm_node_linear_info (dev, 0, 0, &partition_start))
|
||||
|
||||
if (stat (dev, &st) >= 0
|
||||
&& grub_util_device_is_mapped_stat (&st)
|
||||
&& grub_util_get_dm_node_linear_info (st.st_rdev, 0, 0, &partition_start))
|
||||
return partition_start;
|
||||
#endif
|
||||
|
||||
return grub_util_find_partition_start_os (dev);
|
||||
}
|
||||
|
||||
@@ -741,7 +741,7 @@ grub_install_copy_files (const char *src,
|
||||
"fs.lst", "partmap.lst",
|
||||
"parttool.lst",
|
||||
"video.lst", "crypto.lst",
|
||||
"terminal.lst" };
|
||||
"terminal.lst", "modinfo.sh" };
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE (pkglib_DATA); i++)
|
||||
|
||||
+8
-46
@@ -55,7 +55,6 @@ usage () {
|
||||
gettext "Generate a grub config file"; echo
|
||||
echo
|
||||
print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")"
|
||||
print_option_help "-r, --root-directory=$(gettext DIR)" "$(gettext "use DIR as root directory [default=/]")"
|
||||
print_option_help "-h, --help" "$(gettext "print this message and exit")"
|
||||
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
|
||||
echo
|
||||
@@ -73,8 +72,6 @@ argument () {
|
||||
echo $1
|
||||
}
|
||||
|
||||
GRUB_ROOT=
|
||||
|
||||
# Check the arguments.
|
||||
while test $# -gt 0
|
||||
do
|
||||
@@ -93,11 +90,6 @@ do
|
||||
--output=*)
|
||||
grub_cfg=`echo "$option" | sed 's/--output=//'`
|
||||
;;
|
||||
-r | --root-directory)
|
||||
GRUB_ROOT=`argument $option "$@"`; shift;;
|
||||
--root-directory=*)
|
||||
GRUB_ROOT=`echo "$option" | sed 's/--output=//'`
|
||||
;;
|
||||
-*)
|
||||
gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2
|
||||
usage
|
||||
@@ -137,19 +129,19 @@ else
|
||||
fi
|
||||
|
||||
# Device containing our userland. Typically used for root= parameter.
|
||||
GRUB_DEVICE="`${grub_probe} --target=device "$GRUB_ROOT"/`"
|
||||
GRUB_DEVICE="`${grub_probe} --target=device /`"
|
||||
GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
|
||||
|
||||
# Device containing our /boot partition. Usually the same as GRUB_DEVICE.
|
||||
GRUB_DEVICE_BOOT="`${grub_probe} --target=device "$GRUB_ROOT"/boot`"
|
||||
GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
|
||||
GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
|
||||
|
||||
# Filesystem for the device containing our userland. Used for stuff like
|
||||
# choosing Hurd filesystem module.
|
||||
GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
|
||||
|
||||
if [ x"$GRUB_FS" = x ] || [ x"$GRUB_FS" = xunknown ]; then
|
||||
GRUB_FS="$(stat -f --printf=%T "$GRUB_ROOT"/ || echo unknown)"
|
||||
if [ x"$GRUB_FS" = xunknown ]; then
|
||||
GRUB_FS="$(stat -f --printf=%T / || echo unknown)"
|
||||
fi
|
||||
|
||||
if test -f ${sysconfdir}/default/grub ; then
|
||||
@@ -186,7 +178,6 @@ if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub
|
||||
# These are defined in this script, export them here so that user can
|
||||
# override them.
|
||||
export GRUB_DEVICE \
|
||||
GRUB_ROOT \
|
||||
GRUB_DEVICE_UUID \
|
||||
GRUB_DEVICE_BOOT \
|
||||
GRUB_DEVICE_BOOT_UUID \
|
||||
@@ -256,45 +247,16 @@ EOF
|
||||
|
||||
for i in "${grub_mkconfig_dir}"/* ; do
|
||||
case "$i" in
|
||||
"${grub_mkconfig_dir}"/00_header \
|
||||
| "${grub_mkconfig_dir}"/30_os-prober \
|
||||
| "${grub_mkconfig_dir}"/40_custom \
|
||||
| "${grub_mkconfig_dir}"/41_custom)
|
||||
if test -x "$i" ; then
|
||||
echo
|
||||
echo "### BEGIN $i ###"
|
||||
"$i"
|
||||
echo "### END $i ###"
|
||||
fi
|
||||
;;
|
||||
# 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
|
||||
for platform in x86 i386-xen-pae x86_64-xen mips mipsel sparc64 powerpc ia64 arm; do
|
||||
GRUB_PLATFORM=$platform
|
||||
export GRUB_PLATFORM
|
||||
buf="$($i)"
|
||||
if [ x"$buf" != x ]; then
|
||||
echo
|
||||
echo "### BEGIN $i ($platform) ###"
|
||||
case x$platform in
|
||||
xx86)
|
||||
echo "if [ x\"\$grub_platform\" != xxen \\( x\"\$grub_cpu\" = xi386 -o x\"\$grub_cpu\" = xx86_64 -o x\"\$grub_platform\" = x \\) ]; then" ;;
|
||||
xi386-xen-pae)
|
||||
echo "if [ x\"\$grub_cpu-\$grub_platform\" = xi386-xen -o x\"\$grub_cpu-\$grub_platform\" = x ]; then" ;;
|
||||
xx86_64-xen)
|
||||
echo "if [ x\"\$grub_cpu-\$grub_platform\" = xx86_64-xen -o x\"\$grub_cpu-\$grub_platform\" = x ]; then" ;;
|
||||
*)
|
||||
echo "if [ x\"\$grub_cpu\" = x$platform -o x\"\$grub_platform\" = x ]; then" ;;
|
||||
esac
|
||||
echo "$buf"
|
||||
echo "fi"
|
||||
echo "### END $i ($platform) ###"
|
||||
fi
|
||||
done
|
||||
echo
|
||||
echo "### BEGIN $i ###"
|
||||
"$i"
|
||||
echo "### END $i ###"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
+26
-10
@@ -119,8 +119,22 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case ARGP_KEY_HELP_PRE_DOC:
|
||||
/* TRANSLATORS: it generates one single image which is bootable through any method. */
|
||||
return strdup (_("Make GRUB CD-ROM, disk, pendrive and floppy bootable image."));
|
||||
case ARGP_KEY_HELP_POST_DOC:
|
||||
return xasprintf (text, "xorriso -as mkisofs -help");
|
||||
{
|
||||
char *p1, *out;
|
||||
|
||||
p1 = xasprintf (_("Generates a bootable CD/USB/floppy image. Arguments other than options to this program"
|
||||
" are passed to xorriso, and indicate source files, source directories, or any of the "
|
||||
"mkisofs options listed by the output of `%s'."), "xorriso -as mkisofs -help");
|
||||
out = xasprintf ("%s\n\n%s\n\n%s", p1,
|
||||
_("Option -- switches to native xorriso command mode."),
|
||||
_("Mail xorriso support requests to <bug-xorriso@gnu.org>."));
|
||||
free (p1);
|
||||
return out;
|
||||
}
|
||||
default:
|
||||
return grub_install_help_filter (key, text, input);
|
||||
}
|
||||
@@ -214,14 +228,7 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
||||
|
||||
struct argp argp = {
|
||||
options, argp_parser, N_("[OPTION] SOURCE..."),
|
||||
/* TRANSLATORS: it generates one single image which is bootable through any method. */
|
||||
N_("Make GRUB CD-ROM, disk, pendrive and floppy bootable image.")"\v"
|
||||
N_("Generates a bootable CD/USB/floppy image. Arguments other than options to this program"
|
||||
" are passed to xorriso, and indicate source files, source directories, or any of the "
|
||||
"mkisofs options listed by the output of `%s'.\n\n"
|
||||
"Option -- switches to native xorriso command mode.\n\n"
|
||||
"Mail xorriso support requests to <bug-xorriso@gnu.org>."),
|
||||
NULL, help_filter, NULL
|
||||
NULL, NULL, help_filter, NULL
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -434,6 +441,9 @@ main (int argc, char *argv[])
|
||||
if (source_dirs[GRUB_INSTALL_PLATFORM_I386_PC]
|
||||
|| source_dirs[GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275]
|
||||
|| source_dirs[GRUB_INSTALL_PLATFORM_I386_EFI]
|
||||
|| source_dirs[GRUB_INSTALL_PLATFORM_IA64_EFI]
|
||||
|| source_dirs[GRUB_INSTALL_PLATFORM_ARM_EFI]
|
||||
|| source_dirs[GRUB_INSTALL_PLATFORM_ARM64_EFI]
|
||||
|| source_dirs[GRUB_INSTALL_PLATFORM_X86_64_EFI])
|
||||
system_area = SYS_AREA_COMMON;
|
||||
else if (source_dirs[GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275])
|
||||
@@ -629,7 +639,8 @@ main (int argc, char *argv[])
|
||||
if (source_dirs[GRUB_INSTALL_PLATFORM_I386_EFI]
|
||||
|| source_dirs[GRUB_INSTALL_PLATFORM_X86_64_EFI]
|
||||
|| source_dirs[GRUB_INSTALL_PLATFORM_IA64_EFI]
|
||||
|| source_dirs[GRUB_INSTALL_PLATFORM_ARM_EFI])
|
||||
|| source_dirs[GRUB_INSTALL_PLATFORM_ARM_EFI]
|
||||
|| source_dirs[GRUB_INSTALL_PLATFORM_ARM64_EFI])
|
||||
{
|
||||
char *efidir = grub_util_make_temporary_dir ();
|
||||
char *efidir_efi = grub_util_path_concat (2, efidir, "efi");
|
||||
@@ -652,6 +663,11 @@ main (int argc, char *argv[])
|
||||
make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_ARM_EFI, "arm-efi", imgname);
|
||||
free (imgname);
|
||||
|
||||
imgname = grub_util_path_concat (2, efidir_efi_boot, "bootaarch64.efi");
|
||||
make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_ARM64_EFI, "arm64-efi",
|
||||
imgname);
|
||||
free (imgname);
|
||||
|
||||
if (source_dirs[GRUB_INSTALL_PLATFORM_I386_EFI])
|
||||
{
|
||||
imgname = grub_util_path_concat (2, efidir_efi_boot, "boot.efi");
|
||||
|
||||
+124
-155
@@ -21,7 +21,6 @@
|
||||
#include <grub/util/install.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/emu/config.h>
|
||||
#include <grub/greffs.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -35,6 +34,7 @@ static char *output_image;
|
||||
static char **files;
|
||||
static int nfiles;
|
||||
const struct grub_install_image_target_desc *format;
|
||||
static FILE *memdisk;
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -116,56 +116,91 @@ struct argp argp = {
|
||||
NULL, help_filter, NULL
|
||||
};
|
||||
|
||||
struct file_desc
|
||||
/* tar support */
|
||||
#define MAGIC "ustar"
|
||||
struct head
|
||||
{
|
||||
char *name;
|
||||
char *source;
|
||||
grub_size_t size;
|
||||
grub_size_t mtime;
|
||||
};
|
||||
static struct file_desc *file_descs;
|
||||
static size_t n_file_descs, alloc_file_descs;
|
||||
char name[100];
|
||||
char mode[8];
|
||||
char uid[8];
|
||||
char gid[8];
|
||||
char size[12];
|
||||
char mtime[12];
|
||||
char chksum[8];
|
||||
char typeflag;
|
||||
char linkname[100];
|
||||
char magic[6];
|
||||
char version[2];
|
||||
char uname[32];
|
||||
char gname[32];
|
||||
char devmajor[8];
|
||||
char devminor[8];
|
||||
char prefix[155];
|
||||
char pad[12];
|
||||
} GRUB_PACKED;
|
||||
|
||||
static inline void
|
||||
canonicalize (char *name)
|
||||
static void
|
||||
write_zeros (unsigned rsz)
|
||||
{
|
||||
char *iptr, *optr;
|
||||
for (iptr = name, optr = name; *iptr; )
|
||||
{
|
||||
while (*iptr == '/')
|
||||
iptr++;
|
||||
if (iptr[0] == '.' && (iptr[1] == '/' || iptr[1] == 0))
|
||||
{
|
||||
iptr += 2;
|
||||
continue;
|
||||
}
|
||||
if (iptr[0] == '.' && iptr[1] == '.' && (iptr[2] == '/' || iptr[2] == 0))
|
||||
{
|
||||
iptr += 3;
|
||||
if (optr == name)
|
||||
continue;
|
||||
for (optr -= 2; optr >= name && *optr != '/'; optr--);
|
||||
optr++;
|
||||
continue;
|
||||
}
|
||||
while (*iptr && *iptr != '/')
|
||||
*optr++ = *iptr++;
|
||||
if (*iptr)
|
||||
*optr++ = *iptr++;
|
||||
}
|
||||
*optr = 0;
|
||||
char buf[512];
|
||||
|
||||
memset (buf, 0, 512);
|
||||
fwrite (buf, 1, rsz, memdisk);
|
||||
}
|
||||
|
||||
static void
|
||||
write_pad (unsigned sz)
|
||||
{
|
||||
write_zeros ((~sz + 1) & 511);
|
||||
}
|
||||
|
||||
static void
|
||||
set_tar_value (char *field, grub_uint32_t val,
|
||||
unsigned len)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < len - 1; i++)
|
||||
field[len - 2 - i] = '0' + ((val >> (3 * i)) & 7);
|
||||
}
|
||||
|
||||
static void
|
||||
compute_checksum (struct head *hd)
|
||||
{
|
||||
unsigned int chk = 0;
|
||||
unsigned char *ptr;
|
||||
memset (hd->chksum, ' ', 8);
|
||||
for (ptr = (unsigned char *) hd; ptr < (unsigned char *) (hd + 1); ptr++)
|
||||
chk += *ptr;
|
||||
set_tar_value (hd->chksum, chk, 8);
|
||||
}
|
||||
|
||||
static void
|
||||
add_tar_file (const char *from,
|
||||
const char *to)
|
||||
{
|
||||
char *tcn;
|
||||
const char *iptr;
|
||||
char *optr;
|
||||
struct head hd;
|
||||
grub_util_fd_t in;
|
||||
size_t idx;
|
||||
ssize_t r;
|
||||
grub_uint32_t mtime = 0;
|
||||
grub_uint32_t size;
|
||||
|
||||
COMPILE_TIME_ASSERT (sizeof (hd) == 512);
|
||||
|
||||
if (grub_util_is_special_file (from))
|
||||
return;
|
||||
|
||||
mtime = grub_util_get_mtime (from);
|
||||
|
||||
optr = tcn = xmalloc (strlen (to) + 1);
|
||||
for (iptr = to; *iptr == '/'; iptr++);
|
||||
for (; *iptr; iptr++)
|
||||
if (!(iptr[0] == '/' && iptr[1] == '/'))
|
||||
*optr++ = *iptr;
|
||||
*optr = '\0';
|
||||
|
||||
if (grub_util_is_directory (from))
|
||||
{
|
||||
grub_util_fd_dir_t d;
|
||||
@@ -186,138 +221,69 @@ add_tar_file (const char *from,
|
||||
free (fp);
|
||||
}
|
||||
grub_util_fd_closedir (d);
|
||||
free (tcn);
|
||||
return;
|
||||
}
|
||||
|
||||
idx = n_file_descs++;
|
||||
if (idx >= alloc_file_descs)
|
||||
if (optr - tcn > 99)
|
||||
{
|
||||
alloc_file_descs = 2 * n_file_descs;
|
||||
file_descs = xrealloc (file_descs, alloc_file_descs
|
||||
* sizeof (file_descs[0]));
|
||||
memset (&hd, 0, sizeof (hd));
|
||||
memcpy (hd.name, tcn, 99);
|
||||
memcpy (hd.mode, "0000600", 7);
|
||||
memcpy (hd.uid, "0001750", 7);
|
||||
memcpy (hd.gid, "0001750", 7);
|
||||
|
||||
set_tar_value (hd.size, optr - tcn, 12);
|
||||
set_tar_value (hd.mtime, mtime, 12);
|
||||
hd.typeflag = 'L';
|
||||
memcpy (hd.magic, "ustar ", 7);
|
||||
memcpy (hd.uname, "grub", 4);
|
||||
memcpy (hd.gname, "grub", 4);
|
||||
|
||||
compute_checksum (&hd);
|
||||
|
||||
fwrite (&hd, 1, sizeof (hd), memdisk);
|
||||
fwrite (tcn, 1, optr - tcn, memdisk);
|
||||
|
||||
write_pad (optr - tcn);
|
||||
}
|
||||
|
||||
in = grub_util_fd_open (from, GRUB_UTIL_FD_O_RDONLY);
|
||||
if (!GRUB_UTIL_FD_IS_VALID (in))
|
||||
grub_util_error (_("cannot open `%s': %s"), from, grub_util_fd_strerror ());
|
||||
|
||||
file_descs[idx].name = xstrdup (to);
|
||||
file_descs[idx].source = xstrdup (from);
|
||||
canonicalize (file_descs[idx].name);
|
||||
file_descs[idx].mtime = grub_util_get_mtime (from);
|
||||
file_descs[idx].size = grub_util_get_fd_size (in, from, NULL);
|
||||
|
||||
grub_util_fd_close (in);
|
||||
}
|
||||
|
||||
static int
|
||||
filecmp (const void *p1, const void *p2)
|
||||
{
|
||||
const struct file_desc *a = p1, *b = p2;
|
||||
|
||||
/* Don't use strcmp, it's buggy on some systems. */
|
||||
return grub_strcmp (a->name, b->name);
|
||||
}
|
||||
|
||||
static void
|
||||
write_memdisk (char *memdisk_img)
|
||||
{
|
||||
FILE *memdisk;
|
||||
struct grub_greffs_header head;
|
||||
struct grub_greffs_inode inode;
|
||||
size_t total_strlen = 0, i;
|
||||
size_t name_pad = 0;
|
||||
grub_uint32_t file_offset;
|
||||
|
||||
qsort (file_descs, n_file_descs, sizeof (file_descs[0]), filecmp);
|
||||
|
||||
for (i = 0; i < n_file_descs; i++)
|
||||
total_strlen += grub_strlen (file_descs[i].name);
|
||||
name_pad = ALIGN_UP (total_strlen, 4) - total_strlen;
|
||||
total_strlen += name_pad;
|
||||
|
||||
grub_memcpy (head.magic, GRUB_GREFFS_MAGIC, sizeof (head.magic));
|
||||
head.nfiles = grub_cpu_to_le32 (n_file_descs);
|
||||
head.inodes_offset = grub_cpu_to_le32 (sizeof (head)
|
||||
+ sizeof (grub_uint32_t)
|
||||
* (n_file_descs + 1));
|
||||
head.string_ptrs_offset = grub_cpu_to_le32 (sizeof (head));
|
||||
|
||||
memdisk = grub_util_fopen (memdisk_img, "wb");
|
||||
if (!memdisk)
|
||||
grub_util_error (_("Can't create file: %s"), strerror (errno));
|
||||
|
||||
fwrite (&head, 1, sizeof (head), memdisk);
|
||||
|
||||
grub_uint32_t curname = sizeof (head) + sizeof (grub_uint32_t)
|
||||
* (n_file_descs + 1) + sizeof (inode) * n_file_descs;
|
||||
for (i = 0; i <= n_file_descs; i++)
|
||||
{
|
||||
grub_uint32_t curname_le = grub_cpu_to_le32 (curname);
|
||||
fwrite (&curname_le, 1, sizeof (curname_le), memdisk);
|
||||
if (i != n_file_descs)
|
||||
curname += grub_strlen (file_descs[i].name);
|
||||
}
|
||||
|
||||
file_offset = sizeof (head) + sizeof (grub_uint32_t)
|
||||
* (n_file_descs + 1) + sizeof (inode) * n_file_descs + total_strlen;
|
||||
for (i = 0; i < n_file_descs; i++)
|
||||
{
|
||||
inode.start = grub_cpu_to_le32 (file_offset);
|
||||
inode.size = grub_cpu_to_le32 (file_descs[i].size);
|
||||
inode.mtime = grub_cpu_to_le32 (file_descs[i].mtime);
|
||||
inode.type = 0;
|
||||
fwrite (&inode, 1, sizeof (inode), memdisk);
|
||||
file_offset += file_descs[i].size;
|
||||
}
|
||||
|
||||
for (i = 0; i < n_file_descs; i++)
|
||||
fwrite (file_descs[i].name, 1, grub_strlen (file_descs[i].name), memdisk);
|
||||
|
||||
if (!grub_install_copy_buffer)
|
||||
grub_install_copy_buffer = xmalloc (GRUB_INSTALL_COPY_BUFFER_SIZE);
|
||||
|
||||
grub_memset (grub_install_copy_buffer, 0, 4);
|
||||
fwrite (grub_install_copy_buffer, 1, name_pad, memdisk);
|
||||
size = grub_util_get_fd_size (in, from, NULL);
|
||||
|
||||
for (i = 0; i < n_file_descs; i++)
|
||||
{
|
||||
grub_util_fd_t in;
|
||||
size_t remaining = file_descs[i].size;
|
||||
in = grub_util_fd_open (file_descs[i].source, GRUB_UTIL_FD_O_RDONLY);
|
||||
if (!GRUB_UTIL_FD_IS_VALID (in))
|
||||
grub_util_error (_("cannot open `%s': %s"),
|
||||
file_descs[i].source, grub_util_fd_strerror ());
|
||||
memset (&hd, 0, sizeof (hd));
|
||||
memcpy (hd.name, tcn, optr - tcn < 99 ? optr - tcn : 99);
|
||||
memcpy (hd.mode, "0000600", 7);
|
||||
memcpy (hd.uid, "0001750", 7);
|
||||
memcpy (hd.gid, "0001750", 7);
|
||||
|
||||
set_tar_value (hd.size, size, 12);
|
||||
set_tar_value (hd.mtime, mtime, 12);
|
||||
hd.typeflag = '0';
|
||||
memcpy (hd.magic, "ustar ", 7);
|
||||
memcpy (hd.uname, "grub", 4);
|
||||
memcpy (hd.gname, "grub", 4);
|
||||
|
||||
compute_checksum (&hd);
|
||||
|
||||
fwrite (&hd, 1, sizeof (hd), memdisk);
|
||||
|
||||
while (remaining)
|
||||
{
|
||||
size_t toread = remaining;
|
||||
ssize_t r;
|
||||
if (remaining > GRUB_INSTALL_COPY_BUFFER_SIZE)
|
||||
toread = GRUB_INSTALL_COPY_BUFFER_SIZE;
|
||||
r = grub_util_fd_read (in, grub_install_copy_buffer, toread);
|
||||
if (r <= 0)
|
||||
break;
|
||||
fwrite (grub_install_copy_buffer, 1, r, memdisk);
|
||||
if (r >= remaining)
|
||||
remaining = 0;
|
||||
else
|
||||
remaining -= r;
|
||||
}
|
||||
grub_util_fd_close (in);
|
||||
|
||||
grub_memset (grub_install_copy_buffer, 0, GRUB_INSTALL_COPY_BUFFER_SIZE);
|
||||
while (remaining)
|
||||
{
|
||||
size_t toread = remaining;
|
||||
if (remaining > GRUB_INSTALL_COPY_BUFFER_SIZE)
|
||||
toread = GRUB_INSTALL_COPY_BUFFER_SIZE;
|
||||
fwrite (grub_install_copy_buffer, 1, toread, memdisk);
|
||||
remaining -= toread;
|
||||
}
|
||||
while (1)
|
||||
{
|
||||
r = grub_util_fd_read (in, grub_install_copy_buffer, GRUB_INSTALL_COPY_BUFFER_SIZE);
|
||||
if (r <= 0)
|
||||
break;
|
||||
fwrite (grub_install_copy_buffer, 1, r, memdisk);
|
||||
}
|
||||
grub_util_fd_close (in);
|
||||
|
||||
fclose (memdisk);
|
||||
write_pad (size);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -353,6 +319,8 @@ main (int argc, char *argv[])
|
||||
|
||||
char *memdisk_img = grub_util_make_temporary_file ();
|
||||
|
||||
memdisk = grub_util_fopen (memdisk_img, "wb");
|
||||
|
||||
add_tar_file (memdisk_dir, "");
|
||||
for (i = 0; i < nfiles; i++)
|
||||
{
|
||||
@@ -373,12 +341,14 @@ main (int argc, char *argv[])
|
||||
to++;
|
||||
add_tar_file (from, to);
|
||||
}
|
||||
write_zeros (512);
|
||||
|
||||
fclose (memdisk);
|
||||
|
||||
write_memdisk (memdisk_img);
|
||||
grub_util_unlink_recursive (memdisk_dir);
|
||||
|
||||
grub_install_push_module ("memdisk");
|
||||
grub_install_push_module ("greffs");
|
||||
grub_install_push_module ("tar");
|
||||
|
||||
grub_install_make_image_wrap (grub_install_source_directory,
|
||||
"(memdisk)/boot/grub", output_image,
|
||||
@@ -386,6 +356,5 @@ main (int argc, char *argv[])
|
||||
grub_util_get_target_name (format), 0);
|
||||
|
||||
grub_util_unlink (memdisk_img);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+72
-42
@@ -77,9 +77,58 @@ enum {
|
||||
PRINT_DISK
|
||||
};
|
||||
|
||||
static const char *targets[] =
|
||||
{
|
||||
[PRINT_FS] = "fs",
|
||||
[PRINT_FS_UUID] = "fs_uuid",
|
||||
[PRINT_FS_LABEL] = "fs_label",
|
||||
[PRINT_DRIVE] = "drive",
|
||||
[PRINT_DEVICE] = "device",
|
||||
[PRINT_PARTMAP] = "partmap",
|
||||
[PRINT_ABSTRACTION] = "abstraction",
|
||||
[PRINT_CRYPTODISK_UUID] = "cryptodisk_uuid",
|
||||
[PRINT_HINT_STR] = "hints_string",
|
||||
[PRINT_BIOS_HINT] = "bios_hints",
|
||||
[PRINT_IEEE1275_HINT] = "ieee1275_hints",
|
||||
[PRINT_BAREMETAL_HINT] = "baremetal_hints",
|
||||
[PRINT_EFI_HINT] = "efi_hints",
|
||||
[PRINT_ARC_HINT] = "arc_hints",
|
||||
[PRINT_COMPATIBILITY_HINT] = "compatibility_hint",
|
||||
[PRINT_MSDOS_PARTTYPE] = "msdos_parttype",
|
||||
[PRINT_GPT_PARTTYPE] = "gpt_parttype",
|
||||
[PRINT_ZERO_CHECK] = "zero_check",
|
||||
[PRINT_DISK] = "disk",
|
||||
};
|
||||
|
||||
static int print = PRINT_FS;
|
||||
static unsigned int argument_is_device = 0;
|
||||
|
||||
static char *
|
||||
get_targets_string (void)
|
||||
{
|
||||
char **arr = xmalloc (sizeof (targets));
|
||||
int len = 0;
|
||||
char *str;
|
||||
char *ptr;
|
||||
unsigned i;
|
||||
|
||||
memcpy (arr, targets, sizeof (targets));
|
||||
qsort (arr, ARRAY_SIZE (targets), sizeof (char *), grub_qsort_strcmp);
|
||||
for (i = 0; i < ARRAY_SIZE (targets); i++)
|
||||
len += grub_strlen (targets[i]) + 2;
|
||||
ptr = str = xmalloc (len);
|
||||
for (i = 0; i < ARRAY_SIZE (targets); i++)
|
||||
{
|
||||
ptr = grub_stpcpy (ptr, arr[i]);
|
||||
*ptr++ = ',';
|
||||
*ptr++ = ' ';
|
||||
}
|
||||
ptr[-2] = '\0';
|
||||
free (arr);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static void
|
||||
do_print (const char *x)
|
||||
{
|
||||
@@ -660,8 +709,7 @@ static struct argp_option options[] = {
|
||||
N_("given argument is a system device, not a path"), 0},
|
||||
{"device-map", 'm', N_("FILE"), 0,
|
||||
N_("use FILE as the device map [default=%s]"), 0},
|
||||
{"target", 't', "(fs|fs_uuid|fs_label|drive|device|partmap|abstraction|cryptodisk_uuid|msdos_parttype)", 0,
|
||||
N_("print filesystem module, GRUB drive, system device, partition map module, abstraction module or cryptographic container UUID [default=fs]"), 0},
|
||||
{"target", 't', N_("TARGET"), 0, 0, 0},
|
||||
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
|
||||
{ 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
@@ -676,6 +724,16 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
|
||||
case 'm':
|
||||
return xasprintf (text, DEFAULT_DEVICE_MAP);
|
||||
|
||||
case 't':
|
||||
{
|
||||
char *ret, *t = get_targets_string ();
|
||||
|
||||
ret = xasprintf ("%s\n%s %s [default=%s]", _("print TARGET"),
|
||||
_("available targets:"), t, targets[print]);
|
||||
free (t);
|
||||
return ret;
|
||||
}
|
||||
|
||||
default:
|
||||
return (char *) text;
|
||||
}
|
||||
@@ -713,46 +771,18 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
||||
break;
|
||||
|
||||
case 't':
|
||||
if (!strcmp (arg, "fs"))
|
||||
print = PRINT_FS;
|
||||
else if (!strcmp (arg, "fs_uuid"))
|
||||
print = PRINT_FS_UUID;
|
||||
else if (!strcmp (arg, "fs_label"))
|
||||
print = PRINT_FS_LABEL;
|
||||
else if (!strcmp (arg, "drive"))
|
||||
print = PRINT_DRIVE;
|
||||
else if (!strcmp (arg, "device"))
|
||||
print = PRINT_DEVICE;
|
||||
else if (!strcmp (arg, "partmap"))
|
||||
print = PRINT_PARTMAP;
|
||||
else if (!strcmp (arg, "abstraction"))
|
||||
print = PRINT_ABSTRACTION;
|
||||
else if (!strcmp (arg, "cryptodisk_uuid"))
|
||||
print = PRINT_CRYPTODISK_UUID;
|
||||
else if (!strcmp (arg, "msdos_parttype"))
|
||||
print = PRINT_MSDOS_PARTTYPE;
|
||||
else if (!strcmp (arg, "gpt_parttype"))
|
||||
print = PRINT_GPT_PARTTYPE;
|
||||
else if (!strcmp (arg, "hints_string"))
|
||||
print = PRINT_HINT_STR;
|
||||
else if (!strcmp (arg, "bios_hints"))
|
||||
print = PRINT_BIOS_HINT;
|
||||
else if (!strcmp (arg, "ieee1275_hints"))
|
||||
print = PRINT_IEEE1275_HINT;
|
||||
else if (!strcmp (arg, "baremetal_hints"))
|
||||
print = PRINT_BAREMETAL_HINT;
|
||||
else if (!strcmp (arg, "efi_hints"))
|
||||
print = PRINT_EFI_HINT;
|
||||
else if (!strcmp (arg, "arc_hints"))
|
||||
print = PRINT_ARC_HINT;
|
||||
else if (!strcmp (arg, "compatibility_hint"))
|
||||
print = PRINT_COMPATIBILITY_HINT;
|
||||
else if (strcmp (arg, "zero_check") == 0)
|
||||
print = PRINT_ZERO_CHECK;
|
||||
else if (!strcmp (arg, "disk"))
|
||||
print = PRINT_DISK;
|
||||
else
|
||||
argp_usage (state);
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = PRINT_FS; i < ARRAY_SIZE (targets); i++)
|
||||
if (strcmp (arg, targets[i]) == 0)
|
||||
{
|
||||
print = i;
|
||||
break;
|
||||
}
|
||||
if (i == ARRAY_SIZE (targets))
|
||||
argp_usage (state);
|
||||
}
|
||||
break;
|
||||
|
||||
case '0':
|
||||
|
||||
+31
-29
@@ -152,7 +152,7 @@ if [ "x$gfxterm" = x1 ]; then
|
||||
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT}"` ; then
|
||||
EOF
|
||||
else
|
||||
for dir in "${pkgdatadir}" "`echo "$GRUB_ROOT"'/@bootdirname@/@grubdirname@' | sed "s,//*,/,g"`" "`echo "$GRUB_ROOT"'/usr/share/grub' | sed "s,//*,/,g"`" ; do
|
||||
for dir in "${pkgdatadir}" "`echo '/@bootdirname@/@grubdirname@' | sed "s,//*,/,g"`" /usr/share/grub ; do
|
||||
for basename in unicode unifont ascii; do
|
||||
path="${dir}/${basename}.pf2"
|
||||
if is_path_readable_by_grub "${path}" > /dev/null ; then
|
||||
@@ -282,48 +282,50 @@ fi
|
||||
|
||||
make_timeout ()
|
||||
{
|
||||
if [ "x${1}${3}" != "x" ] ; then
|
||||
if [ "x${3}" != "x" ] ; then
|
||||
timeout="${2}"
|
||||
style="${3}"
|
||||
else
|
||||
# Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
|
||||
timeout="${1}"
|
||||
if [ "x${2}" != "x0" ] ; then
|
||||
grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
|
||||
fi
|
||||
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
|
||||
style="hidden"
|
||||
else
|
||||
style="countdown"
|
||||
fi
|
||||
if [ "x${3}" != "x" ] ; then
|
||||
timeout="${2}"
|
||||
style="${3}"
|
||||
elif [ "x${1}" != "x" -a "x${1}" != "x0" ] ; then
|
||||
# Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
|
||||
timeout="${1}"
|
||||
if [ "x${2}" != "x0" ] ; then
|
||||
grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
|
||||
fi
|
||||
if [ "x${style}" = "xcountdown" ] ; then
|
||||
verbose=" --verbose"
|
||||
else
|
||||
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
|
||||
style="hidden"
|
||||
verbose=
|
||||
else
|
||||
style="countdown"
|
||||
verbose=" --verbose"
|
||||
fi
|
||||
cat << EOF
|
||||
else
|
||||
# No hidden timeout, so treat as GRUB_TIMEOUT_STYLE=menu
|
||||
timeout="${2}"
|
||||
style="menu"
|
||||
fi
|
||||
cat << EOF
|
||||
if [ x\$feature_timeout_style = xy ] ; then
|
||||
set timeout_style=${style}
|
||||
set timeout=${timeout}
|
||||
EOF
|
||||
if [ "x${style}" != "xmenu" ] ; then
|
||||
cat << EOF
|
||||
if [ "x${style}" = "xmenu" ] ; then
|
||||
cat << EOF
|
||||
# Fallback normal timeout code in case the timeout_style feature is
|
||||
# unavailable.
|
||||
else
|
||||
set timeout=${timeout}
|
||||
EOF
|
||||
else
|
||||
cat << EOF
|
||||
# Fallback hidden-timeout code in case the timeout_style feature is
|
||||
# unavailable.
|
||||
elif sleep${verbose} --interruptible ${timeout} ; then
|
||||
set timeout=0
|
||||
EOF
|
||||
fi
|
||||
cat << EOF
|
||||
fi
|
||||
cat << EOF
|
||||
fi
|
||||
EOF
|
||||
else
|
||||
cat << EOF
|
||||
set timeout=${2}
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
|
||||
|
||||
+8
-18
@@ -21,16 +21,6 @@ prefix="@prefix@"
|
||||
exec_prefix="@exec_prefix@"
|
||||
datarootdir="@datarootdir@"
|
||||
|
||||
if [ x$GRUB_PLATFORM = xx86 ]; then
|
||||
check=--is-x86-multiboot
|
||||
elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
|
||||
check=--is-i386-xen-pae-domu
|
||||
elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
|
||||
check=--is-x86_64-xen-domu
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
export TEXTDOMAIN=@PACKAGE@
|
||||
export TEXTDOMAINDIR="@localedir@"
|
||||
|
||||
@@ -50,11 +40,11 @@ all_of_them=true
|
||||
|
||||
# FIXME: add l4 here?
|
||||
kernel=
|
||||
for i in "$GRUB_ROOT"/boot/gnumach* ; do
|
||||
if test -f "$i" && "${grub_file}" $check "$i" ; then
|
||||
basename=`basename "$i"`
|
||||
dirname=`dirname "$i"`
|
||||
rel_dirname=`make_system_path_relative_to_its_root "$dirname"`
|
||||
for i in /boot/gnumach* ; do
|
||||
if test -e $i ; then
|
||||
basename=`basename $i`
|
||||
dirname=`dirname $i`
|
||||
rel_dirname=`make_system_path_relative_to_its_root $dirname`
|
||||
gettext_printf "Found GNU Mach: %s" "$i" >&2
|
||||
echo >&2
|
||||
kernels="${kernels} ${rel_dirname}/${basename}"
|
||||
@@ -68,8 +58,8 @@ case "${GRUB_FS}" in
|
||||
*) hurd_fs="${GRUB_FS}fs" ;;
|
||||
esac
|
||||
|
||||
for i in "$GRUB_ROOT"/hurd/${hurd_fs}.static "$GRUB_ROOT"/hurd/exec ; do
|
||||
if test -f "$i" ; then
|
||||
for i in /hurd/${hurd_fs}.static /hurd/exec ; do
|
||||
if test -e "$i" ; then
|
||||
gettext_printf "Found Hurd module: %s" "$i" >&2
|
||||
echo >&2
|
||||
at_least_one=true
|
||||
@@ -83,7 +73,7 @@ if ${at_least_one} ; then : ; else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ${all_of_them} && test -f "$GRUB_ROOT"/lib/ld.so.1 ; then : ; else
|
||||
if ${all_of_them} && test -e /lib/ld.so.1 ; then : ; else
|
||||
gettext "Some Hurd stuff found, but not enough to boot." >&2
|
||||
echo >&2
|
||||
exit 1
|
||||
|
||||
@@ -27,21 +27,6 @@ export TEXTDOMAINDIR="@localedir@"
|
||||
|
||||
CLASS="--class os"
|
||||
|
||||
if [ x$GRUB_PLATFORM = xx86 ]; then
|
||||
check=--is-x86-multiboot
|
||||
elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
|
||||
check=--is-i386-xen-pae-domu
|
||||
elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
|
||||
check=--is-x86_64-xen-domu
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! test -f "$GRUB_ROOT"/platform/i86pc/kernel || ! "${grub_file}" $check "$GRUB_ROOT"/platform/i86pc/kernel; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
case "${GRUB_DISTRIBUTOR}" in
|
||||
*)
|
||||
OS="Illumos"
|
||||
@@ -60,7 +45,7 @@ message="$(gettext_printf "Loading kernel of Illumos ...")"
|
||||
else
|
||||
ISADIR=
|
||||
fi
|
||||
zfs-bootfs $($grub_mkrelpath "$GRUB_ROOT"/) ZFS_BOOTFS
|
||||
zfs-bootfs $($grub_mkrelpath /) ZFS_BOOTFS
|
||||
echo '$(echo "$message" | grub_quote)'
|
||||
multiboot $($grub_mkrelpath /platform/i86pc/kernel)/\$ISADIR/unix /platform/i86pc/kernel/\$ISADIR/unix -B \$ZFS_BOOTFS,console=text
|
||||
module $($grub_mkrelpath /platform/i86pc)/\$ISADIR/boot_archive /platform/i86pc/\$ISADIR/boot_archive
|
||||
|
||||
+10
-20
@@ -27,16 +27,6 @@ export TEXTDOMAINDIR="@localedir@"
|
||||
|
||||
CLASS="--class os"
|
||||
|
||||
if [ x$GRUB_PLATFORM = xx86 ]; then
|
||||
check=--is-x86-kfreebsd
|
||||
elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
|
||||
check=--is-i386-xen-pae-domu
|
||||
elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
|
||||
check=--is-x86_64-xen-domu
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case "${GRUB_DISTRIBUTOR}" in
|
||||
Debian)
|
||||
OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD"
|
||||
@@ -132,10 +122,10 @@ EOF
|
||||
zfs)
|
||||
load_kfreebsd_module opensolaris false
|
||||
|
||||
ls "$GRUB_ROOT/boot/zfs/zpool.cache" > /dev/null
|
||||
ls "/boot/zfs/zpool.cache" > /dev/null
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
sed "s/^/$submenu_indentation/" << EOF
|
||||
kfreebsd_module $(make_system_path_relative_to_its_root $GRUB_ROOT/boot)/zfs/zpool.cache type=/boot/zfs/zpool.cache
|
||||
kfreebsd_module $(make_system_path_relative_to_its_root /boot)/zfs/zpool.cache type=/boot/zfs/zpool.cache
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
@@ -153,8 +143,8 @@ EOF
|
||||
EOF
|
||||
}
|
||||
|
||||
list=`for i in $GRUB_ROOT/boot/kfreebsd-* $GRUB_ROOT/boot/kernel/kernel ; do
|
||||
if grub_file_is_not_garbage "$i" && ${grub_file} $check "$i"; then echo -n "$i " ; fi
|
||||
list=`for i in /boot/kfreebsd-* /boot/kernel/kernel ; do
|
||||
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
|
||||
done`
|
||||
prepare_boot_cache=
|
||||
boot_device_id=
|
||||
@@ -173,8 +163,8 @@ while [ "x$list" != "x" ] ; do
|
||||
dirname=`dirname $kfreebsd`
|
||||
rel_dirname=`make_system_path_relative_to_its_root $dirname`
|
||||
|
||||
if [ -f "$GRUB_ROOT"/boot/device.hints ] ; then
|
||||
devices="$GRUB_ROOT"/boot/device.hints
|
||||
if [ -f /boot/device.hints ] ; then
|
||||
devices=/boot/device.hints
|
||||
devices_basename=`basename $devices`
|
||||
devices_dirname=`dirname $devices`
|
||||
devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname`
|
||||
@@ -191,14 +181,14 @@ while [ "x$list" != "x" ] ; do
|
||||
# zpool name
|
||||
kfreebsd_device=$(${grub_probe} -t fs_label --device ${GRUB_DEVICE})
|
||||
# filesystem name (empty string for the main filesystem)
|
||||
kfreebsd_device="${kfreebsd_device}$(${grub_mkrelpath} "$GRUB_ROOT"/ | sed -e "s,/*@$,,")"
|
||||
kfreebsd_device="${kfreebsd_device}$(${grub_mkrelpath} / | sed -e "s,/*@$,,")"
|
||||
;;
|
||||
*)
|
||||
kfreebsd_device=${kfreebsd_fs}id/${GRUB_DEVICE_UUID}
|
||||
# Debian GNU/kFreeBSD can't remount root if it's supplied as UUID but
|
||||
# as an UUID
|
||||
if [ "x${GRUB_DISTRIBUTOR}" = "xDebian" ] \
|
||||
&& ! (cat "$GRUB_ROOT"/etc/fstab | awk '!/^[[:space:]]*#/ && $2=="/" { print $1; }' \
|
||||
&& ! (cat /etc/fstab | awk '!/^[[:space:]]*#/ && $2=="/" { print $1; }' \
|
||||
| grep "${kfreebsd_fs}id/${GRUB_DEVICE_UUID}" > /dev/null); then
|
||||
kfreebsd_device=${GRUB_DEVICE}
|
||||
fi
|
||||
@@ -209,8 +199,8 @@ while [ "x$list" != "x" ] ; do
|
||||
alt_version=`echo $version | sed -e "s,\.old$,,g"`
|
||||
|
||||
module_dir=
|
||||
for i in "$GRUB_ROOT/lib/modules/${version}" "$GRUB_ROOT/lib/modules/${alt_version}" \
|
||||
"$GRUB_ROOT/boot/kernel"; do
|
||||
for i in "/lib/modules/${version}" "/lib/modules/${alt_version}" \
|
||||
"/boot/kernel"; do
|
||||
if test -e "$i" ; then
|
||||
module_dir="$i"
|
||||
break
|
||||
|
||||
+19
-32
@@ -26,31 +26,6 @@ datarootdir="@datarootdir@"
|
||||
export TEXTDOMAIN=@PACKAGE@
|
||||
export TEXTDOMAINDIR="@localedir@"
|
||||
|
||||
if [ x$GRUB_PLATFORM = xx86 ]; then
|
||||
check=--is-x86-linux32
|
||||
elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
|
||||
check=--is-i386-xen-pae-domu
|
||||
elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
|
||||
check=--is-x86_64-xen-domu
|
||||
else
|
||||
check=--is-${GRUB_PLATFORM}-linux
|
||||
fi
|
||||
|
||||
case "x$GRUB_PLATFORM" in
|
||||
xx86)
|
||||
list=`for i in "$GRUB_ROOT"/boot/vmlinuz-* "$GRUB_ROOT"/vmlinuz-* "$GRUB_ROOT"/boot/kernel-* ; do
|
||||
if grub_file_is_not_garbage "$i" && "${grub_file}" $check "$i" ; then echo -n "$i " ; fi
|
||||
done` ;;
|
||||
*)
|
||||
list=`for i in "$GRUB_ROOT"/boot/vmlinuz-* "$GRUB_ROOT"/boot/vmlinux-* "$GRUB_ROOT"/vmlinuz-* "$GRUB_ROOT"/vmlinux-* "$GRUB_ROOT"/boot/kernel-* ; do
|
||||
if grub_file_is_not_garbage "$i" && "${grub_file}" $check "$i" ; then echo -n "$i " ; fi
|
||||
done` ;;
|
||||
esac
|
||||
|
||||
if [ x"$list" = x ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CLASS="--class gnu-linux --class gnu --class os"
|
||||
|
||||
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
||||
@@ -78,14 +53,14 @@ fi
|
||||
|
||||
case x"$GRUB_FS" in
|
||||
xbtrfs)
|
||||
rootsubvol="`make_system_path_relative_to_its_root "$GRUB_ROOT"/`"
|
||||
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;;
|
||||
xzfs)
|
||||
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
|
||||
bootfs="`make_system_path_relative_to_its_root "$GRUB_ROOT"/ | sed -e "s,@$,,"`"
|
||||
bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
|
||||
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
|
||||
;;
|
||||
esac
|
||||
@@ -140,7 +115,7 @@ linux_entry ()
|
||||
|
||||
echo " insmod gzio" | sed "s/^/$submenu_indentation/"
|
||||
|
||||
if [ x$dirname = x"$GRUB_ROOT"/ ]; then
|
||||
if [ x$dirname = x/ ]; then
|
||||
if [ -z "${prepare_root_cache}" ]; then
|
||||
prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)"
|
||||
fi
|
||||
@@ -169,12 +144,24 @@ EOF
|
||||
EOF
|
||||
}
|
||||
|
||||
case "$GRUB_PLATFORM" in
|
||||
x86 | i386-xen-pae | x86_64-xen) GENKERNEL_ARCH="x86" ;;
|
||||
machine=`uname -m`
|
||||
case "x$machine" 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
|
||||
|
||||
case "$machine" in
|
||||
i?86) GENKERNEL_ARCH="x86" ;;
|
||||
mips|mips64) GENKERNEL_ARCH="mips" ;;
|
||||
mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;;
|
||||
arm*) GENKERNEL_ARCH="arm" ;;
|
||||
*) GENKERNEL_ARCH="$GRUB_PLATFORM" ;;
|
||||
*) GENKERNEL_ARCH="$machine" ;;
|
||||
esac
|
||||
|
||||
prepare_boot_cache=
|
||||
@@ -213,7 +200,7 @@ while [ "x$list" != "x" ] ; do
|
||||
done
|
||||
|
||||
config=
|
||||
for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "$GRUB_ROOT/etc/kernels/kernel-config-${version}" ; do
|
||||
for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
|
||||
if test -e "${i}" ; then
|
||||
config="${i}"
|
||||
break
|
||||
|
||||
+13
-24
@@ -22,16 +22,6 @@ exec_prefix="@exec_prefix@"
|
||||
datarootdir="@datarootdir@"
|
||||
. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
|
||||
|
||||
if [ x$GRUB_PLATFORM = xx86 ]; then
|
||||
check=--is-x86-kfreebsd
|
||||
elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
|
||||
check=--is-i386-xen-pae-domu
|
||||
elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
|
||||
check=--is-x86_64-xen-domu
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
export TEXTDOMAIN=@PACKAGE@
|
||||
export TEXTDOMAINDIR="@localedir@"
|
||||
|
||||
@@ -46,13 +36,19 @@ netbsd_load_fs_module ()
|
||||
loader="$1" # "knetbsd" or "multiboot"
|
||||
kernel="$2" # absolute path to the kernel file
|
||||
|
||||
if "${grub_file}" --is-x86_64-kfreebsd "${kernel}"; then
|
||||
karch="amd64"
|
||||
else
|
||||
case $(zcat -f "${kernel}" | file -bL - | cut -d , -f 2 | tr -d ' ') in
|
||||
Intel80386)
|
||||
karch="i386"
|
||||
fi
|
||||
;;
|
||||
x86-64)
|
||||
karch="amd64"
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case $GRUB_FS in
|
||||
case $(${grub_probe} --target=fs -d ${GRUB_DEVICE}) in
|
||||
ext2)
|
||||
kmod="ext2fs"
|
||||
;;
|
||||
@@ -71,7 +67,7 @@ netbsd_load_fs_module ()
|
||||
esac
|
||||
|
||||
kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }')
|
||||
kmodule="$GRUB_ROOT/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod"
|
||||
kmodule="/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod"
|
||||
|
||||
if test -z "$karch" -o -z "$kversion" -o ! -f "${kmodule}"; then
|
||||
return
|
||||
@@ -98,10 +94,6 @@ netbsd_entry ()
|
||||
type="$3"
|
||||
args="$4" # extra arguments appended to loader command
|
||||
|
||||
if [ "x${loader}" = xmultiboot ] && [ x$GRUB_PLATFORM = xx86 ] && ! "$grub_file" --is-x86-multiboot "$kernel"; then
|
||||
return
|
||||
fi
|
||||
|
||||
kroot_device="$(echo ${GRUB_DEVICE} | sed -e 's,^/dev/r,,')"
|
||||
|
||||
if [ -z "$boot_device_id" ]; then
|
||||
@@ -155,13 +147,10 @@ pattern="^ELF[^,]*executable.*statically linked"
|
||||
submenu_indentation=""
|
||||
|
||||
is_top_level=true
|
||||
for k in "$GRUB_ROOT"/netbsd $(ls -t "$GRUB_ROOT"/netbsd?* 2>/dev/null) ; do
|
||||
for k in /netbsd $(ls -t /netbsd?* 2>/dev/null) ; do
|
||||
if ! grub_file_is_not_garbage "$k" ; then
|
||||
continue
|
||||
fi
|
||||
if ! "$grub_file" $check "$k"; then
|
||||
continue
|
||||
fi
|
||||
if ! (zcat -f "$k" | file -bL - | grep -q "${pattern}") 2>/dev/null ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
+3
-12
@@ -26,28 +26,18 @@ export TEXTDOMAINDIR="@localedir@"
|
||||
|
||||
. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
|
||||
|
||||
if [ x$GRUB_PLATFORM != xx86 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
osx_entry() {
|
||||
if [ x$2 = x32 ]; then
|
||||
# TRANSLATORS: it refers to kernel architecture (32-bit)
|
||||
bitstr="$(gettext "(32-bit)")"
|
||||
if ! [ -f "$GRUB_ROOT"/mach_kernel ] || ! "${grub_file}" --is-i386-xnu "$GRUB_ROOT"/mach_kernel; then
|
||||
return;
|
||||
fi
|
||||
else
|
||||
# TRANSLATORS: it refers to kernel architecture (64-bit)
|
||||
bitstr="$(gettext "(64-bit)")"
|
||||
if ! [ -f "$GRUB_ROOT"/mach_kernel ] || ! "${grub_file}" --is-x86_64-xnu "$GRUB_ROOT"/mach_kernel; then
|
||||
return;
|
||||
fi
|
||||
fi
|
||||
# TRANSLATORS: it refers on the OS residing on device %s
|
||||
onstr="$(gettext_printf "(on %s)" "${GRUB_DEVICE}")"
|
||||
cat << EOF
|
||||
menuentry '$(echo "Darwin/Mac OS X $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'xnu-$2-$(grub_get_device_id "${GRUB_DEVICE}")' {
|
||||
menuentry '$(echo "Darwin/Mac OS X $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${GRUB_DEVICE}")' {
|
||||
EOF
|
||||
save_default_entry | grub_add_tab
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab
|
||||
@@ -60,7 +50,7 @@ EOF
|
||||
fi
|
||||
fi
|
||||
if [ \$do_resume = 0 ]; then
|
||||
xnu_uuid ${GRUB_DEVICE_UUID} uuid
|
||||
xnu_uuid ${OSXUUID} uuid
|
||||
if [ -f /Extra/DSDT.aml ]; then
|
||||
acpi -e /Extra/DSDT.aml
|
||||
fi
|
||||
@@ -100,5 +90,6 @@ EOF
|
||||
EOF
|
||||
}
|
||||
|
||||
OSXUUID="`${grub_probe} --target=fs_uuid --device ${GRUB_DEVICE} 2> /dev/null`"
|
||||
osx_entry xnu_kernel 32
|
||||
osx_entry xnu_kernel64 64
|
||||
+17
-11
@@ -26,10 +26,6 @@ datarootdir="@datarootdir@"
|
||||
export TEXTDOMAIN=@PACKAGE@
|
||||
export TEXTDOMAINDIR="@localedir@"
|
||||
|
||||
if [ x$GRUB_PLATFORM != xx86 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CLASS="--class gnu-linux --class gnu --class os --class xen"
|
||||
|
||||
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
||||
@@ -65,14 +61,14 @@ fi
|
||||
|
||||
case x"$GRUB_FS" in
|
||||
xbtrfs)
|
||||
rootsubvol="`make_system_path_relative_to_its_root "$GRUB_ROOT"/`"
|
||||
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;;
|
||||
xzfs)
|
||||
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
|
||||
bootfs="`make_system_path_relative_to_its_root "$GRUB_ROOT"/ | sed -e "s,@$,,"`"
|
||||
bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
|
||||
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
|
||||
;;
|
||||
esac
|
||||
@@ -141,9 +137,19 @@ EOF
|
||||
EOF
|
||||
}
|
||||
|
||||
linux_list=`for i in "$GRUB_ROOT"/boot/vmlinu[xz]-* "$GRUB_ROOT"/vmlinu[xz]-* "$GRUB_ROOT"/boot/kernel-*; do
|
||||
if grub_file_is_not_garbage "$i" && "${grub_file}" --is-x86-xen-dom0 "$i"; then
|
||||
echo -n "$i " ;
|
||||
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")
|
||||
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
|
||||
@@ -159,8 +165,8 @@ file_is_not_sym () {
|
||||
esac
|
||||
}
|
||||
|
||||
xen_list=`for i in "$GRUB_ROOT"/boot/xen*; do
|
||||
if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" && ${grub_file} --is-x86-multiboot "$i"; then echo -n "$i " ; fi
|
||||
xen_list=`for i in /boot/xen*; do
|
||||
if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then echo -n "$i " ; fi
|
||||
done`
|
||||
prepare_boot_cache=
|
||||
boot_device_id=
|
||||
|
||||
Reference in new issue
Block a user