Index: radix-1.9/X11/X.org/app/xcm/0.5.4/Makefile
===================================================================
--- radix-1.9/X11/X.org/app/xcm/0.5.4/Makefile (revision 215)
+++ radix-1.9/X11/X.org/app/xcm/0.5.4/Makefile (revision 216)
@@ -165,6 +165,10 @@
$(install_target): $(build_target)
@mkdir -p $(XORG_PKG)
@cd $(build_dir) && $(BUILD_ENVIRONMENT) $(MAKE) -j1 install $(env_sysroot)
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_RISCV64_GLIBC)),)
+ # ======= riscv64: skip /dev/i2c-5 device until issue is fixed: =======
+ @sed -i 's,0-9,0-46-9,' $(XORG_PKG)/lib/udev/rules.d/90-xcm-i2c.rules
+endif
# ======= Install Documentation =======
@if [ -d $(XORG_PKG)/usr/share/man ]; then \
( cd $(XORG_PKG)/usr/share/man ; \
Index: radix-1.9/base/radix-system/Makefile
===================================================================
--- radix-1.9/base/radix-system/Makefile (revision 215)
+++ radix-1.9/base/radix-system/Makefile (revision 216)
@@ -321,6 +321,9 @@
ifneq ($(filter $(HARDWARE),$(HARDWARE_ORANGE_PI5)),)
@echo "s1:12345:respawn:/sbin/agetty -L ttyFIQ0 1500000 vt100" >> $(SYSINIT_BIN_PKG)/etc/inittab.new
endif
+ifneq ($(filter $(HARDWARE),$(HARDWARE_VISIONFIVE2)),)
+ @echo "s1:12345:respawn:/sbin/agetty -L ttyS0 115200 vt100" >> $(SYSINIT_BIN_PKG)/etc/inittab.new
+endif
@echo "" >> $(SYSINIT_BIN_PKG)/etc/inittab.new
@echo "# End of /etc/inittab" >> $(SYSINIT_BIN_PKG)/etc/inittab.new
# ======= etc/fstab =======
@@ -351,6 +354,9 @@
fi ; \
done ; \
)
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_RISCV64_GLIBC)),)
+ @sed -i 's, --id=, -i ,g' $(SYSINIT_BIN_PKG)/etc/rc.d/rc.inet1.new
+endif
@chmod a+x $(SYSINIT_BIN_PKG)/etc/rc.d/rc.{inet1.new,inet2.new,wireless.new}
@chmod 600 $(SYSINIT_BIN_PKG)/etc/rc.d/rc.{inet1.conf.new,wireless.conf.new}
# ======= etc/profile.d =======
Index: radix-1.9/boot/grub/visionfive2/2.06/Makefile
===================================================================
--- radix-1.9/boot/grub/visionfive2/2.06/Makefile (nonexistent)
+++ radix-1.9/boot/grub/visionfive2/2.06/Makefile (revision 216)
@@ -0,0 +1,419 @@
+
+COMPONENT_TARGETS = $(HARDWARE_VISIONFIVE2)
+
+
+NEED_ABS_PATH = true
+COMPONENT_IS_3PP = true
+
+
+include ../../../../build-system/constants.mk
+
+
+SOURCE_REQUIRES = sources/GNU/grub
+
+REQUIRES = boot/kernel/visionfive2/6.1.31-3.8.2
+REQUIRES += app/xz/5.2.7
+REQUIRES += libs/zlib/1.2.13
+REQUIRES += libs/zstd/1.5.2
+REQUIRES += dev/bison/3.7.4
+REQUIRES += dev/flex/2.6.4
+
+REQUIRES += share/fonts-collection
+
+# ======= __END_OF_REQUIRES__ =======
+
+
+version = 2.06
+tar_xz_archive = $(SRC_PACKAGE_PATH)/GNU/grub/grub-$(version).tar.xz
+SRC_ARCHIVE = $(tar_xz_archive)
+SRC_DIR = $(TARGET_BUILD_DIR)/grub-$(version)
+src_dir_name = grub-$(version)
+src_done = $(TARGET_BUILD_DIR)/.source_done
+
+PATCHES = PATCHES
+
+build_dev_dir = $(TARGET_BUILD_DIR)/build-dev
+build_dev_target = $(TARGET_BUILD_DIR)/.build_dev_done
+install_dev_target = $(TARGET_BUILD_DIR)/.install_dev_done
+
+build_dir = $(TARGET_BUILD_DIR)/build
+build_target = $(TARGET_BUILD_DIR)/.build_done
+install_target = $(TARGET_BUILD_DIR)/.install_done
+
+boot_efi32fs = $(TARGET_BUILD_DIR)/$(HARDWARE).efi32fs
+install_efi32fs = $(TARGET_BUILD_DIR)/.install_efi32fs_done
+
+
+####### Targets
+
+PKG_GROUP = boot
+
+#
+# *PKG_NAME & *PKG_VERSION shouldn't be a reference to value.
+#
+GRUB_PKG_NAME = grub
+GRUB_PKG_VERSION = 2.06
+GRUB_PKG_ARCH = $(PKGARCH)
+GRUB_PKG_DISTRO_NAME = $(DISTRO_NAME)
+GRUB_PKG_DISTRO_VERSION = $(DISTRO_VERSION)
+GRUB_PKG_GROUP = $(PKG_GROUP)
+### |---handy-ruler-------------------------------|
+GRUB_PKG_SHORT_DESCRIPTION = the GRand Unified Bootloader
+GRUB_PKG_URL = $(BUG_URL)
+GRUB_PKG_LICENSE = GPLv3
+GRUB_PKG_DESCRIPTION_FILE = $(TARGET_BUILD_DIR)/$(GRUB_PKG_NAME)-pkg-description
+GRUB_PKG_DESCRIPTION_GRUB_IN = $(GRUB_PKG_NAME)-pkg-description.in
+GRUB_PKG_INSTALL_SCRIPT = $(GRUB_PKG_NAME)-pkg-install.sh
+
+GRUB_PKG = $(CURDIR)/$(TARGET_BUILD_DIR)/$(GRUB_PKG_NAME)-package
+
+pkg_basename = $(GRUB_PKG_NAME)-$(GRUB_PKG_VERSION)-$(GRUB_PKG_ARCH)-$(GRUB_PKG_DISTRO_NAME)-$(GRUB_PKG_DISTRO_VERSION)
+
+pkg_archive = $(TARGET_BUILD_DIR)/$(PKG_GROUP)/$(pkg_basename).$(pkg_arch_suffix)
+pkg_certificate = $(call cert-name,$(pkg_archive))
+pkg_signature = $(call sign-name,$(pkg_archive))
+pkg_description = $(call desc-name,$(pkg_archive))
+products = $(call pkg-files,$(pkg_archive))
+
+BUILD_TARGETS = $(build_target)
+BUILD_TARGETS += $(install_target)
+BUILD_TARGETS += $(install_efi32fs)
+
+PRODUCT_TARGETS = $(products)
+
+ROOTFS_TARGETS = $(pkg_archive)
+
+
+include ../../../../build-system/core.mk
+
+
+env_sysroot = DESTDIR=$(GRUB_PKG)
+
+extra_configure_switches = --libdir=/usr/lib$(LIBSUFFIX)
+extra_configure_switches += --docdir=/usr/share/doc/$(src_dir_name)
+extra_configure_switches += --infodir=/usr/share/info
+extra_configure_switches += --mandir=/usr/share/man
+extra_configure_switches += --disable-dependency-tracking
+extra_configure_switches += --sysconfdir=/etc
+
+extra_configure_switches += --enable-threads=posix
+extra_configure_switches += --disable-rpath
+extra_configure_switches += --enable-stack-protector=no
+extra_configure_switches += --enable-mm-debug=no
+extra_configure_switches += --enable-cache-stats=no
+extra_configure_switches += --enable-boot-time=no
+extra_configure_switches += --enable-grub-emu-sdl=no
+extra_configure_switches += --enable-grub-emu-pci=no
+extra_configure_switches += --enable-grub-themes=no
+extra_configure_switches += --enable-device-mapper=no
+extra_configure_switches += --enable-liblzma
+extra_configure_switches += --enable-libzfs=no
+extra_configure_switches += --disable-werror
+extra_configure_switches += --enable-grub-themes
+extra_configure_switches += --enable-grub-mkfont
+
+extra_configure_switches += --with-bootdir='/boot'
+extra_configure_switches += --with-grubdir='grub'
+
+#
+# GRUB for Development environment:
+#
+build_dev_switches += --enable-efiemu=no
+build_dev_switches += --with-platform=efi
+build_dev_switches += --target=$(TARGET)
+build_dev_switches += --program-prefix=$(TARGET)-
+build_dev_switches += --enable-grub-mkfont
+build_dev_switches += --enable-grub-mount
+
+BUILD_DEV_ENVIRONMENT = HOST_CC=gcc
+BUILD_DEV_ENVIRONMENT += BUILD_CC=gcc
+BUILD_DEV_ENVIRONMENT += BUILD_CFLAGS='-I/usr/include'
+BUILD_DEV_ENVIRONMENT += BUILD_CPPFLAGS='-I/usr/include'
+BUILD_DEV_ENVIRONMENT += BUILD_LDFLAGS='-L/usr/lib$(BUILD_MULTILIB_SUFFIX)'
+BUILD_DEV_ENVIRONMENT += TARGET_CC='$(CC)'
+BUILD_DEV_ENVIRONMENT += TARGET_NM='$(NM)'
+BUILD_DEV_ENVIRONMENT += TARGET_RANLIB='$(RANLIB)'
+BUILD_DEV_ENVIRONMENT += TARGET_STRIP='$(STRIP)'
+BUILD_DEV_ENVIRONMENT += TARGET_OBJCOPY='$(OBJCOPY)'
+
+grub_CFLAGS = -isystem $(TARGET_DEST_DIR)/usr/include $(OPTIMIZATION_FLAGS) $(ARCH_FLAGS) $(HW_FLAGS)
+BUILD_DEV_ENVIRONMENT += TARGET_CFLAGS='--sysroot=$(TARGET_DEST_DIR) $(grub_CFLAGS)'
+BUILD_DEV_ENVIRONMENT += TARGET_LDFLAGS='--sysroot=$(TARGET_DEST_DIR)'
+
+
+#
+# GRUB for TARGET machine:
+#
+target_switches += --enable-efiemu=no
+target_switches += --with-platform=efi
+target_switches += --target=$(TARGET)
+target_switches += --program-prefix=''
+
+extra_environment = HOST_CC=gcc
+extra_environment += BUILD_CC=gcc
+extra_environment += BUILD_CFLAGS='-I/usr/include'
+extra_environment += BUILD_CPPFLAGS='-I/usr/include'
+extra_environment += BUILD_LDFLAGS='-L/usr/lib$(BUILD_MULTILIB_SUFFIX)'
+extra_environment += BUILD_FREETYPE_CFLAGS='-I/usr/include -I/usr/include/freetype2'
+extra_environment += BUILD_FREETYPE_LIBS='-L/usr/lib$(BUILD_MULTILIB_SUFFIX) -lfreetype'
+extra_environment += TARGET_CC='$(CC)'
+extra_environment += TARGET_NM='$(NM)'
+extra_environment += TARGET_RANLIB='$(RANLIB)'
+extra_environment += TARGET_STRIP='$(STRIP)'
+extra_environment += TARGET_OBJCOPY='$(OBJCOPY)'
+extra_environment += TARGET_CFLAGS='--sysroot=$(TARGET_DEST_DIR) $(grub_CFLAGS)'
+extra_environment += TARGET_LDFLAGS='--sysroot=$(TARGET_DEST_DIR)'
+
+
+#
+# GRUB EFI image for TARGET machine:
+#
+efi_image = $(TARGET_BUILD_DIR)/bootriscv64.efi
+efi_embedded_cfg = $(TARGET_BUILD_DIR)/grub-$(DISTRO_NAME).cfg
+root_uuid = eaf0eef1-f13a-726F-6F74-203aefe0f0f2
+linux_cmdline = console=ttyS0,115200n8 earlycon=sbi console=tty1
+device_tree = starfive/jh7110-visionfive-v2.dtb
+
+grub_modules = all_video archelp bfs bitmap bitmap_scale blocklist boot btrfs
+grub_modules += cat chain configfile cpio date datehook datetime disk diskfilter
+grub_modules += echo efi_gop efifwsetup efinet elf eval exfat ext2 extcmd f2fs fat
+grub_modules += fdt file font fshelp gettext gfxmenu gfxterm gfxterm_background
+grub_modules += gfxterm_menu gptsync gzio halt hashsum help hexdump iso9660 jpeg
+grub_modules += json keystatus linux loadenv loopback ls lsefi lzopio mdraid1x
+grub_modules += memdisk minicmd msdospart net newc normal part_gpt part_msdos
+grub_modules += png probe procfs read reboot regexp reiserfs search search_fs_file
+grub_modules += search_fs_uuid search_label serial squash4 tar terminal terminfo
+grub_modules += test tftp time tr trig true udf ufs1 ufs2 video video_colors
+grub_modules += video_fb videoinfo xzio zstd
+
+FONT_SIZE = 19
+
+
+####### Dependencies
+
+$(src_done): $(SRC_ARCHIVE) $(PATCHES_DEP)
+ $(UNPACK_SRC_ARCHIVE)
+ $(APPLY_PATCHES)
+ @( cd $(SRC_DIR) ; \
+ sed -i 's,-march=rv64imac,-march=rv64gc,g' configure.ac ; \
+ sed -i 's,-march=rv64imac,-march=rv64gc,g' configure ; \
+ )
+ @touch $@
+
+$(build_dev_target): $(src_done)
+ @mkdir -p $(build_dev_dir)
+ @cd $(build_dev_dir) && \
+ PKG_CONFIG_PATH= $(BUILD_DEV_ENVIRONMENT) ../$(src_dir_name)/configure \
+ --prefix=/usr \
+ --build=$(BUILD) \
+ --host=$(BUILD) \
+ $(extra_configure_switches) \
+ $(build_dev_switches)
+ @cd $(build_dev_dir) && $(BUILD_DEV_ENVIRONMENT) $(MAKE)
+ @touch $@
+
+$(install_dev_target): $(build_dev_target)
+ @mkdir -p $(GRUB_PKG)
+ @cd $(build_dev_dir) && $(BUILD_DEV_ENVIRONMENT) $(MAKE) -j1 install $(env_sysroot)
+ @rm -rf $(GRUB_PKG)/etc
+ @rm -rf $(GRUB_PKG)/usr/share
+ @rm -rf $(GRUB_PKG)/usr/lib
+ @touch $@
+
+$(build_target): $(install_dev_target)
+ @mkdir -p $(build_dir)
+ @cd $(build_dir) && \
+ $(BUILD_ENVIRONMENT) $(extra_environment) ../$(src_dir_name)/configure \
+ --prefix=/usr \
+ --build=$(BUILD) \
+ --host=$(TARGET) \
+ $(extra_configure_switches) \
+ $(target_switches)
+ @cd $(build_dir) && $(BUILD_ENVIRONMENT) $(extra_environment) $(MAKE)
+ @cd $(build_dir) && $(BUILD_ENVIRONMENT) $(extra_environment) $(MAKE) html
+ @touch $@
+
+$(install_target): $(build_target)
+ @mkdir -p $(GRUB_PKG)
+ @cd $(build_dir) && $(BUILD_ENVIRONMENT) $(extra_environment) $(MAKE) -j1 install $(env_sysroot)
+ # ======= Install MANs (GRUB sources cannot generate MANs during cross-compilation) =======
+ @cd $(build_dev_dir) && $(MAKE) -j1 install-man1 $(env_sysroot)
+ @cd $(build_dev_dir) && $(MAKE) -j1 install-man8 $(env_sysroot)
+ @( cd $(GRUB_PKG)/usr/share/man ; \
+ for sname in `find . -type f -name '$(TARGET)-*'` ; do \
+ dname=`echo $${sname} | sed 's,$(TARGET)-,,'` ; \
+ mv $${sname} $${dname} ; \
+ done ; \
+ echo "# ======= remove MANs of not provided utils =======" ; \
+ rm -f man1/grub-mount.1 ; \
+ )
+ # ======= Install default options file =======
+ @mkdir -p $(GRUB_PKG)/etc/default
+ @cat $(CURDIR)/conf/etc.default > $(GRUB_PKG)/etc/default/grub.new
+ # ======= Create a grub.cfg =======
+ @mkdir -p $(GRUB_PKG)/boot/grub
+ @echo "" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "set menu_color_normal=black/light-gray" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "set menu_color_highlight=white/light-gray" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "set background_color=black" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "set timeout=5" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "font '/boot/grub/fonts/dejavusansmono.pf2'" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "loadfont dejavusansmono" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "menuentry 'Radix cross Linux' {" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo " set root_uuid=$(root_uuid)" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo " insmod gzio" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo " insmod xzio" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo " insmod part_gpt" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo " insmod ext2" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo " search --set=root --fs-uuid \$$root_uuid" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo " devicetree /boot/$(device_tree)" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo " linux /boot/Image root=PARTUUID=\$$root_uuid ro rootwait $(linux_cmdline)" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ @echo "}" >> $(GRUB_PKG)/boot/grub/grub.cfg
+ # ======= Preserve the contents of /etc/grub.d/40_custom =======
+ @mv $(GRUB_PKG)/etc/grub.d/40_custom $(GRUB_PKG)/etc/grub.d/40_custom.new
+ # ======= Put bash-completion file in system directory =======
+ @mkdir -p $(GRUB_PKG)/usr/share/bash-completion/completions/
+ @mv $(GRUB_PKG)/etc/bash_completion.d/grub \
+ $(GRUB_PKG)/usr/share/bash-completion/completions/grub
+ @rm -rf $(GRUB_PKG)/etc/bash_completion.d
+ # ======= Add fonts, if found on the system =======
+ @if [ -r $(TARGET_DEST_DIR)/usr/share/fonts/TTF/unifont.ttf ] ; then \
+ $(GRUB_PKG)/usr/bin/$(TARGET)-grub-mkfont \
+ -o $(GRUB_PKG)/usr/share/grub/unifont.pf2 -abv \
+ -s $(FONT_SIZE) /usr/share/fonts/TTF/unifont.ttf \
+ 2>/dev/null 1>/dev/null ; \
+ fi
+ @if [ -r $(TARGET_DEST_DIR)/usr/share/fonts/TTF/DejaVuSansMono.ttf ] ; then \
+ $(GRUB_PKG)/usr/bin/$(TARGET)-grub-mkfont \
+ -o $(GRUB_PKG)/usr/share/grub/dejavusansmono.pf2 -abv \
+ -s $(FONT_SIZE) /usr/share/fonts/TTF/DejaVuSansMono.ttf \
+ 2>/dev/null 1>/dev/null ; \
+ fi
+ # ======= remove devenv paths from modinfo.sh script =======
+ @( cd $(GRUB_PKG)/usr/lib$(LIBSUFFIX)/grub/riscv64-efi ; \
+ sed -i 's,$(TARGET_DEST_DIR),,g' modinfo.sh ; \
+ sed -i 's,$(TOOLCHAIN_PATH),,g' modinfo.sh ; \
+ sed -i 's,$(CROSS_PREFIX),,g' modinfo.sh ; \
+ sed -i 's,$(TARGET)-,,g' modinfo.sh ; \
+ sed -i 's,--sysroot= ,,g' modinfo.sh ; \
+ sed -i 's,-isystem /lib,-isystem /usr/lib,g' modinfo.sh ; \
+ )
+ # ======= Install GRUB =======
+ @$(GRUB_PKG)/usr/sbin/$(TARGET)-grub-install \
+ --skip-fs-probe \
+ --fonts=dejavusansmono \
+ --boot-directory=$(GRUB_PKG)/boot \
+ --directory=$(GRUB_PKG)/usr/lib$(LIBSUFFIX)/grub/riscv64-efi \
+ --target=riscv64-efi --no-efi --no-bootsector --no-nvram
+ # ======= Build EFI image =======
+ @echo "" > $(efi_embedded_cfg)
+ @echo "set color_normal=black/black" >> $(efi_embedded_cfg)
+ @echo "" >> $(efi_embedded_cfg)
+ @echo "set pager=1" >> $(efi_embedded_cfg)
+ @echo "search.fs_uuid $(root_uuid) root" >> $(efi_embedded_cfg)
+ @echo "set prefix=(\$$root)/boot/grub" >> $(efi_embedded_cfg)
+ @echo "" >> $(efi_embedded_cfg)
+ @echo "set color_normal=light-gray/black" >> $(efi_embedded_cfg)
+ @echo "clear" >> $(efi_embedded_cfg)
+ @cp -a $(efi_embedded_cfg) $(GRUB_PKG)/boot/grub/riscv64-efi/load.cfg
+ @$(GRUB_PKG)/usr/bin/$(TARGET)-grub-mkimage \
+ --format=riscv64-efi \
+ --directory=$(GRUB_PKG)/usr/lib$(LIBSUFFIX)/grub/riscv64-efi \
+ --compression=xz \
+ --prefix=/efi/boot \
+ --config=$(efi_embedded_cfg) \
+ --output=$(efi_image) \
+ $(grub_modules)
+ # ======= Install Documentation =======
+ @rm -f $(GRUB_PKG)/usr/share/info/dir
+ @gzip -9 $(GRUB_PKG)/usr/share/info/*
+ @if [ -d $(GRUB_PKG)/usr/share/man ]; then \
+ ( cd $(GRUB_PKG)/usr/share/man ; \
+ for manpagedir in `find . -type d -name "man*"` ; do \
+ ( cd $$manpagedir ; \
+ for eachpage in `find . -type l -maxdepth 1` ; do \
+ ln -s `readlink $$eachpage`.gz $$eachpage.gz ; \
+ rm $$eachpage ; \
+ done ; \
+ gzip -9 *.? ; \
+ ) \
+ done \
+ ) \
+ fi
+ @mkdir -p $(GRUB_PKG)/usr/doc/$(src_dir_name)
+ @cp -a $(SRC_DIR)/AUTHORS $(SRC_DIR)/COPYING \
+ $(GRUB_PKG)/usr/doc/$(src_dir_name)
+ @mkdir -p $(GRUB_PKG)/usr/share/doc/$(src_dir_name)/html/grub{,-dev}
+ @( cd $(SRC_DIR) ; \
+ cp -a AUTHORS COPYING INSTALL NEWS README THANKS TODO \
+ $(GRUB_PKG)/usr/share/doc/$(src_dir_name) \
+ )
+ @cp -a $(build_dir)/docs/grub-dev.html/*.html \
+ $(GRUB_PKG)/usr/share/doc/$(src_dir_name)/html/grub-dev
+ @cp -a $(build_dir)/docs/grub.html/*.html \
+ $(GRUB_PKG)/usr/share/doc/$(src_dir_name)/html/grub
+ @( cd $(SRC_DIR) ; \
+ if [ -r ChangeLog ]; then \
+ DOCSDIR=`echo $(GRUB_PKG)/usr/share/doc/$(src_dir_name)` ; \
+ cat ChangeLog | head -n 1000 > $$DOCSDIR/ChangeLog ; \
+ touch -r ChangeLog $$DOCSDIR/ChangeLog ; \
+ fi \
+ )
+ # ======= Install the same to $(TARGET_DEST_DIR) =======
+ $(call install-into-devenv, $(GRUB_PKG))
+ # ======= remove devenv utils from target package =======
+ @( cd $(GRUB_PKG)/usr ; \
+ find . -type f -name '$(TARGET)-*' -exec rm -f {} \+ ; \
+ )
+ # ======= Strip binaries =======
+ @( cd $(GRUB_PKG) ; \
+ find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
+ )
+ @touch $@
+
+$(boot_efi32fs): $(install_target)
+ # ======= Create FAT32 boot partition image =======
+ @$(DD) if=/dev/zero of=$@ bs=1M count=256
+ @$(MKDOSFS) -F 32 -n UEFI $@
+ @$(MMD) -i $@ ::/efi
+ @$(MMD) -i $@ ::/efi/boot
+ @$(MCOPY) -i $@ $(efi_image) ::/efi/boot/
+ @touch $@
+
+$(install_efi32fs): $(boot_efi32fs)
+ @$(BUILDSYSTEM)/install_targets \
+ --destination=$(PRODUCTS_DEST_DIR) \
+ --toolchain=$(TOOLCHAIN) \
+ --hardware=$(HARDWARE) \
+ --flavour=$(FLAVOUR) \
+ $^
+ @touch $@
+
+$(GRUB_PKG_DESCRIPTION_FILE): $(GRUB_PKG_DESCRIPTION_GRUB_IN)
+ @cat $< | $(SED) -e "s/@VERSION@/$(version)/g" > $@
+
+$(pkg_certificate) : $(pkg_archive) ;
+$(pkg_signature) : $(pkg_archive) ;
+$(pkg_description) : $(pkg_archive) ;
+
+$(pkg_archive): $(install_efi32fs) $(GRUB_PKG_DESCRIPTION_FILE) $(GRUB_PKG_INSTALL_SCRIPT)
+ @cp $(GRUB_PKG_DESCRIPTION_FILE) $(GRUB_PKG)/.DESCRIPTION
+ @cp $(GRUB_PKG_INSTALL_SCRIPT) $(GRUB_PKG)/.INSTALL
+ @$(BUILD_PKG_REQUIRES) $(GRUB_PKG)/.REQUIRES
+ @echo "pkgname=$(GRUB_PKG_NAME)" > $(GRUB_PKG)/.PKGINFO ; \
+ echo "pkgver=$(GRUB_PKG_VERSION)" >> $(GRUB_PKG)/.PKGINFO ; \
+ echo "arch=$(GRUB_PKG_ARCH)" >> $(GRUB_PKG)/.PKGINFO ; \
+ echo "distroname=$(GRUB_PKG_DISTRO_NAME)" >> $(GRUB_PKG)/.PKGINFO ; \
+ echo "distrover=$(GRUB_PKG_DISTRO_VERSION)" >> $(GRUB_PKG)/.PKGINFO ; \
+ echo "group=$(GRUB_PKG_GROUP)" >> $(GRUB_PKG)/.PKGINFO ; \
+ echo "short_description=\"$(GRUB_PKG_SHORT_DESCRIPTION)\"" >> $(GRUB_PKG)/.PKGINFO ; \
+ echo "url=$(GRUB_PKG_URL)" >> $(GRUB_PKG)/.PKGINFO ; \
+ echo "license=$(GRUB_PKG_LICENSE)" >> $(GRUB_PKG)/.PKGINFO
+ @$(PSEUDO) sh -c "cd $(GRUB_PKG) && \
+ chown -R root:root . && \
+ $(MAKE_PACKAGE) -J --linkadd=yes $(GNUPG_OPTIONS) -m -d .. ."
Index: radix-1.9/boot/grub/visionfive2/2.06/PATCHES
===================================================================
--- radix-1.9/boot/grub/visionfive2/2.06/PATCHES (nonexistent)
+++ radix-1.9/boot/grub/visionfive2/2.06/PATCHES (revision 216)
@@ -0,0 +1,13 @@
+
+../../../../sources/GNU/grub/patches/grub-2.06-align-struct.patch -p0
+../../../../sources/GNU/grub/patches/grub-2.06-dejavu-sans.patch -p0
+../../../../sources/GNU/grub/patches/grub-2.06-fonts-ttf.patch -p0
+../../../../sources/GNU/grub/patches/grub-2.06-gensyminfo.patch -p0
+../../../../sources/GNU/grub/patches/grub-2.06-initrd-names.patch -p0
+../../../../sources/GNU/grub/patches/grub-2.06-modinfo.patch -p0
+../../../../sources/GNU/grub/patches/grub-2.06-no-efi.patch -p0
+
+../../../../sources/GNU/grub/patches/grub-2.06-normal-welcome.patch -p0
+../../../../sources/GNU/grub/patches/grub-2.06-riscv-linux-loader.patch -p0
+../../../../sources/GNU/grub/patches/grub-2.06-riscv-image-header.patch -p0
+../../../../sources/GNU/grub/patches/grub-2.06-riscv-relocation.patch -p0
Index: radix-1.9/boot/grub/visionfive2/2.06/conf/etc.default
===================================================================
--- radix-1.9/boot/grub/visionfive2/2.06/conf/etc.default (nonexistent)
+++ radix-1.9/boot/grub/visionfive2/2.06/conf/etc.default (revision 216)
@@ -0,0 +1,28 @@
+# If you change this file, run grub-mkconfig -o /boot/grub/grub.cfg
+# afterwards to update /boot/grub/grub.cfg.
+
+GRUB_DEFAULT=0
+#GRUB_HIDDEN_TIMEOUT=0
+GRUB_HIDDEN_TIMEOUT_QUIET=false
+GRUB_TIMEOUT=10
+GRUB_DISTRIBUTOR=$( sed 's/Radix /Radix-/' /etc/radix-version )
+GRUB_CMDLINE_LINUX_DEFAULT=""
+GRUB_CMDLINE_LINUX=""
+
+# Uncomment to disable graphical terminal (grub-pc only)
+#GRUB_TERMINAL=console
+
+# The resolution used on graphical terminal
+# note that you can use only modes which your graphic card supports via VBE
+# you can see them in real GRUB with the command `vbeinfo'
+#GRUB_GFXMODE=640x480
+#GRUB_GFXMODE=1024x768x32
+
+# Font used on the graphical terminal:
+#GRUB_FONT=/usr/share/grub/dejavusansmono.pf2
+
+# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
+#GRUB_DISABLE_LINUX_UUID=true
+
+# Uncomment to disable generation of recovery mode menu entries
+#GRUB_DISABLE_RECOVERY="true"
Index: radix-1.9/boot/grub/visionfive2/2.06/grub-pkg-description.in
===================================================================
--- radix-1.9/boot/grub/visionfive2/2.06/grub-pkg-description.in (nonexistent)
+++ radix-1.9/boot/grub/visionfive2/2.06/grub-pkg-description.in (revision 216)
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+grub: grub @VERSION@ (the GRand Unified Bootloader)
+grub:
+grub: GNU GRUB is a multiboot boot loader.
+grub:
+grub: Website: http://www.gnu.org/software/grub/
+grub:
+grub:
+grub:
+grub:
+grub:
+grub:
Index: radix-1.9/boot/grub/visionfive2/2.06/grub-pkg-install.sh
===================================================================
--- radix-1.9/boot/grub/visionfive2/2.06/grub-pkg-install.sh (nonexistent)
+++ radix-1.9/boot/grub/visionfive2/2.06/grub-pkg-install.sh (revision 216)
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+# Preserve new files
+install_file() {
+ NEW="$1"
+ OLD="`dirname $NEW`/`basename $NEW .new`"
+ # If there's no file by that name, mv it over:
+ if [ ! -r $OLD ]; then
+ mv $NEW $OLD
+ elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
+ rm $NEW
+ fi
+ # Otherwise, we leave the .new copy for the admin to consider...
+}
+
+preserve_perms() {
+ NEW="$1"
+ OLD="$(dirname $NEW)/$(basename $NEW .new)"
+ if [ -e $OLD ]; then
+ cp -a $OLD ${NEW}.incoming
+ cat $NEW > ${NEW}.incoming
+ touch -r $NEW ${NEW}.incoming
+ mv ${NEW}.incoming $NEW
+ fi
+ install_file $NEW
+}
+
+
+# arg 1: the new package version
+pre_install() {
+ /bin/true
+}
+
+# arg 1: the new package version
+post_install() {
+ install_file etc/grub.d/40_custom.new
+ rm -f etc/grub.d/40_custom.new
+ install_file etc/default/grub.new
+
+ #
+ # NOTE:
+ # 'install-info' can work using relative paths and we can make use build machine
+ # utility during installation to the some partition and use target 'install-info'
+ # during installation directly on the running target machine.
+ #
+ if [ -x /usr/bin/install-info ] ; then
+ install-info --info-dir=usr/share/info usr/share/info/grub.info.gz 2>/dev/null
+ install-info --info-dir=usr/share/info usr/share/info/grub-dev.info.gz 2>/dev/null
+ elif ! grep "(grub)" usr/share/info/dir 1> /dev/null 2> /dev/null ; then
+ cat << EOF >> usr/share/info/dir
+
+Kernel
+* grub-dev: (grub-dev). The GRand Unified Bootloader Dev
+* grub-install: (grub)Invoking grub-install.
+ Install GRUB on your drive
+* grub-mkconfig: (grub)Invoking grub-mkconfig.
+ Generate GRUB configuration
+* grub-mkpasswd-pbkdf2: (grub)Invoking grub-mkpasswd-pbkdf2.
+* grub-mkrelpath: (grub)Invoking grub-mkrelpath.
+* grub-mkrescue: (grub)Invoking grub-mkrescue.
+ Make a GRUB rescue image
+* grub-mount: (grub)Invoking grub-mount.
+ Mount a file system using GRUB
+* grub-probe: (grub)Invoking grub-probe.
+ Probe device information
+* grub-script-check: (grub)Invoking grub-script-check.
+* GRUB: (grub). The GRand Unified Bootloader
+EOF
+ fi
+}
+
+# arg 1: the new package version
+# arg 2: the old package version
+pre_update() {
+ /bin/true
+}
+
+# arg 1: the new package version
+# arg 2: the old package version
+post_update() {
+ post_install
+}
+
+# arg 1: the old package version
+pre_remove() {
+ if [ -x /usr/bin/install-info ] ; then
+ install-info --delete --info-file=usr/share/info/grub-dev.info.gz --dir-file=usr/share/info/dir 2> /dev/null || /bin/true
+ install-info --delete --info-file=usr/share/info/grub.info.gz --dir-file=usr/share/info/dir 2> /dev/null || /bin/true
+ fi
+}
+
+# arg 1: the old package version
+post_remove() {
+ /bin/true
+}
+
+
+operation=$1
+shift
+
+$operation $*
Property changes on: radix-1.9/boot/grub/visionfive2/2.06/grub-pkg-install.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/boot/grub/visionfive2/2.06
===================================================================
--- radix-1.9/boot/grub/visionfive2/2.06 (nonexistent)
+++ radix-1.9/boot/grub/visionfive2/2.06 (revision 216)
Property changes on: radix-1.9/boot/grub/visionfive2/2.06
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,74 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.rk358x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: radix-1.9/media/alsa-utils/1.2.8/Makefile
===================================================================
--- radix-1.9/media/alsa-utils/1.2.8/Makefile (revision 215)
+++ radix-1.9/media/alsa-utils/1.2.8/Makefile (revision 216)
@@ -176,7 +176,7 @@
else
@cp $(conf_dir)/rc.d/rc.alsa $(ALSA_UTILS_PKG)/etc/rc.d/rc.alsa.new
endif
-ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_RK358X_GLIBC)),)
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_RK358X_GLIBC) $(TOOLCHAIN_RISCV64_GLIBC)),)
@sed -i 's, restore, --no-ucm restore,g' $(ALSA_UTILS_PKG)/etc/rc.d/rc.alsa.new
endif
@chmod 0755 $(ALSA_UTILS_PKG)/etc/rc.d/rc.alsa.new
Index: radix-1.9/products/base/Makefile
===================================================================
--- radix-1.9/products/base/Makefile (revision 215)
+++ radix-1.9/products/base/Makefile (revision 216)
@@ -78,6 +78,7 @@
ifneq ($(filter $(HARDWARE),$(HARDWARE_VISIONFIVE2)),)
REQUIRES = boot/kernel/visionfive2/6.1.31-3.8.2
+REQUIRES += boot/grub/visionfive2/2.06
endif
ifneq ($(filter $(HARDWARE),$(HARDWARE_REPKA_PI3)),)
Index: radix-1.9/sources/GNU/grub/Makefile
===================================================================
--- radix-1.9/sources/GNU/grub/Makefile (revision 215)
+++ radix-1.9/sources/GNU/grub/Makefile (revision 216)
@@ -21,6 +21,10 @@
patches += $(CURDIR)/patches/grub-2.06-no-efi.patch
patches += $(CURDIR)/patches/grub-2.06-gensyminfo.patch
patches += $(CURDIR)/patches/grub-2.06-modinfo.patch
+patches += $(CURDIR)/patches/grub-2.06-normal-welcome.patch
+patches += $(CURDIR)/patches/grub-2.06-riscv-image-header.patch
+patches += $(CURDIR)/patches/grub-2.06-riscv-linux-loader.patch
+patches += $(CURDIR)/patches/grub-2.06-riscv-relocation.patch
.NOTPARALLEL: $(patches)
@@ -55,13 +59,17 @@
$(patches): $(sha1s)
@echo -e "\n======= Create Patches =======\n" ; \
- ( cd create-2.06-initrd-names-patch ; ./create.patch.sh ) ; \
- ( cd create-2.06-dejavu-sans-patch ; ./create.patch.sh ) ; \
- ( cd create-2.06-align-struct-patch ; ./create.patch.sh ) ; \
- ( cd create-2.06-fonts-ttf-patch ; ./create.patch.sh ) ; \
- ( cd create-2.06-no-efi-patch ; ./create.patch.sh ) ; \
- ( cd create-2.06-gensyminfo-patch ; ./create.patch.sh ) ; \
- ( cd create-2.06-modinfo-patch ; ./create.patch.sh ) ; \
+ ( cd create-2.06-initrd-names-patch ; ./create.patch.sh ) ; \
+ ( cd create-2.06-dejavu-sans-patch ; ./create.patch.sh ) ; \
+ ( cd create-2.06-align-struct-patch ; ./create.patch.sh ) ; \
+ ( cd create-2.06-fonts-ttf-patch ; ./create.patch.sh ) ; \
+ ( cd create-2.06-no-efi-patch ; ./create.patch.sh ) ; \
+ ( cd create-2.06-gensyminfo-patch ; ./create.patch.sh ) ; \
+ ( cd create-2.06-modinfo-patch ; ./create.patch.sh ) ; \
+ ( cd create-2.06-normal-welcome-patch ; ./create.patch.sh ) ; \
+ ( cd create-2.06-riscv-image-header-patch ; ./create.patch.sh ) ; \
+ ( cd create-2.06-riscv-linux-loader-patch ; ./create.patch.sh ) ; \
+ ( cd create-2.06-riscv-relocation-patch ; ./create.patch.sh ) ; \
echo -e "\n"
download_clean:
Index: radix-1.9/sources/GNU/grub/create-2.06-normal-welcome-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-normal-welcome-patch/create.patch.sh (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-normal-welcome-patch/create.patch.sh (revision 216)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=2.06
+
+tar --files-from=file.list -xJvf ../grub-$VERSION.tar.xz
+mv grub-$VERSION grub-$VERSION-orig
+
+cp -rf ./grub-$VERSION-new ./grub-$VERSION
+
+diff --unified -Nr grub-$VERSION-orig grub-$VERSION > grub-$VERSION-normal-welcome.patch
+
+mv grub-$VERSION-normal-welcome.patch ../patches
+
+rm -rf ./grub-$VERSION
+rm -rf ./grub-$VERSION-orig
Property changes on: radix-1.9/sources/GNU/grub/create-2.06-normal-welcome-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/GNU/grub/create-2.06-normal-welcome-patch/file.list
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-normal-welcome-patch/file.list (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-normal-welcome-patch/file.list (revision 216)
@@ -0,0 +1 @@
+grub-2.06/grub-core/kern/main.c
Index: radix-1.9/sources/GNU/grub/create-2.06-normal-welcome-patch/grub-2.06-new/grub-core/kern/main.c
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-normal-welcome-patch/grub-2.06-new/grub-core/kern/main.c (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-normal-welcome-patch/grub-2.06-new/grub-core/kern/main.c (revision 216)
@@ -0,0 +1,316 @@
+/* main.c - the kernel main routine */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2006,2008,2009 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/kernel.h>
+#include <grub/misc.h>
+#include <grub/symbol.h>
+#include <grub/dl.h>
+#include <grub/term.h>
+#include <grub/file.h>
+#include <grub/device.h>
+#include <grub/env.h>
+#include <grub/mm.h>
+#include <grub/command.h>
+#include <grub/reader.h>
+#include <grub/parser.h>
+#include <grub/verify.h>
+
+#ifdef GRUB_MACHINE_PCBIOS
+#include <grub/machine/memory.h>
+#endif
+
+grub_addr_t
+grub_modules_get_end (void)
+{
+ struct grub_module_info *modinfo;
+
+ modinfo = (struct grub_module_info *) grub_modbase;
+
+ /* Check if there are any modules. */
+ if ((modinfo == 0) || modinfo->magic != GRUB_MODULE_MAGIC)
+ return grub_modbase;
+
+ return grub_modbase + modinfo->size;
+}
+
+/* Load all modules in core. */
+static void
+grub_load_modules (void)
+{
+ struct grub_module_header *header;
+ FOR_MODULES (header)
+ {
+ /* Not an ELF module, skip. */
+ if (header->type != OBJ_TYPE_ELF)
+ continue;
+
+ if (! grub_dl_load_core ((char *) header + sizeof (struct grub_module_header),
+ (header->size - sizeof (struct grub_module_header))))
+ grub_fatal ("%s", grub_errmsg);
+
+ if (grub_errno)
+ grub_print_error ();
+ }
+}
+
+static char *load_config;
+
+static void
+grub_load_config (void)
+{
+ struct grub_module_header *header;
+ FOR_MODULES (header)
+ {
+ /* Not an embedded config, skip. */
+ if (header->type != OBJ_TYPE_CONFIG)
+ continue;
+
+ load_config = grub_malloc (header->size - sizeof (struct grub_module_header) + 1);
+ if (!load_config)
+ {
+ grub_print_error ();
+ break;
+ }
+ grub_memcpy (load_config, (char *) header +
+ sizeof (struct grub_module_header),
+ header->size - sizeof (struct grub_module_header));
+ load_config[header->size - sizeof (struct grub_module_header)] = 0;
+ break;
+ }
+}
+
+/* Write hook for the environment variables of root. Remove surrounding
+ parentheses, if any. */
+static char *
+grub_env_write_root (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val)
+{
+ /* XXX Is it better to check the existence of the device? */
+ grub_size_t len = grub_strlen (val);
+
+ if (val[0] == '(' && val[len - 1] == ')')
+ return grub_strndup (val + 1, len - 2);
+
+ return grub_strdup (val);
+}
+
+static void
+grub_set_prefix_and_root (void)
+{
+ char *device = NULL;
+ char *path = NULL;
+ char *fwdevice = NULL;
+ char *fwpath = NULL;
+ char *prefix = NULL;
+ struct grub_module_header *header;
+
+ FOR_MODULES (header)
+ if (header->type == OBJ_TYPE_PREFIX)
+ prefix = (char *) header + sizeof (struct grub_module_header);
+
+ grub_register_variable_hook ("root", 0, grub_env_write_root);
+
+ grub_machine_get_bootlocation (&fwdevice, &fwpath);
+
+ if (fwdevice)
+ {
+ char *cmdpath;
+
+ cmdpath = grub_xasprintf ("(%s)%s", fwdevice, fwpath ? : "");
+ if (cmdpath)
+ {
+ grub_env_set ("cmdpath", cmdpath);
+ grub_env_export ("cmdpath");
+ grub_free (cmdpath);
+ }
+ }
+
+ if (prefix)
+ {
+ char *pptr = NULL;
+ if (prefix[0] == '(')
+ {
+ pptr = grub_strrchr (prefix, ')');
+ if (pptr)
+ {
+ device = grub_strndup (prefix + 1, pptr - prefix - 1);
+ pptr++;
+ }
+ }
+ if (!pptr)
+ pptr = prefix;
+ if (pptr[0])
+ path = grub_strdup (pptr);
+ }
+
+ if (!device && fwdevice)
+ device = fwdevice;
+ else if (fwdevice && (device[0] == ',' || !device[0]))
+ {
+ /* We have a partition, but still need to fill in the drive. */
+ char *comma, *new_device;
+
+ for (comma = fwdevice; *comma; )
+ {
+ if (comma[0] == '\\' && comma[1] == ',')
+ {
+ comma += 2;
+ continue;
+ }
+ if (*comma == ',')
+ break;
+ comma++;
+ }
+ if (*comma)
+ {
+ char *drive = grub_strndup (fwdevice, comma - fwdevice);
+ new_device = grub_xasprintf ("%s%s", drive, device);
+ grub_free (drive);
+ }
+ else
+ new_device = grub_xasprintf ("%s%s", fwdevice, device);
+
+ grub_free (fwdevice);
+ grub_free (device);
+ device = new_device;
+ }
+ else
+ grub_free (fwdevice);
+ if (fwpath && !path)
+ {
+ grub_size_t len = grub_strlen (fwpath);
+ while (len > 1 && fwpath[len - 1] == '/')
+ fwpath[--len] = 0;
+ if (len >= sizeof (GRUB_TARGET_CPU "-" GRUB_PLATFORM) - 1
+ && grub_memcmp (fwpath + len - (sizeof (GRUB_TARGET_CPU "-" GRUB_PLATFORM) - 1), GRUB_TARGET_CPU "-" GRUB_PLATFORM,
+ sizeof (GRUB_TARGET_CPU "-" GRUB_PLATFORM) - 1) == 0)
+ fwpath[len - (sizeof (GRUB_TARGET_CPU "-" GRUB_PLATFORM) - 1)] = 0;
+ path = fwpath;
+ }
+ else
+ grub_free (fwpath);
+ if (device)
+ {
+ char *prefix_set;
+
+ prefix_set = grub_xasprintf ("(%s)%s", device, path ? : "");
+ if (prefix_set)
+ {
+ grub_env_set ("prefix", prefix_set);
+ grub_free (prefix_set);
+ }
+ grub_env_set ("root", device);
+ }
+
+ grub_free (device);
+ grub_free (path);
+ grub_print_error ();
+}
+
+/* Load the normal mode module and execute the normal mode if possible. */
+static void
+grub_load_normal_mode (void)
+{
+ /* Load the module. */
+ grub_dl_load ("normal");
+
+ /* Print errors if any. */
+ grub_print_error ();
+ grub_errno = 0;
+
+ grub_command_execute ("normal", 0, 0);
+}
+
+static void
+reclaim_module_space (void)
+{
+ grub_addr_t modstart, modend;
+
+ if (!grub_modbase)
+ return;
+
+#ifdef GRUB_MACHINE_PCBIOS
+ modstart = GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR;
+#else
+ modstart = grub_modbase;
+#endif
+ modend = grub_modules_get_end ();
+ grub_modbase = 0;
+
+#if GRUB_KERNEL_PRELOAD_SPACE_REUSABLE
+ grub_mm_init_region ((void *) modstart, modend - modstart);
+#else
+ (void) modstart;
+ (void) modend;
+#endif
+}
+
+/* The main routine. */
+void __attribute__ ((noreturn))
+grub_main (void)
+{
+ /* First of all, initialize the machine. */
+ grub_machine_init ();
+
+ grub_boot_time ("After machine init.");
+
+ /* Hello. */
+ grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
+ grub_printf ("Welcome to GRUB!\n\n");
+ grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
+
+ /* Init verifiers API. */
+ grub_verifiers_init ();
+
+ grub_load_config ();
+
+ grub_boot_time ("Before loading embedded modules.");
+
+ /* Load pre-loaded modules and free the space. */
+ grub_register_exported_symbols ();
+#ifdef GRUB_LINKER_HAVE_INIT
+ grub_arch_dl_init_linker ();
+#endif
+ grub_load_modules ();
+
+ grub_boot_time ("After loading embedded modules.");
+
+ /* It is better to set the root device as soon as possible,
+ for convenience. */
+ grub_set_prefix_and_root ();
+ grub_env_export ("root");
+ grub_env_export ("prefix");
+
+ /* Reclaim space used for modules. */
+ reclaim_module_space ();
+
+ grub_boot_time ("After reclaiming module space.");
+
+ grub_register_core_commands ();
+
+ grub_boot_time ("Before execution of embedded config.");
+
+ if (load_config)
+ grub_parser_execute (load_config);
+
+ grub_boot_time ("After execution of embedded config. Attempt to go to normal mode");
+
+ grub_load_normal_mode ();
+ grub_rescue_run ();
+}
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/create.patch.sh (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/create.patch.sh (revision 216)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=2.06
+
+tar --files-from=file.list -xJvf ../grub-$VERSION.tar.xz
+mv grub-$VERSION grub-$VERSION-orig
+
+cp -rf ./grub-$VERSION-new ./grub-$VERSION
+
+diff --unified -Nr grub-$VERSION-orig grub-$VERSION > grub-$VERSION-riscv-image-header.patch
+
+mv grub-$VERSION-riscv-image-header.patch ../patches
+
+rm -rf ./grub-$VERSION
+rm -rf ./grub-$VERSION-orig
Property changes on: radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/file.list
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/file.list (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/file.list (revision 216)
@@ -0,0 +1,2 @@
+grub-2.06/include/grub/riscv32/linux.h
+grub-2.06/include/grub/riscv64/linux.h
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/grub-2.06-new/include/grub/riscv32/linux.h
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/grub-2.06-new/include/grub/riscv32/linux.h (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/grub-2.06-new/include/grub/riscv32/linux.h (revision 216)
@@ -0,0 +1,42 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 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/>.
+ */
+
+#ifndef GRUB_RISCV32_LINUX_HEADER
+#define GRUB_RISCV32_LINUX_HEADER 1
+
+#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x05435352 /* 'RSC\0x5' */
+
+/* From linux/Documentation/riscv/boot-image-header.rst */
+struct linux_riscv_kernel_header
+{
+ grub_uint32_t code0; /* Executable code */
+ grub_uint32_t code1; /* Executable code */
+ grub_uint64_t text_offset; /* Image load offset, little endian */
+ grub_uint64_t image_size; /* Effective Image size, little endian */
+ grub_uint64_t flags; /* kernel flags, little endian */
+ grub_uint32_t version; /* Version of this header */
+ grub_uint32_t res1; /* reserved */
+ grub_uint64_t res2; /* reserved */
+ grub_uint64_t res3; /* reserved */
+ grub_uint32_t magic; /* Magic number, little endian, "RSC\0x5" */
+ grub_uint32_t hdr_offset; /* Offset of PE/COFF header */
+};
+
+#define linux_arch_kernel_header linux_riscv_kernel_header
+
+#endif /* ! GRUB_RISCV32_LINUX_HEADER */
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/grub-2.06-new/include/grub/riscv64/linux.h
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/grub-2.06-new/include/grub/riscv64/linux.h (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-image-header-patch/grub-2.06-new/include/grub/riscv64/linux.h (revision 216)
@@ -0,0 +1,44 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 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/>.
+ */
+
+#ifndef GRUB_RISCV64_LINUX_HEADER
+#define GRUB_RISCV64_LINUX_HEADER 1
+
+#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x05435352 /* 'RSC\0x5' */
+
+#define GRUB_EFI_PE_MAGIC 0x5A4D
+
+/* From linux/Documentation/riscv/boot-image-header.rst */
+struct linux_riscv_kernel_header
+{
+ grub_uint32_t code0; /* Executable code */
+ grub_uint32_t code1; /* Executable code */
+ grub_uint64_t text_offset; /* Image load offset, little endian */
+ grub_uint64_t image_size; /* Effective Image size, little endian */
+ grub_uint64_t flags; /* kernel flags, little endian */
+ grub_uint32_t version; /* Version of this header */
+ grub_uint32_t res1; /* reserved */
+ grub_uint64_t res2; /* reserved */
+ grub_uint64_t res3; /* reserved */
+ grub_uint32_t magic; /* Magic number, little endian, "RSC\0x5" */
+ grub_uint32_t hdr_offset; /* Offset of PE/COFF header */
+};
+
+#define linux_arch_kernel_header linux_riscv_kernel_header
+
+#endif /* ! GRUB_RISCV64_LINUX_HEADER */
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/create.patch.sh (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/create.patch.sh (revision 216)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=2.06
+
+tar --files-from=file.list -xJvf ../grub-$VERSION.tar.xz
+mv grub-$VERSION grub-$VERSION-orig
+
+cp -rf ./grub-$VERSION-new ./grub-$VERSION
+
+diff --unified -Nr grub-$VERSION-orig grub-$VERSION > grub-$VERSION-riscv-linux-loader.patch
+
+mv grub-$VERSION-riscv-linux-loader.patch ../patches
+
+rm -rf ./grub-$VERSION
+rm -rf ./grub-$VERSION-orig
Property changes on: radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/file.list
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/file.list (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/file.list (revision 216)
@@ -0,0 +1,8 @@
+grub-2.06/grub-core/Makefile.core.def
+grub-2.06/grub-core/commands/efi/lsefi.c
+grub-2.06/grub-core/loader/efi/fdt.c
+grub-2.06/grub-core/loader/riscv/linux.c
+grub-2.06/include/grub/efi/api.h
+grub-2.06/include/grub/riscv32/linux.h
+grub-2.06/include/grub/riscv64/linux.h
+grub-2.06/po/POTFILES.in
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/grub-core/Makefile.core.def
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/grub-core/Makefile.core.def (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/grub-core/Makefile.core.def (revision 216)
@@ -0,0 +1,2529 @@
+AutoGen definitions Makefile.tpl;
+
+transform_data = {
+ installdir = noinst;
+ name = gensyminfo.sh;
+ common = gensyminfo.sh.in;
+};
+
+transform_data = {
+ installdir = noinst;
+ name = genmod.sh;
+ common = genmod.sh.in;
+};
+
+transform_data = {
+ installdir = noinst;
+ name = modinfo.sh;
+ common = modinfo.sh.in;
+};
+
+transform_data = {
+ installdir = platform;
+ name = gmodule.pl;
+ common = gmodule.pl.in;
+};
+
+transform_data = {
+ installdir = platform;
+ name = gdb_grub;
+ common = gdb_grub.in;
+};
+
+transform_data = {
+ installdir = platform;
+ name = grub.chrp;
+ common = boot/powerpc/grub.chrp.in;
+ enable = powerpc_ieee1275;
+};
+
+transform_data = {
+ installdir = platform;
+ name = bootinfo.txt;
+ common = boot/powerpc/bootinfo.txt.in;
+ enable = powerpc_ieee1275;
+};
+
+kernel = {
+ name = kernel;
+
+ nostrip = emu;
+
+ emu_ldflags = '-Wl,-r,-d';
+ i386_efi_ldflags = '-Wl,-r,-d';
+ i386_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+ x86_64_efi_ldflags = '-Wl,-r,-d';
+ x86_64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+
+ ia64_efi_cflags = '-fno-builtin -fpic -minline-int-divide-max-throughput';
+ ia64_efi_ldflags = '-Wl,-r,-d';
+ ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+
+ arm_efi_ldflags = '-Wl,-r,-d';
+ arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+
+ arm64_efi_ldflags = '-Wl,-r,-d';
+ arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
+
+ riscv32_efi_ldflags = '-Wl,-r,-d';
+ riscv32_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
+
+ riscv64_efi_ldflags = '-Wl,-r,-d';
+ riscv64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
+
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
+ i386_qemu_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
+ i386_coreboot_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_coreboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
+ i386_multiboot_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_multiboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
+ i386_ieee1275_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_ieee1275_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x10000';
+ i386_xen_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0';
+ x86_64_xen_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ x86_64_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0';
+ i386_xen_pvh_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_xen_pvh_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x100000';
+
+ mips_loongson_ldflags = '-Wl,-Ttext,0x80200000';
+ powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
+ sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
+ mips_arc_ldflags = '-Wl,-Ttext,$(TARGET_LINK_ADDR)';
+ mips_qemu_mips_ldflags = '-Wl,-Ttext,0x80200000';
+
+ mips_arc_cppflags = '-DGRUB_DECOMPRESSOR_LINK_ADDR=$(TARGET_DECOMPRESSOR_LINK_ADDR)';
+ i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
+ emu_cflags = '$(CFLAGS_GNULIB)';
+ emu_cppflags = '$(CPPFLAGS_GNULIB)';
+ arm_uboot_ldflags = '-Wl,-r,-d';
+ arm_uboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+ arm_coreboot_ldflags = '-Wl,-r,-d';
+ arm_coreboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+
+ i386_pc_startup = kern/i386/pc/startup.S;
+ i386_efi_startup = kern/i386/efi/startup.S;
+ x86_64_efi_startup = kern/x86_64/efi/startup.S;
+ i386_xen_startup = kern/i386/xen/startup.S;
+ x86_64_xen_startup = kern/x86_64/xen/startup.S;
+ i386_xen_pvh_startup = kern/i386/xen/startup_pvh.S;
+ i386_qemu_startup = kern/i386/qemu/startup.S;
+ i386_ieee1275_startup = kern/i386/ieee1275/startup.S;
+ i386_coreboot_startup = kern/i386/coreboot/startup.S;
+ i386_multiboot_startup = kern/i386/coreboot/startup.S;
+ mips_startup = kern/mips/startup.S;
+ sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S;
+ powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S;
+ arm_uboot_startup = kern/arm/startup.S;
+ arm_coreboot_startup = kern/arm/startup.S;
+ arm_efi_startup = kern/arm/efi/startup.S;
+ arm64_efi_startup = kern/arm64/efi/startup.S;
+ riscv32_efi_startup = kern/riscv/efi/startup.S;
+ riscv64_efi_startup = kern/riscv/efi/startup.S;
+
+ common = kern/buffer.c;
+ common = kern/command.c;
+ common = kern/corecmd.c;
+ common = kern/device.c;
+ common = kern/disk.c;
+ common = kern/dl.c;
+ common = kern/env.c;
+ common = kern/err.c;
+ common = kern/file.c;
+ common = kern/fs.c;
+ common = kern/list.c;
+ common = kern/main.c;
+ common = kern/misc.c;
+ common = kern/parser.c;
+ common = kern/partition.c;
+ common = kern/rescue_parser.c;
+ common = kern/rescue_reader.c;
+ common = kern/term.c;
+ common = kern/verifiers.c;
+
+ noemu = kern/compiler-rt.c;
+ noemu = kern/mm.c;
+ noemu = kern/time.c;
+ noemu = kern/generic/millisleep.c;
+
+ noemu_nodist = symlist.c;
+
+ mips = kern/generic/rtc_get_time_ms.c;
+
+ ieee1275 = disk/ieee1275/ofdisk.c;
+ ieee1275 = kern/ieee1275/cmain.c;
+ ieee1275 = kern/ieee1275/ieee1275.c;
+ ieee1275 = kern/ieee1275/mmap.c;
+ ieee1275 = kern/ieee1275/openfw.c;
+ ieee1275 = term/ieee1275/console.c;
+ ieee1275 = kern/ieee1275/init.c;
+
+ uboot = disk/uboot/ubootdisk.c;
+ uboot = kern/uboot/uboot.c;
+ uboot = kern/uboot/init.c;
+ uboot = kern/uboot/hw.c;
+ uboot = term/uboot/console.c;
+ arm_uboot = kern/arm/uboot/init.c;
+ arm_uboot = kern/arm/uboot/uboot.S;
+
+ arm_coreboot = kern/arm/coreboot/init.c;
+ arm_coreboot = kern/arm/coreboot/timer.c;
+ arm_coreboot = kern/arm/coreboot/coreboot.S;
+ arm_coreboot = lib/fdt.c;
+ arm_coreboot = bus/fdt.c;
+ arm_coreboot = term/ps2.c;
+ arm_coreboot = term/arm/pl050.c;
+ arm_coreboot = term/arm/cros.c;
+ arm_coreboot = term/arm/cros_ec.c;
+ arm_coreboot = bus/spi/rk3288_spi.c;
+ arm_coreboot = commands/keylayouts.c;
+ arm_coreboot = kern/arm/coreboot/dma.c;
+
+ terminfoinkernel = term/terminfo.c;
+ terminfoinkernel = term/tparm.c;
+ terminfoinkernel = commands/extcmd.c;
+ terminfoinkernel = lib/arg.c;
+
+ softdiv = lib/division.c;
+
+ i386 = kern/i386/dl.c;
+ i386_xen = kern/i386/dl.c;
+ i386_xen_pvh = kern/i386/dl.c;
+
+ i386_coreboot = kern/i386/coreboot/init.c;
+ i386_multiboot = kern/i386/coreboot/init.c;
+ i386_qemu = kern/i386/qemu/init.c;
+ i386_coreboot_multiboot_qemu = term/i386/pc/vga_text.c;
+ coreboot = video/coreboot/cbfb.c;
+
+ efi = disk/efi/efidisk.c;
+ efi = kern/efi/efi.c;
+ efi = kern/efi/init.c;
+ efi = kern/efi/mm.c;
+ efi = term/efi/console.c;
+ efi = kern/acpi.c;
+ efi = kern/efi/acpi.c;
+ efi = kern/efi/sb.c;
+ efi = kern/lockdown.c;
+ i386_coreboot = kern/i386/pc/acpi.c;
+ i386_multiboot = kern/i386/pc/acpi.c;
+ i386_coreboot = kern/acpi.c;
+ i386_multiboot = kern/acpi.c;
+
+ x86 = kern/i386/tsc.c;
+ x86 = kern/i386/tsc_pit.c;
+ i386_efi = kern/i386/efi/tsc.c;
+ x86_64_efi = kern/i386/efi/tsc.c;
+ i386_efi = kern/i386/tsc_pmtimer.c;
+ i386_coreboot = kern/i386/tsc_pmtimer.c;
+ x86_64_efi = kern/i386/tsc_pmtimer.c;
+
+ i386_efi = kern/i386/efi/init.c;
+ i386_efi = bus/pci.c;
+
+ x86_64 = kern/x86_64/dl.c;
+ x86_64_xen = kern/x86_64/dl.c;
+ x86_64_efi = kern/x86_64/efi/callwrap.S;
+ x86_64_efi = kern/i386/efi/init.c;
+ x86_64_efi = bus/pci.c;
+
+ xen = kern/i386/tsc.c;
+ xen = kern/i386/xen/tsc.c;
+ x86_64_xen = kern/x86_64/xen/hypercall.S;
+ i386_xen = kern/i386/xen/hypercall.S;
+ xen = kern/xen/init.c;
+ xen = term/xen/console.c;
+ xen = disk/xen/xendisk.c;
+ xen = commands/boot.c;
+
+ i386_xen_pvh = commands/boot.c;
+ i386_xen_pvh = disk/xen/xendisk.c;
+ i386_xen_pvh = kern/i386/tsc.c;
+ i386_xen_pvh = kern/i386/xen/tsc.c;
+ i386_xen_pvh = kern/i386/xen/pvh.c;
+ i386_xen_pvh = kern/xen/init.c;
+ i386_xen_pvh = term/xen/console.c;
+
+ ia64_efi = kern/ia64/efi/startup.S;
+ ia64_efi = kern/ia64/efi/init.c;
+ ia64_efi = kern/ia64/dl.c;
+ ia64_efi = kern/ia64/dl_helper.c;
+ ia64_efi = kern/ia64/cache.c;
+
+ arm_efi = kern/arm/efi/init.c;
+ arm_efi = kern/efi/fdt.c;
+
+ arm64_efi = kern/arm64/efi/init.c;
+ arm64_efi = kern/efi/fdt.c;
+
+ riscv32_efi = kern/riscv/efi/init.c;
+ riscv32_efi = kern/efi/fdt.c;
+
+ riscv64_efi = kern/riscv/efi/init.c;
+ riscv64_efi = kern/efi/fdt.c;
+
+ i386_pc = kern/i386/pc/init.c;
+ i386_pc = kern/i386/pc/mmap.c;
+ i386_pc = term/i386/pc/console.c;
+
+ i386_qemu = bus/pci.c;
+ i386_qemu = kern/vga_init.c;
+ i386_qemu = kern/i386/qemu/mmap.c;
+
+ coreboot = kern/coreboot/mmap.c;
+ i386_coreboot = kern/i386/coreboot/cbtable.c;
+ coreboot = kern/coreboot/cbtable.c;
+ arm_coreboot = kern/arm/coreboot/cbtable.c;
+
+ i386_multiboot = kern/i386/multiboot_mmap.c;
+
+ mips = kern/mips/cache.S;
+ mips = kern/mips/dl.c;
+ mips = kern/mips/init.c;
+
+ mips_qemu_mips = kern/mips/qemu_mips/init.c;
+ mips_qemu_mips = term/ns8250.c;
+ mips_qemu_mips = term/serial.c;
+ mips_qemu_mips = term/at_keyboard.c;
+ mips_qemu_mips = term/ps2.c;
+ mips_qemu_mips = commands/boot.c;
+ mips_qemu_mips = commands/keylayouts.c;
+ mips_qemu_mips = term/i386/pc/vga_text.c;
+ mips_qemu_mips = kern/vga_init.c;
+
+ mips_arc = kern/mips/arc/init.c;
+ mips_arc = term/arc/console.c;
+ mips_arc = disk/arc/arcdisk.c;
+
+ mips_loongson = term/ns8250.c;
+ mips_loongson = bus/bonito.c;
+ mips_loongson = bus/cs5536.c;
+ mips_loongson = bus/pci.c;
+ mips_loongson = kern/mips/loongson/init.c;
+ mips_loongson = term/at_keyboard.c;
+ mips_loongson = term/ps2.c;
+ mips_loongson = commands/boot.c;
+ mips_loongson = term/serial.c;
+ mips_loongson = video/sm712.c;
+ mips_loongson = video/sis315pro.c;
+ mips_loongson = video/radeon_fuloong2e.c;
+ mips_loongson = video/radeon_yeeloong3a.c;
+ extra_dist = video/sm712_init.c;
+ extra_dist = video/sis315_init.c;
+ mips_loongson = commands/keylayouts.c;
+
+ powerpc_ieee1275 = kern/powerpc/cache.S;
+ powerpc_ieee1275 = kern/powerpc/dl.c;
+ powerpc_ieee1275 = kern/powerpc/compiler-rt.S;
+
+ sparc64_ieee1275 = kern/sparc64/cache.S;
+ sparc64_ieee1275 = kern/sparc64/dl.c;
+ sparc64_ieee1275 = kern/sparc64/ieee1275/ieee1275.c;
+ sparc64_ieee1275 = disk/ieee1275/obdisk.c;
+
+ arm = kern/arm/dl.c;
+ arm = kern/arm/dl_helper.c;
+ arm = kern/arm/cache_armv6.S;
+ arm = kern/arm/cache_armv7.S;
+ extra_dist = kern/arm/cache.S;
+ arm = kern/arm/cache.c;
+ arm = kern/arm/compiler-rt.S;
+
+ arm64 = kern/arm64/cache.c;
+ arm64 = kern/arm64/cache_flush.S;
+ arm64 = kern/arm64/dl.c;
+ arm64 = kern/arm64/dl_helper.c;
+
+ riscv32 = kern/riscv/cache.c;
+ riscv32 = kern/riscv/cache_flush.S;
+ riscv32 = kern/riscv/dl.c;
+
+ riscv64 = kern/riscv/cache.c;
+ riscv64 = kern/riscv/cache_flush.S;
+ riscv64 = kern/riscv/dl.c;
+
+ emu = disk/host.c;
+ emu = kern/emu/cache_s.S;
+ emu = kern/emu/hostdisk.c;
+ emu = osdep/unix/hostdisk.c;
+ emu = osdep/exec.c;
+ extra_dist = osdep/unix/exec.c;
+ emu = osdep/devmapper/hostdisk.c;
+ emu = osdep/hostdisk.c;
+ emu = kern/emu/hostfs.c;
+ emu = kern/emu/main.c;
+ emu = kern/emu/argp_common.c;
+ emu = kern/emu/misc.c;
+ emu = kern/emu/mm.c;
+ emu = kern/emu/time.c;
+ emu = kern/emu/cache.c;
+ emu = osdep/emuconsole.c;
+ extra_dist = osdep/unix/emuconsole.c;
+ extra_dist = osdep/windows/emuconsole.c;
+ emu = osdep/dl.c;
+ extra_dist = osdep/unix/dl.c;
+ extra_dist = osdep/windows/dl.c;
+ emu = osdep/sleep.c;
+ emu = osdep/init.c;
+ emu = osdep/emunet.c;
+ extra_dist = osdep/linux/emunet.c;
+ extra_dist = osdep/basic/emunet.c;
+ emu = osdep/cputime.c;
+ extra_dist = osdep/unix/cputime.c;
+ extra_dist = osdep/windows/cputime.c;
+
+ videoinkernel = term/gfxterm.c;
+ videoinkernel = font/font.c;
+ videoinkernel = font/font_cmd.c;
+ videoinkernel = io/bufio.c;
+ videoinkernel = video/fb/fbblit.c;
+ videoinkernel = video/fb/fbfill.c;
+ videoinkernel = video/fb/fbutil.c;
+ videoinkernel = video/fb/video_fb.c;
+ videoinkernel = video/video.c;
+
+ extra_dist = kern/i386/int.S;
+ extra_dist = kern/i386/realmode.S;
+ extra_dist = boot/i386/pc/lzma_decode.S;
+ extra_dist = kern/mips/cache_flush.S;
+};
+
+program = {
+ name = grub-emu;
+ mansection = 1;
+
+ emu = kern/emu/full.c;
+ emu_nodist = grub_emu_init.c;
+
+ ldadd = 'kernel.exec$(EXEEXT)';
+ ldadd = '$(MODULE_FILES)';
+ ldadd = 'lib/gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
+
+ enable = emu;
+};
+
+program = {
+ name = grub-emu-lite;
+
+ emu = kern/emu/lite.c;
+ emu_nodist = symlist.c;
+
+ ldadd = 'kernel.exec$(EXEEXT)';
+ ldadd = 'lib/gnulib/libgnu.a $(LIBINTL) $(LIBUTIL) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
+
+ enable = emu;
+};
+
+image = {
+ name = boot;
+ i386_pc = boot/i386/pc/boot.S;
+ i386_qemu = boot/i386/qemu/boot.S;
+ sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
+
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
+
+ i386_qemu_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),$(GRUB_BOOT_MACHINE_LINK_ADDR)';
+ i386_qemu_ccasflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
+
+ /* The entry point for a.out binaries on sparc64 starts
+ at 0x4000. Since we are writing the 32 bytes long a.out
+ header in the assembly code ourselves, we need to tell
+ the linker to adjust the start of the text segment to
+ 0x4000 - 0x20 = 0x3fe0.
+ */
+ sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x3fe0';
+ sparc64_ieee1275_objcopyflags = '-O binary';
+
+ objcopyflags = '-O binary';
+ enable = i386_pc;
+ enable = i386_qemu;
+ enable = sparc64_ieee1275;
+};
+
+image = {
+ name = boot_hybrid;
+ i386_pc = boot/i386/pc/boot.S;
+
+ cppflags = '-DHYBRID_BOOT=1';
+
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
+
+ objcopyflags = '-O binary';
+ enable = i386_pc;
+};
+
+image = {
+ name = cdboot;
+
+ i386_pc = boot/i386/pc/cdboot.S;
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
+
+ sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
+
+ /* See comment for sparc64_ieee1275_ldflags above. */
+ sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x3fe0';
+ sparc64_ieee1275_objcopyflags = '-O binary';
+ sparc64_ieee1275_cppflags = '-DCDBOOT=1';
+
+ objcopyflags = '-O binary';
+
+ enable = sparc64_ieee1275;
+ enable = i386_pc;
+};
+
+image = {
+ name = pxeboot;
+ i386_pc = boot/i386/pc/pxeboot.S;
+
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
+
+ objcopyflags = '-O binary';
+ enable = i386_pc;
+};
+
+image = {
+ name = diskboot;
+ i386_pc = boot/i386/pc/diskboot.S;
+
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8000';
+
+ sparc64_ieee1275 = boot/sparc64/ieee1275/diskboot.S;
+ sparc64_ieee1275_ldflags = '-Wl,-Ttext=0x4200';
+
+ objcopyflags = '-O binary';
+
+ enable = i386_pc;
+ enable = sparc64_ieee1275;
+};
+
+image = {
+ name = lnxboot;
+ i386_pc = boot/i386/pc/lnxboot.S;
+
+ i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+ i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x6000';
+
+ objcopyflags = '-O binary';
+ enable = i386_pc;
+};
+
+image = {
+ name = xz_decompress;
+ mips = boot/mips/startup_raw.S;
+ common = boot/decompressor/minilib.c;
+ common = boot/decompressor/xz.c;
+ common = lib/xzembed/xz_dec_bcj.c;
+ common = lib/xzembed/xz_dec_lzma2.c;
+ common = lib/xzembed/xz_dec_stream.c;
+ common = kern/compiler-rt.c;
+
+ cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1';
+
+ objcopyflags = '-O binary';
+ mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
+ cflags = '-Wno-unreachable-code';
+ enable = mips;
+};
+
+image = {
+ name = none_decompress;
+ mips = boot/mips/startup_raw.S;
+ common = boot/decompressor/none.c;
+
+ cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1';
+
+ objcopyflags = '-O binary';
+ mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
+ enable = mips;
+};
+
+image = {
+ name = lzma_decompress;
+ i386_pc = boot/i386/pc/startup_raw.S;
+ i386_pc_nodist = rs_decoder.h;
+
+ objcopyflags = '-O binary';
+ ldflags = '$(TARGET_IMG_LDFLAGS) $(TARGET_IMG_BASE_LDOPT),0x8200';
+ enable = i386_pc;
+};
+
+image = {
+ name = fwstart;
+ mips_loongson = boot/mips/loongson/fwstart.S;
+ objcopyflags = '-O binary';
+ ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
+ enable = mips_loongson;
+};
+
+image = {
+ name = fwstart_fuloong2f;
+ mips_loongson = boot/mips/loongson/fuloong2f.S;
+ objcopyflags = '-O binary';
+ ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
+ enable = mips_loongson;
+};
+
+module = {
+ name = disk;
+ common = lib/disk.c;
+ extra_dist = kern/disk_common.c;
+};
+
+module = {
+ name = trig;
+ common_nodist = trigtables.c;
+ extra_dist = gentrigtables.c;
+};
+
+module = {
+ name = cs5536;
+ x86 = bus/cs5536.c;
+ enable = x86;
+};
+
+module = {
+ name = lsspd;
+ mips_loongson = commands/mips/loongson/lsspd.c;
+ enable = mips_loongson;
+};
+
+module = {
+ name = usb;
+ common = bus/usb/usb.c;
+ common = bus/usb/usbtrans.c;
+ common = bus/usb/usbhub.c;
+ enable = usb;
+};
+
+module = {
+ name = usbserial_common;
+ common = bus/usb/serial/common.c;
+ enable = usb;
+};
+
+module = {
+ name = usbserial_pl2303;
+ common = bus/usb/serial/pl2303.c;
+ enable = usb;
+};
+
+module = {
+ name = usbserial_ftdi;
+ common = bus/usb/serial/ftdi.c;
+ enable = usb;
+};
+
+module = {
+ name = usbserial_usbdebug;
+ common = bus/usb/serial/usbdebug_late.c;
+ enable = usb;
+};
+
+module = {
+ name = uhci;
+ common = bus/usb/uhci.c;
+ enable = pci;
+};
+
+module = {
+ name = ohci;
+ common = bus/usb/ohci.c;
+ enable = pci;
+};
+
+module = {
+ name = ehci;
+ common = bus/usb/ehci.c;
+ arm_coreboot = bus/usb/ehci-fdt.c;
+ pci = bus/usb/ehci-pci.c;
+ enable = pci;
+ enable = arm_coreboot;
+};
+
+module = {
+ name = pci;
+ common = bus/pci.c;
+ i386_ieee1275 = bus/i386/ieee1275/pci.c;
+
+ enable = i386_pc;
+ enable = i386_ieee1275;
+ enable = i386_coreboot;
+ enable = i386_multiboot;
+};
+
+module = {
+ name = nativedisk;
+ common = commands/nativedisk.c;
+
+ enable = x86;
+ enable = mips_loongson;
+ enable = mips_qemu_mips;
+};
+
+module = {
+ name = emupci;
+ common = bus/emu/pci.c;
+ common = commands/lspci.c;
+
+ enable = emu;
+ condition = COND_GRUB_EMU_PCI;
+};
+
+module = {
+ name = lsdev;
+ common = commands/arc/lsdev.c;
+
+ enable = mips_arc;
+};
+
+module = {
+ name = lsxen;
+ common = commands/xen/lsxen.c;
+
+ enable = xen;
+};
+
+module = {
+ name = cmostest;
+ common = commands/i386/cmostest.c;
+ enable = cmos;
+};
+
+module = {
+ name = cmosdump;
+ common = commands/i386/cmosdump.c;
+ enable = cmos;
+};
+
+module = {
+ name = iorw;
+ common = commands/iorw.c;
+ enable = x86;
+};
+
+module = {
+ name = cbtable;
+ common = kern/i386/coreboot/cbtable.c;
+ common = kern/coreboot/cbtable.c;
+ enable = i386_pc;
+ enable = i386_efi;
+ enable = i386_qemu;
+ enable = i386_multiboot;
+ enable = i386_ieee1275;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = cbtime;
+ common = commands/i386/coreboot/cb_timestamps.c;
+ enable = x86;
+};
+
+module = {
+ name = cbls;
+ common = commands/i386/coreboot/cbls.c;
+ enable = x86;
+};
+
+module = {
+ name = cbmemc;
+ common = term/i386/coreboot/cbmemc.c;
+ enable = x86;
+};
+
+module = {
+ name = regexp;
+ common = commands/regexp.c;
+ common = commands/wildcard.c;
+ common = lib/gnulib/regex.c;
+ cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
+ cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
+};
+
+module = {
+ name = acpi;
+
+ common = commands/acpi.c;
+ i386_pc = kern/acpi.c;
+ i386_pc = kern/i386/pc/acpi.c;
+
+ enable = efi;
+ enable = i386_pc;
+ enable = i386_coreboot;
+ enable = i386_multiboot;
+};
+
+module = {
+ name = lsacpi;
+
+ common = commands/lsacpi.c;
+
+ enable = efi;
+ enable = i386_pc;
+ enable = i386_coreboot;
+ enable = i386_multiboot;
+};
+
+module = {
+ name = lsefisystab;
+
+ common = commands/efi/lsefisystab.c;
+
+ enable = efi;
+};
+
+module = {
+ name = lssal;
+
+ common = commands/efi/lssal.c;
+
+ enable = efi;
+};
+
+module = {
+ name = lsefimmap;
+
+ common = commands/efi/lsefimmap.c;
+
+ enable = efi;
+};
+
+module = {
+ name = lsefi;
+ common = commands/efi/lsefi.c;
+ enable = efi;
+};
+
+module = {
+ name = efifwsetup;
+ efi = commands/efi/efifwsetup.c;
+ enable = efi;
+};
+
+module = {
+ name = blocklist;
+ common = commands/blocklist.c;
+};
+
+module = {
+ name = boot;
+ common = commands/boot.c;
+ i386_pc = lib/i386/pc/biosnum.c;
+ enable = x86;
+ enable = emu;
+ enable = sparc64_ieee1275;
+ enable = powerpc_ieee1275;
+ enable = mips_arc;
+ enable = ia64_efi;
+ enable = arm_efi;
+ enable = arm64_efi;
+ enable = arm_uboot;
+ enable = arm_coreboot;
+ enable = riscv32_efi;
+ enable = riscv64_efi;
+};
+
+module = {
+ name = cat;
+ common = commands/cat.c;
+};
+
+module = {
+ name = cmp;
+ common = commands/cmp.c;
+};
+
+module = {
+ name = configfile;
+ common = commands/configfile.c;
+};
+
+module = {
+ name = cpuid;
+ common = commands/i386/cpuid.c;
+ enable = x86;
+ enable = i386_xen_pvh;
+ enable = i386_xen;
+ enable = x86_64_xen;
+};
+
+module = {
+ name = date;
+ common = commands/date.c;
+};
+
+module = {
+ name = drivemap;
+
+ i386_pc = commands/i386/pc/drivemap.c;
+ i386_pc = commands/i386/pc/drivemap_int13h.S;
+ enable = i386_pc;
+};
+
+module = {
+ name = echo;
+ common = commands/echo.c;
+};
+
+module = {
+ name = eval;
+ common = commands/eval.c;
+};
+
+module = {
+ name = extcmd;
+ common = commands/extcmd.c;
+ common = lib/arg.c;
+ enable = terminfomodule;
+};
+
+module = {
+ name = fixvideo;
+ common = commands/efi/fixvideo.c;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = gptsync;
+ common = commands/gptsync.c;
+};
+
+module = {
+ name = halt;
+ nopc = commands/halt.c;
+ i386_pc = commands/i386/pc/halt.c;
+ i386_pc = commands/acpihalt.c;
+ i386_coreboot = commands/acpihalt.c;
+ i386_multiboot = commands/acpihalt.c;
+ i386_efi = commands/acpihalt.c;
+ x86_64_efi = commands/acpihalt.c;
+ i386_multiboot = lib/i386/halt.c;
+ i386_coreboot = lib/i386/halt.c;
+ i386_qemu = lib/i386/halt.c;
+ xen = lib/xen/halt.c;
+ i386_xen_pvh = lib/xen/halt.c;
+ efi = lib/efi/halt.c;
+ ieee1275 = lib/ieee1275/halt.c;
+ emu = lib/emu/halt.c;
+ uboot = lib/dummy/halt.c;
+ arm_coreboot = lib/dummy/halt.c;
+};
+
+module = {
+ name = reboot;
+ i386 = lib/i386/reboot.c;
+ i386 = lib/i386/reboot_trampoline.S;
+ powerpc_ieee1275 = lib/ieee1275/reboot.c;
+ sparc64_ieee1275 = lib/ieee1275/reboot.c;
+ mips_arc = lib/mips/arc/reboot.c;
+ mips_loongson = lib/mips/loongson/reboot.c;
+ mips_qemu_mips = lib/mips/qemu_mips/reboot.c;
+ xen = lib/xen/reboot.c;
+ i386_xen_pvh = lib/xen/reboot.c;
+ uboot = lib/uboot/reboot.c;
+ arm_coreboot = lib/dummy/reboot.c;
+ common = commands/reboot.c;
+};
+
+module = {
+ name = hashsum;
+ common = commands/hashsum.c;
+};
+
+module = {
+ name = pgp;
+ common = commands/pgp.c;
+ cflags = '$(CFLAGS_POSIX)';
+ cppflags = '-I$(srcdir)/lib/posix_wrap';
+};
+
+module = {
+ name = hdparm;
+ common = commands/hdparm.c;
+ enable = pci;
+ enable = mips_qemu_mips;
+};
+
+module = {
+ name = help;
+ common = commands/help.c;
+};
+
+module = {
+ name = hexdump;
+ common = commands/hexdump.c;
+ common = lib/hexdump.c;
+};
+
+module = {
+ name = keystatus;
+ common = commands/keystatus.c;
+};
+
+module = {
+ name = loadbios;
+ common = commands/efi/loadbios.c;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = loadenv;
+ common = commands/loadenv.c;
+ common = lib/envblk.c;
+};
+
+module = {
+ name = ls;
+ common = commands/ls.c;
+};
+
+module = {
+ name = lsmmap;
+ common = commands/lsmmap.c;
+};
+
+module = {
+ name = lspci;
+ common = commands/lspci.c;
+
+ enable = pci;
+};
+
+module = {
+ name = memrw;
+ common = commands/memrw.c;
+};
+
+module = {
+ name = minicmd;
+ common = commands/minicmd.c;
+};
+
+module = {
+ name = parttool;
+ common = commands/parttool.c;
+};
+
+module = {
+ name = password;
+ common = commands/password.c;
+};
+
+module = {
+ name = password_pbkdf2;
+ common = commands/password_pbkdf2.c;
+};
+
+module = {
+ name = play;
+ x86 = commands/i386/pc/play.c;
+ enable = x86;
+};
+
+module = {
+ name = spkmodem;
+ x86 = term/spkmodem.c;
+ enable = x86;
+};
+
+module = {
+ name = morse;
+ x86 = term/morse.c;
+ enable = x86;
+};
+
+module = {
+ name = probe;
+ common = commands/probe.c;
+};
+
+module = {
+ name = read;
+ common = commands/read.c;
+};
+
+module = {
+ name = search;
+ common = commands/search_wrap.c;
+ extra_dist = commands/search.c;
+};
+
+module = {
+ name = search_fs_file;
+ common = commands/search_file.c;
+};
+
+module = {
+ name = search_fs_uuid;
+ common = commands/search_uuid.c;
+};
+
+module = {
+ name = search_label;
+ common = commands/search_label.c;
+};
+
+module = {
+ name = setpci;
+ common = commands/setpci.c;
+ enable = pci;
+};
+
+module = {
+ name = pcidump;
+ common = commands/pcidump.c;
+ enable = pci;
+};
+
+module = {
+ name = sleep;
+ common = commands/sleep.c;
+};
+
+module = {
+ name = smbios;
+
+ common = commands/smbios.c;
+ efi = commands/efi/smbios.c;
+ i386_pc = commands/i386/pc/smbios.c;
+ i386_coreboot = commands/i386/pc/smbios.c;
+ i386_multiboot = commands/i386/pc/smbios.c;
+
+ enable = efi;
+ enable = i386_pc;
+ enable = i386_coreboot;
+ enable = i386_multiboot;
+};
+
+module = {
+ name = suspend;
+ ieee1275 = commands/ieee1275/suspend.c;
+ enable = i386_ieee1275;
+ enable = powerpc_ieee1275;
+};
+
+module = {
+ name = escc;
+ ieee1275 = term/ieee1275/escc.c;
+ enable = powerpc_ieee1275;
+};
+
+module = {
+ name = terminal;
+ common = commands/terminal.c;
+};
+
+module = {
+ name = test;
+ common = commands/test.c;
+};
+
+module = {
+ name = true;
+ common = commands/true.c;
+};
+
+module = {
+ name = usbtest;
+ common = commands/usbtest.c;
+ enable = usb;
+};
+
+module = {
+ name = videoinfo;
+ common = commands/videoinfo.c;
+};
+
+module = {
+ name = videotest;
+ common = commands/videotest.c;
+};
+
+module = {
+ name = xnu_uuid;
+ common = commands/xnu_uuid.c;
+};
+
+module = {
+ name = dm_nv;
+ common = disk/dmraid_nvidia.c;
+};
+
+module = {
+ name = loopback;
+ common = disk/loopback.c;
+};
+
+module = {
+ name = cryptodisk;
+ common = disk/cryptodisk.c;
+};
+
+module = {
+ name = json;
+ common = lib/json/json.c;
+};
+
+module = {
+ name = afsplitter;
+ common = disk/AFSplitter.c;
+};
+
+module = {
+ name = luks;
+ common = disk/luks.c;
+};
+
+module = {
+ name = luks2;
+ common = disk/luks2.c;
+ common = lib/gnulib/base64.c;
+ cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
+ cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB) -I$(srcdir)/lib/json';
+};
+
+module = {
+ name = geli;
+ common = disk/geli.c;
+};
+
+module = {
+ name = lvm;
+ common = disk/lvm.c;
+};
+
+module = {
+ name = ldm;
+ common = disk/ldm.c;
+};
+
+module = {
+ name = mdraid09;
+ common = disk/mdraid_linux.c;
+};
+
+module = {
+ name = mdraid09_be;
+ common = disk/mdraid_linux_be.c;
+};
+
+module = {
+ name = mdraid1x;
+ common = disk/mdraid1x_linux.c;
+};
+
+module = {
+ name = diskfilter;
+ common = disk/diskfilter.c;
+};
+
+module = {
+ name = raid5rec;
+ common = disk/raid5_recover.c;
+};
+
+module = {
+ name = raid6rec;
+ common = disk/raid6_recover.c;
+};
+
+module = {
+ name = scsi;
+ common = disk/scsi.c;
+};
+
+module = {
+ name = memdisk;
+ common = disk/memdisk.c;
+};
+
+module = {
+ name = ata;
+ common = disk/ata.c;
+ enable = pci;
+ enable = mips_qemu_mips;
+};
+
+module = {
+ name = ahci;
+ common = disk/ahci.c;
+ enable = pci;
+};
+
+module = {
+ name = pata;
+ common = disk/pata.c;
+ enable = pci;
+ enable = mips_qemu_mips;
+};
+
+module = {
+ name = biosdisk;
+ i386_pc = disk/i386/pc/biosdisk.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = usbms;
+ common = disk/usbms.c;
+ enable = usb;
+};
+
+module = {
+ name = nand;
+ ieee1275 = disk/ieee1275/nand.c;
+ enable = i386_ieee1275;
+};
+
+module = {
+ name = efiemu;
+ common = efiemu/main.c;
+ common = efiemu/i386/loadcore32.c;
+ common = efiemu/i386/loadcore64.c;
+ i386_pc = efiemu/i386/pc/cfgtables.c;
+ i386_coreboot = efiemu/i386/pc/cfgtables.c;
+ i386_multiboot = efiemu/i386/pc/cfgtables.c;
+ i386_ieee1275 = efiemu/i386/nocfgtables.c;
+ i386_qemu = efiemu/i386/nocfgtables.c;
+ common = efiemu/mm.c;
+ common = efiemu/loadcore_common.c;
+ common = efiemu/symbols.c;
+ common = efiemu/loadcore32.c;
+ common = efiemu/loadcore64.c;
+ common = efiemu/prepare32.c;
+ common = efiemu/prepare64.c;
+ common = efiemu/pnvram.c;
+ common = efiemu/i386/coredetect.c;
+
+ extra_dist = efiemu/prepare.c;
+ extra_dist = efiemu/loadcore.c;
+ extra_dist = efiemu/runtime/efiemu.S;
+ extra_dist = efiemu/runtime/efiemu.c;
+
+ enable = i386_pc;
+ enable = i386_coreboot;
+ enable = i386_ieee1275;
+ enable = i386_multiboot;
+ enable = i386_qemu;
+};
+
+module = {
+ name = font;
+ common = font/font.c;
+ common = font/font_cmd.c;
+ enable = videomodules;
+};
+
+module = {
+ name = procfs;
+ common = fs/proc.c;
+};
+
+module = {
+ name = affs;
+ common = fs/affs.c;
+};
+
+module = {
+ name = afs;
+ common = fs/afs.c;
+};
+
+module = {
+ name = bfs;
+ common = fs/bfs.c;
+};
+
+module = {
+ name = zstd;
+ common = lib/zstd/debug.c;
+ common = lib/zstd/entropy_common.c;
+ common = lib/zstd/error_private.c;
+ common = lib/zstd/fse_decompress.c;
+ common = lib/zstd/huf_decompress.c;
+ common = lib/zstd/module.c;
+ common = lib/zstd/xxhash.c;
+ common = lib/zstd/zstd_common.c;
+ common = lib/zstd/zstd_decompress.c;
+ cflags = '$(CFLAGS_POSIX) -Wno-undef';
+ cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/zstd';
+};
+
+module = {
+ name = btrfs;
+ common = fs/btrfs.c;
+ common = lib/crc.c;
+ cflags = '$(CFLAGS_POSIX) -Wno-undef';
+ cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo -I$(srcdir)/lib/zstd -DMINILZO_HAVE_CONFIG_H';
+};
+
+module = {
+ name = archelp;
+ common = fs/archelp.c;
+};
+
+module = {
+ name = cbfs;
+ common = fs/cbfs.c;
+};
+
+module = {
+ name = cpio;
+ common = fs/cpio.c;
+};
+
+module = {
+ name = cpio_be;
+ common = fs/cpio_be.c;
+};
+
+module = {
+ name = newc;
+ common = fs/newc.c;
+};
+
+module = {
+ name = odc;
+ common = fs/odc.c;
+};
+
+module = {
+ name = ext2;
+ common = fs/ext2.c;
+};
+
+module = {
+ name = fat;
+ common = fs/fat.c;
+};
+
+module = {
+ name = exfat;
+ common = fs/exfat.c;
+};
+
+module = {
+ name = f2fs;
+ common = fs/f2fs.c;
+};
+
+module = {
+ name = fshelp;
+ common = fs/fshelp.c;
+};
+
+module = {
+ name = hfs;
+ common = fs/hfs.c;
+};
+
+module = {
+ name = hfsplus;
+ common = fs/hfsplus.c;
+};
+
+module = {
+ name = hfspluscomp;
+ common = fs/hfspluscomp.c;
+};
+
+module = {
+ name = iso9660;
+ common = fs/iso9660.c;
+};
+
+module = {
+ name = jfs;
+ common = fs/jfs.c;
+};
+
+module = {
+ name = minix;
+ common = fs/minix.c;
+};
+
+module = {
+ name = minix2;
+ common = fs/minix2.c;
+};
+
+module = {
+ name = minix3;
+ common = fs/minix3.c;
+};
+
+module = {
+ name = minix_be;
+ common = fs/minix_be.c;
+};
+
+module = {
+ name = minix2_be;
+ common = fs/minix2_be.c;
+};
+
+module = {
+ name = minix3_be;
+ common = fs/minix3_be.c;
+};
+
+module = {
+ name = nilfs2;
+ common = fs/nilfs2.c;
+};
+
+module = {
+ name = ntfs;
+ common = fs/ntfs.c;
+};
+
+module = {
+ name = ntfscomp;
+ common = fs/ntfscomp.c;
+};
+
+module = {
+ name = reiserfs;
+ common = fs/reiserfs.c;
+};
+
+module = {
+ name = romfs;
+ common = fs/romfs.c;
+};
+
+module = {
+ name = sfs;
+ common = fs/sfs.c;
+};
+
+module = {
+ name = squash4;
+ common = fs/squash4.c;
+ cflags = '$(CFLAGS_POSIX) -Wno-undef';
+ cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H';
+};
+
+module = {
+ name = tar;
+ common = fs/tar.c;
+};
+
+module = {
+ name = udf;
+ common = fs/udf.c;
+};
+
+module = {
+ name = ufs1;
+ common = fs/ufs.c;
+};
+
+module = {
+ name = ufs1_be;
+ common = fs/ufs_be.c;
+};
+
+module = {
+ name = ufs2;
+ common = fs/ufs2.c;
+};
+
+module = {
+ name = xfs;
+ common = fs/xfs.c;
+};
+
+module = {
+ name = zfs;
+ common = fs/zfs/zfs.c;
+ common = fs/zfs/zfs_lzjb.c;
+ common = fs/zfs/zfs_lz4.c;
+ common = fs/zfs/zfs_sha256.c;
+ common = fs/zfs/zfs_fletcher.c;
+};
+
+module = {
+ name = zfscrypt;
+ common = fs/zfs/zfscrypt.c;
+};
+
+module = {
+ name = zfsinfo;
+ common = fs/zfs/zfsinfo.c;
+};
+
+module = {
+ name = macbless;
+ common = commands/macbless.c;
+};
+
+module = {
+ name = pxe;
+ i386_pc = net/drivers/i386/pc/pxe.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = gettext;
+ common = gettext/gettext.c;
+};
+
+module = {
+ name = gfxmenu;
+ common = gfxmenu/gfxmenu.c;
+ common = gfxmenu/view.c;
+ common = gfxmenu/font.c;
+ common = gfxmenu/icon_manager.c;
+ common = gfxmenu/theme_loader.c;
+ common = gfxmenu/widget-box.c;
+ common = gfxmenu/gui_canvas.c;
+ common = gfxmenu/gui_circular_progress.c;
+ common = gfxmenu/gui_box.c;
+ common = gfxmenu/gui_label.c;
+ common = gfxmenu/gui_list.c;
+ common = gfxmenu/gui_image.c;
+ common = gfxmenu/gui_progress_bar.c;
+ common = gfxmenu/gui_util.c;
+ common = gfxmenu/gui_string_util.c;
+};
+
+module = {
+ name = hello;
+ common = hello/hello.c;
+};
+
+module = {
+ name = gzio;
+ common = io/gzio.c;
+};
+
+module = {
+ name = offsetio;
+ common = io/offset.c;
+};
+
+module = {
+ name = bufio;
+ common = io/bufio.c;
+ enable = videomodules;
+};
+
+module = {
+ name = elf;
+ common = kern/elf.c;
+
+ extra_dist = kern/elfXX.c;
+};
+
+module = {
+ name = crypto;
+ common = lib/crypto.c;
+
+ extra_dist = lib/libgcrypt-grub/cipher/crypto.lst;
+};
+
+module = {
+ name = pbkdf2;
+ common = lib/pbkdf2.c;
+};
+
+module = {
+ name = relocator;
+ common = lib/relocator.c;
+ x86 = lib/i386/relocator16.S;
+ x86 = lib/i386/relocator32.S;
+ x86 = lib/i386/relocator64.S;
+ i386_xen_pvh = lib/i386/relocator16.S;
+ i386_xen_pvh = lib/i386/relocator32.S;
+ i386_xen_pvh = lib/i386/relocator64.S;
+ i386 = lib/i386/relocator_asm.S;
+ i386_xen_pvh = lib/i386/relocator_asm.S;
+ x86_64 = lib/x86_64/relocator_asm.S;
+ i386_xen = lib/i386/relocator_asm.S;
+ x86_64_xen = lib/x86_64/relocator_asm.S;
+ x86 = lib/i386/relocator.c;
+ x86 = lib/i386/relocator_common_c.c;
+ i386_xen_pvh = lib/i386/relocator.c;
+ i386_xen_pvh = lib/i386/relocator_common_c.c;
+ ieee1275 = lib/ieee1275/relocator.c;
+ efi = lib/efi/relocator.c;
+ mips = lib/mips/relocator_asm.S;
+ mips = lib/mips/relocator.c;
+ powerpc = lib/powerpc/relocator_asm.S;
+ powerpc = lib/powerpc/relocator.c;
+ xen = lib/xen/relocator.c;
+ i386_xen = lib/i386/xen/relocator.S;
+ x86_64_xen = lib/x86_64/xen/relocator.S;
+ xen = lib/i386/relocator_common_c.c;
+ x86_64_efi = lib/x86_64/efi/relocator.c;
+
+ extra_dist = lib/i386/relocator_common.S;
+ extra_dist = kern/powerpc/cache_flush.S;
+
+ enable = mips;
+ enable = powerpc;
+ enable = x86;
+ enable = i386_xen_pvh;
+ enable = xen;
+};
+
+module = {
+ name = datetime;
+ common = lib/datetime.c;
+ cmos = lib/cmos_datetime.c;
+ efi = lib/efi/datetime.c;
+ uboot = lib/dummy/datetime.c;
+ arm_coreboot = lib/dummy/datetime.c;
+ sparc64_ieee1275 = lib/ieee1275/datetime.c;
+ powerpc_ieee1275 = lib/ieee1275/datetime.c;
+ sparc64_ieee1275 = lib/ieee1275/cmos.c;
+ powerpc_ieee1275 = lib/ieee1275/cmos.c;
+ xen = lib/xen/datetime.c;
+ i386_xen_pvh = lib/xen/datetime.c;
+
+ mips_arc = lib/arc/datetime.c;
+};
+
+module = {
+ name = setjmp;
+ common = lib/setjmp.S;
+ extra_dist = lib/i386/setjmp.S;
+ extra_dist = lib/mips/setjmp.S;
+ extra_dist = lib/x86_64/setjmp.S;
+ extra_dist = lib/sparc64/setjmp.S;
+ extra_dist = lib/powerpc/setjmp.S;
+ extra_dist = lib/ia64/setjmp.S;
+ extra_dist = lib/ia64/longjmp.S;
+ extra_dist = lib/arm/setjmp.S;
+ extra_dist = lib/arm64/setjmp.S;
+ extra_dist = lib/riscv/setjmp.S;
+};
+
+module = {
+ name = aout;
+ common = loader/aout.c;
+ enable = x86;
+};
+
+module = {
+ name = bsd;
+ x86 = loader/i386/bsd.c;
+ x86 = loader/i386/bsd32.c;
+ x86 = loader/i386/bsd64.c;
+
+ extra_dist = loader/i386/bsdXX.c;
+ extra_dist = loader/i386/bsd_pagetable.c;
+
+ enable = x86;
+};
+
+module = {
+ name = plan9;
+ i386_pc = loader/i386/pc/plan9.c;
+ enable = i386_pc;
+};
+
+
+module = {
+ name = linux16;
+ common = loader/i386/pc/linux.c;
+ enable = x86;
+};
+
+module = {
+ name = ntldr;
+ i386_pc = loader/i386/pc/ntldr.c;
+ enable = i386_pc;
+};
+
+
+module = {
+ name = truecrypt;
+ i386_pc = loader/i386/pc/truecrypt.c;
+ enable = i386_pc;
+};
+
+
+module = {
+ name = freedos;
+ i386_pc = loader/i386/pc/freedos.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = pxechain;
+ i386_pc = loader/i386/pc/pxechainloader.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = multiboot2;
+ cppflags = "-DGRUB_USE_MULTIBOOT2";
+
+ common = loader/multiboot.c;
+ common = loader/multiboot_mbi2.c;
+ enable = x86;
+ enable = i386_xen_pvh;
+ enable = mips;
+};
+
+module = {
+ name = multiboot;
+ common = loader/multiboot.c;
+ x86 = loader/i386/multiboot_mbi.c;
+ i386_xen_pvh = loader/i386/multiboot_mbi.c;
+ extra_dist = loader/multiboot_elfxx.c;
+ enable = x86;
+ enable = i386_xen_pvh;
+};
+
+module = {
+ name = xen_boot;
+ arm64 = loader/arm64/xen_boot.c;
+ enable = arm64;
+};
+
+module = {
+ name = linux;
+ x86 = loader/i386/linux.c;
+ i386_xen_pvh = loader/i386/linux.c;
+ xen = loader/i386/xen.c;
+ i386_pc = lib/i386/pc/vesa_modes_table.c;
+ i386_xen_pvh = lib/i386/pc/vesa_modes_table.c;
+ mips = loader/mips/linux.c;
+ powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
+ sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c;
+ ia64_efi = loader/ia64/efi/linux.c;
+ arm_coreboot = loader/arm/linux.c;
+ arm_efi = loader/arm64/linux.c;
+ arm_uboot = loader/arm/linux.c;
+ arm64 = loader/arm64/linux.c;
+ riscv32 = loader/efi/linux.c;
+ riscv64 = loader/efi/linux.c;
+ common = loader/linux.c;
+ common = lib/cmdline.c;
+ enable = noemu;
+};
+
+module = {
+ name = fdt;
+ efi = loader/efi/fdt.c;
+ common = lib/fdt.c;
+ enable = fdt;
+};
+
+module = {
+ name = xnu;
+ x86 = loader/xnu_resume.c;
+ x86 = loader/i386/xnu.c;
+ x86 = loader/xnu.c;
+
+ /* Code is pretty generic but relies on RNG which
+ is available only on few platforms. It's not a
+ big deal as xnu needs ACPI anyway and we have
+ RNG on all platforms with ACPI.
+ */
+ enable = i386_multiboot;
+ enable = i386_coreboot;
+ enable = i386_pc;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = random;
+ x86 = lib/i386/random.c;
+ common = lib/random.c;
+
+ i386_multiboot = kern/i386/tsc_pmtimer.c;
+ i386_coreboot = kern/i386/tsc_pmtimer.c;
+ i386_pc = kern/i386/tsc_pmtimer.c;
+
+ enable = i386_multiboot;
+ enable = i386_coreboot;
+ enable = i386_pc;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = macho;
+
+ common = loader/macho.c;
+ common = loader/macho32.c;
+ common = loader/macho64.c;
+ common = loader/lzss.c;
+ extra_dist = loader/machoXX.c;
+};
+
+module = {
+ name = appleldr;
+ common = loader/efi/appleloader.c;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = chain;
+ efi = loader/efi/chainloader.c;
+ i386_pc = loader/i386/pc/chainloader.c;
+ i386_coreboot = loader/i386/coreboot/chainloader.c;
+ i386_coreboot = lib/LzmaDec.c;
+ enable = i386_pc;
+ enable = i386_coreboot;
+ enable = efi;
+};
+
+module = {
+ name = mmap;
+ common = mmap/mmap.c;
+ x86 = mmap/i386/uppermem.c;
+ x86 = mmap/i386/mmap.c;
+ i386_xen_pvh = mmap/i386/uppermem.c;
+ i386_xen_pvh = mmap/i386/mmap.c;
+
+ i386_pc = mmap/i386/pc/mmap.c;
+ i386_pc = mmap/i386/pc/mmap_helper.S;
+
+ efi = mmap/efi/mmap.c;
+
+ mips = mmap/mips/uppermem.c;
+
+ enable = x86;
+ enable = i386_xen_pvh;
+ enable = ia64_efi;
+ enable = arm_efi;
+ enable = arm64_efi;
+ enable = riscv32_efi;
+ enable = riscv64_efi;
+ enable = mips;
+};
+
+module = {
+ name = normal;
+ common = normal/main.c;
+ common = normal/cmdline.c;
+ common = normal/dyncmd.c;
+ common = normal/auth.c;
+ common = normal/autofs.c;
+ common = normal/color.c;
+ common = normal/completion.c;
+ common = normal/menu.c;
+ common = normal/menu_entry.c;
+ common = normal/menu_text.c;
+ common = normal/misc.c;
+ common = normal/crypto.c;
+ common = normal/term.c;
+ common = normal/context.c;
+ common = normal/charset.c;
+ common = lib/getline.c;
+
+ common = script/main.c;
+ common = script/script.c;
+ common = script/execute.c;
+ common = script/function.c;
+ common = script/lexer.c;
+ common = script/argv.c;
+
+ common = commands/menuentry.c;
+
+ common = unidata.c;
+ common_nodist = grub_script.tab.c;
+ common_nodist = grub_script.yy.c;
+ common_nodist = grub_script.tab.h;
+ common_nodist = grub_script.yy.h;
+
+ extra_dist = script/yylex.l;
+ extra_dist = script/parser.y;
+
+ cflags = '$(CFLAGS_POSIX) -Wno-redundant-decls';
+ cppflags = '$(CPPFLAGS_POSIX)';
+};
+
+module = {
+ name = part_acorn;
+ common = partmap/acorn.c;
+};
+
+module = {
+ name = part_amiga;
+ common = partmap/amiga.c;
+};
+
+module = {
+ name = part_apple;
+ common = partmap/apple.c;
+};
+
+module = {
+ name = part_gpt;
+ common = partmap/gpt.c;
+};
+
+module = {
+ name = part_msdos;
+ common = partmap/msdos.c;
+};
+
+module = {
+ name = part_sun;
+ common = partmap/sun.c;
+};
+
+module = {
+ name = part_plan;
+ common = partmap/plan.c;
+};
+
+module = {
+ name = part_dvh;
+ common = partmap/dvh.c;
+};
+
+module = {
+ name = part_bsd;
+ common = partmap/bsdlabel.c;
+};
+
+module = {
+ name = part_sunpc;
+ common = partmap/sunpc.c;
+};
+
+module = {
+ name = part_dfly;
+ common = partmap/dfly.c;
+};
+
+module = {
+ name = msdospart;
+ common = parttool/msdospart.c;
+};
+
+module = {
+ name = at_keyboard;
+ common = term/at_keyboard.c;
+ common = term/ps2.c;
+ enable = x86;
+};
+
+module = {
+ name = gfxterm;
+ common = term/gfxterm.c;
+ enable = videomodules;
+};
+
+module = {
+ name = gfxterm_background;
+ common = term/gfxterm_background.c;
+};
+
+module = {
+ name = serial;
+ common = term/serial.c;
+ x86 = term/ns8250.c;
+ ieee1275 = term/ieee1275/serial.c;
+ mips_arc = term/arc/serial.c;
+ efi = term/efi/serial.c;
+
+ enable = terminfomodule;
+ enable = ieee1275;
+ enable = mips_arc;
+};
+
+module = {
+ name = sendkey;
+ i386_pc = commands/i386/pc/sendkey.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = terminfo;
+ common = term/terminfo.c;
+ common = term/tparm.c;
+ enable = terminfomodule;
+};
+
+module = {
+ name = usb_keyboard;
+ common = term/usb_keyboard.c;
+ enable = usb;
+};
+
+module = {
+ name = vga;
+ common = video/i386/pc/vga.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = vga_text;
+ common = term/i386/pc/vga_text.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = mda_text;
+ common = term/i386/pc/mda_text.c;
+ enable = i386_pc;
+ enable = i386_coreboot_multiboot_qemu;
+};
+
+module = {
+ name = video_cirrus;
+ x86 = video/cirrus.c;
+ enable = x86;
+};
+
+module = {
+ name = video_bochs;
+ x86 = video/bochs.c;
+ enable = x86;
+};
+
+module = {
+ name = functional_test;
+ common = tests/lib/functional_test.c;
+ common = tests/lib/test.c;
+ common = tests/checksums.h;
+ common = tests/video_checksum.c;
+ common = tests/fake_input.c;
+ common = video/capture.c;
+};
+
+module = {
+ name = exfctest;
+ common = tests/example_functional_test.c;
+};
+
+module = {
+ name = strtoull_test;
+ common = tests/strtoull_test.c;
+};
+
+module = {
+ name = setjmp_test;
+ common = tests/setjmp_test.c;
+};
+
+module = {
+ name = signature_test;
+ common = tests/signature_test.c;
+ common = tests/signatures.h;
+};
+
+module = {
+ name = sleep_test;
+ common = tests/sleep_test.c;
+};
+
+module = {
+ name = xnu_uuid_test;
+ common = tests/xnu_uuid_test.c;
+};
+
+module = {
+ name = pbkdf2_test;
+ common = tests/pbkdf2_test.c;
+};
+
+module = {
+ name = legacy_password_test;
+ common = tests/legacy_password_test.c;
+ enable = i386_pc;
+ enable = i386_xen_pvh;
+ enable = i386_efi;
+ enable = x86_64_efi;
+ enable = emu;
+ enable = xen;
+};
+
+module = {
+ name = div;
+ common = lib/division.c;
+ enable = no_softdiv;
+};
+
+module = {
+ name = div_test;
+ common = tests/div_test.c;
+};
+
+module = {
+ name = mul_test;
+ common = tests/mul_test.c;
+};
+
+module = {
+ name = shift_test;
+ common = tests/shift_test.c;
+};
+
+module = {
+ name = cmp_test;
+ common = tests/cmp_test.c;
+};
+
+module = {
+ name = ctz_test;
+ common = tests/ctz_test.c;
+};
+
+module = {
+ name = bswap_test;
+ common = tests/bswap_test.c;
+};
+
+module = {
+ name = videotest_checksum;
+ common = tests/videotest_checksum.c;
+};
+
+module = {
+ name = gfxterm_menu;
+ common = tests/gfxterm_menu.c;
+};
+
+module = {
+ name = cmdline_cat_test;
+ common = tests/cmdline_cat_test.c;
+};
+
+module = {
+ name = bitmap;
+ common = video/bitmap.c;
+};
+
+module = {
+ name = bitmap_scale;
+ common = video/bitmap_scale.c;
+};
+
+module = {
+ name = efi_gop;
+ efi = video/efi_gop.c;
+ enable = efi;
+};
+
+module = {
+ name = efi_uga;
+ efi = video/efi_uga.c;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = jpeg;
+ common = video/readers/jpeg.c;
+};
+
+module = {
+ name = png;
+ common = video/readers/png.c;
+};
+
+module = {
+ name = tga;
+ common = video/readers/tga.c;
+};
+
+module = {
+ name = vbe;
+ common = video/i386/pc/vbe.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = video_fb;
+ common = video/fb/video_fb.c;
+ common = video/fb/fbblit.c;
+ common = video/fb/fbfill.c;
+ common = video/fb/fbutil.c;
+ enable = videomodules;
+};
+
+module = {
+ name = video;
+ common = video/video.c;
+ enable = videomodules;
+};
+
+module = {
+ name = video_colors;
+ common = video/colors.c;
+};
+
+module = {
+ name = ieee1275_fb;
+ ieee1275 = video/ieee1275.c;
+ enable = powerpc_ieee1275;
+};
+
+module = {
+ name = sdl;
+ emu = video/emu/sdl.c;
+ enable = emu;
+ condition = COND_GRUB_EMU_SDL;
+};
+
+module = {
+ name = datehook;
+ common = hook/datehook.c;
+};
+
+module = {
+ name = net;
+ common = net/net.c;
+ common = net/dns.c;
+ common = net/bootp.c;
+ common = net/ip.c;
+ common = net/udp.c;
+ common = net/tcp.c;
+ common = net/icmp.c;
+ common = net/icmp6.c;
+ common = net/ethernet.c;
+ common = net/arp.c;
+ common = net/netbuff.c;
+};
+
+module = {
+ name = tftp;
+ common = net/tftp.c;
+};
+
+module = {
+ name = http;
+ common = net/http.c;
+};
+
+module = {
+ name = ofnet;
+ common = net/drivers/ieee1275/ofnet.c;
+ enable = ieee1275;
+};
+
+module = {
+ name = ubootnet;
+ common = net/drivers/uboot/ubootnet.c;
+ enable = uboot;
+};
+
+module = {
+ name = efinet;
+ common = net/drivers/efi/efinet.c;
+ enable = efi;
+};
+
+module = {
+ name = emunet;
+ emu = net/drivers/emu/emunet.c;
+ enable = emu;
+};
+
+module = {
+ name = legacycfg;
+ common = commands/legacycfg.c;
+ common = lib/legacy_parse.c;
+ emu = lib/i386/pc/vesa_modes_table.c;
+ i386_efi = lib/i386/pc/vesa_modes_table.c;
+ x86_64_efi = lib/i386/pc/vesa_modes_table.c;
+ xen = lib/i386/pc/vesa_modes_table.c;
+
+ enable = i386_pc;
+ enable = i386_xen_pvh;
+ enable = i386_efi;
+ enable = x86_64_efi;
+ enable = emu;
+ enable = xen;
+};
+
+module = {
+ name = syslinuxcfg;
+ common = lib/syslinux_parse.c;
+ common = commands/syslinuxcfg.c;
+};
+
+module = {
+ name = test_blockarg;
+ common = tests/test_blockarg.c;
+};
+
+module = {
+ name = xzio;
+ common = io/xzio.c;
+ common = lib/xzembed/xz_dec_bcj.c;
+ common = lib/xzembed/xz_dec_lzma2.c;
+ common = lib/xzembed/xz_dec_stream.c;
+ cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed';
+ cflags='-Wno-unreachable-code';
+};
+
+module = {
+ name = lzopio;
+ common = io/lzopio.c;
+ common = lib/minilzo/minilzo.c;
+ cflags = '$(CFLAGS_POSIX) -Wno-undef -Wno-redundant-decls -Wno-error';
+ cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H';
+};
+
+module = {
+ name = testload;
+ common = commands/testload.c;
+};
+
+module = {
+ name = backtrace;
+ x86 = lib/i386/backtrace.c;
+ i386_xen_pvh = lib/i386/backtrace.c;
+ i386_xen = lib/i386/backtrace.c;
+ x86_64_xen = lib/i386/backtrace.c;
+ common = lib/backtrace.c;
+ enable = x86;
+ enable = i386_xen_pvh;
+ enable = i386_xen;
+ enable = x86_64_xen;
+};
+
+module = {
+ name = lsapm;
+ common = commands/i386/pc/lsapm.c;
+ enable = i386_pc;
+};
+
+module = {
+ name = keylayouts;
+ common = commands/keylayouts.c;
+ enable = x86;
+};
+
+module = {
+ name = priority_queue;
+ common = lib/priority_queue.c;
+};
+
+module = {
+ name = time;
+ common = commands/time.c;
+};
+
+module = {
+ name = cacheinfo;
+ common = commands/cacheinfo.c;
+ condition = COND_ENABLE_CACHE_STATS;
+};
+
+module = {
+ name = boottime;
+ common = commands/boottime.c;
+ condition = COND_ENABLE_BOOT_TIME_STATS;
+};
+
+module = {
+ name = adler32;
+ common = lib/adler32.c;
+};
+
+module = {
+ name = crc64;
+ common = lib/crc64.c;
+};
+
+module = {
+ name = mpi;
+ common = lib/libgcrypt-grub/mpi/mpiutil.c;
+ common = lib/libgcrypt-grub/mpi/mpi-bit.c;
+ common = lib/libgcrypt-grub/mpi/mpi-add.c;
+ common = lib/libgcrypt-grub/mpi/mpi-mul.c;
+ common = lib/libgcrypt-grub/mpi/mpi-mod.c;
+ common = lib/libgcrypt-grub/mpi/mpi-gcd.c;
+ common = lib/libgcrypt-grub/mpi/mpi-div.c;
+ common = lib/libgcrypt-grub/mpi/mpi-cmp.c;
+ common = lib/libgcrypt-grub/mpi/mpi-inv.c;
+ common = lib/libgcrypt-grub/mpi/mpi-pow.c;
+ common = lib/libgcrypt-grub/mpi/mpi-mpow.c;
+ common = lib/libgcrypt-grub/mpi/mpih-lshift.c;
+ common = lib/libgcrypt-grub/mpi/mpih-mul.c;
+ common = lib/libgcrypt-grub/mpi/mpih-mul1.c;
+ common = lib/libgcrypt-grub/mpi/mpih-mul2.c;
+ common = lib/libgcrypt-grub/mpi/mpih-mul3.c;
+ common = lib/libgcrypt-grub/mpi/mpih-add1.c;
+ common = lib/libgcrypt-grub/mpi/mpih-sub1.c;
+ common = lib/libgcrypt-grub/mpi/mpih-div.c;
+ common = lib/libgcrypt-grub/mpi/mpicoder.c;
+ common = lib/libgcrypt-grub/mpi/mpih-rshift.c;
+ common = lib/libgcrypt-grub/mpi/mpi-inline.c;
+ common = lib/libgcrypt_wrap/mem.c;
+
+ cflags = '$(CFLAGS_GCRY) -Wno-redundant-decls -Wno-sign-compare';
+ cppflags = '$(CPPFLAGS_GCRY)';
+};
+
+module = {
+ name = all_video;
+ common = lib/fake_module.c;
+};
+
+module = {
+ name = gdb;
+ common = gdb/cstub.c;
+ common = gdb/gdb.c;
+ i386 = gdb/i386/idt.c;
+ i386 = gdb/i386/machdep.S;
+ i386 = gdb/i386/signal.c;
+ enable = i386;
+};
+
+module = {
+ name = testspeed;
+ common = commands/testspeed.c;
+};
+
+module = {
+ name = tpm;
+ common = commands/tpm.c;
+ efi = commands/efi/tpm.c;
+ enable = efi;
+};
+
+module = {
+ name = tr;
+ common = commands/tr.c;
+};
+
+module = {
+ name = progress;
+ common = lib/progress.c;
+};
+
+module = {
+ name = file;
+ common = commands/file.c;
+ common = commands/file32.c;
+ common = commands/file64.c;
+ extra_dist = commands/fileXX.c;
+ common = loader/i386/xen_file.c;
+ common = loader/i386/xen_file32.c;
+ common = loader/i386/xen_file64.c;
+ extra_dist = loader/i386/xen_fileXX.c;
+};
+module = {
+ name = rdmsr;
+ common = commands/i386/rdmsr.c;
+ enable = x86;
+};
+module = {
+ name = wrmsr;
+ common = commands/i386/wrmsr.c;
+ enable = x86;
+};
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/grub-core/commands/efi/lsefi.c
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/grub-core/commands/efi/lsefi.c (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/grub-core/commands/efi/lsefi.c (revision 216)
@@ -0,0 +1,156 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2012 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/types.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+#include <grub/efi/api.h>
+#include <grub/efi/edid.h>
+#include <grub/efi/pci.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/uga_draw.h>
+#include <grub/efi/graphics_output.h>
+#include <grub/efi/console_control.h>
+#include <grub/command.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+struct known_protocol
+{
+ grub_efi_guid_t guid;
+ const char *name;
+} known_protocols[] =
+ {
+ { GRUB_EFI_DISK_IO_GUID, "disk" },
+ { GRUB_EFI_BLOCK_IO_GUID, "block" },
+ { GRUB_EFI_SERIAL_IO_GUID, "serial" },
+ { GRUB_EFI_SIMPLE_NETWORK_GUID, "network" },
+ { GRUB_EFI_PXE_GUID, "pxe" },
+ { GRUB_EFI_DEVICE_PATH_GUID, "device path" },
+ { GRUB_EFI_PCI_IO_GUID, "PCI" },
+ { GRUB_EFI_PCI_ROOT_IO_GUID, "PCI root" },
+ { GRUB_EFI_EDID_ACTIVE_GUID, "active EDID" },
+ { GRUB_EFI_EDID_DISCOVERED_GUID, "discovered EDID" },
+ { GRUB_EFI_EDID_OVERRIDE_GUID, "override EDID" },
+ { GRUB_EFI_GOP_GUID, "GOP" },
+ { GRUB_EFI_UGA_DRAW_GUID, "UGA draw" },
+ { GRUB_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID, "simple text output" },
+ { GRUB_EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID, "simple text input" },
+ { GRUB_EFI_SIMPLE_POINTER_PROTOCOL_GUID, "simple pointer" },
+ { GRUB_EFI_CONSOLE_CONTROL_GUID, "console control" },
+ { GRUB_EFI_ABSOLUTE_POINTER_PROTOCOL_GUID, "absolute pointer" },
+ { GRUB_EFI_DRIVER_BINDING_PROTOCOL_GUID, "EFI driver binding" },
+ { GRUB_EFI_LOAD_FILE_PROTOCOL_GUID, "load file" },
+ { GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID, "load file2" },
+ { GRUB_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, "simple FS" },
+ { GRUB_EFI_TAPE_IO_PROTOCOL_GUID, "tape I/O" },
+ { GRUB_EFI_UNICODE_COLLATION_PROTOCOL_GUID, "unicode collation" },
+ { GRUB_EFI_SCSI_IO_PROTOCOL_GUID, "SCSI I/O" },
+ { GRUB_EFI_USB2_HC_PROTOCOL_GUID, "USB host" },
+ { GRUB_EFI_DEBUG_SUPPORT_PROTOCOL_GUID, "debug support" },
+ { GRUB_EFI_DEBUGPORT_PROTOCOL_GUID, "debug port" },
+ { GRUB_EFI_DECOMPRESS_PROTOCOL_GUID, "decompress" },
+ { GRUB_EFI_LOADED_IMAGE_PROTOCOL_GUID, "loaded image" },
+ { GRUB_EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID, "device path to text" },
+ { GRUB_EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID, "device path utilities" },
+ { GRUB_EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID, "device path from text" },
+ { GRUB_EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID, "HII config routing" },
+ { GRUB_EFI_HII_DATABASE_PROTOCOL_GUID, "HII database" },
+ { GRUB_EFI_HII_STRING_PROTOCOL_GUID, "HII string" },
+ { GRUB_EFI_HII_IMAGE_PROTOCOL_GUID, "HII image" },
+ { GRUB_EFI_HII_FONT_PROTOCOL_GUID, "HII font" },
+ { GRUB_EFI_COMPONENT_NAME2_PROTOCOL_GUID, "component name 2" },
+ { GRUB_EFI_HII_CONFIGURATION_ACCESS_PROTOCOL_GUID,
+ "HII configuration access" },
+ { GRUB_EFI_USB_IO_PROTOCOL_GUID, "USB I/O" },
+ };
+
+static grub_err_t
+grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
+ int argc __attribute__ ((unused)),
+ char **args __attribute__ ((unused)))
+{
+ grub_efi_handle_t *handles;
+ grub_efi_uintn_t num_handles;
+ unsigned i, j, k;
+
+ handles = grub_efi_locate_handle (GRUB_EFI_ALL_HANDLES,
+ NULL, NULL, &num_handles);
+
+ for (i = 0; i < num_handles; i++)
+ {
+ grub_efi_handle_t handle = handles[i];
+ grub_efi_status_t status;
+ grub_efi_uintn_t num_protocols;
+ grub_efi_packed_guid_t **protocols;
+ grub_efi_device_path_t *dp;
+
+ grub_printf ("Handle %p\n", handle);
+
+ dp = grub_efi_get_device_path (handle);
+ if (dp)
+ {
+ grub_printf (" ");
+ grub_efi_print_device_path (dp);
+ }
+
+ status = efi_call_3 (grub_efi_system_table->boot_services->protocols_per_handle,
+ handle, &protocols, &num_protocols);
+ if (status != GRUB_EFI_SUCCESS) {
+ grub_printf ("Unable to retrieve protocols\n");
+ continue;
+ }
+ for (j = 0; j < num_protocols; j++)
+ {
+ for (k = 0; k < ARRAY_SIZE (known_protocols); k++)
+ if (grub_memcmp (protocols[j], &known_protocols[k].guid,
+ sizeof (known_protocols[k].guid)) == 0)
+ break;
+ if (k < ARRAY_SIZE (known_protocols))
+ grub_printf (" %s\n", known_protocols[k].name);
+ else
+ grub_printf (" %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
+ protocols[j]->data1,
+ protocols[j]->data2,
+ protocols[j]->data3,
+ (unsigned) protocols[j]->data4[0],
+ (unsigned) protocols[j]->data4[1],
+ (unsigned) protocols[j]->data4[2],
+ (unsigned) protocols[j]->data4[3],
+ (unsigned) protocols[j]->data4[4],
+ (unsigned) protocols[j]->data4[5],
+ (unsigned) protocols[j]->data4[6],
+ (unsigned) protocols[j]->data4[7]);
+ }
+
+ }
+
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT(lsefi)
+{
+ cmd = grub_register_command ("lsefi", grub_cmd_lsefi,
+ NULL, "Display EFI handles.");
+}
+
+GRUB_MOD_FINI(lsefi)
+{
+ grub_unregister_command (cmd);
+}
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/grub-core/loader/efi/fdt.c
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/grub-core/loader/efi/fdt.c (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/grub-core/loader/efi/fdt.c (revision 216)
@@ -0,0 +1,182 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2013-2015 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/fdt.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/file.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/fdtload.h>
+#include <grub/efi/memory.h>
+#include <grub/cpu/efi/memory.h>
+
+static void *loaded_fdt;
+static void *fdt;
+
+#define FDT_ADDR_CELLS_STRING "#address-cells"
+#define FDT_SIZE_CELLS_STRING "#size-cells"
+#define FDT_ADDR_SIZE_EXTRA ((2 * grub_fdt_prop_entry_size (sizeof(grub_uint32_t))) + \
+ sizeof (FDT_ADDR_CELLS_STRING) + \
+ sizeof (FDT_SIZE_CELLS_STRING))
+
+void *
+grub_fdt_load (grub_size_t additional_size)
+{
+ void *raw_fdt;
+ unsigned int size;
+
+ if (fdt)
+ {
+ size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt));
+ grub_efi_free_pages ((grub_addr_t) fdt, size);
+ }
+
+ if (loaded_fdt)
+ raw_fdt = loaded_fdt;
+ else
+ raw_fdt = grub_efi_get_firmware_fdt();
+
+ if (raw_fdt)
+ size = grub_fdt_get_totalsize (raw_fdt);
+ else
+ size = GRUB_FDT_EMPTY_TREE_SZ + FDT_ADDR_SIZE_EXTRA;
+
+ size += additional_size;
+
+ grub_dprintf ("linux", "allocating %d bytes for fdt\n", size);
+ fdt = grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS,
+ GRUB_EFI_BYTES_TO_PAGES (size),
+ GRUB_EFI_ALLOCATE_MAX_ADDRESS,
+ GRUB_EFI_ACPI_RECLAIM_MEMORY);
+ if (!fdt)
+ return NULL;
+
+ if (raw_fdt)
+ {
+ grub_memmove (fdt, raw_fdt, size - additional_size);
+ grub_fdt_set_totalsize (fdt, size);
+ }
+ else
+ {
+ grub_fdt_create_empty_tree (fdt, size);
+ grub_fdt_set_prop32 (fdt, 0, FDT_ADDR_CELLS_STRING, 2);
+ grub_fdt_set_prop32 (fdt, 0, FDT_SIZE_CELLS_STRING, 2);
+ }
+ return fdt;
+}
+
+grub_err_t
+grub_fdt_install (void)
+{
+ grub_efi_boot_services_t *b;
+ grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
+ grub_efi_status_t status;
+
+ if (!fdt && !loaded_fdt)
+ return GRUB_ERR_NONE;
+
+ b = grub_efi_system_table->boot_services;
+ status = b->install_configuration_table (&fdt_guid, fdt ?: loaded_fdt);
+ if (status != GRUB_EFI_SUCCESS)
+ return grub_error (GRUB_ERR_IO, "failed to install FDT");
+
+ grub_dprintf ("fdt", "Installed/updated FDT configuration table @ %p\n",
+ fdt ?: loaded_fdt);
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_fdt_unload (void) {
+ if (!fdt) {
+ return;
+ }
+ grub_efi_free_pages ((grub_addr_t) fdt,
+ GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)));
+ fdt = NULL;
+}
+
+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_fdt)
+ grub_free (loaded_fdt);
+ loaded_fdt = NULL;
+
+ /* No arguments means "use firmware FDT". */
+ if (argc == 0)
+ {
+ return GRUB_ERR_NONE;
+ }
+
+ dtb = grub_file_open (argv[0], GRUB_FILE_TYPE_DEVICE_TREE_IMAGE);
+ 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_command_t cmd_devicetree;
+
+GRUB_MOD_INIT (fdt)
+{
+ cmd_devicetree =
+ grub_register_command_lockdown ("devicetree", grub_cmd_devicetree, 0,
+ N_("Load DTB file."));
+}
+
+GRUB_MOD_FINI (fdt)
+{
+ grub_unregister_command (cmd_devicetree);
+}
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/grub-core/loader/efi/linux.c
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/grub-core/loader/efi/linux.c (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/grub-core/loader/efi/linux.c (revision 216)
@@ -0,0 +1,521 @@
+/*
+ * 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/fdtload.h>
+#include <grub/efi/memory.h>
+#include <grub/efi/pe32.h>
+#include <grub/i18n.h>
+#include <grub/lib/cmdline.h>
+#include <grub/verify.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+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 struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
+static grub_efi_handle_t initrd_lf2_handle;
+static int initrd_use_loadfile2;
+static grub_efi_guid_t load_file2_guid = GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID;
+static grub_efi_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
+
+#ifndef get_hartid
+#define grub_fdt_set_hartid(__fdt, __node)
+#else
+static int hartid = 0;
+#define grub_fdt_set_hartid(__fdt, __node) \
+({ \
+ get_hartid(hartid); \
+ grub_fdt_set_prop32 (__fdt, __node, "boot-hartid", hartid); \
+})
+#endif
+
+grub_err_t
+grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh)
+{
+ struct grub_pe32_coff_header *coff_header;
+ struct grub_pe32_optional_header *optional_header;
+
+ if (lh->magic != GRUB_LINUX_ARCH_MAGIC_SIGNATURE)
+ return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
+
+ if ((lh->code0 & 0xffff) != GRUB_PE32_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", "PE/COFF header @ %08x\n", lh->hdr_offset);
+
+ coff_header = (struct grub_pe32_coff_header *)((unsigned long)lh + lh->hdr_offset);
+ optional_header = (struct grub_pe32_optional_header *)(coff_header + 1);
+
+ /*
+ * Linux kernels built for any architecture are guaranteed to support the
+ * LoadFile2 based initrd loading protocol if the image version is >= 1.
+ */
+ if (optional_header->major_image_version >= 1)
+ initrd_use_loadfile2 = 1;
+ else
+ initrd_use_loadfile2 = 0;
+
+ grub_dprintf ("linux", "LoadFile2 initrd loading %sabled\n",
+ initrd_use_loadfile2 ? "en" : "dis");
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+finalize_params_linux (void)
+{
+ int node, retval;
+
+ void *fdt;
+
+ fdt = grub_fdt_load (GRUB_EFI_LINUX_FDT_EXTRA_SPACE);
+
+ 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 @ %p-%p\n",
+ (void *) initrd_start, (void *) 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;
+ }
+
+ grub_fdt_set_hartid(fdt, node);
+
+ if (grub_fdt_install() != GRUB_ERR_NONE)
+ goto failure;
+
+ return GRUB_ERR_NONE;
+
+failure:
+ grub_fdt_unload();
+ return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT");
+}
+
+grub_err_t
+grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args)
+{
+ 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_efi_loaded_image_t *loaded_image;
+ int len;
+
+ 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 = addr;
+ mempath[0].end_address = addr + 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 = sizeof (grub_efi_device_path_t);
+
+ b = grub_efi_system_table->boot_services;
+ status = b->load_image (0, grub_efi_image_handle,
+ (grub_efi_device_path_t *) mempath,
+ (void *) addr, 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", args);
+
+ /* Convert command line to UCS-2 */
+ loaded_image = grub_efi_get_loaded_image (image_handle);
+ loaded_image->load_options_size = len =
+ (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t);
+ loaded_image->load_options =
+ grub_efi_allocate_any_pages (GRUB_EFI_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 *) 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_addr_t) loaded_image->load_options,
+ GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size));
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_linux_boot (void)
+{
+ if (finalize_params_linux () != GRUB_ERR_NONE)
+ return grub_errno;
+
+ return (grub_arch_efi_linux_boot_image((grub_addr_t)kernel_addr,
+ kernel_size, linux_args));
+}
+
+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,
+ GRUB_EFI_BYTES_TO_PAGES (initrd_end - initrd_start));
+ initrd_start = initrd_end = 0;
+ grub_free (linux_args);
+ if (kernel_addr)
+ grub_efi_free_pages ((grub_addr_t) kernel_addr,
+ GRUB_EFI_BYTES_TO_PAGES (kernel_size));
+ grub_fdt_unload ();
+ return GRUB_ERR_NONE;
+}
+
+/*
+ * As per linux/Documentation/arm/Booting
+ * ARM initrd needs to be covered by kernel linear mapping,
+ * so place it in the first 512MB of DRAM.
+ *
+ * As per linux/Documentation/arm64/booting.txt
+ * ARM64 initrd needs to be contained entirely within a 1GB aligned window
+ * of up to 32GB of size that covers the kernel image as well.
+ * Since the EFI stub loader will attempt to load the kernel near start of
+ * RAM, place the buffer in the first 32GB of RAM.
+ */
+#ifdef __arm__
+#define INITRD_MAX_ADDRESS_OFFSET (512U * 1024 * 1024)
+#else /* __aarch64__ */
+#define INITRD_MAX_ADDRESS_OFFSET (32ULL * 1024 * 1024 * 1024)
+#endif
+
+/*
+ * This function returns a pointer to a legally allocated initrd buffer,
+ * or NULL if unsuccessful
+ */
+static void *
+allocate_initrd_mem (int initrd_pages)
+{
+ grub_addr_t max_addr;
+
+ if (grub_efi_get_ram_base (&max_addr) != GRUB_ERR_NONE)
+ return NULL;
+
+ max_addr += INITRD_MAX_ADDRESS_OFFSET - 1;
+
+ return grub_efi_allocate_pages_real (max_addr, initrd_pages,
+ GRUB_EFI_ALLOCATE_MAX_ADDRESS,
+ GRUB_EFI_LOADER_DATA);
+}
+
+struct initrd_media_device_path {
+ grub_efi_vendor_media_device_path_t vendor;
+ grub_efi_device_path_t end;
+} GRUB_PACKED;
+
+#define LINUX_EFI_INITRD_MEDIA_GUID \
+ { 0x5568e427, 0x68fc, 0x4f3d, \
+ { 0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68 } \
+ }
+
+static struct initrd_media_device_path initrd_lf2_device_path = {
+ {
+ {
+ GRUB_EFI_MEDIA_DEVICE_PATH_TYPE,
+ GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE,
+ sizeof(grub_efi_vendor_media_device_path_t),
+ },
+ LINUX_EFI_INITRD_MEDIA_GUID
+ }, {
+ GRUB_EFI_END_DEVICE_PATH_TYPE,
+ GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ sizeof(grub_efi_device_path_t)
+ }
+};
+
+static grub_efi_status_t
+grub_efi_initrd_load_file2(grub_efi_load_file2_t *this,
+ grub_efi_device_path_t *device_path,
+ grub_efi_boolean_t boot_policy,
+ grub_efi_uintn_t *buffer_size,
+ void *buffer);
+
+static grub_efi_load_file2_t initrd_lf2 = {
+ grub_efi_initrd_load_file2
+};
+
+static grub_efi_status_t
+grub_efi_initrd_load_file2(grub_efi_load_file2_t *this,
+ grub_efi_device_path_t *device_path,
+ grub_efi_boolean_t boot_policy,
+ grub_efi_uintn_t *buffer_size,
+ void *buffer)
+{
+ grub_efi_status_t status = GRUB_EFI_SUCCESS;
+ grub_efi_uintn_t initrd_size;
+
+ if (!this || this != &initrd_lf2 || !buffer_size)
+ return GRUB_EFI_INVALID_PARAMETER;
+
+ if (device_path->type != GRUB_EFI_END_DEVICE_PATH_TYPE ||
+ device_path->subtype != GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)
+ return GRUB_EFI_NOT_FOUND;
+
+ if (boot_policy)
+ return GRUB_EFI_UNSUPPORTED;
+
+ initrd_size = grub_get_initrd_size (&initrd_ctx);
+ if (!buffer || *buffer_size < initrd_size)
+ {
+ *buffer_size = initrd_size;
+ return GRUB_EFI_BUFFER_TOO_SMALL;
+ }
+
+ grub_dprintf ("linux", "Providing initrd via LOAD_FILE2_PROTOCOL\n");
+
+ if (grub_initrd_load (&initrd_ctx, NULL, buffer))
+ status = GRUB_EFI_LOAD_ERROR;
+
+ grub_initrd_close (&initrd_ctx);
+ return status;
+}
+
+static grub_err_t
+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ int initrd_size, initrd_pages;
+ void *initrd_mem = NULL;
+ grub_efi_boot_services_t *b;
+ grub_efi_status_t status;
+
+ 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;
+
+ if (initrd_use_loadfile2 && !initrd_lf2_handle)
+ {
+ b = grub_efi_system_table->boot_services;
+ status = b->install_multiple_protocol_interfaces (&initrd_lf2_handle,
+ &load_file2_guid,
+ &initrd_lf2,
+ &device_path_guid,
+ &initrd_lf2_device_path,
+ NULL);
+ if (status == GRUB_EFI_OUT_OF_RESOURCES)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return grub_errno;
+ }
+ grub_dprintf ("linux", "LoadFile2 initrd loading protocol installed\n");
+ return GRUB_ERR_NONE;
+ }
+
+ initrd_size = grub_get_initrd_size (&initrd_ctx);
+ grub_dprintf ("linux", "Loading initrd\n");
+
+ initrd_pages = (GRUB_EFI_BYTES_TO_PAGES (initrd_size));
+ initrd_mem = allocate_initrd_mem (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_addr_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 linux_arch_kernel_header lh;
+ grub_err_t err;
+
+ 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], GRUB_FILE_TYPE_LINUX_KERNEL);
+ 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 (grub_arch_efi_linux_check_image (&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_any_pages (GRUB_EFI_BYTES_TO_PAGES (kernel_size));
+ grub_dprintf ("linux", "kernel numpages: %lld\n",
+ (long long) GRUB_EFI_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));
+ err = grub_create_loader_cmdline (argc, argv,
+ linux_args + sizeof (LINUX_IMAGE) - 1,
+ cmdline_size,
+ GRUB_VERIFY_KERNEL_CMDLINE);
+ if (err)
+ goto fail;
+
+ 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_addr_t) kernel_addr,
+ GRUB_EFI_BYTES_TO_PAGES (kernel_size));
+
+ return grub_errno;
+}
+
+
+static grub_command_t cmd_linux, cmd_initrd;
+
+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."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI (linux)
+{
+ grub_unregister_command (cmd_linux);
+ grub_unregister_command (cmd_initrd);
+}
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/include/grub/efi/api.h
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/include/grub/efi/api.h (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/include/grub/efi/api.h (revision 216)
@@ -0,0 +1,1820 @@
+/* efi.h - declare EFI types and functions */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,2009 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/>.
+ */
+
+#ifndef GRUB_EFI_API_HEADER
+#define GRUB_EFI_API_HEADER 1
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+
+/* For consistency and safety, we name the EFI-defined types differently.
+ All names are transformed into lower case, _t appended, and
+ grub_efi_ prepended. */
+
+/* Constants. */
+#define GRUB_EFI_EVT_TIMER 0x80000000
+#define GRUB_EFI_EVT_RUNTIME 0x40000000
+#define GRUB_EFI_EVT_RUNTIME_CONTEXT 0x20000000
+#define GRUB_EFI_EVT_NOTIFY_WAIT 0x00000100
+#define GRUB_EFI_EVT_NOTIFY_SIGNAL 0x00000200
+#define GRUB_EFI_EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
+#define GRUB_EFI_EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
+
+#define GRUB_EFI_TPL_APPLICATION 4
+#define GRUB_EFI_TPL_CALLBACK 8
+#define GRUB_EFI_TPL_NOTIFY 16
+#define GRUB_EFI_TPL_HIGH_LEVEL 31
+
+#define GRUB_EFI_MEMORY_UC 0x0000000000000001LL
+#define GRUB_EFI_MEMORY_WC 0x0000000000000002LL
+#define GRUB_EFI_MEMORY_WT 0x0000000000000004LL
+#define GRUB_EFI_MEMORY_WB 0x0000000000000008LL
+#define GRUB_EFI_MEMORY_UCE 0x0000000000000010LL
+#define GRUB_EFI_MEMORY_WP 0x0000000000001000LL
+#define GRUB_EFI_MEMORY_RP 0x0000000000002000LL
+#define GRUB_EFI_MEMORY_XP 0x0000000000004000LL
+#define GRUB_EFI_MEMORY_NV 0x0000000000008000LL
+#define GRUB_EFI_MEMORY_MORE_RELIABLE 0x0000000000010000LL
+#define GRUB_EFI_MEMORY_RO 0x0000000000020000LL
+#define GRUB_EFI_MEMORY_RUNTIME 0x8000000000000000LL
+
+#define GRUB_EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
+#define GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
+#define GRUB_EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
+#define GRUB_EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
+#define GRUB_EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
+#define GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE 0x00000020
+
+#define GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001ULL
+
+#define GRUB_EFI_VARIABLE_NON_VOLATILE 0x0000000000000001
+#define GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
+#define GRUB_EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004
+
+#define GRUB_EFI_TIME_ADJUST_DAYLIGHT 0x01
+#define GRUB_EFI_TIME_IN_DAYLIGHT 0x02
+
+#define GRUB_EFI_UNSPECIFIED_TIMEZONE 0x07FF
+
+#define GRUB_EFI_OPTIONAL_PTR 0x00000001
+
+#define GRUB_EFI_LOADED_IMAGE_GUID \
+ { 0x5b1b31a1, 0x9562, 0x11d2, \
+ { 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
+ }
+
+#define GRUB_EFI_DISK_IO_GUID \
+ { 0xce345171, 0xba0b, 0x11d2, \
+ { 0x8e, 0x4f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
+ }
+
+#define GRUB_EFI_BLOCK_IO_GUID \
+ { 0x964e5b21, 0x6459, 0x11d2, \
+ { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
+ }
+
+#define GRUB_EFI_SERIAL_IO_GUID \
+ { 0xbb25cf6f, 0xf1d4, 0x11d2, \
+ { 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0xfd } \
+ }
+
+#define GRUB_EFI_SIMPLE_NETWORK_GUID \
+ { 0xa19832b9, 0xac25, 0x11d3, \
+ { 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+ }
+
+#define GRUB_EFI_PXE_GUID \
+ { 0x03c4e603, 0xac28, 0x11d3, \
+ { 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+ }
+
+#define GRUB_EFI_DEVICE_PATH_GUID \
+ { 0x09576e91, 0x6d3f, 0x11d2, \
+ { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
+ }
+
+#define GRUB_EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
+ { 0x387477c1, 0x69c7, 0x11d2, \
+ { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
+ }
+
+#define GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
+ { 0xdd9e7534, 0x7762, 0x4698, \
+ { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } \
+ }
+
+#define GRUB_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
+ { 0x387477c2, 0x69c7, 0x11d2, \
+ { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
+ }
+
+#define GRUB_EFI_SIMPLE_POINTER_PROTOCOL_GUID \
+ { 0x31878c87, 0xb75, 0x11d5, \
+ { 0x9a, 0x4f, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+ }
+
+#define GRUB_EFI_ABSOLUTE_POINTER_PROTOCOL_GUID \
+ { 0x8D59D32B, 0xC655, 0x4AE9, \
+ { 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 } \
+ }
+
+#define GRUB_EFI_DRIVER_BINDING_PROTOCOL_GUID \
+ { 0x18A031AB, 0xB443, 0x4D1A, \
+ { 0xA5, 0xC0, 0x0C, 0x09, 0x26, 0x1E, 0x9F, 0x71 } \
+ }
+
+#define GRUB_EFI_LOADED_IMAGE_PROTOCOL_GUID \
+ { 0x5B1B31A1, 0x9562, 0x11d2, \
+ { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \
+ }
+
+#define GRUB_EFI_LOAD_FILE_PROTOCOL_GUID \
+ { 0x56EC3091, 0x954C, 0x11d2, \
+ { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \
+ }
+
+#define GRUB_EFI_LOAD_FILE2_PROTOCOL_GUID \
+ { 0x4006c0c1, 0xfcb3, 0x403e, \
+ { 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d } \
+ }
+
+#define GRUB_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
+ { 0x0964e5b22, 0x6459, 0x11d2, \
+ { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
+ }
+
+#define GRUB_EFI_TAPE_IO_PROTOCOL_GUID \
+ { 0x1e93e633, 0xd65a, 0x459e, \
+ { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } \
+ }
+
+#define GRUB_EFI_UNICODE_COLLATION_PROTOCOL_GUID \
+ { 0x1d85cd7f, 0xf43d, 0x11d2, \
+ { 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+ }
+
+#define GRUB_EFI_SCSI_IO_PROTOCOL_GUID \
+ { 0x932f47e6, 0x2362, 0x4002, \
+ { 0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \
+ }
+
+#define GRUB_EFI_USB2_HC_PROTOCOL_GUID \
+ { 0x3e745226, 0x9818, 0x45b6, \
+ { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } \
+ }
+
+#define GRUB_EFI_DEBUG_SUPPORT_PROTOCOL_GUID \
+ { 0x2755590C, 0x6F3C, 0x42FA, \
+ { 0x9E, 0xA4, 0xA3, 0xBA, 0x54, 0x3C, 0xDA, 0x25 } \
+ }
+
+#define GRUB_EFI_DEBUGPORT_PROTOCOL_GUID \
+ { 0xEBA4E8D2, 0x3858, 0x41EC, \
+ { 0xA2, 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 } \
+ }
+
+#define GRUB_EFI_DECOMPRESS_PROTOCOL_GUID \
+ { 0xd8117cfe, 0x94a6, 0x11d4, \
+ { 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+ }
+
+#define GRUB_EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
+ { 0x8b843e20, 0x8132, 0x4852, \
+ { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } \
+ }
+
+#define GRUB_EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \
+ { 0x379be4e, 0xd706, 0x437d, \
+ { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } \
+ }
+
+#define GRUB_EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \
+ { 0x5c99a21, 0xc70f, 0x4ad2, \
+ { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } \
+ }
+
+#define GRUB_EFI_ACPI_TABLE_PROTOCOL_GUID \
+ { 0xffe06bdd, 0x6107, 0x46a6, \
+ { 0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c} \
+ }
+
+#define GRUB_EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \
+ { 0x587e72d7, 0xcc50, 0x4f79, \
+ { 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f } \
+ }
+
+#define GRUB_EFI_HII_DATABASE_PROTOCOL_GUID \
+ { 0xef9fc172, 0xa1b2, 0x4693, \
+ { 0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42 } \
+ }
+
+#define GRUB_EFI_HII_STRING_PROTOCOL_GUID \
+ { 0xfd96974, 0x23aa, 0x4cdc, \
+ { 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a } \
+ }
+
+#define GRUB_EFI_HII_IMAGE_PROTOCOL_GUID \
+ { 0x31a6406a, 0x6bdf, 0x4e46, \
+ { 0xb2, 0xa2, 0xeb, 0xaa, 0x89, 0xc4, 0x9, 0x20 } \
+ }
+
+#define GRUB_EFI_HII_FONT_PROTOCOL_GUID \
+ { 0xe9ca4775, 0x8657, 0x47fc, \
+ { 0x97, 0xe7, 0x7e, 0xd6, 0x5a, 0x8, 0x43, 0x24 } \
+ }
+
+#define GRUB_EFI_HII_CONFIGURATION_ACCESS_PROTOCOL_GUID \
+ { 0x330d4706, 0xf2a0, 0x4e4f, \
+ { 0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85 } \
+ }
+
+#define GRUB_EFI_COMPONENT_NAME2_PROTOCOL_GUID \
+ { 0x6a7a5cff, 0xe8d9, 0x4f70, \
+ { 0xba, 0xda, 0x75, 0xab, 0x30, 0x25, 0xce, 0x14} \
+ }
+
+#define GRUB_EFI_USB_IO_PROTOCOL_GUID \
+ { 0x2B2F68D6, 0x0CD2, 0x44cf, \
+ { 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } \
+ }
+
+#define GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID \
+ { 0xa31280ad, 0x481e, 0x41b6, \
+ { 0x95, 0xe8, 0x12, 0x7f, 0x4c, 0x98, 0x47, 0x79 } \
+ }
+
+#define GRUB_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID \
+ { 0xfc1bcdb0, 0x7d31, 0x49aa, \
+ { 0x93, 0x6a, 0xa4, 0x60, 0x0d, 0x9d, 0xd0, 0x83 } \
+ }
+
+#define GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID \
+ { 0xee4e5898, 0x3914, 0x4259, \
+ { 0x9d, 0x6e, 0xdc, 0x7b, 0xd7, 0x94, 0x03, 0xcf } \
+ }
+
+#define GRUB_EFI_TSC_FREQUENCY_GUID \
+ { 0xdba6a7e3, 0xbb57, 0x4be7, \
+ { 0x8a, 0xf8, 0xd5, 0x78, 0xdb, 0x7e, 0x56, 0x87 } \
+ }
+
+#define GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID \
+ { 0xb122a263, 0x3661, 0x4f68, \
+ { 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 } \
+ }
+
+#define GRUB_EFI_DXE_SERVICES_TABLE_GUID \
+ { 0x05ad34ba, 0x6f02, 0x4214, \
+ { 0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } \
+ }
+
+#define GRUB_EFI_HOB_LIST_GUID \
+ { 0x7739f24c, 0x93d7, 0x11d4, \
+ { 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+ }
+
+#define GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID \
+ { 0x4c19049f, 0x4137, 0x4dd3, \
+ { 0x9c, 0x10, 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa } \
+ }
+
+#define GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID \
+ { 0x49152e77, 0x1ada, 0x4764, \
+ { 0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b } \
+ }
+
+#define GRUB_EFI_MPS_TABLE_GUID \
+ { 0xeb9d2d2f, 0x2d88, 0x11d3, \
+ { 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+ }
+
+#define GRUB_EFI_ACPI_TABLE_GUID \
+ { 0xeb9d2d30, 0x2d88, 0x11d3, \
+ { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+ }
+
+#define GRUB_EFI_ACPI_20_TABLE_GUID \
+ { 0x8868e871, 0xe4f1, 0x11d3, \
+ { 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } \
+ }
+
+#define GRUB_EFI_SMBIOS_TABLE_GUID \
+ { 0xeb9d2d31, 0x2d88, 0x11d3, \
+ { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+ }
+
+#define GRUB_EFI_SMBIOS3_TABLE_GUID \
+ { 0xf2fd1544, 0x9794, 0x4a2c, \
+ { 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94 } \
+ }
+
+#define GRUB_EFI_SAL_TABLE_GUID \
+ { 0xeb9d2d32, 0x2d88, 0x11d3, \
+ { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+ }
+
+#define GRUB_EFI_HCDP_TABLE_GUID \
+ { 0xf951938d, 0x620b, 0x42ef, \
+ { 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 } \
+ }
+
+#define GRUB_EFI_RT_PROPERTIES_TABLE_GUID \
+ { 0xeb66918a, 0x7eef, 0x402a, \
+ { 0x84, 0x2e, 0x93, 0x1d, 0x21, 0xc3, 0x8a, 0xe9 } \
+ }
+
+#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 } \
+ }
+
+#define GRUB_EFI_SHIM_LOCK_GUID \
+ { 0x605dab50, 0xe046, 0x4300, \
+ { 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } \
+ }
+
+#define GRUB_EFI_RNG_PROTOCOL_GUID \
+ { 0x3152bca5, 0xeade, 0x433d, \
+ { 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 } \
+ }
+
+struct grub_efi_sal_system_table
+{
+ grub_uint32_t signature;
+ grub_uint32_t total_table_len;
+ grub_uint16_t sal_rev;
+ grub_uint16_t entry_count;
+ grub_uint8_t checksum;
+ grub_uint8_t reserved1[7];
+ grub_uint16_t sal_a_version;
+ grub_uint16_t sal_b_version;
+ grub_uint8_t oem_id[32];
+ grub_uint8_t product_id[32];
+ grub_uint8_t reserved2[8];
+ grub_uint8_t entries[0];
+};
+
+enum
+ {
+ GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_ENTRYPOINT_DESCRIPTOR = 0,
+ GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_MEMORY_DESCRIPTOR = 1,
+ GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PLATFORM_FEATURES = 2,
+ GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_TRANSLATION_REGISTER_DESCRIPTOR = 3,
+ GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_PURGE_TRANSLATION_COHERENCE = 4,
+ GRUB_EFI_SAL_SYSTEM_TABLE_TYPE_AP_WAKEUP = 5
+ };
+
+struct grub_efi_sal_system_table_entrypoint_descriptor
+{
+ grub_uint8_t type;
+ grub_uint8_t pad[7];
+ grub_uint64_t pal_proc_addr;
+ grub_uint64_t sal_proc_addr;
+ grub_uint64_t global_data_ptr;
+ grub_uint64_t reserved[2];
+};
+
+struct grub_efi_sal_system_table_memory_descriptor
+{
+ grub_uint8_t type;
+ grub_uint8_t sal_used;
+ grub_uint8_t attr;
+ grub_uint8_t ar;
+ grub_uint8_t attr_mask;
+ grub_uint8_t mem_type;
+ grub_uint8_t usage;
+ grub_uint8_t unknown;
+ grub_uint64_t addr;
+ grub_uint64_t len;
+ grub_uint64_t unknown2;
+};
+
+struct grub_efi_sal_system_table_platform_features
+{
+ grub_uint8_t type;
+ grub_uint8_t flags;
+ grub_uint8_t reserved[14];
+};
+
+struct grub_efi_sal_system_table_translation_register_descriptor
+{
+ grub_uint8_t type;
+ grub_uint8_t register_type;
+ grub_uint8_t register_number;
+ grub_uint8_t reserved[5];
+ grub_uint64_t addr;
+ grub_uint64_t page_size;
+ grub_uint64_t reserver;
+};
+
+struct grub_efi_sal_system_table_purge_translation_coherence
+{
+ grub_uint8_t type;
+ grub_uint8_t reserved[3];
+ grub_uint32_t ndomains;
+ grub_uint64_t coherence;
+};
+
+struct grub_efi_sal_system_table_ap_wakeup
+{
+ grub_uint8_t type;
+ grub_uint8_t mechanism;
+ grub_uint8_t reserved[6];
+ grub_uint64_t vector;
+};
+
+enum
+ {
+ GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_BUSLOCK = 1,
+ GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IRQREDIRECT = 2,
+ GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_IPIREDIRECT = 4,
+ GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_ITCDRIFT = 8,
+ };
+
+typedef enum grub_efi_parity_type
+ {
+ GRUB_EFI_SERIAL_DEFAULT_PARITY,
+ GRUB_EFI_SERIAL_NO_PARITY,
+ GRUB_EFI_SERIAL_EVEN_PARITY,
+ GRUB_EFI_SERIAL_ODD_PARITY
+ }
+grub_efi_parity_type_t;
+
+typedef enum grub_efi_stop_bits
+ {
+ GRUB_EFI_SERIAL_DEFAULT_STOP_BITS,
+ GRUB_EFI_SERIAL_1_STOP_BIT,
+ GRUB_EFI_SERIAL_1_5_STOP_BITS,
+ GRUB_EFI_SERIAL_2_STOP_BITS
+ }
+ grub_efi_stop_bits_t;
+
+/* Enumerations. */
+enum grub_efi_timer_delay
+ {
+ GRUB_EFI_TIMER_CANCEL,
+ GRUB_EFI_TIMER_PERIODIC,
+ GRUB_EFI_TIMER_RELATIVE
+ };
+typedef enum grub_efi_timer_delay grub_efi_timer_delay_t;
+
+enum grub_efi_allocate_type
+ {
+ GRUB_EFI_ALLOCATE_ANY_PAGES,
+ GRUB_EFI_ALLOCATE_MAX_ADDRESS,
+ GRUB_EFI_ALLOCATE_ADDRESS,
+ GRUB_EFI_MAX_ALLOCATION_TYPE
+ };
+typedef enum grub_efi_allocate_type grub_efi_allocate_type_t;
+
+enum grub_efi_memory_type
+ {
+ GRUB_EFI_RESERVED_MEMORY_TYPE,
+ GRUB_EFI_LOADER_CODE,
+ GRUB_EFI_LOADER_DATA,
+ GRUB_EFI_BOOT_SERVICES_CODE,
+ GRUB_EFI_BOOT_SERVICES_DATA,
+ GRUB_EFI_RUNTIME_SERVICES_CODE,
+ GRUB_EFI_RUNTIME_SERVICES_DATA,
+ GRUB_EFI_CONVENTIONAL_MEMORY,
+ GRUB_EFI_UNUSABLE_MEMORY,
+ GRUB_EFI_ACPI_RECLAIM_MEMORY,
+ GRUB_EFI_ACPI_MEMORY_NVS,
+ GRUB_EFI_MEMORY_MAPPED_IO,
+ GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE,
+ GRUB_EFI_PAL_CODE,
+ GRUB_EFI_PERSISTENT_MEMORY,
+ GRUB_EFI_MAX_MEMORY_TYPE
+ };
+typedef enum grub_efi_memory_type grub_efi_memory_type_t;
+
+enum grub_efi_interface_type
+ {
+ GRUB_EFI_NATIVE_INTERFACE
+ };
+typedef enum grub_efi_interface_type grub_efi_interface_type_t;
+
+enum grub_efi_locate_search_type
+ {
+ GRUB_EFI_ALL_HANDLES,
+ GRUB_EFI_BY_REGISTER_NOTIFY,
+ GRUB_EFI_BY_PROTOCOL
+ };
+typedef enum grub_efi_locate_search_type grub_efi_locate_search_type_t;
+
+enum grub_efi_reset_type
+ {
+ GRUB_EFI_RESET_COLD,
+ GRUB_EFI_RESET_WARM,
+ GRUB_EFI_RESET_SHUTDOWN
+ };
+typedef enum grub_efi_reset_type grub_efi_reset_type_t;
+
+/* Types. */
+typedef char grub_efi_boolean_t;
+#if GRUB_CPU_SIZEOF_VOID_P == 8
+typedef grub_int64_t grub_efi_intn_t;
+typedef grub_uint64_t grub_efi_uintn_t;
+#else
+typedef grub_int32_t grub_efi_intn_t;
+typedef grub_uint32_t grub_efi_uintn_t;
+#endif
+typedef grub_int8_t grub_efi_int8_t;
+typedef grub_uint8_t grub_efi_uint8_t;
+typedef grub_int16_t grub_efi_int16_t;
+typedef grub_uint16_t grub_efi_uint16_t;
+typedef grub_int32_t grub_efi_int32_t;
+typedef grub_uint32_t grub_efi_uint32_t;
+typedef grub_int64_t grub_efi_int64_t;
+typedef grub_uint64_t grub_efi_uint64_t;
+typedef grub_uint8_t grub_efi_char8_t;
+typedef grub_uint16_t grub_efi_char16_t;
+
+typedef grub_efi_uintn_t grub_efi_status_t;
+
+#define GRUB_EFI_ERROR_CODE(value) \
+ ((((grub_efi_status_t) 1) << (sizeof (grub_efi_status_t) * 8 - 1)) | (value))
+
+#define GRUB_EFI_WARNING_CODE(value) (value)
+
+#define GRUB_EFI_SUCCESS 0
+
+#define GRUB_EFI_LOAD_ERROR GRUB_EFI_ERROR_CODE (1)
+#define GRUB_EFI_INVALID_PARAMETER GRUB_EFI_ERROR_CODE (2)
+#define GRUB_EFI_UNSUPPORTED GRUB_EFI_ERROR_CODE (3)
+#define GRUB_EFI_BAD_BUFFER_SIZE GRUB_EFI_ERROR_CODE (4)
+#define GRUB_EFI_BUFFER_TOO_SMALL GRUB_EFI_ERROR_CODE (5)
+#define GRUB_EFI_NOT_READY GRUB_EFI_ERROR_CODE (6)
+#define GRUB_EFI_DEVICE_ERROR GRUB_EFI_ERROR_CODE (7)
+#define GRUB_EFI_WRITE_PROTECTED GRUB_EFI_ERROR_CODE (8)
+#define GRUB_EFI_OUT_OF_RESOURCES GRUB_EFI_ERROR_CODE (9)
+#define GRUB_EFI_VOLUME_CORRUPTED GRUB_EFI_ERROR_CODE (10)
+#define GRUB_EFI_VOLUME_FULL GRUB_EFI_ERROR_CODE (11)
+#define GRUB_EFI_NO_MEDIA GRUB_EFI_ERROR_CODE (12)
+#define GRUB_EFI_MEDIA_CHANGED GRUB_EFI_ERROR_CODE (13)
+#define GRUB_EFI_NOT_FOUND GRUB_EFI_ERROR_CODE (14)
+#define GRUB_EFI_ACCESS_DENIED GRUB_EFI_ERROR_CODE (15)
+#define GRUB_EFI_NO_RESPONSE GRUB_EFI_ERROR_CODE (16)
+#define GRUB_EFI_NO_MAPPING GRUB_EFI_ERROR_CODE (17)
+#define GRUB_EFI_TIMEOUT GRUB_EFI_ERROR_CODE (18)
+#define GRUB_EFI_NOT_STARTED GRUB_EFI_ERROR_CODE (19)
+#define GRUB_EFI_ALREADY_STARTED GRUB_EFI_ERROR_CODE (20)
+#define GRUB_EFI_ABORTED GRUB_EFI_ERROR_CODE (21)
+#define GRUB_EFI_ICMP_ERROR GRUB_EFI_ERROR_CODE (22)
+#define GRUB_EFI_TFTP_ERROR GRUB_EFI_ERROR_CODE (23)
+#define GRUB_EFI_PROTOCOL_ERROR GRUB_EFI_ERROR_CODE (24)
+#define GRUB_EFI_INCOMPATIBLE_VERSION GRUB_EFI_ERROR_CODE (25)
+#define GRUB_EFI_SECURITY_VIOLATION GRUB_EFI_ERROR_CODE (26)
+#define GRUB_EFI_CRC_ERROR GRUB_EFI_ERROR_CODE (27)
+
+#define GRUB_EFI_WARN_UNKNOWN_GLYPH GRUB_EFI_WARNING_CODE (1)
+#define GRUB_EFI_WARN_DELETE_FAILURE GRUB_EFI_WARNING_CODE (2)
+#define GRUB_EFI_WARN_WRITE_FAILURE GRUB_EFI_WARNING_CODE (3)
+#define GRUB_EFI_WARN_BUFFER_TOO_SMALL GRUB_EFI_WARNING_CODE (4)
+
+typedef void *grub_efi_handle_t;
+typedef void *grub_efi_event_t;
+typedef grub_efi_uint64_t grub_efi_lba_t;
+typedef grub_efi_uintn_t grub_efi_tpl_t;
+typedef grub_uint8_t grub_efi_mac_address_t[32];
+typedef grub_uint8_t grub_efi_ipv4_address_t[4];
+typedef grub_uint16_t grub_efi_ipv6_address_t[8];
+typedef grub_uint8_t grub_efi_ip_address_t[8] __attribute__ ((aligned(4)));
+typedef grub_efi_uint64_t grub_efi_physical_address_t;
+typedef grub_efi_uint64_t grub_efi_virtual_address_t;
+
+struct grub_efi_guid
+{
+ grub_uint32_t data1;
+ grub_uint16_t data2;
+ grub_uint16_t data3;
+ grub_uint8_t data4[8];
+} __attribute__ ((aligned(8)));
+typedef struct grub_efi_guid grub_efi_guid_t;
+
+struct grub_efi_packed_guid
+{
+ grub_uint32_t data1;
+ grub_uint16_t data2;
+ grub_uint16_t data3;
+ grub_uint8_t data4[8];
+} GRUB_PACKED;
+typedef struct grub_efi_packed_guid grub_efi_packed_guid_t;
+
+/* XXX although the spec does not specify the padding, this actually
+ must have the padding! */
+struct grub_efi_memory_descriptor
+{
+ grub_efi_uint32_t type;
+ grub_efi_uint32_t padding;
+ grub_efi_physical_address_t physical_start;
+ grub_efi_virtual_address_t virtual_start;
+ grub_efi_uint64_t num_pages;
+ grub_efi_uint64_t attribute;
+} GRUB_PACKED;
+typedef struct grub_efi_memory_descriptor grub_efi_memory_descriptor_t;
+
+/* Device Path definitions. */
+struct grub_efi_device_path
+{
+ grub_efi_uint8_t type;
+ grub_efi_uint8_t subtype;
+ grub_efi_uint16_t length;
+} GRUB_PACKED;
+typedef struct grub_efi_device_path grub_efi_device_path_t;
+/* XXX EFI does not define EFI_DEVICE_PATH_PROTOCOL but uses it.
+ It seems to be identical to EFI_DEVICE_PATH. */
+typedef struct grub_efi_device_path grub_efi_device_path_protocol_t;
+
+#define GRUB_EFI_DEVICE_PATH_TYPE(dp) ((dp)->type & 0x7f)
+#define GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) ((dp)->subtype)
+#define GRUB_EFI_DEVICE_PATH_LENGTH(dp) ((dp)->length)
+#define GRUB_EFI_DEVICE_PATH_VALID(dp) ((dp) != NULL && GRUB_EFI_DEVICE_PATH_LENGTH (dp) >= 4)
+
+/* The End of Device Path nodes. */
+#define GRUB_EFI_END_DEVICE_PATH_TYPE (0xff & 0x7f)
+
+#define GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff
+#define GRUB_EFI_END_THIS_DEVICE_PATH_SUBTYPE 0x01
+
+#define GRUB_EFI_END_ENTIRE_DEVICE_PATH(dp) \
+ (!GRUB_EFI_DEVICE_PATH_VALID (dp) || \
+ (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_END_DEVICE_PATH_TYPE \
+ && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp) \
+ == GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)))
+
+#define GRUB_EFI_NEXT_DEVICE_PATH(dp) \
+ (GRUB_EFI_DEVICE_PATH_VALID (dp) \
+ ? ((grub_efi_device_path_t *) \
+ ((char *) (dp) + GRUB_EFI_DEVICE_PATH_LENGTH (dp))) \
+ : NULL)
+
+/* Hardware Device Path. */
+#define GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE 1
+
+#define GRUB_EFI_PCI_DEVICE_PATH_SUBTYPE 1
+
+struct grub_efi_pci_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint8_t function;
+ grub_efi_uint8_t device;
+} GRUB_PACKED;
+typedef struct grub_efi_pci_device_path grub_efi_pci_device_path_t;
+
+#define GRUB_EFI_PCCARD_DEVICE_PATH_SUBTYPE 2
+
+struct grub_efi_pccard_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint8_t function;
+} GRUB_PACKED;
+typedef struct grub_efi_pccard_device_path grub_efi_pccard_device_path_t;
+
+#define GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE 3
+
+struct grub_efi_memory_mapped_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint32_t memory_type;
+ grub_efi_physical_address_t start_address;
+ grub_efi_physical_address_t end_address;
+} GRUB_PACKED;
+typedef struct grub_efi_memory_mapped_device_path grub_efi_memory_mapped_device_path_t;
+
+#define GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE 4
+
+struct grub_efi_vendor_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_packed_guid_t vendor_guid;
+ grub_efi_uint8_t vendor_defined_data[0];
+} GRUB_PACKED;
+typedef struct grub_efi_vendor_device_path grub_efi_vendor_device_path_t;
+
+#define GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE 5
+
+struct grub_efi_controller_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint32_t controller_number;
+} GRUB_PACKED;
+typedef struct grub_efi_controller_device_path grub_efi_controller_device_path_t;
+
+/* ACPI Device Path. */
+#define GRUB_EFI_ACPI_DEVICE_PATH_TYPE 2
+
+#define GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE 1
+
+struct grub_efi_acpi_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint32_t hid;
+ grub_efi_uint32_t uid;
+} GRUB_PACKED;
+typedef struct grub_efi_acpi_device_path grub_efi_acpi_device_path_t;
+
+#define GRUB_EFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE 2
+
+struct grub_efi_expanded_acpi_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint32_t hid;
+ grub_efi_uint32_t uid;
+ grub_efi_uint32_t cid;
+ char hidstr[0];
+} GRUB_PACKED;
+typedef struct grub_efi_expanded_acpi_device_path grub_efi_expanded_acpi_device_path_t;
+
+#define GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp) \
+ (((grub_efi_expanded_acpi_device_path_t *) dp)->hidstr)
+#define GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp) \
+ (GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp) \
+ + grub_strlen (GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp)) + 1)
+#define GRUB_EFI_EXPANDED_ACPI_CIDSTR(dp) \
+ (GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp) \
+ + grub_strlen (GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp)) + 1)
+
+/* Messaging Device Path. */
+#define GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE 3
+
+#define GRUB_EFI_ATAPI_DEVICE_PATH_SUBTYPE 1
+
+struct grub_efi_atapi_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint8_t primary_secondary;
+ grub_efi_uint8_t slave_master;
+ grub_efi_uint16_t lun;
+} GRUB_PACKED;
+typedef struct grub_efi_atapi_device_path grub_efi_atapi_device_path_t;
+
+#define GRUB_EFI_SCSI_DEVICE_PATH_SUBTYPE 2
+
+struct grub_efi_scsi_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint16_t pun;
+ grub_efi_uint16_t lun;
+} GRUB_PACKED;
+typedef struct grub_efi_scsi_device_path grub_efi_scsi_device_path_t;
+
+#define GRUB_EFI_FIBRE_CHANNEL_DEVICE_PATH_SUBTYPE 3
+
+struct grub_efi_fibre_channel_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint32_t reserved;
+ grub_efi_uint64_t wwn;
+ grub_efi_uint64_t lun;
+} GRUB_PACKED;
+typedef struct grub_efi_fibre_channel_device_path grub_efi_fibre_channel_device_path_t;
+
+#define GRUB_EFI_1394_DEVICE_PATH_SUBTYPE 4
+
+struct grub_efi_1394_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint32_t reserved;
+ grub_efi_uint64_t guid;
+} GRUB_PACKED;
+typedef struct grub_efi_1394_device_path grub_efi_1394_device_path_t;
+
+#define GRUB_EFI_USB_DEVICE_PATH_SUBTYPE 5
+
+struct grub_efi_usb_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint8_t parent_port_number;
+ grub_efi_uint8_t usb_interface;
+} GRUB_PACKED;
+typedef struct grub_efi_usb_device_path grub_efi_usb_device_path_t;
+
+#define GRUB_EFI_USB_CLASS_DEVICE_PATH_SUBTYPE 15
+
+struct grub_efi_usb_class_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint16_t vendor_id;
+ grub_efi_uint16_t product_id;
+ grub_efi_uint8_t device_class;
+ grub_efi_uint8_t device_subclass;
+ grub_efi_uint8_t device_protocol;
+} GRUB_PACKED;
+typedef struct grub_efi_usb_class_device_path grub_efi_usb_class_device_path_t;
+
+#define GRUB_EFI_I2O_DEVICE_PATH_SUBTYPE 6
+
+struct grub_efi_i2o_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint32_t tid;
+} GRUB_PACKED;
+typedef struct grub_efi_i2o_device_path grub_efi_i2o_device_path_t;
+
+#define GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE 11
+
+struct grub_efi_mac_address_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_mac_address_t mac_address;
+ grub_efi_uint8_t if_type;
+} GRUB_PACKED;
+typedef struct grub_efi_mac_address_device_path grub_efi_mac_address_device_path_t;
+
+#define GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE 12
+
+struct grub_efi_ipv4_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_ipv4_address_t local_ip_address;
+ grub_efi_ipv4_address_t remote_ip_address;
+ grub_efi_uint16_t local_port;
+ grub_efi_uint16_t remote_port;
+ grub_efi_uint16_t protocol;
+ grub_efi_uint8_t static_ip_address;
+} GRUB_PACKED;
+typedef struct grub_efi_ipv4_device_path grub_efi_ipv4_device_path_t;
+
+#define GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE 13
+
+struct grub_efi_ipv6_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_ipv6_address_t local_ip_address;
+ grub_efi_ipv6_address_t remote_ip_address;
+ grub_efi_uint16_t local_port;
+ grub_efi_uint16_t remote_port;
+ grub_efi_uint16_t protocol;
+ grub_efi_uint8_t static_ip_address;
+} GRUB_PACKED;
+typedef struct grub_efi_ipv6_device_path grub_efi_ipv6_device_path_t;
+
+#define GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE 9
+
+struct grub_efi_infiniband_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint32_t resource_flags;
+ grub_efi_uint8_t port_gid[16];
+ grub_efi_uint64_t remote_id;
+ grub_efi_uint64_t target_port_id;
+ grub_efi_uint64_t device_id;
+} GRUB_PACKED;
+typedef struct grub_efi_infiniband_device_path grub_efi_infiniband_device_path_t;
+
+#define GRUB_EFI_UART_DEVICE_PATH_SUBTYPE 14
+
+struct grub_efi_uart_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint32_t reserved;
+ grub_efi_uint64_t baud_rate;
+ grub_efi_uint8_t data_bits;
+ grub_efi_uint8_t parity;
+ grub_efi_uint8_t stop_bits;
+} GRUB_PACKED;
+typedef struct grub_efi_uart_device_path grub_efi_uart_device_path_t;
+
+#define GRUB_EFI_SATA_DEVICE_PATH_SUBTYPE 18
+
+struct grub_efi_sata_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint16_t hba_port;
+ grub_efi_uint16_t multiplier_port;
+ grub_efi_uint16_t lun;
+} GRUB_PACKED;
+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
+
+#define GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE 1
+
+struct grub_efi_hard_drive_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint32_t partition_number;
+ grub_efi_lba_t partition_start;
+ grub_efi_lba_t partition_size;
+ grub_efi_uint8_t partition_signature[16];
+ grub_efi_uint8_t partmap_type;
+ grub_efi_uint8_t signature_type;
+} GRUB_PACKED;
+typedef struct grub_efi_hard_drive_device_path grub_efi_hard_drive_device_path_t;
+
+#define GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE 2
+
+struct grub_efi_cdrom_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint32_t boot_entry;
+ grub_efi_lba_t partition_start;
+ grub_efi_lba_t partition_size;
+} GRUB_PACKED;
+typedef struct grub_efi_cdrom_device_path grub_efi_cdrom_device_path_t;
+
+#define GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE 3
+
+struct grub_efi_vendor_media_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_packed_guid_t vendor_guid;
+ grub_efi_uint8_t vendor_defined_data[0];
+} GRUB_PACKED;
+typedef struct grub_efi_vendor_media_device_path grub_efi_vendor_media_device_path_t;
+
+#define GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE 4
+
+struct grub_efi_file_path_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_char16_t path_name[0];
+} GRUB_PACKED;
+typedef struct grub_efi_file_path_device_path grub_efi_file_path_device_path_t;
+
+#define GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE 5
+
+struct grub_efi_protocol_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_packed_guid_t guid;
+} GRUB_PACKED;
+typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t;
+
+#define GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE 6
+
+struct grub_efi_piwg_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_packed_guid_t guid;
+} GRUB_PACKED;
+typedef struct grub_efi_piwg_device_path grub_efi_piwg_device_path_t;
+
+
+/* BIOS Boot Specification Device Path. */
+#define GRUB_EFI_BIOS_DEVICE_PATH_TYPE 5
+
+#define GRUB_EFI_BIOS_DEVICE_PATH_SUBTYPE 1
+
+struct grub_efi_bios_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_uint16_t device_type;
+ grub_efi_uint16_t status_flags;
+ char description[0];
+} GRUB_PACKED;
+typedef struct grub_efi_bios_device_path grub_efi_bios_device_path_t;
+
+struct grub_efi_open_protocol_information_entry
+{
+ grub_efi_handle_t agent_handle;
+ grub_efi_handle_t controller_handle;
+ grub_efi_uint32_t attributes;
+ grub_efi_uint32_t open_count;
+};
+typedef struct grub_efi_open_protocol_information_entry grub_efi_open_protocol_information_entry_t;
+
+struct grub_efi_time
+{
+ grub_efi_uint16_t year;
+ grub_efi_uint8_t month;
+ grub_efi_uint8_t day;
+ grub_efi_uint8_t hour;
+ grub_efi_uint8_t minute;
+ grub_efi_uint8_t second;
+ grub_efi_uint8_t pad1;
+ grub_efi_uint32_t nanosecond;
+ grub_efi_int16_t time_zone;
+ grub_efi_uint8_t daylight;
+ grub_efi_uint8_t pad2;
+} GRUB_PACKED;
+typedef struct grub_efi_time grub_efi_time_t;
+
+struct grub_efi_time_capabilities
+{
+ grub_efi_uint32_t resolution;
+ grub_efi_uint32_t accuracy;
+ grub_efi_boolean_t sets_to_zero;
+};
+typedef struct grub_efi_time_capabilities grub_efi_time_capabilities_t;
+
+struct grub_efi_input_key
+{
+ grub_efi_uint16_t scan_code;
+ grub_efi_char16_t unicode_char;
+};
+typedef struct grub_efi_input_key grub_efi_input_key_t;
+
+typedef grub_efi_uint8_t grub_efi_key_toggle_state_t;
+struct grub_efi_key_state
+{
+ grub_efi_uint32_t key_shift_state;
+ grub_efi_key_toggle_state_t key_toggle_state;
+};
+typedef struct grub_efi_key_state grub_efi_key_state_t;
+
+#define GRUB_EFI_SHIFT_STATE_VALID 0x80000000
+#define GRUB_EFI_RIGHT_SHIFT_PRESSED 0x00000001
+#define GRUB_EFI_LEFT_SHIFT_PRESSED 0x00000002
+#define GRUB_EFI_RIGHT_CONTROL_PRESSED 0x00000004
+#define GRUB_EFI_LEFT_CONTROL_PRESSED 0x00000008
+#define GRUB_EFI_RIGHT_ALT_PRESSED 0x00000010
+#define GRUB_EFI_LEFT_ALT_PRESSED 0x00000020
+#define GRUB_EFI_RIGHT_LOGO_PRESSED 0x00000040
+#define GRUB_EFI_LEFT_LOGO_PRESSED 0x00000080
+#define GRUB_EFI_MENU_KEY_PRESSED 0x00000100
+#define GRUB_EFI_SYS_REQ_PRESSED 0x00000200
+
+#define GRUB_EFI_TOGGLE_STATE_VALID 0x80
+#define GRUB_EFI_KEY_STATE_EXPOSED 0x40
+#define GRUB_EFI_SCROLL_LOCK_ACTIVE 0x01
+#define GRUB_EFI_NUM_LOCK_ACTIVE 0x02
+#define GRUB_EFI_CAPS_LOCK_ACTIVE 0x04
+
+struct grub_efi_simple_text_output_mode
+{
+ grub_efi_int32_t max_mode;
+ grub_efi_int32_t mode;
+ grub_efi_int32_t attribute;
+ grub_efi_int32_t cursor_column;
+ grub_efi_int32_t cursor_row;
+ grub_efi_boolean_t cursor_visible;
+};
+typedef struct grub_efi_simple_text_output_mode grub_efi_simple_text_output_mode_t;
+
+/* Tables. */
+struct grub_efi_table_header
+{
+ grub_efi_uint64_t signature;
+ grub_efi_uint32_t revision;
+ grub_efi_uint32_t header_size;
+ grub_efi_uint32_t crc32;
+ grub_efi_uint32_t reserved;
+};
+typedef struct grub_efi_table_header grub_efi_table_header_t;
+
+struct grub_efi_boot_services
+{
+ grub_efi_table_header_t hdr;
+
+ grub_efi_tpl_t
+ (*raise_tpl) (grub_efi_tpl_t new_tpl);
+
+ void
+ (*restore_tpl) (grub_efi_tpl_t old_tpl);
+
+ grub_efi_status_t
+ (*allocate_pages) (grub_efi_allocate_type_t type,
+ grub_efi_memory_type_t memory_type,
+ grub_efi_uintn_t pages,
+ grub_efi_physical_address_t *memory);
+
+ grub_efi_status_t
+ (*free_pages) (grub_efi_physical_address_t memory,
+ grub_efi_uintn_t pages);
+
+ grub_efi_status_t
+ (*get_memory_map) (grub_efi_uintn_t *memory_map_size,
+ grub_efi_memory_descriptor_t *memory_map,
+ grub_efi_uintn_t *map_key,
+ grub_efi_uintn_t *descriptor_size,
+ grub_efi_uint32_t *descriptor_version);
+
+ grub_efi_status_t
+ (*allocate_pool) (grub_efi_memory_type_t pool_type,
+ grub_efi_uintn_t size,
+ void **buffer);
+
+ grub_efi_status_t
+ (*free_pool) (void *buffer);
+
+ grub_efi_status_t
+ (*create_event) (grub_efi_uint32_t type,
+ grub_efi_tpl_t notify_tpl,
+ void (*notify_function) (grub_efi_event_t event,
+ void *context),
+ void *notify_context,
+ grub_efi_event_t *event);
+
+ grub_efi_status_t
+ (*set_timer) (grub_efi_event_t event,
+ grub_efi_timer_delay_t type,
+ grub_efi_uint64_t trigger_time);
+
+ grub_efi_status_t
+ (*wait_for_event) (grub_efi_uintn_t num_events,
+ grub_efi_event_t *event,
+ grub_efi_uintn_t *index);
+
+ grub_efi_status_t
+ (*signal_event) (grub_efi_event_t event);
+
+ grub_efi_status_t
+ (*close_event) (grub_efi_event_t event);
+
+ grub_efi_status_t
+ (*check_event) (grub_efi_event_t event);
+
+ grub_efi_status_t
+ (*install_protocol_interface) (grub_efi_handle_t *handle,
+ grub_efi_guid_t *protocol,
+ grub_efi_interface_type_t protocol_interface_type,
+ void *protocol_interface);
+
+ grub_efi_status_t
+ (*reinstall_protocol_interface) (grub_efi_handle_t handle,
+ grub_efi_guid_t *protocol,
+ void *old_interface,
+ void *new_interface);
+
+ grub_efi_status_t
+ (*uninstall_protocol_interface) (grub_efi_handle_t handle,
+ grub_efi_guid_t *protocol,
+ void *protocol_interface);
+
+ grub_efi_status_t
+ (*handle_protocol) (grub_efi_handle_t handle,
+ grub_efi_guid_t *protocol,
+ void **protocol_interface);
+
+ void *reserved;
+
+ grub_efi_status_t
+ (*register_protocol_notify) (grub_efi_guid_t *protocol,
+ grub_efi_event_t event,
+ void **registration);
+
+ grub_efi_status_t
+ (*locate_handle) (grub_efi_locate_search_type_t search_type,
+ grub_efi_guid_t *protocol,
+ void *search_key,
+ grub_efi_uintn_t *buffer_size,
+ grub_efi_handle_t *buffer);
+
+ grub_efi_status_t
+ (*locate_device_path) (grub_efi_guid_t *protocol,
+ grub_efi_device_path_t **device_path,
+ grub_efi_handle_t *device);
+
+ grub_efi_status_t
+ (*install_configuration_table) (grub_efi_guid_t *guid, void *table);
+
+ grub_efi_status_t
+ (*load_image) (grub_efi_boolean_t boot_policy,
+ grub_efi_handle_t parent_image_handle,
+ grub_efi_device_path_t *file_path,
+ void *source_buffer,
+ grub_efi_uintn_t source_size,
+ grub_efi_handle_t *image_handle);
+
+ grub_efi_status_t
+ (*start_image) (grub_efi_handle_t image_handle,
+ grub_efi_uintn_t *exit_data_size,
+ grub_efi_char16_t **exit_data);
+
+ grub_efi_status_t
+ (*exit) (grub_efi_handle_t image_handle,
+ grub_efi_status_t exit_status,
+ grub_efi_uintn_t exit_data_size,
+ grub_efi_char16_t *exit_data) __attribute__((noreturn));
+
+ grub_efi_status_t
+ (*unload_image) (grub_efi_handle_t image_handle);
+
+ grub_efi_status_t
+ (*exit_boot_services) (grub_efi_handle_t image_handle,
+ grub_efi_uintn_t map_key);
+
+ grub_efi_status_t
+ (*get_next_monotonic_count) (grub_efi_uint64_t *count);
+
+ grub_efi_status_t
+ (*stall) (grub_efi_uintn_t microseconds);
+
+ grub_efi_status_t
+ (*set_watchdog_timer) (grub_efi_uintn_t timeout,
+ grub_efi_uint64_t watchdog_code,
+ grub_efi_uintn_t data_size,
+ grub_efi_char16_t *watchdog_data);
+
+ grub_efi_status_t
+ (*connect_controller) (grub_efi_handle_t controller_handle,
+ grub_efi_handle_t *driver_image_handle,
+ grub_efi_device_path_protocol_t *remaining_device_path,
+ grub_efi_boolean_t recursive);
+
+ grub_efi_status_t
+ (*disconnect_controller) (grub_efi_handle_t controller_handle,
+ grub_efi_handle_t driver_image_handle,
+ grub_efi_handle_t child_handle);
+
+ grub_efi_status_t
+ (*open_protocol) (grub_efi_handle_t handle,
+ grub_efi_guid_t *protocol,
+ void **protocol_interface,
+ grub_efi_handle_t agent_handle,
+ grub_efi_handle_t controller_handle,
+ grub_efi_uint32_t attributes);
+
+ grub_efi_status_t
+ (*close_protocol) (grub_efi_handle_t handle,
+ grub_efi_guid_t *protocol,
+ grub_efi_handle_t agent_handle,
+ grub_efi_handle_t controller_handle);
+
+ grub_efi_status_t
+ (*open_protocol_information) (grub_efi_handle_t handle,
+ grub_efi_guid_t *protocol,
+ grub_efi_open_protocol_information_entry_t **entry_buffer,
+ grub_efi_uintn_t *entry_count);
+
+ grub_efi_status_t
+ (*protocols_per_handle) (grub_efi_handle_t handle,
+ grub_efi_packed_guid_t ***protocol_buffer,
+ grub_efi_uintn_t *protocol_buffer_count);
+
+ grub_efi_status_t
+ (*locate_handle_buffer) (grub_efi_locate_search_type_t search_type,
+ grub_efi_guid_t *protocol,
+ void *search_key,
+ grub_efi_uintn_t *no_handles,
+ grub_efi_handle_t **buffer);
+
+ grub_efi_status_t
+ (*locate_protocol) (grub_efi_guid_t *protocol,
+ void *registration,
+ void **protocol_interface);
+
+ grub_efi_status_t
+ (*install_multiple_protocol_interfaces) (grub_efi_handle_t *handle, ...);
+
+ grub_efi_status_t
+ (*uninstall_multiple_protocol_interfaces) (grub_efi_handle_t handle, ...);
+
+ grub_efi_status_t
+ (*calculate_crc32) (void *data,
+ grub_efi_uintn_t data_size,
+ grub_efi_uint32_t *crc32);
+
+ void
+ (*copy_mem) (void *destination, void *source, grub_efi_uintn_t length);
+
+ void
+ (*set_mem) (void *buffer, grub_efi_uintn_t size, grub_efi_uint8_t value);
+};
+typedef struct grub_efi_boot_services grub_efi_boot_services_t;
+
+struct grub_efi_runtime_services
+{
+ grub_efi_table_header_t hdr;
+
+ grub_efi_status_t
+ (*get_time) (grub_efi_time_t *time,
+ grub_efi_time_capabilities_t *capabilities);
+
+ grub_efi_status_t
+ (*set_time) (grub_efi_time_t *time);
+
+ grub_efi_status_t
+ (*get_wakeup_time) (grub_efi_boolean_t *enabled,
+ grub_efi_boolean_t *pending,
+ grub_efi_time_t *time);
+
+ grub_efi_status_t
+ (*set_wakeup_time) (grub_efi_boolean_t enabled,
+ grub_efi_time_t *time);
+
+ grub_efi_status_t
+ (*set_virtual_address_map) (grub_efi_uintn_t memory_map_size,
+ grub_efi_uintn_t descriptor_size,
+ grub_efi_uint32_t descriptor_version,
+ grub_efi_memory_descriptor_t *virtual_map);
+
+ grub_efi_status_t
+ (*convert_pointer) (grub_efi_uintn_t debug_disposition, void **address);
+
+#define GRUB_EFI_GLOBAL_VARIABLE_GUID \
+ { 0x8BE4DF61, 0x93CA, 0x11d2, { 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C }}
+
+
+ grub_efi_status_t
+ (*get_variable) (grub_efi_char16_t *variable_name,
+ const grub_efi_guid_t *vendor_guid,
+ grub_efi_uint32_t *attributes,
+ grub_efi_uintn_t *data_size,
+ void *data);
+
+ grub_efi_status_t
+ (*get_next_variable_name) (grub_efi_uintn_t *variable_name_size,
+ grub_efi_char16_t *variable_name,
+ grub_efi_guid_t *vendor_guid);
+
+ grub_efi_status_t
+ (*set_variable) (grub_efi_char16_t *variable_name,
+ const grub_efi_guid_t *vendor_guid,
+ grub_efi_uint32_t attributes,
+ grub_efi_uintn_t data_size,
+ void *data);
+
+ grub_efi_status_t
+ (*get_next_high_monotonic_count) (grub_efi_uint32_t *high_count);
+
+ void
+ (*reset_system) (grub_efi_reset_type_t reset_type,
+ grub_efi_status_t reset_status,
+ grub_efi_uintn_t data_size,
+ grub_efi_char16_t *reset_data);
+};
+typedef struct grub_efi_runtime_services grub_efi_runtime_services_t;
+
+struct grub_efi_configuration_table
+{
+ grub_efi_packed_guid_t vendor_guid;
+ void *vendor_table;
+} GRUB_PACKED;
+typedef struct grub_efi_configuration_table grub_efi_configuration_table_t;
+
+#define GRUB_EFIEMU_SYSTEM_TABLE_SIGNATURE 0x5453595320494249LL
+#define GRUB_EFIEMU_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552LL
+
+struct grub_efi_serial_io_interface
+{
+ grub_efi_uint32_t revision;
+ void (*reset) (void);
+ grub_efi_status_t (*set_attributes) (struct grub_efi_serial_io_interface *this,
+ grub_efi_uint64_t speed,
+ grub_efi_uint32_t fifo_depth,
+ grub_efi_uint32_t timeout,
+ grub_efi_parity_type_t parity,
+ grub_uint8_t word_len,
+ grub_efi_stop_bits_t stop_bits);
+ grub_efi_status_t (*set_control_bits) (struct grub_efi_serial_io_interface *this,
+ grub_efi_uint32_t flags);
+ void (*get_control_bits) (void);
+ grub_efi_status_t (*write) (struct grub_efi_serial_io_interface *this,
+ grub_efi_uintn_t *buf_size,
+ void *buffer);
+ grub_efi_status_t (*read) (struct grub_efi_serial_io_interface *this,
+ grub_efi_uintn_t *buf_size,
+ void *buffer);
+};
+
+struct grub_efi_simple_input_interface
+{
+ grub_efi_status_t
+ (*reset) (struct grub_efi_simple_input_interface *this,
+ grub_efi_boolean_t extended_verification);
+
+ grub_efi_status_t
+ (*read_key_stroke) (struct grub_efi_simple_input_interface *this,
+ grub_efi_input_key_t *key);
+
+ grub_efi_event_t wait_for_key;
+};
+typedef struct grub_efi_simple_input_interface grub_efi_simple_input_interface_t;
+
+struct grub_efi_key_data {
+ grub_efi_input_key_t key;
+ grub_efi_key_state_t key_state;
+};
+typedef struct grub_efi_key_data grub_efi_key_data_t;
+
+typedef grub_efi_status_t (*grub_efi_key_notify_function_t) (
+ grub_efi_key_data_t *key_data
+ );
+
+struct grub_efi_simple_text_input_ex_interface
+{
+ grub_efi_status_t
+ (*reset) (struct grub_efi_simple_text_input_ex_interface *this,
+ grub_efi_boolean_t extended_verification);
+
+ grub_efi_status_t
+ (*read_key_stroke) (struct grub_efi_simple_text_input_ex_interface *this,
+ grub_efi_key_data_t *key_data);
+
+ grub_efi_event_t wait_for_key;
+
+ grub_efi_status_t
+ (*set_state) (struct grub_efi_simple_text_input_ex_interface *this,
+ grub_efi_key_toggle_state_t *key_toggle_state);
+
+ grub_efi_status_t
+ (*register_key_notify) (struct grub_efi_simple_text_input_ex_interface *this,
+ grub_efi_key_data_t *key_data,
+ grub_efi_key_notify_function_t key_notification_function);
+
+ grub_efi_status_t
+ (*unregister_key_notify) (struct grub_efi_simple_text_input_ex_interface *this,
+ void *notification_handle);
+};
+typedef struct grub_efi_simple_text_input_ex_interface grub_efi_simple_text_input_ex_interface_t;
+
+struct grub_efi_simple_text_output_interface
+{
+ grub_efi_status_t
+ (*reset) (struct grub_efi_simple_text_output_interface *this,
+ grub_efi_boolean_t extended_verification);
+
+ grub_efi_status_t
+ (*output_string) (struct grub_efi_simple_text_output_interface *this,
+ grub_efi_char16_t *string);
+
+ grub_efi_status_t
+ (*test_string) (struct grub_efi_simple_text_output_interface *this,
+ grub_efi_char16_t *string);
+
+ grub_efi_status_t
+ (*query_mode) (struct grub_efi_simple_text_output_interface *this,
+ grub_efi_uintn_t mode_number,
+ grub_efi_uintn_t *columns,
+ grub_efi_uintn_t *rows);
+
+ grub_efi_status_t
+ (*set_mode) (struct grub_efi_simple_text_output_interface *this,
+ grub_efi_uintn_t mode_number);
+
+ grub_efi_status_t
+ (*set_attributes) (struct grub_efi_simple_text_output_interface *this,
+ grub_efi_uintn_t attribute);
+
+ grub_efi_status_t
+ (*clear_screen) (struct grub_efi_simple_text_output_interface *this);
+
+ grub_efi_status_t
+ (*set_cursor_position) (struct grub_efi_simple_text_output_interface *this,
+ grub_efi_uintn_t column,
+ grub_efi_uintn_t row);
+
+ grub_efi_status_t
+ (*enable_cursor) (struct grub_efi_simple_text_output_interface *this,
+ grub_efi_boolean_t visible);
+
+ grub_efi_simple_text_output_mode_t *mode;
+};
+typedef struct grub_efi_simple_text_output_interface grub_efi_simple_text_output_interface_t;
+
+typedef grub_uint8_t grub_efi_pxe_packet_t[1472];
+
+typedef struct grub_efi_pxe_mode
+{
+ grub_uint8_t unused[52];
+ grub_efi_pxe_packet_t dhcp_discover;
+ grub_efi_pxe_packet_t dhcp_ack;
+ grub_efi_pxe_packet_t proxy_offer;
+ grub_efi_pxe_packet_t pxe_discover;
+ grub_efi_pxe_packet_t pxe_reply;
+} grub_efi_pxe_mode_t;
+
+typedef struct grub_efi_pxe
+{
+ grub_uint64_t rev;
+ void (*start) (void);
+ void (*stop) (void);
+ void (*dhcp) (void);
+ void (*discover) (void);
+ void (*mftp) (void);
+ void (*udpwrite) (void);
+ void (*udpread) (void);
+ void (*setipfilter) (void);
+ void (*arp) (void);
+ void (*setparams) (void);
+ void (*setstationip) (void);
+ void (*setpackets) (void);
+ struct grub_efi_pxe_mode *mode;
+} grub_efi_pxe_t;
+
+#define GRUB_EFI_BLACK 0x00
+#define GRUB_EFI_BLUE 0x01
+#define GRUB_EFI_GREEN 0x02
+#define GRUB_EFI_CYAN 0x03
+#define GRUB_EFI_RED 0x04
+#define GRUB_EFI_MAGENTA 0x05
+#define GRUB_EFI_BROWN 0x06
+#define GRUB_EFI_LIGHTGRAY 0x07
+#define GRUB_EFI_BRIGHT 0x08
+#define GRUB_EFI_DARKGRAY 0x08
+#define GRUB_EFI_LIGHTBLUE 0x09
+#define GRUB_EFI_LIGHTGREEN 0x0A
+#define GRUB_EFI_LIGHTCYAN 0x0B
+#define GRUB_EFI_LIGHTRED 0x0C
+#define GRUB_EFI_LIGHTMAGENTA 0x0D
+#define GRUB_EFI_YELLOW 0x0E
+#define GRUB_EFI_WHITE 0x0F
+
+#define GRUB_EFI_BACKGROUND_BLACK 0x00
+#define GRUB_EFI_BACKGROUND_BLUE 0x10
+#define GRUB_EFI_BACKGROUND_GREEN 0x20
+#define GRUB_EFI_BACKGROUND_CYAN 0x30
+#define GRUB_EFI_BACKGROUND_RED 0x40
+#define GRUB_EFI_BACKGROUND_MAGENTA 0x50
+#define GRUB_EFI_BACKGROUND_BROWN 0x60
+#define GRUB_EFI_BACKGROUND_LIGHTGRAY 0x70
+
+#define GRUB_EFI_TEXT_ATTR(fg, bg) ((fg) | ((bg)))
+
+struct grub_efi_system_table
+{
+ grub_efi_table_header_t hdr;
+ grub_efi_char16_t *firmware_vendor;
+ grub_efi_uint32_t firmware_revision;
+ grub_efi_handle_t console_in_handler;
+ grub_efi_simple_input_interface_t *con_in;
+ grub_efi_handle_t console_out_handler;
+ grub_efi_simple_text_output_interface_t *con_out;
+ grub_efi_handle_t standard_error_handle;
+ grub_efi_simple_text_output_interface_t *std_err;
+ grub_efi_runtime_services_t *runtime_services;
+ grub_efi_boot_services_t *boot_services;
+ grub_efi_uintn_t num_table_entries;
+ grub_efi_configuration_table_t *configuration_table;
+};
+typedef struct grub_efi_system_table grub_efi_system_table_t;
+
+struct grub_efi_loaded_image
+{
+ grub_efi_uint32_t revision;
+ grub_efi_handle_t parent_handle;
+ grub_efi_system_table_t *system_table;
+
+ grub_efi_handle_t device_handle;
+ grub_efi_device_path_t *file_path;
+ void *reserved;
+
+ grub_efi_uint32_t load_options_size;
+ void *load_options;
+
+ void *image_base;
+ grub_efi_uint64_t image_size;
+ grub_efi_memory_type_t image_code_type;
+ grub_efi_memory_type_t image_data_type;
+
+ grub_efi_status_t (*unload) (grub_efi_handle_t image_handle);
+};
+typedef struct grub_efi_loaded_image grub_efi_loaded_image_t;
+
+struct grub_efi_disk_io
+{
+ grub_efi_uint64_t revision;
+ grub_efi_status_t (*read) (struct grub_efi_disk_io *this,
+ grub_efi_uint32_t media_id,
+ grub_efi_uint64_t offset,
+ grub_efi_uintn_t buffer_size,
+ void *buffer);
+ grub_efi_status_t (*write) (struct grub_efi_disk_io *this,
+ grub_efi_uint32_t media_id,
+ grub_efi_uint64_t offset,
+ grub_efi_uintn_t buffer_size,
+ void *buffer);
+};
+typedef struct grub_efi_disk_io grub_efi_disk_io_t;
+
+struct grub_efi_block_io_media
+{
+ grub_efi_uint32_t media_id;
+ grub_efi_boolean_t removable_media;
+ grub_efi_boolean_t media_present;
+ grub_efi_boolean_t logical_partition;
+ grub_efi_boolean_t read_only;
+ grub_efi_boolean_t write_caching;
+ grub_efi_uint8_t pad[3];
+ grub_efi_uint32_t block_size;
+ grub_efi_uint32_t io_align;
+ grub_efi_uint8_t pad2[4];
+ grub_efi_lba_t last_block;
+};
+typedef struct grub_efi_block_io_media grub_efi_block_io_media_t;
+
+typedef grub_uint8_t grub_efi_mac_t[32];
+
+struct grub_efi_simple_network_mode
+{
+ grub_uint32_t state;
+ grub_uint32_t hwaddr_size;
+ grub_uint32_t media_header_size;
+ grub_uint32_t max_packet_size;
+ grub_uint32_t nvram_size;
+ grub_uint32_t nvram_access_size;
+ grub_uint32_t receive_filter_mask;
+ grub_uint32_t receive_filter_setting;
+ grub_uint32_t max_mcast_filter_count;
+ grub_uint32_t mcast_filter_count;
+ grub_efi_mac_t mcast_filter[16];
+ grub_efi_mac_t current_address;
+ grub_efi_mac_t broadcast_address;
+ grub_efi_mac_t permanent_address;
+ grub_uint8_t if_type;
+ grub_uint8_t mac_changeable;
+ grub_uint8_t multitx_supported;
+ grub_uint8_t media_present_supported;
+ grub_uint8_t media_present;
+};
+
+enum
+ {
+ GRUB_EFI_NETWORK_STOPPED,
+ GRUB_EFI_NETWORK_STARTED,
+ GRUB_EFI_NETWORK_INITIALIZED,
+ };
+
+enum
+ {
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST = 0x01,
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST = 0x02,
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST = 0x04,
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS = 0x08,
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST = 0x10,
+ };
+
+struct grub_efi_simple_network
+{
+ grub_uint64_t revision;
+ grub_efi_status_t (*start) (struct grub_efi_simple_network *this);
+ grub_efi_status_t (*stop) (struct grub_efi_simple_network *this);
+ grub_efi_status_t (*initialize) (struct grub_efi_simple_network *this,
+ grub_efi_uintn_t extra_rx,
+ grub_efi_uintn_t extra_tx);
+ void (*reset) (void);
+ grub_efi_status_t (*shutdown) (struct grub_efi_simple_network *this);
+ grub_efi_status_t (*receive_filters) (struct grub_efi_simple_network *this,
+ grub_uint32_t enable,
+ grub_uint32_t disable,
+ grub_efi_boolean_t reset_mcast_filter,
+ grub_efi_uintn_t mcast_filter_count,
+ grub_efi_mac_address_t *mcast_filter);
+ void (*station_address) (void);
+ void (*statistics) (void);
+ void (*mcastiptomac) (void);
+ void (*nvdata) (void);
+ grub_efi_status_t (*get_status) (struct grub_efi_simple_network *this,
+ grub_uint32_t *int_status,
+ void **txbuf);
+ grub_efi_status_t (*transmit) (struct grub_efi_simple_network *this,
+ grub_efi_uintn_t header_size,
+ grub_efi_uintn_t buffer_size,
+ void *buffer,
+ grub_efi_mac_t *src_addr,
+ grub_efi_mac_t *dest_addr,
+ grub_efi_uint16_t *protocol);
+ grub_efi_status_t (*receive) (struct grub_efi_simple_network *this,
+ grub_efi_uintn_t *header_size,
+ grub_efi_uintn_t *buffer_size,
+ void *buffer,
+ grub_efi_mac_t *src_addr,
+ grub_efi_mac_t *dest_addr,
+ grub_uint16_t *protocol);
+ void (*waitforpacket) (void);
+ struct grub_efi_simple_network_mode *mode;
+};
+typedef struct grub_efi_simple_network grub_efi_simple_network_t;
+
+
+struct grub_efi_block_io
+{
+ grub_efi_uint64_t revision;
+ grub_efi_block_io_media_t *media;
+ grub_efi_status_t (*reset) (struct grub_efi_block_io *this,
+ grub_efi_boolean_t extended_verification);
+ grub_efi_status_t (*read_blocks) (struct grub_efi_block_io *this,
+ grub_efi_uint32_t media_id,
+ grub_efi_lba_t lba,
+ grub_efi_uintn_t buffer_size,
+ void *buffer);
+ grub_efi_status_t (*write_blocks) (struct grub_efi_block_io *this,
+ grub_efi_uint32_t media_id,
+ grub_efi_lba_t lba,
+ grub_efi_uintn_t buffer_size,
+ void *buffer);
+ grub_efi_status_t (*flush_blocks) (struct grub_efi_block_io *this);
+};
+typedef struct grub_efi_block_io grub_efi_block_io_t;
+
+struct grub_efi_shim_lock_protocol
+{
+ grub_efi_status_t (*verify) (void *buffer, grub_uint32_t size);
+};
+typedef struct grub_efi_shim_lock_protocol grub_efi_shim_lock_protocol_t;
+
+typedef grub_efi_guid_t grub_efi_rng_algorithm_t;
+
+struct grub_efi_rng_protocol
+{
+ grub_efi_status_t (*get_info) (struct grub_efi_rng_protocol *this,
+ grub_efi_uintn_t *rng_algorithm_list_size,
+ grub_efi_rng_algorithm_t *rng_algorithm_list);
+ grub_efi_status_t (*get_rng) (struct grub_efi_rng_protocol *this,
+ grub_efi_rng_algorithm_t *rng_algorithm,
+ grub_efi_uintn_t rng_value_length,
+ grub_efi_uint8_t *rng_value);
+};
+typedef struct grub_efi_rng_protocol grub_efi_rng_protocol_t;
+
+struct grub_efi_load_file2
+{
+ grub_efi_status_t (*load_file)(struct grub_efi_load_file2 *this,
+ grub_efi_device_path_t *file_path,
+ grub_efi_boolean_t boot_policy,
+ grub_efi_uintn_t *buffer_size,
+ void *buffer);
+};
+typedef struct grub_efi_load_file2 grub_efi_load_file2_t;
+
+#if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \
+ || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) \
+ || defined(__riscv)
+
+#define efi_call_0(func) func()
+#define efi_call_1(func, a) func(a)
+#define efi_call_2(func, a, b) func(a, b)
+#define efi_call_3(func, a, b, c) func(a, b, c)
+#define efi_call_4(func, a, b, c, d) func(a, b, c, d)
+#define efi_call_5(func, a, b, c, d, e) func(a, b, c, d, e)
+#define efi_call_6(func, a, b, c, d, e, f) func(a, b, c, d, e, f)
+#define efi_call_7(func, a, b, c, d, e, f, g) func(a, b, c, d, e, f, g)
+#define efi_call_10(func, a, b, c, d, e, f, g, h, i, j) func(a, b, c, d, e, f, g, h, i, j)
+
+#else
+
+#define efi_call_0(func) \
+ efi_wrap_0(func)
+#define efi_call_1(func, a) \
+ efi_wrap_1(func, (grub_uint64_t) (a))
+#define efi_call_2(func, a, b) \
+ efi_wrap_2(func, (grub_uint64_t) (a), (grub_uint64_t) (b))
+#define efi_call_3(func, a, b, c) \
+ efi_wrap_3(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
+ (grub_uint64_t) (c))
+#define efi_call_4(func, a, b, c, d) \
+ efi_wrap_4(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
+ (grub_uint64_t) (c), (grub_uint64_t) (d))
+#define efi_call_5(func, a, b, c, d, e) \
+ efi_wrap_5(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
+ (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e))
+#define efi_call_6(func, a, b, c, d, e, f) \
+ efi_wrap_6(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
+ (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e), \
+ (grub_uint64_t) (f))
+#define efi_call_7(func, a, b, c, d, e, f, g) \
+ efi_wrap_7(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
+ (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e), \
+ (grub_uint64_t) (f), (grub_uint64_t) (g))
+#define efi_call_10(func, a, b, c, d, e, f, g, h, i, j) \
+ efi_wrap_10(func, (grub_uint64_t) (a), (grub_uint64_t) (b), \
+ (grub_uint64_t) (c), (grub_uint64_t) (d), (grub_uint64_t) (e), \
+ (grub_uint64_t) (f), (grub_uint64_t) (g), (grub_uint64_t) (h), \
+ (grub_uint64_t) (i), (grub_uint64_t) (j))
+
+grub_uint64_t EXPORT_FUNC(efi_wrap_0) (void *func);
+grub_uint64_t EXPORT_FUNC(efi_wrap_1) (void *func, grub_uint64_t arg1);
+grub_uint64_t EXPORT_FUNC(efi_wrap_2) (void *func, grub_uint64_t arg1,
+ grub_uint64_t arg2);
+grub_uint64_t EXPORT_FUNC(efi_wrap_3) (void *func, grub_uint64_t arg1,
+ grub_uint64_t arg2, grub_uint64_t arg3);
+grub_uint64_t EXPORT_FUNC(efi_wrap_4) (void *func, grub_uint64_t arg1,
+ grub_uint64_t arg2, grub_uint64_t arg3,
+ grub_uint64_t arg4);
+grub_uint64_t EXPORT_FUNC(efi_wrap_5) (void *func, grub_uint64_t arg1,
+ grub_uint64_t arg2, grub_uint64_t arg3,
+ grub_uint64_t arg4, grub_uint64_t arg5);
+grub_uint64_t EXPORT_FUNC(efi_wrap_6) (void *func, grub_uint64_t arg1,
+ grub_uint64_t arg2, grub_uint64_t arg3,
+ grub_uint64_t arg4, grub_uint64_t arg5,
+ grub_uint64_t arg6);
+grub_uint64_t EXPORT_FUNC(efi_wrap_7) (void *func, grub_uint64_t arg1,
+ grub_uint64_t arg2, grub_uint64_t arg3,
+ grub_uint64_t arg4, grub_uint64_t arg5,
+ grub_uint64_t arg6, grub_uint64_t arg7);
+grub_uint64_t EXPORT_FUNC(efi_wrap_10) (void *func, grub_uint64_t arg1,
+ grub_uint64_t arg2, grub_uint64_t arg3,
+ grub_uint64_t arg4, grub_uint64_t arg5,
+ grub_uint64_t arg6, grub_uint64_t arg7,
+ grub_uint64_t arg8, grub_uint64_t arg9,
+ grub_uint64_t arg10);
+#endif
+
+#endif /* ! GRUB_EFI_API_HEADER */
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/include/grub/riscv32/linux.h
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/include/grub/riscv32/linux.h (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/include/grub/riscv32/linux.h (revision 216)
@@ -0,0 +1,42 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 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/>.
+ */
+
+#ifndef GRUB_RISCV32_LINUX_HEADER
+#define GRUB_RISCV32_LINUX_HEADER 1
+
+#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x52534356 /* 'RSCV' */
+
+/* From linux/Documentation/riscv/booting.txt */
+struct linux_riscv_kernel_header
+{
+ 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, "RSCV" */
+ grub_uint32_t hdr_offset; /* Offset of PE/COFF header */
+};
+
+#define linux_arch_kernel_header linux_riscv_kernel_header
+#define GRUB_LINUX_ARCH_MAGIC_SIGNATURE GRUB_LINUX_RISCV_MAGIC_SIGNATURE
+
+#endif /* ! GRUB_RISCV32_LINUX_HEADER */
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/include/grub/riscv64/linux.h
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/include/grub/riscv64/linux.h (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/include/grub/riscv64/linux.h (revision 216)
@@ -0,0 +1,51 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 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/>.
+ */
+
+#ifndef GRUB_RISCV64_LINUX_HEADER
+#define GRUB_RISCV64_LINUX_HEADER 1
+
+#define GRUB_LINUX_RISCV_MAGIC_SIGNATURE 0x52534356 /* 'RSCV' */
+
+#define GRUB_EFI_PE_MAGIC 0x5A4D
+
+/* From linux/Documentation/riscv/booting.txt */
+struct linux_riscv_kernel_header
+{
+ 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, "RSCV" */
+ grub_uint32_t hdr_offset; /* Offset of PE/COFF header */
+};
+
+#define linux_arch_kernel_header linux_riscv_kernel_header
+#define GRUB_LINUX_ARCH_MAGIC_SIGNATURE GRUB_LINUX_RISCV_MAGIC_SIGNATURE
+
+#define get_hartid(__v) \
+{ \
+ __asm__ __volatile__ ("mv %0, tp" \
+ : "=r" (__v) : \
+ : "memory"); \
+}
+
+#endif /* ! GRUB_RISCV64_LINUX_HEADER */
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/po/POTFILES.in
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/po/POTFILES.in (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-linux-loader-patch/grub-2.06-new/po/POTFILES.in (revision 216)
@@ -0,0 +1,1293 @@
+./grub-core/boot/decompressor/minilib.c
+./grub-core/boot/decompressor/none.c
+./grub-core/boot/decompressor/xz.c
+./grub-core/bus/bonito.c
+./grub-core/bus/cs5536.c
+./grub-core/bus/emu/pci.c
+./grub-core/bus/fdt.c
+./grub-core/bus/i386/ieee1275/pci.c
+./grub-core/bus/pci.c
+./grub-core/bus/spi/rk3288_spi.c
+./grub-core/bus/usb/ehci-fdt.c
+./grub-core/bus/usb/ehci-pci.c
+./grub-core/bus/usb/ehci.c
+./grub-core/bus/usb/ohci.c
+./grub-core/bus/usb/serial/common.c
+./grub-core/bus/usb/serial/ftdi.c
+./grub-core/bus/usb/serial/pl2303.c
+./grub-core/bus/usb/serial/usbdebug_late.c
+./grub-core/bus/usb/uhci.c
+./grub-core/bus/usb/usb.c
+./grub-core/bus/usb/usbhub.c
+./grub-core/bus/usb/usbtrans.c
+./grub-core/commands/acpi.c
+./grub-core/commands/acpihalt.c
+./grub-core/commands/arc/lsdev.c
+./grub-core/commands/blocklist.c
+./grub-core/commands/boot.c
+./grub-core/commands/boottime.c
+./grub-core/commands/cacheinfo.c
+./grub-core/commands/cat.c
+./grub-core/commands/cmp.c
+./grub-core/commands/configfile.c
+./grub-core/commands/date.c
+./grub-core/commands/echo.c
+./grub-core/commands/efi/efifwsetup.c
+./grub-core/commands/efi/fixvideo.c
+./grub-core/commands/efi/loadbios.c
+./grub-core/commands/efi/lsefi.c
+./grub-core/commands/efi/lsefimmap.c
+./grub-core/commands/efi/lsefisystab.c
+./grub-core/commands/efi/lssal.c
+./grub-core/commands/efi/smbios.c
+./grub-core/commands/efi/tpm.c
+./grub-core/commands/eval.c
+./grub-core/commands/extcmd.c
+./grub-core/commands/file.c
+./grub-core/commands/file32.c
+./grub-core/commands/file64.c
+./grub-core/commands/fileXX.c
+./grub-core/commands/gptsync.c
+./grub-core/commands/halt.c
+./grub-core/commands/hashsum.c
+./grub-core/commands/hdparm.c
+./grub-core/commands/help.c
+./grub-core/commands/hexdump.c
+./grub-core/commands/i386/cmosdump.c
+./grub-core/commands/i386/cmostest.c
+./grub-core/commands/i386/coreboot/cb_timestamps.c
+./grub-core/commands/i386/coreboot/cbls.c
+./grub-core/commands/i386/cpuid.c
+./grub-core/commands/i386/pc/drivemap.c
+./grub-core/commands/i386/pc/halt.c
+./grub-core/commands/i386/pc/lsapm.c
+./grub-core/commands/i386/pc/play.c
+./grub-core/commands/i386/pc/sendkey.c
+./grub-core/commands/i386/pc/smbios.c
+./grub-core/commands/i386/rdmsr.c
+./grub-core/commands/i386/wrmsr.c
+./grub-core/commands/ieee1275/suspend.c
+./grub-core/commands/iorw.c
+./grub-core/commands/keylayouts.c
+./grub-core/commands/keystatus.c
+./grub-core/commands/legacycfg.c
+./grub-core/commands/loadenv.c
+./grub-core/commands/ls.c
+./grub-core/commands/lsacpi.c
+./grub-core/commands/lsmmap.c
+./grub-core/commands/lspci.c
+./grub-core/commands/macbless.c
+./grub-core/commands/memrw.c
+./grub-core/commands/menuentry.c
+./grub-core/commands/minicmd.c
+./grub-core/commands/mips/loongson/lsspd.c
+./grub-core/commands/nativedisk.c
+./grub-core/commands/parttool.c
+./grub-core/commands/password.c
+./grub-core/commands/password_pbkdf2.c
+./grub-core/commands/pcidump.c
+./grub-core/commands/pgp.c
+./grub-core/commands/probe.c
+./grub-core/commands/read.c
+./grub-core/commands/reboot.c
+./grub-core/commands/regexp.c
+./grub-core/commands/search.c
+./grub-core/commands/search_file.c
+./grub-core/commands/search_label.c
+./grub-core/commands/search_uuid.c
+./grub-core/commands/search_wrap.c
+./grub-core/commands/setpci.c
+./grub-core/commands/sleep.c
+./grub-core/commands/smbios.c
+./grub-core/commands/syslinuxcfg.c
+./grub-core/commands/terminal.c
+./grub-core/commands/test.c
+./grub-core/commands/testload.c
+./grub-core/commands/testspeed.c
+./grub-core/commands/time.c
+./grub-core/commands/tpm.c
+./grub-core/commands/tr.c
+./grub-core/commands/true.c
+./grub-core/commands/usbtest.c
+./grub-core/commands/videoinfo.c
+./grub-core/commands/videotest.c
+./grub-core/commands/wildcard.c
+./grub-core/commands/xen/lsxen.c
+./grub-core/commands/xnu_uuid.c
+./grub-core/disk/AFSplitter.c
+./grub-core/disk/ahci.c
+./grub-core/disk/arc/arcdisk.c
+./grub-core/disk/ata.c
+./grub-core/disk/cryptodisk.c
+./grub-core/disk/diskfilter.c
+./grub-core/disk/dmraid_nvidia.c
+./grub-core/disk/efi/efidisk.c
+./grub-core/disk/geli.c
+./grub-core/disk/host.c
+./grub-core/disk/i386/pc/biosdisk.c
+./grub-core/disk/ieee1275/nand.c
+./grub-core/disk/ieee1275/obdisk.c
+./grub-core/disk/ieee1275/ofdisk.c
+./grub-core/disk/ldm.c
+./grub-core/disk/loopback.c
+./grub-core/disk/luks.c
+./grub-core/disk/luks2.c
+./grub-core/disk/lvm.c
+./grub-core/disk/mdraid1x_linux.c
+./grub-core/disk/mdraid_linux.c
+./grub-core/disk/mdraid_linux_be.c
+./grub-core/disk/memdisk.c
+./grub-core/disk/pata.c
+./grub-core/disk/raid5_recover.c
+./grub-core/disk/raid6_recover.c
+./grub-core/disk/scsi.c
+./grub-core/disk/uboot/ubootdisk.c
+./grub-core/disk/usbms.c
+./grub-core/disk/xen/xendisk.c
+./grub-core/efiemu/i386/coredetect.c
+./grub-core/efiemu/i386/loadcore32.c
+./grub-core/efiemu/i386/loadcore64.c
+./grub-core/efiemu/i386/nocfgtables.c
+./grub-core/efiemu/i386/pc/cfgtables.c
+./grub-core/efiemu/loadcore.c
+./grub-core/efiemu/loadcore32.c
+./grub-core/efiemu/loadcore64.c
+./grub-core/efiemu/loadcore_common.c
+./grub-core/efiemu/main.c
+./grub-core/efiemu/mm.c
+./grub-core/efiemu/pnvram.c
+./grub-core/efiemu/prepare.c
+./grub-core/efiemu/prepare32.c
+./grub-core/efiemu/prepare64.c
+./grub-core/efiemu/runtime/config.h
+./grub-core/efiemu/runtime/efiemu.c
+./grub-core/efiemu/symbols.c
+./grub-core/font/font.c
+./grub-core/font/font_cmd.c
+./grub-core/fs/affs.c
+./grub-core/fs/afs.c
+./grub-core/fs/archelp.c
+./grub-core/fs/bfs.c
+./grub-core/fs/btrfs.c
+./grub-core/fs/cbfs.c
+./grub-core/fs/cpio.c
+./grub-core/fs/cpio_be.c
+./grub-core/fs/cpio_common.c
+./grub-core/fs/exfat.c
+./grub-core/fs/ext2.c
+./grub-core/fs/f2fs.c
+./grub-core/fs/fat.c
+./grub-core/fs/fshelp.c
+./grub-core/fs/hfs.c
+./grub-core/fs/hfsplus.c
+./grub-core/fs/hfspluscomp.c
+./grub-core/fs/iso9660.c
+./grub-core/fs/jfs.c
+./grub-core/fs/minix.c
+./grub-core/fs/minix2.c
+./grub-core/fs/minix2_be.c
+./grub-core/fs/minix3.c
+./grub-core/fs/minix3_be.c
+./grub-core/fs/minix_be.c
+./grub-core/fs/newc.c
+./grub-core/fs/nilfs2.c
+./grub-core/fs/ntfs.c
+./grub-core/fs/ntfscomp.c
+./grub-core/fs/odc.c
+./grub-core/fs/proc.c
+./grub-core/fs/reiserfs.c
+./grub-core/fs/romfs.c
+./grub-core/fs/sfs.c
+./grub-core/fs/squash4.c
+./grub-core/fs/tar.c
+./grub-core/fs/udf.c
+./grub-core/fs/ufs.c
+./grub-core/fs/ufs2.c
+./grub-core/fs/ufs_be.c
+./grub-core/fs/xfs.c
+./grub-core/fs/zfs/zfs.c
+./grub-core/fs/zfs/zfs_fletcher.c
+./grub-core/fs/zfs/zfs_lz4.c
+./grub-core/fs/zfs/zfs_lzjb.c
+./grub-core/fs/zfs/zfs_sha256.c
+./grub-core/fs/zfs/zfscrypt.c
+./grub-core/fs/zfs/zfsinfo.c
+./grub-core/gdb/cstub.c
+./grub-core/gdb/gdb.c
+./grub-core/gdb/i386/idt.c
+./grub-core/gdb/i386/signal.c
+./grub-core/gentrigtables.c
+./grub-core/gettext/gettext.c
+./grub-core/gfxmenu/font.c
+./grub-core/gfxmenu/gfxmenu.c
+./grub-core/gfxmenu/gui_box.c
+./grub-core/gfxmenu/gui_canvas.c
+./grub-core/gfxmenu/gui_circular_progress.c
+./grub-core/gfxmenu/gui_image.c
+./grub-core/gfxmenu/gui_label.c
+./grub-core/gfxmenu/gui_list.c
+./grub-core/gfxmenu/gui_progress_bar.c
+./grub-core/gfxmenu/gui_string_util.c
+./grub-core/gfxmenu/gui_util.c
+./grub-core/gfxmenu/icon_manager.c
+./grub-core/gfxmenu/theme_loader.c
+./grub-core/gfxmenu/view.c
+./grub-core/gfxmenu/widget-box.c
+./grub-core/hello/hello.c
+./grub-core/hook/datehook.c
+./grub-core/io/bufio.c
+./grub-core/io/gzio.c
+./grub-core/io/lzopio.c
+./grub-core/io/offset.c
+./grub-core/io/xzio.c
+./grub-core/kern/acpi.c
+./grub-core/kern/arm/cache.c
+./grub-core/kern/arm/coreboot/cbtable.c
+./grub-core/kern/arm/coreboot/dma.c
+./grub-core/kern/arm/coreboot/init.c
+./grub-core/kern/arm/coreboot/timer.c
+./grub-core/kern/arm/dl.c
+./grub-core/kern/arm/dl_helper.c
+./grub-core/kern/arm/efi/init.c
+./grub-core/kern/arm/uboot/init.c
+./grub-core/kern/arm64/cache.c
+./grub-core/kern/arm64/dl.c
+./grub-core/kern/arm64/dl_helper.c
+./grub-core/kern/arm64/efi/init.c
+./grub-core/kern/buffer.c
+./grub-core/kern/command.c
+./grub-core/kern/compiler-rt.c
+./grub-core/kern/coreboot/cbtable.c
+./grub-core/kern/coreboot/mmap.c
+./grub-core/kern/corecmd.c
+./grub-core/kern/device.c
+./grub-core/kern/disk.c
+./grub-core/kern/disk_common.c
+./grub-core/kern/dl.c
+./grub-core/kern/efi/acpi.c
+./grub-core/kern/efi/efi.c
+./grub-core/kern/efi/fdt.c
+./grub-core/kern/efi/init.c
+./grub-core/kern/efi/mm.c
+./grub-core/kern/efi/sb.c
+./grub-core/kern/elf.c
+./grub-core/kern/elfXX.c
+./grub-core/kern/emu/argp_common.c
+./grub-core/kern/emu/cache.c
+./grub-core/kern/emu/full.c
+./grub-core/kern/emu/hostdisk.c
+./grub-core/kern/emu/hostfs.c
+./grub-core/kern/emu/lite.c
+./grub-core/kern/emu/main.c
+./grub-core/kern/emu/misc.c
+./grub-core/kern/emu/mm.c
+./grub-core/kern/emu/time.c
+./grub-core/kern/env.c
+./grub-core/kern/err.c
+./grub-core/kern/file.c
+./grub-core/kern/fs.c
+./grub-core/kern/generic/millisleep.c
+./grub-core/kern/generic/rtc_get_time_ms.c
+./grub-core/kern/i386/coreboot/cbtable.c
+./grub-core/kern/i386/coreboot/init.c
+./grub-core/kern/i386/dl.c
+./grub-core/kern/i386/efi/init.c
+./grub-core/kern/i386/efi/tsc.c
+./grub-core/kern/i386/multiboot_mmap.c
+./grub-core/kern/i386/pc/acpi.c
+./grub-core/kern/i386/pc/init.c
+./grub-core/kern/i386/pc/mmap.c
+./grub-core/kern/i386/qemu/init.c
+./grub-core/kern/i386/qemu/mmap.c
+./grub-core/kern/i386/tsc.c
+./grub-core/kern/i386/tsc_pit.c
+./grub-core/kern/i386/tsc_pmtimer.c
+./grub-core/kern/i386/xen/pvh.c
+./grub-core/kern/i386/xen/tsc.c
+./grub-core/kern/ia64/cache.c
+./grub-core/kern/ia64/dl.c
+./grub-core/kern/ia64/dl_helper.c
+./grub-core/kern/ia64/efi/init.c
+./grub-core/kern/ieee1275/cmain.c
+./grub-core/kern/ieee1275/ieee1275.c
+./grub-core/kern/ieee1275/init.c
+./grub-core/kern/ieee1275/mmap.c
+./grub-core/kern/ieee1275/openfw.c
+./grub-core/kern/list.c
+./grub-core/kern/lockdown.c
+./grub-core/kern/main.c
+./grub-core/kern/mips/arc/init.c
+./grub-core/kern/mips/dl.c
+./grub-core/kern/mips/init.c
+./grub-core/kern/mips/loongson/init.c
+./grub-core/kern/mips/qemu_mips/init.c
+./grub-core/kern/misc.c
+./grub-core/kern/mm.c
+./grub-core/kern/parser.c
+./grub-core/kern/partition.c
+./grub-core/kern/powerpc/dl.c
+./grub-core/kern/rescue_parser.c
+./grub-core/kern/rescue_reader.c
+./grub-core/kern/riscv/cache.c
+./grub-core/kern/riscv/dl.c
+./grub-core/kern/riscv/efi/init.c
+./grub-core/kern/sparc64/dl.c
+./grub-core/kern/sparc64/ieee1275/ieee1275.c
+./grub-core/kern/term.c
+./grub-core/kern/time.c
+./grub-core/kern/uboot/hw.c
+./grub-core/kern/uboot/init.c
+./grub-core/kern/uboot/uboot.c
+./grub-core/kern/verifiers.c
+./grub-core/kern/vga_init.c
+./grub-core/kern/x86_64/dl.c
+./grub-core/kern/xen/init.c
+./grub-core/lib/LzFind.c
+./grub-core/lib/LzmaDec.c
+./grub-core/lib/LzmaEnc.c
+./grub-core/lib/adler32.c
+./grub-core/lib/arc/datetime.c
+./grub-core/lib/arg.c
+./grub-core/lib/backtrace.c
+./grub-core/lib/cmdline.c
+./grub-core/lib/cmos_datetime.c
+./grub-core/lib/crc.c
+./grub-core/lib/crc64.c
+./grub-core/lib/crypto.c
+./grub-core/lib/datetime.c
+./grub-core/lib/disk.c
+./grub-core/lib/division.c
+./grub-core/lib/dummy/datetime.c
+./grub-core/lib/dummy/halt.c
+./grub-core/lib/dummy/reboot.c
+./grub-core/lib/efi/datetime.c
+./grub-core/lib/efi/halt.c
+./grub-core/lib/efi/relocator.c
+./grub-core/lib/emu/halt.c
+./grub-core/lib/envblk.c
+./grub-core/lib/fake_module.c
+./grub-core/lib/fdt.c
+./grub-core/lib/getline.c
+./grub-core/lib/hexdump.c
+./grub-core/lib/i386/backtrace.c
+./grub-core/lib/i386/halt.c
+./grub-core/lib/i386/pc/biosnum.c
+./grub-core/lib/i386/pc/vesa_modes_table.c
+./grub-core/lib/i386/random.c
+./grub-core/lib/i386/reboot.c
+./grub-core/lib/i386/relocator.c
+./grub-core/lib/i386/relocator_common_c.c
+./grub-core/lib/ieee1275/cmos.c
+./grub-core/lib/ieee1275/datetime.c
+./grub-core/lib/ieee1275/halt.c
+./grub-core/lib/ieee1275/reboot.c
+./grub-core/lib/ieee1275/relocator.c
+./grub-core/lib/json/jsmn.h
+./grub-core/lib/json/json.c
+./grub-core/lib/json/json.h
+./grub-core/lib/legacy_parse.c
+./grub-core/lib/libgcrypt/cipher/ac.c
+./grub-core/lib/libgcrypt/cipher/arcfour.c
+./grub-core/lib/libgcrypt/cipher/bithelp.h
+./grub-core/lib/libgcrypt/cipher/blowfish.c
+./grub-core/lib/libgcrypt/cipher/bufhelp.h
+./grub-core/lib/libgcrypt/cipher/camellia-glue.c
+./grub-core/lib/libgcrypt/cipher/camellia.c
+./grub-core/lib/libgcrypt/cipher/camellia.h
+./grub-core/lib/libgcrypt/cipher/cast5.c
+./grub-core/lib/libgcrypt/cipher/cipher.c
+./grub-core/lib/libgcrypt/cipher/crc.c
+./grub-core/lib/libgcrypt/cipher/des.c
+./grub-core/lib/libgcrypt/cipher/dsa.c
+./grub-core/lib/libgcrypt/cipher/ecc.c
+./grub-core/lib/libgcrypt/cipher/elgamal.c
+./grub-core/lib/libgcrypt/cipher/hash-common.c
+./grub-core/lib/libgcrypt/cipher/hash-common.h
+./grub-core/lib/libgcrypt/cipher/hmac-tests.c
+./grub-core/lib/libgcrypt/cipher/idea.c
+./grub-core/lib/libgcrypt/cipher/kdf.c
+./grub-core/lib/libgcrypt/cipher/md.c
+./grub-core/lib/libgcrypt/cipher/md4.c
+./grub-core/lib/libgcrypt/cipher/md5.c
+./grub-core/lib/libgcrypt/cipher/primegen.c
+./grub-core/lib/libgcrypt/cipher/pubkey.c
+./grub-core/lib/libgcrypt/cipher/rfc2268.c
+./grub-core/lib/libgcrypt/cipher/rijndael-tables.h
+./grub-core/lib/libgcrypt/cipher/rijndael.c
+./grub-core/lib/libgcrypt/cipher/rmd.h
+./grub-core/lib/libgcrypt/cipher/rmd160.c
+./grub-core/lib/libgcrypt/cipher/rsa.c
+./grub-core/lib/libgcrypt/cipher/seed.c
+./grub-core/lib/libgcrypt/cipher/serpent.c
+./grub-core/lib/libgcrypt/cipher/sha1.c
+./grub-core/lib/libgcrypt/cipher/sha256.c
+./grub-core/lib/libgcrypt/cipher/sha512.c
+./grub-core/lib/libgcrypt/cipher/test-getrusage.c
+./grub-core/lib/libgcrypt/cipher/tiger.c
+./grub-core/lib/libgcrypt/cipher/twofish.c
+./grub-core/lib/libgcrypt/cipher/whirlpool.c
+./grub-core/lib/libgcrypt/mpi/amd64/mpi-asm-defs.h
+./grub-core/lib/libgcrypt/mpi/ec.c
+./grub-core/lib/libgcrypt/mpi/generic/mpi-asm-defs.h
+./grub-core/lib/libgcrypt/mpi/generic/mpih-add1.c
+./grub-core/lib/libgcrypt/mpi/generic/mpih-lshift.c
+./grub-core/lib/libgcrypt/mpi/generic/mpih-mul1.c
+./grub-core/lib/libgcrypt/mpi/generic/mpih-mul2.c
+./grub-core/lib/libgcrypt/mpi/generic/mpih-mul3.c
+./grub-core/lib/libgcrypt/mpi/generic/mpih-rshift.c
+./grub-core/lib/libgcrypt/mpi/generic/mpih-sub1.c
+./grub-core/lib/libgcrypt/mpi/generic/udiv-w-sdiv.c
+./grub-core/lib/libgcrypt/mpi/i386/syntax.h
+./grub-core/lib/libgcrypt/mpi/longlong.h
+./grub-core/lib/libgcrypt/mpi/m68k/syntax.h
+./grub-core/lib/libgcrypt/mpi/mips3/mpi-asm-defs.h
+./grub-core/lib/libgcrypt/mpi/mpi-add.c
+./grub-core/lib/libgcrypt/mpi/mpi-bit.c
+./grub-core/lib/libgcrypt/mpi/mpi-cmp.c
+./grub-core/lib/libgcrypt/mpi/mpi-div.c
+./grub-core/lib/libgcrypt/mpi/mpi-gcd.c
+./grub-core/lib/libgcrypt/mpi/mpi-inline.c
+./grub-core/lib/libgcrypt/mpi/mpi-inline.h
+./grub-core/lib/libgcrypt/mpi/mpi-internal.h
+./grub-core/lib/libgcrypt/mpi/mpi-inv.c
+./grub-core/lib/libgcrypt/mpi/mpi-mod.c
+./grub-core/lib/libgcrypt/mpi/mpi-mpow.c
+./grub-core/lib/libgcrypt/mpi/mpi-mul.c
+./grub-core/lib/libgcrypt/mpi/mpi-pow.c
+./grub-core/lib/libgcrypt/mpi/mpi-scan.c
+./grub-core/lib/libgcrypt/mpi/mpicoder.c
+./grub-core/lib/libgcrypt/mpi/mpih-div.c
+./grub-core/lib/libgcrypt/mpi/mpih-mul.c
+./grub-core/lib/libgcrypt/mpi/mpiutil.c
+./grub-core/lib/libgcrypt/mpi/powerpc32/syntax.h
+./grub-core/lib/libgcrypt/src/ath.c
+./grub-core/lib/libgcrypt/src/ath.h
+./grub-core/lib/libgcrypt/src/cipher-proto.h
+./grub-core/lib/libgcrypt/src/cipher.h
+./grub-core/lib/libgcrypt/src/dumpsexp.c
+./grub-core/lib/libgcrypt/src/fips.c
+./grub-core/lib/libgcrypt/src/g10lib.h
+./grub-core/lib/libgcrypt/src/gcrypt-module.h
+./grub-core/lib/libgcrypt/src/gcryptrnd.c
+./grub-core/lib/libgcrypt/src/getrandom.c
+./grub-core/lib/libgcrypt/src/hmac256.c
+./grub-core/lib/libgcrypt/src/hmac256.h
+./grub-core/lib/libgcrypt/src/hwfeatures.c
+./grub-core/lib/libgcrypt/src/missing-string.c
+./grub-core/lib/libgcrypt/src/module.c
+./grub-core/lib/libgcrypt/src/mpi.h
+./grub-core/lib/libgcrypt/src/secmem.h
+./grub-core/lib/libgcrypt/src/sexp.c
+./grub-core/lib/libgcrypt/src/stdmem.c
+./grub-core/lib/libgcrypt/src/stdmem.h
+./grub-core/lib/libgcrypt/src/types.h
+./grub-core/lib/libgcrypt/src/visibility.c
+./grub-core/lib/libgcrypt/src/visibility.h
+./grub-core/lib/libgcrypt_wrap/cipher_wrap.h
+./grub-core/lib/libgcrypt_wrap/mem.c
+./grub-core/lib/minilzo/lzoconf.h
+./grub-core/lib/minilzo/lzodefs.h
+./grub-core/lib/minilzo/minilzo.c
+./grub-core/lib/minilzo/minilzo.h
+./grub-core/lib/mips/arc/reboot.c
+./grub-core/lib/mips/loongson/reboot.c
+./grub-core/lib/mips/qemu_mips/reboot.c
+./grub-core/lib/mips/relocator.c
+./grub-core/lib/pbkdf2.c
+./grub-core/lib/posix_wrap/assert.h
+./grub-core/lib/posix_wrap/ctype.h
+./grub-core/lib/posix_wrap/errno.h
+./grub-core/lib/posix_wrap/inttypes.h
+./grub-core/lib/posix_wrap/langinfo.h
+./grub-core/lib/posix_wrap/limits.h
+./grub-core/lib/posix_wrap/localcharset.h
+./grub-core/lib/posix_wrap/locale.h
+./grub-core/lib/posix_wrap/stdint.h
+./grub-core/lib/posix_wrap/stdio.h
+./grub-core/lib/posix_wrap/stdlib.h
+./grub-core/lib/posix_wrap/string.h
+./grub-core/lib/posix_wrap/sys/types.h
+./grub-core/lib/posix_wrap/unistd.h
+./grub-core/lib/posix_wrap/wchar.h
+./grub-core/lib/posix_wrap/wctype.h
+./grub-core/lib/powerpc/relocator.c
+./grub-core/lib/priority_queue.c
+./grub-core/lib/progress.c
+./grub-core/lib/random.c
+./grub-core/lib/reed_solomon.c
+./grub-core/lib/relocator.c
+./grub-core/lib/syslinux_parse.c
+./grub-core/lib/uboot/reboot.c
+./grub-core/lib/x86_64/efi/relocator.c
+./grub-core/lib/xen/datetime.c
+./grub-core/lib/xen/halt.c
+./grub-core/lib/xen/reboot.c
+./grub-core/lib/xen/relocator.c
+./grub-core/lib/xzembed/xz.h
+./grub-core/lib/xzembed/xz_config.h
+./grub-core/lib/xzembed/xz_dec_bcj.c
+./grub-core/lib/xzembed/xz_dec_lzma2.c
+./grub-core/lib/xzembed/xz_dec_stream.c
+./grub-core/lib/xzembed/xz_lzma2.h
+./grub-core/lib/xzembed/xz_private.h
+./grub-core/lib/xzembed/xz_stream.h
+./grub-core/lib/zstd/bitstream.h
+./grub-core/lib/zstd/compiler.h
+./grub-core/lib/zstd/cpu.h
+./grub-core/lib/zstd/debug.c
+./grub-core/lib/zstd/debug.h
+./grub-core/lib/zstd/entropy_common.c
+./grub-core/lib/zstd/error_private.c
+./grub-core/lib/zstd/error_private.h
+./grub-core/lib/zstd/fse.h
+./grub-core/lib/zstd/fse_decompress.c
+./grub-core/lib/zstd/huf.h
+./grub-core/lib/zstd/huf_decompress.c
+./grub-core/lib/zstd/mem.h
+./grub-core/lib/zstd/module.c
+./grub-core/lib/zstd/xxhash.c
+./grub-core/lib/zstd/xxhash.h
+./grub-core/lib/zstd/zstd.h
+./grub-core/lib/zstd/zstd_common.c
+./grub-core/lib/zstd/zstd_decompress.c
+./grub-core/lib/zstd/zstd_errors.h
+./grub-core/lib/zstd/zstd_internal.h
+./grub-core/loader/aout.c
+./grub-core/loader/arm/linux.c
+./grub-core/loader/arm64/linux.c
+./grub-core/loader/arm64/xen_boot.c
+./grub-core/loader/efi/appleloader.c
+./grub-core/loader/efi/chainloader.c
+./grub-core/loader/efi/fdt.c
+./grub-core/loader/i386/bsd.c
+./grub-core/loader/i386/bsd32.c
+./grub-core/loader/i386/bsd64.c
+./grub-core/loader/i386/bsdXX.c
+./grub-core/loader/i386/bsd_pagetable.c
+./grub-core/loader/i386/coreboot/chainloader.c
+./grub-core/loader/i386/linux.c
+./grub-core/loader/i386/multiboot_mbi.c
+./grub-core/loader/i386/pc/chainloader.c
+./grub-core/loader/i386/pc/freedos.c
+./grub-core/loader/i386/pc/linux.c
+./grub-core/loader/i386/pc/ntldr.c
+./grub-core/loader/i386/pc/plan9.c
+./grub-core/loader/i386/pc/pxechainloader.c
+./grub-core/loader/i386/pc/truecrypt.c
+./grub-core/loader/i386/xen.c
+./grub-core/loader/i386/xen_file.c
+./grub-core/loader/i386/xen_file32.c
+./grub-core/loader/i386/xen_file64.c
+./grub-core/loader/i386/xen_fileXX.c
+./grub-core/loader/i386/xnu.c
+./grub-core/loader/ia64/efi/linux.c
+./grub-core/loader/linux.c
+./grub-core/loader/lzss.c
+./grub-core/loader/macho.c
+./grub-core/loader/macho32.c
+./grub-core/loader/macho64.c
+./grub-core/loader/machoXX.c
+./grub-core/loader/mips/linux.c
+./grub-core/loader/multiboot.c
+./grub-core/loader/multiboot_elfxx.c
+./grub-core/loader/multiboot_mbi2.c
+./grub-core/loader/powerpc/ieee1275/linux.c
+./grub-core/loader/efi/linux.c
+./grub-core/loader/sparc64/ieee1275/linux.c
+./grub-core/loader/xnu.c
+./grub-core/loader/xnu_resume.c
+./grub-core/mmap/efi/mmap.c
+./grub-core/mmap/i386/mmap.c
+./grub-core/mmap/i386/pc/mmap.c
+./grub-core/mmap/i386/uppermem.c
+./grub-core/mmap/mips/uppermem.c
+./grub-core/mmap/mmap.c
+./grub-core/net/arp.c
+./grub-core/net/bootp.c
+./grub-core/net/dns.c
+./grub-core/net/drivers/efi/efinet.c
+./grub-core/net/drivers/emu/emunet.c
+./grub-core/net/drivers/i386/pc/pxe.c
+./grub-core/net/drivers/ieee1275/ofnet.c
+./grub-core/net/drivers/uboot/ubootnet.c
+./grub-core/net/ethernet.c
+./grub-core/net/http.c
+./grub-core/net/icmp.c
+./grub-core/net/icmp6.c
+./grub-core/net/ip.c
+./grub-core/net/net.c
+./grub-core/net/netbuff.c
+./grub-core/net/tcp.c
+./grub-core/net/tftp.c
+./grub-core/net/udp.c
+./grub-core/normal/auth.c
+./grub-core/normal/autofs.c
+./grub-core/normal/charset.c
+./grub-core/normal/cmdline.c
+./grub-core/normal/color.c
+./grub-core/normal/completion.c
+./grub-core/normal/context.c
+./grub-core/normal/crypto.c
+./grub-core/normal/dyncmd.c
+./grub-core/normal/main.c
+./grub-core/normal/menu.c
+./grub-core/normal/menu_entry.c
+./grub-core/normal/menu_text.c
+./grub-core/normal/misc.c
+./grub-core/normal/term.c
+./grub-core/osdep/apple/getroot.c
+./grub-core/osdep/apple/hostdisk.c
+./grub-core/osdep/aros/config.c
+./grub-core/osdep/aros/getroot.c
+./grub-core/osdep/aros/hostdisk.c
+./grub-core/osdep/aros/relpath.c
+./grub-core/osdep/basic/compress.c
+./grub-core/osdep/basic/emunet.c
+./grub-core/osdep/basic/getroot.c
+./grub-core/osdep/basic/hostdisk.c
+./grub-core/osdep/basic/init.c
+./grub-core/osdep/basic/no_platform.c
+./grub-core/osdep/basic/ofpath.c
+./grub-core/osdep/basic/platform.c
+./grub-core/osdep/basic/random.c
+./grub-core/osdep/blocklist.c
+./grub-core/osdep/bsd/getroot.c
+./grub-core/osdep/bsd/hostdisk.c
+./grub-core/osdep/compress.c
+./grub-core/osdep/config.c
+./grub-core/osdep/cputime.c
+./grub-core/osdep/devmapper/getroot.c
+./grub-core/osdep/devmapper/hostdisk.c
+./grub-core/osdep/dl.c
+./grub-core/osdep/emuconsole.c
+./grub-core/osdep/emunet.c
+./grub-core/osdep/exec.c
+./grub-core/osdep/freebsd/getroot.c
+./grub-core/osdep/freebsd/hostdisk.c
+./grub-core/osdep/generic/blocklist.c
+./grub-core/osdep/getroot.c
+./grub-core/osdep/haiku/getroot.c
+./grub-core/osdep/haiku/hostdisk.c
+./grub-core/osdep/hostdisk.c
+./grub-core/osdep/hurd/getroot.c
+./grub-core/osdep/hurd/hostdisk.c
+./grub-core/osdep/init.c
+./grub-core/osdep/linux/blocklist.c
+./grub-core/osdep/linux/emunet.c
+./grub-core/osdep/linux/getroot.c
+./grub-core/osdep/linux/hostdisk.c
+./grub-core/osdep/linux/ofpath.c
+./grub-core/osdep/linux/platform.c
+./grub-core/osdep/ofpath.c
+./grub-core/osdep/password.c
+./grub-core/osdep/platform.c
+./grub-core/osdep/platform_unix.c
+./grub-core/osdep/random.c
+./grub-core/osdep/relpath.c
+./grub-core/osdep/sleep.c
+./grub-core/osdep/sun/getroot.c
+./grub-core/osdep/sun/hostdisk.c
+./grub-core/osdep/unix/compress.c
+./grub-core/osdep/unix/config.c
+./grub-core/osdep/unix/cputime.c
+./grub-core/osdep/unix/dl.c
+./grub-core/osdep/unix/emuconsole.c
+./grub-core/osdep/unix/exec.c
+./grub-core/osdep/unix/getroot.c
+./grub-core/osdep/unix/hostdisk.c
+./grub-core/osdep/unix/password.c
+./grub-core/osdep/unix/platform.c
+./grub-core/osdep/unix/random.c
+./grub-core/osdep/unix/relpath.c
+./grub-core/osdep/unix/sleep.c
+./grub-core/osdep/windows/blocklist.c
+./grub-core/osdep/windows/config.c
+./grub-core/osdep/windows/cputime.c
+./grub-core/osdep/windows/dl.c
+./grub-core/osdep/windows/emuconsole.c
+./grub-core/osdep/windows/getroot.c
+./grub-core/osdep/windows/hostdisk.c
+./grub-core/osdep/windows/init.c
+./grub-core/osdep/windows/password.c
+./grub-core/osdep/windows/platform.c
+./grub-core/osdep/windows/random.c
+./grub-core/osdep/windows/relpath.c
+./grub-core/osdep/windows/sleep.c
+./grub-core/partmap/acorn.c
+./grub-core/partmap/amiga.c
+./grub-core/partmap/apple.c
+./grub-core/partmap/bsdlabel.c
+./grub-core/partmap/dfly.c
+./grub-core/partmap/dvh.c
+./grub-core/partmap/gpt.c
+./grub-core/partmap/msdos.c
+./grub-core/partmap/plan.c
+./grub-core/partmap/sun.c
+./grub-core/partmap/sunpc.c
+./grub-core/parttool/msdospart.c
+./grub-core/script/argv.c
+./grub-core/script/execute.c
+./grub-core/script/function.c
+./grub-core/script/lexer.c
+./grub-core/script/main.c
+./grub-core/script/script.c
+./grub-core/term/arc/console.c
+./grub-core/term/arc/serial.c
+./grub-core/term/arm/cros.c
+./grub-core/term/arm/cros_ec.c
+./grub-core/term/arm/pl050.c
+./grub-core/term/at_keyboard.c
+./grub-core/term/efi/console.c
+./grub-core/term/efi/serial.c
+./grub-core/term/gfxterm.c
+./grub-core/term/gfxterm_background.c
+./grub-core/term/i386/coreboot/cbmemc.c
+./grub-core/term/i386/pc/console.c
+./grub-core/term/i386/pc/mda_text.c
+./grub-core/term/i386/pc/vga_text.c
+./grub-core/term/ieee1275/console.c
+./grub-core/term/ieee1275/escc.c
+./grub-core/term/ieee1275/serial.c
+./grub-core/term/morse.c
+./grub-core/term/ns8250.c
+./grub-core/term/ps2.c
+./grub-core/term/serial.c
+./grub-core/term/spkmodem.c
+./grub-core/term/terminfo.c
+./grub-core/term/tparm.c
+./grub-core/term/uboot/console.c
+./grub-core/term/usb_keyboard.c
+./grub-core/term/xen/console.c
+./grub-core/tests/bswap_test.c
+./grub-core/tests/checksums.h
+./grub-core/tests/cmdline_cat_test.c
+./grub-core/tests/cmp_test.c
+./grub-core/tests/ctz_test.c
+./grub-core/tests/div_test.c
+./grub-core/tests/example_functional_test.c
+./grub-core/tests/fake_input.c
+./grub-core/tests/gfxterm_menu.c
+./grub-core/tests/legacy_password_test.c
+./grub-core/tests/lib/functional_test.c
+./grub-core/tests/lib/test.c
+./grub-core/tests/mul_test.c
+./grub-core/tests/pbkdf2_test.c
+./grub-core/tests/setjmp_test.c
+./grub-core/tests/shift_test.c
+./grub-core/tests/signature_test.c
+./grub-core/tests/signatures.h
+./grub-core/tests/sleep_test.c
+./grub-core/tests/strtoull_test.c
+./grub-core/tests/test_blockarg.c
+./grub-core/tests/video_checksum.c
+./grub-core/tests/videotest_checksum.c
+./grub-core/tests/xnu_uuid_test.c
+./grub-core/video/bitmap.c
+./grub-core/video/bitmap_scale.c
+./grub-core/video/bochs.c
+./grub-core/video/capture.c
+./grub-core/video/cirrus.c
+./grub-core/video/colors.c
+./grub-core/video/coreboot/cbfb.c
+./grub-core/video/efi_gop.c
+./grub-core/video/efi_uga.c
+./grub-core/video/emu/sdl.c
+./grub-core/video/fb/fbblit.c
+./grub-core/video/fb/fbfill.c
+./grub-core/video/fb/fbutil.c
+./grub-core/video/fb/video_fb.c
+./grub-core/video/i386/pc/vbe.c
+./grub-core/video/i386/pc/vga.c
+./grub-core/video/ieee1275.c
+./grub-core/video/radeon_fuloong2e.c
+./grub-core/video/radeon_yeeloong3a.c
+./grub-core/video/readers/jpeg.c
+./grub-core/video/readers/png.c
+./grub-core/video/readers/tga.c
+./grub-core/video/sis315_init.c
+./grub-core/video/sis315pro.c
+./grub-core/video/sm712.c
+./grub-core/video/sm712_init.c
+./grub-core/video/video.c
+./include/grub/acorn_filecore.h
+./include/grub/acpi.h
+./include/grub/aout.h
+./include/grub/arc/arc.h
+./include/grub/arc/console.h
+./include/grub/archelp.h
+./include/grub/arm/coreboot/console.h
+./include/grub/arm/coreboot/kernel.h
+./include/grub/arm/cros_ec.h
+./include/grub/arm/efi/memory.h
+./include/grub/arm/linux.h
+./include/grub/arm/reloc.h
+./include/grub/arm/setjmp.h
+./include/grub/arm/startup.h
+./include/grub/arm/system.h
+./include/grub/arm/time.h
+./include/grub/arm/types.h
+./include/grub/arm/uboot/kernel.h
+./include/grub/arm64/efi/memory.h
+./include/grub/arm64/linux.h
+./include/grub/arm64/reloc.h
+./include/grub/arm64/setjmp.h
+./include/grub/arm64/time.h
+./include/grub/arm64/types.h
+./include/grub/at_keyboard.h
+./include/grub/ata.h
+./include/grub/auth.h
+./include/grub/autoefi.h
+./include/grub/backtrace.h
+./include/grub/bitmap.h
+./include/grub/bitmap_scale.h
+./include/grub/boottime.h
+./include/grub/bsdlabel.h
+./include/grub/btrfs.h
+./include/grub/buffer.h
+./include/grub/bufio.h
+./include/grub/cache.h
+./include/grub/cbfs_core.h
+./include/grub/charset.h
+./include/grub/cmos.h
+./include/grub/color.h
+./include/grub/command.h
+./include/grub/compiler-rt-emu.h
+./include/grub/compiler-rt.h
+./include/grub/compiler.h
+./include/grub/coreboot/lbio.h
+./include/grub/crypto.h
+./include/grub/cryptodisk.h
+./include/grub/cs5536.h
+./include/grub/datetime.h
+./include/grub/decompressor.h
+./include/grub/deflate.h
+./include/grub/device.h
+./include/grub/disk.h
+./include/grub/diskfilter.h
+./include/grub/dl.h
+./include/grub/dma.h
+./include/grub/efi/api.h
+./include/grub/efi/console.h
+./include/grub/efi/console_control.h
+./include/grub/efi/disk.h
+./include/grub/efi/edid.h
+./include/grub/efi/efi.h
+./include/grub/efi/fdtload.h
+./include/grub/efi/graphics_output.h
+./include/grub/efi/memory.h
+./include/grub/efi/pci.h
+./include/grub/efi/pe32.h
+./include/grub/efi/sb.h
+./include/grub/efi/tpm.h
+./include/grub/efi/uga_draw.h
+./include/grub/efiemu/efiemu.h
+./include/grub/efiemu/runtime.h
+./include/grub/elf.h
+./include/grub/elfload.h
+./include/grub/emu/config.h
+./include/grub/emu/console.h
+./include/grub/emu/exec.h
+./include/grub/emu/getroot.h
+./include/grub/emu/hostdisk.h
+./include/grub/emu/hostfile.h
+./include/grub/emu/misc.h
+./include/grub/emu/net.h
+./include/grub/env.h
+./include/grub/env_private.h
+./include/grub/err.h
+./include/grub/exfat.h
+./include/grub/extcmd.h
+./include/grub/fat.h
+./include/grub/fbblit.h
+./include/grub/fbfill.h
+./include/grub/fbutil.h
+./include/grub/fdt.h
+./include/grub/fdtbus.h
+./include/grub/file.h
+./include/grub/fileid.h
+./include/grub/font.h
+./include/grub/fontformat.h
+./include/grub/fs.h
+./include/grub/fshelp.h
+./include/grub/gcry/types.h
+./include/grub/gcrypt/gpg-error.h
+./include/grub/gdb.h
+./include/grub/gfxmenu_model.h
+./include/grub/gfxmenu_view.h
+./include/grub/gfxterm.h
+./include/grub/gfxwidgets.h
+./include/grub/gpt_partition.h
+./include/grub/gui.h
+./include/grub/gui_string_util.h
+./include/grub/hfs.h
+./include/grub/hfsplus.h
+./include/grub/i18n.h
+./include/grub/i386/at_keyboard.h
+./include/grub/i386/bsd.h
+./include/grub/i386/cmos.h
+./include/grub/i386/coreboot/boot.h
+./include/grub/i386/coreboot/console.h
+./include/grub/i386/coreboot/kernel.h
+./include/grub/i386/coreboot/memory.h
+./include/grub/i386/coreboot/serial.h
+./include/grub/i386/coreboot/time.h
+./include/grub/i386/cpuid.h
+./include/grub/i386/efi/kernel.h
+./include/grub/i386/efi/memory.h
+./include/grub/i386/efi/serial.h
+./include/grub/i386/efiemu.h
+./include/grub/i386/floppy.h
+./include/grub/i386/freebsd_linker.h
+./include/grub/i386/freebsd_reboot.h
+./include/grub/i386/gdb.h
+./include/grub/i386/ieee1275/ieee1275.h
+./include/grub/i386/ieee1275/kernel.h
+./include/grub/i386/ieee1275/memory.h
+./include/grub/i386/ieee1275/serial.h
+./include/grub/i386/io.h
+./include/grub/i386/linux.h
+./include/grub/i386/macho.h
+./include/grub/i386/memory.h
+./include/grub/i386/memory_raw.h
+./include/grub/i386/multiboot.h
+./include/grub/i386/multiboot/boot.h
+./include/grub/i386/multiboot/console.h
+./include/grub/i386/multiboot/kernel.h
+./include/grub/i386/multiboot/memory.h
+./include/grub/i386/multiboot/serial.h
+./include/grub/i386/multiboot/time.h
+./include/grub/i386/netbsd_bootinfo.h
+./include/grub/i386/netbsd_reboot.h
+./include/grub/i386/openbsd_bootarg.h
+./include/grub/i386/openbsd_reboot.h
+./include/grub/i386/pc/apm.h
+./include/grub/i386/pc/biosdisk.h
+./include/grub/i386/pc/biosnum.h
+./include/grub/i386/pc/boot.h
+./include/grub/i386/pc/chainloader.h
+./include/grub/i386/pc/console.h
+./include/grub/i386/pc/int.h
+./include/grub/i386/pc/int_types.h
+./include/grub/i386/pc/kernel.h
+./include/grub/i386/pc/memory.h
+./include/grub/i386/pc/pxe.h
+./include/grub/i386/pc/time.h
+./include/grub/i386/pc/vbe.h
+./include/grub/i386/pc/vesa_modes_table.h
+./include/grub/i386/pci.h
+./include/grub/i386/pit.h
+./include/grub/i386/pmtimer.h
+./include/grub/i386/qemu/boot.h
+./include/grub/i386/qemu/console.h
+./include/grub/i386/qemu/kernel.h
+./include/grub/i386/qemu/memory.h
+./include/grub/i386/qemu/serial.h
+./include/grub/i386/qemu/time.h
+./include/grub/i386/rdmsr.h
+./include/grub/i386/reboot.h
+./include/grub/i386/relocator.h
+./include/grub/i386/relocator_private.h
+./include/grub/i386/setjmp.h
+./include/grub/i386/time.h
+./include/grub/i386/tsc.h
+./include/grub/i386/types.h
+./include/grub/i386/wrmsr.h
+./include/grub/i386/xen/hypercall.h
+./include/grub/i386/xen/kernel.h
+./include/grub/i386/xen/memory.h
+./include/grub/i386/xen_pvh/boot.h
+./include/grub/i386/xen_pvh/console.h
+./include/grub/i386/xen_pvh/int.h
+./include/grub/i386/xen_pvh/kernel.h
+./include/grub/i386/xen_pvh/memory.h
+./include/grub/i386/xen_pvh/time.h
+./include/grub/i386/xnu.h
+./include/grub/ia64/efi/memory.h
+./include/grub/ia64/efi/time.h
+./include/grub/ia64/kernel.h
+./include/grub/ia64/reloc.h
+./include/grub/ia64/setjmp.h
+./include/grub/ia64/time.h
+./include/grub/ia64/types.h
+./include/grub/icon_manager.h
+./include/grub/ieee1275/console.h
+./include/grub/ieee1275/ieee1275.h
+./include/grub/ieee1275/obdisk.h
+./include/grub/ieee1275/ofdisk.h
+./include/grub/kernel.h
+./include/grub/keyboard_layouts.h
+./include/grub/legacy_parse.h
+./include/grub/lib/LzFind.h
+./include/grub/lib/LzHash.h
+./include/grub/lib/LzmaDec.h
+./include/grub/lib/LzmaEnc.h
+./include/grub/lib/LzmaTypes.h
+./include/grub/lib/arg.h
+./include/grub/lib/cmdline.h
+./include/grub/lib/crc.h
+./include/grub/lib/envblk.h
+./include/grub/lib/hexdump.h
+./include/grub/libpciaccess.h
+./include/grub/linux.h
+./include/grub/list.h
+./include/grub/loader.h
+./include/grub/lockdown.h
+./include/grub/lvm.h
+./include/grub/macho.h
+./include/grub/machoload.h
+./include/grub/memory.h
+./include/grub/menu.h
+./include/grub/menu_viewer.h
+./include/grub/mips/arc/kernel.h
+./include/grub/mips/arc/memory.h
+./include/grub/mips/arc/time.h
+./include/grub/mips/asm.h
+./include/grub/mips/at_keyboard.h
+./include/grub/mips/cmos.h
+./include/grub/mips/io.h
+./include/grub/mips/kernel.h
+./include/grub/mips/loongson.h
+./include/grub/mips/loongson/at_keyboard.h
+./include/grub/mips/loongson/cmos.h
+./include/grub/mips/loongson/ec.h
+./include/grub/mips/loongson/kernel.h
+./include/grub/mips/loongson/memory.h
+./include/grub/mips/loongson/pci.h
+./include/grub/mips/loongson/serial.h
+./include/grub/mips/loongson/time.h
+./include/grub/mips/memory.h
+./include/grub/mips/mips.h
+./include/grub/mips/multiboot.h
+./include/grub/mips/pci.h
+./include/grub/mips/qemu_mips/at_keyboard.h
+./include/grub/mips/qemu_mips/cmos.h
+./include/grub/mips/qemu_mips/console.h
+./include/grub/mips/qemu_mips/kernel.h
+./include/grub/mips/qemu_mips/loader.h
+./include/grub/mips/qemu_mips/memory.h
+./include/grub/mips/qemu_mips/serial.h
+./include/grub/mips/qemu_mips/time.h
+./include/grub/mips/relocator.h
+./include/grub/mips/setjmp.h
+./include/grub/mips/time.h
+./include/grub/mips/types.h
+./include/grub/misc.h
+./include/grub/mm.h
+./include/grub/mm_private.h
+./include/grub/module_verifier.h
+./include/grub/msdos_partition.h
+./include/grub/multiboot.h
+./include/grub/multiboot2.h
+./include/grub/multiboot_loader.h
+./include/grub/net.h
+./include/grub/net/arp.h
+./include/grub/net/ethernet.h
+./include/grub/net/ip.h
+./include/grub/net/netbuff.h
+./include/grub/net/tcp.h
+./include/grub/net/udp.h
+./include/grub/normal.h
+./include/grub/ns8250.h
+./include/grub/ntfs.h
+./include/grub/offsets.h
+./include/grub/osdep/hostfile.h
+./include/grub/osdep/hostfile_aros.h
+./include/grub/osdep/hostfile_unix.h
+./include/grub/osdep/hostfile_windows.h
+./include/grub/parser.h
+./include/grub/partition.h
+./include/grub/parttool.h
+./include/grub/pci.h
+./include/grub/pciutils.h
+./include/grub/powerpc/ieee1275/ieee1275.h
+./include/grub/powerpc/kernel.h
+./include/grub/powerpc/memory.h
+./include/grub/powerpc/relocator.h
+./include/grub/powerpc/setjmp.h
+./include/grub/powerpc/time.h
+./include/grub/powerpc/types.h
+./include/grub/priority_queue.h
+./include/grub/procfs.h
+./include/grub/ps2.h
+./include/grub/pubkey.h
+./include/grub/random.h
+./include/grub/reader.h
+./include/grub/reed_solomon.h
+./include/grub/relocator.h
+./include/grub/relocator_private.h
+./include/grub/riscv32/efi/memory.h
+./include/grub/riscv32/linux.h
+./include/grub/riscv32/setjmp.h
+./include/grub/riscv32/time.h
+./include/grub/riscv32/types.h
+./include/grub/riscv64/efi/memory.h
+./include/grub/riscv64/linux.h
+./include/grub/riscv64/setjmp.h
+./include/grub/riscv64/time.h
+./include/grub/riscv64/types.h
+./include/grub/safemath.h
+./include/grub/script_sh.h
+./include/grub/scsi.h
+./include/grub/scsicmd.h
+./include/grub/sdl.h
+./include/grub/search.h
+./include/grub/serial.h
+./include/grub/setjmp.h
+./include/grub/smbios.h
+./include/grub/smbus.h
+./include/grub/sparc64/ieee1275/boot.h
+./include/grub/sparc64/ieee1275/ieee1275.h
+./include/grub/sparc64/ieee1275/kernel.h
+./include/grub/sparc64/setjmp.h
+./include/grub/sparc64/time.h
+./include/grub/sparc64/types.h
+./include/grub/speaker.h
+./include/grub/stack_protector.h
+./include/grub/symbol.h
+./include/grub/syslinux_parse.h
+./include/grub/term.h
+./include/grub/terminfo.h
+./include/grub/test.h
+./include/grub/time.h
+./include/grub/tparm.h
+./include/grub/tpm.h
+./include/grub/trig.h
+./include/grub/types.h
+./include/grub/uboot/api_public.h
+./include/grub/uboot/console.h
+./include/grub/uboot/disk.h
+./include/grub/uboot/image.h
+./include/grub/uboot/uboot.h
+./include/grub/udf.h
+./include/grub/unicode.h
+./include/grub/usb.h
+./include/grub/usbdesc.h
+./include/grub/usbserial.h
+./include/grub/usbtrans.h
+./include/grub/util/install.h
+./include/grub/util/libnvpair.h
+./include/grub/util/libzfs.h
+./include/grub/util/misc.h
+./include/grub/util/mkimage.h
+./include/grub/util/ofpath.h
+./include/grub/util/resolve.h
+./include/grub/util/windows.h
+./include/grub/verify.h
+./include/grub/vga.h
+./include/grub/vgaregs.h
+./include/grub/video.h
+./include/grub/video_fb.h
+./include/grub/x86_64/at_keyboard.h
+./include/grub/x86_64/efi/boot.h
+./include/grub/x86_64/efi/kernel.h
+./include/grub/x86_64/efi/loader.h
+./include/grub/x86_64/efi/memory.h
+./include/grub/x86_64/efi/serial.h
+./include/grub/x86_64/io.h
+./include/grub/x86_64/linux.h
+./include/grub/x86_64/macho.h
+./include/grub/x86_64/memory.h
+./include/grub/x86_64/multiboot.h
+./include/grub/x86_64/pci.h
+./include/grub/x86_64/relocator.h
+./include/grub/x86_64/setjmp.h
+./include/grub/x86_64/time.h
+./include/grub/x86_64/types.h
+./include/grub/x86_64/xen/hypercall.h
+./include/grub/x86_64/xnu.h
+./include/grub/xen.h
+./include/grub/xen/relocator.h
+./include/grub/xen_file.h
+./include/grub/xnu.h
+./include/grub/zfs/dmu.h
+./include/grub/zfs/dmu_objset.h
+./include/grub/zfs/dnode.h
+./include/grub/zfs/dsl_dataset.h
+./include/grub/zfs/dsl_dir.h
+./include/grub/zfs/sa_impl.h
+./include/grub/zfs/spa.h
+./include/grub/zfs/uberblock_impl.h
+./include/grub/zfs/vdev_impl.h
+./include/grub/zfs/zap_impl.h
+./include/grub/zfs/zap_leaf.h
+./include/grub/zfs/zfs.h
+./include/grub/zfs/zfs_acl.h
+./include/grub/zfs/zfs_znode.h
+./include/grub/zfs/zil.h
+./include/grub/zfs/zio.h
+./include/grub/zfs/zio_checksum.h
+./include/multiboot.h
+./include/multiboot2.h
+./include/xen/arch-x86/xen-x86_32.h
+./include/xen/arch-x86/xen-x86_64.h
+./include/xen/arch-x86/xen.h
+./include/xen/elfnote.h
+./include/xen/event_channel.h
+./include/xen/grant_table.h
+./include/xen/hvm/hvm_op.h
+./include/xen/hvm/params.h
+./include/xen/hvm/start_info.h
+./include/xen/io/blkif.h
+./include/xen/io/console.h
+./include/xen/io/protocols.h
+./include/xen/io/ring.h
+./include/xen/io/xenbus.h
+./include/xen/io/xs_wire.h
+./include/xen/memory.h
+./include/xen/physdev.h
+./include/xen/sched.h
+./include/xen/trace.h
+./include/xen/xen-compat.h
+./include/xen/xen.h
+./tests/cmp_unit_test.c
+./tests/date_unit_test.c
+./tests/example_unit_test.c
+./tests/lib/unit_test.c
+./tests/printf_unit_test.c
+./util/bin2h.c
+./util/config.c
+./util/editenv.c
+./util/garbage-gen.c
+./util/getroot.c
+./util/glue-efi.c
+./util/grub-editenv.c
+./util/grub-file.c
+./util/grub-fstest.c
+./util/grub-glue-efi.c
+./util/grub-install-common.c
+./util/grub-install.c
+./util/grub-macbless.c
+./util/grub-macho2img.c
+./util/grub-menulst2cfg.c
+./util/grub-mkfont.c
+./util/grub-mkimage.c
+./util/grub-mkimage32.c
+./util/grub-mkimage64.c
+./util/grub-mkimagexx.c
+./util/grub-mklayout.c
+./util/grub-mknetdir.c
+./util/grub-mkpasswd-pbkdf2.c
+./util/grub-mkrelpath.c
+./util/grub-mkrescue.c
+./util/grub-mkstandalone.c
+./util/grub-module-verifier.c
+./util/grub-module-verifier32.c
+./util/grub-module-verifier64.c
+./util/grub-module-verifierXX.c
+./util/grub-mount.c
+./util/grub-pe2elf.c
+./util/grub-probe.c
+./util/grub-render-label.c
+./util/grub-script-check.c
+./util/grub-setup.c
+./util/grub-syslinux2cfg.c
+./util/ieee1275/grub-ofpathname.c
+./util/misc.c
+./util/mkimage.c
+./util/probe.c
+./util/render-label.c
+./util/resolve.c
+./util/setup.c
+./util/setup_bios.c
+./util/setup_sparc.c
+./util/spkmodem-recv.c
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/create.patch.sh
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/create.patch.sh (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/create.patch.sh (revision 216)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=2.06
+
+tar --files-from=file.list -xJvf ../grub-$VERSION.tar.xz
+mv grub-$VERSION grub-$VERSION-orig
+
+cp -rf ./grub-$VERSION-new ./grub-$VERSION
+
+diff --unified -Nr grub-$VERSION-orig grub-$VERSION > grub-$VERSION-riscv-relocation.patch
+
+mv grub-$VERSION-riscv-relocation.patch ../patches
+
+rm -rf ./grub-$VERSION
+rm -rf ./grub-$VERSION-orig
Property changes on: radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/file.list
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/file.list (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/file.list (revision 216)
@@ -0,0 +1,2 @@
+grub-2.06/grub-core/kern/riscv/dl.c
+grub-2.06/util/grub-mkimagexx.c
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/grub-2.06-new/grub-core/kern/riscv/dl.c
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/grub-2.06-new/grub-core/kern/riscv/dl.c (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/grub-2.06-new/grub-core/kern/riscv/dl.c (revision 216)
@@ -0,0 +1,346 @@
+/* dl.c - arch-dependent part of loadable module support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2018 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/dl.h>
+#include <grub/elf.h>
+#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/mm.h>
+#include <grub/i18n.h>
+
+/*
+ * Instructions and instruction encoding are documented in the RISC-V
+ * specification. This file is based on version 2.2:
+ *
+ * https://github.com/riscv/riscv-isa-manual/blob/master/release/riscv-spec-v2.2.pdf
+ */
+#define LDR 0x58000050
+#define BR 0xd61f0200
+
+/*
+ * Check if EHDR is a valid ELF header.
+ */
+grub_err_t
+grub_arch_dl_check_header (void *ehdr)
+{
+ Elf_Ehdr *e = ehdr;
+
+ /* Check the magic numbers. */
+ if (e->e_ident[EI_DATA] != ELFDATA2LSB || e->e_machine != EM_RISCV)
+ return grub_error (GRUB_ERR_BAD_OS,
+ N_("invalid arch-dependent ELF magic"));
+
+ return GRUB_ERR_NONE;
+}
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+/* Relocate symbols. */
+grub_err_t
+grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
+ Elf_Shdr *s, grub_dl_segment_t seg)
+{
+ Elf_Rel *rel, *max;
+
+ for (rel = (Elf_Rel *) ((char *) ehdr + s->sh_offset),
+ max = (Elf_Rel *) ((char *) rel + s->sh_size);
+ rel < max;
+ rel = (Elf_Rel *) ((char *) rel + s->sh_entsize))
+ {
+ Elf_Sym *sym;
+ void *place;
+ grub_size_t sym_addr;
+
+ if (rel->r_offset >= seg->size)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "reloc offset is out of the segment");
+
+ sym = (Elf_Sym *) ((char *) mod->symtab
+ + mod->symsize * ELF_R_SYM (rel->r_info));
+
+ sym_addr = sym->st_value;
+ if (s->sh_type == SHT_RELA)
+ sym_addr += ((Elf_Rela *) rel)->r_addend;
+
+ place = (void *) ((grub_addr_t) seg->addr + rel->r_offset);
+
+ switch (ELF_R_TYPE (rel->r_info))
+ {
+ case R_RISCV_32:
+ {
+ grub_uint32_t *abs_place = place;
+
+ grub_dprintf ("dl", " reloc_abs32 %p => 0x%016llx\n",
+ place, (unsigned long long) sym_addr);
+
+ *abs_place = (grub_uint32_t) sym_addr;
+ }
+ break;
+ case R_RISCV_64:
+ {
+ grub_size_t *abs_place = place;
+
+ grub_dprintf ("dl", " reloc_abs64 %p => 0x%016llx\n",
+ place, (unsigned long long) sym_addr);
+
+ *abs_place = (grub_size_t) sym_addr;
+ }
+ break;
+
+ case R_RISCV_ADD8:
+ {
+ grub_uint8_t *abs_place = place;
+
+ *abs_place += (grub_uint8_t) sym_addr;
+ }
+ break;
+ case R_RISCV_ADD16:
+ {
+ grub_uint16_t *abs_place = place;
+
+ *abs_place += (grub_uint16_t) sym_addr;
+ }
+ break;
+ case R_RISCV_ADD32:
+ {
+ grub_uint32_t *abs_place = place;
+
+ *abs_place += (grub_uint32_t) sym_addr;
+ }
+ break;
+ case R_RISCV_ADD64:
+ {
+ grub_size_t *abs_place = place;
+
+ *abs_place += (grub_size_t) sym_addr;
+ }
+ break;
+
+ case R_RISCV_SUB8:
+ {
+ grub_uint8_t *abs_place = place;
+
+ *abs_place -= (grub_uint8_t) sym_addr;
+ }
+ break;
+ case R_RISCV_SUB16:
+ {
+ grub_uint16_t *abs_place = place;
+
+ *abs_place -= (grub_uint16_t) sym_addr;
+ }
+ break;
+ case R_RISCV_SUB32:
+ {
+ grub_uint32_t *abs_place = place;
+
+ *abs_place -= (grub_uint32_t) sym_addr;
+ }
+ break;
+ case R_RISCV_SUB64:
+ {
+ grub_size_t *abs_place = place;
+
+ *abs_place -= (grub_size_t) sym_addr;
+ }
+ break;
+
+ case R_RISCV_BRANCH:
+ {
+ grub_uint32_t *abs_place = place;
+ grub_ssize_t off = sym_addr - (grub_addr_t) place;
+ grub_uint32_t imm12 = (off & 0x1000) << (31 - 12);
+ grub_uint32_t imm11 = (off & 0x800) >> (11 - 7);
+ grub_uint32_t imm10_5 = (off & 0x7e0) << (30 - 10);
+ grub_uint32_t imm4_1 = (off & 0x1e) << (11 - 4);
+ *abs_place = (*abs_place & 0x1fff07f)
+ | imm12 | imm11 | imm10_5 | imm4_1;
+ }
+ break;
+
+ case R_RISCV_JAL:
+ {
+ grub_uint32_t *abs_place = place;
+ grub_ssize_t off = sym_addr - (grub_addr_t) place;
+ grub_uint32_t imm20 = (off & 0x100000) << (31 - 20);
+ grub_uint32_t imm19_12 = (off & 0xff000);
+ grub_uint32_t imm11 = (off & 0x800) << (20 - 11);
+ grub_uint32_t imm10_1 = (off & 0x7fe) << (30 - 10);
+ *abs_place = (*abs_place & 0xfff)
+ | imm20 | imm19_12 | imm11 | imm10_1;
+ }
+ break;
+
+ case R_RISCV_CALL:
+ case R_RISCV_CALL_PLT:
+ {
+ grub_uint32_t *abs_place = place;
+ grub_ssize_t off = sym_addr - (grub_addr_t) place;
+ grub_uint32_t hi20, lo12;
+
+ if (off != (grub_int32_t) off)
+ return grub_error (GRUB_ERR_BAD_MODULE, "relocation overflow");
+
+ hi20 = (off + 0x800) & 0xfffff000;
+ lo12 = (off - hi20) & 0xfff;
+ abs_place[0] = (abs_place[0] & 0xfff) | hi20;
+ abs_place[1] = (abs_place[1] & 0xfffff) | (lo12 << 20);
+ }
+ break;
+
+ case R_RISCV_RVC_BRANCH:
+ {
+ grub_uint16_t *abs_place = place;
+ grub_ssize_t off = sym_addr - (grub_addr_t) place;
+ grub_uint16_t imm8 = (off & 0x100) << (12 - 8);
+ grub_uint16_t imm7_6 = (off & 0xc0) >> (6 - 5);
+ grub_uint16_t imm5 = (off & 0x20) >> (5 - 2);
+ grub_uint16_t imm4_3 = (off & 0x18) << (12 - 5);
+ grub_uint16_t imm2_1 = (off & 0x6) << (12 - 10);
+ *abs_place = (*abs_place & 0xe383)
+ | imm8 | imm7_6 | imm5 | imm4_3 | imm2_1;
+ }
+ break;
+
+ case R_RISCV_RVC_JUMP:
+ {
+ grub_uint16_t *abs_place = place;
+ grub_ssize_t off = sym_addr - (grub_addr_t) place;
+ grub_uint16_t imm11 = (off & 0x800) << (12 - 11);
+ grub_uint16_t imm10 = (off & 0x400) >> (10 - 8);
+ grub_uint16_t imm9_8 = (off & 0x300) << (12 - 11);
+ grub_uint16_t imm7 = (off & 0x80) >> (7 - 6);
+ grub_uint16_t imm6 = (off & 0x40) << (12 - 11);
+ grub_uint16_t imm5 = (off & 0x20) >> (5 - 2);
+ grub_uint16_t imm4 = (off & 0x10) << (12 - 5);
+ grub_uint16_t imm3_1 = (off & 0xe) << (12 - 10);
+ *abs_place = ((*abs_place & 0xe003)
+ | imm11 | imm10 | imm9_8 | imm7 | imm6
+ | imm5 | imm4 | imm3_1);
+ }
+ break;
+
+ case R_RISCV_PCREL_HI20:
+ {
+ grub_uint32_t *abs_place = place;
+ grub_ssize_t off = sym_addr - (grub_addr_t) place;
+ grub_int32_t hi20;
+
+ if (off != (grub_int32_t)off)
+ return grub_error (GRUB_ERR_BAD_MODULE, "relocation overflow");
+
+ hi20 = (off + 0x800) & 0xfffff000;
+ *abs_place = (*abs_place & 0xfff) | hi20;
+ }
+ break;
+
+ case R_RISCV_PCREL_LO12_I:
+ case R_RISCV_PCREL_LO12_S:
+ {
+ grub_uint32_t *t32 = place;
+ Elf_Rela *rel2;
+ /* Search backwards for matching HI20 reloc. */
+ for (rel2 = (Elf_Rela *) ((char *) rel - s->sh_entsize);
+ (unsigned long)rel2 >= ((unsigned long)ehdr + s->sh_offset);
+ rel2 = (Elf_Rela *) ((char *) rel2 - s->sh_entsize))
+ {
+ Elf_Addr rel2_info;
+ Elf_Addr rel2_offset;
+ Elf_Addr rel2_sym_addr;
+ Elf_Addr rel2_loc;
+ grub_ssize_t rel2_off;
+ grub_ssize_t off;
+ Elf_Sym *sym2;
+
+ rel2_offset = rel2->r_offset;
+ rel2_info = rel2->r_info;
+ rel2_loc = (grub_addr_t) seg->addr + rel2_offset;
+
+ if (ELF_R_TYPE (rel2_info) == R_RISCV_PCREL_HI20
+ && rel2_loc == sym_addr)
+ {
+ sym2 = (Elf_Sym *) ((char *) mod->symtab
+ + mod->symsize * ELF_R_SYM (rel2->r_info));
+ rel2_sym_addr = sym2->st_value;
+ if (s->sh_type == SHT_RELA)
+ rel2_sym_addr += ((Elf_Rela *) rel2)->r_addend;
+
+ rel2_off = rel2_sym_addr - rel2_loc;
+ off = rel2_off - ((rel2_off + 0x800) & 0xfffff000);
+
+ if (ELF_R_TYPE (rel->r_info) == R_RISCV_PCREL_LO12_I)
+ *t32 = (*t32 & 0xfffff) | (off & 0xfff) << 20;
+ else
+ {
+ grub_uint32_t imm11_5 = (off & 0xfe0) << (31 - 11);
+ grub_uint32_t imm4_0 = (off & 0x1f) << (11 - 4);
+ *t32 = (*t32 & 0x1fff07f) | imm11_5 | imm4_0;
+ }
+ break;
+ }
+ }
+ if ((unsigned long)rel2 < ((unsigned long)ehdr + s->sh_offset))
+ return grub_error (GRUB_ERR_BAD_MODULE, "cannot find matching HI20 relocation");
+ }
+ break;
+
+ case R_RISCV_HI20:
+ {
+ grub_uint32_t *abs_place = place;
+ *abs_place = (*abs_place & 0xfff) |
+ (((grub_int32_t) sym_addr + 0x800) & 0xfffff000);
+ }
+ break;
+
+ case R_RISCV_LO12_I:
+ {
+ grub_uint32_t *abs_place = place;
+ grub_int32_t lo12 = (grub_int32_t) sym_addr -
+ (((grub_int32_t) sym_addr + 0x800) & 0xfffff000);
+ *abs_place = (*abs_place & 0xfffff) | ((lo12 & 0xfff) << 20);
+ }
+ break;
+
+ case R_RISCV_LO12_S:
+ {
+ grub_uint32_t *abs_place = place;
+ grub_int32_t lo12 = (grub_int32_t) sym_addr -
+ (((grub_int32_t) sym_addr + 0x800) & 0xfffff000);
+ grub_uint32_t imm11_5 = (lo12 & 0xfe0) << (31 - 11);
+ grub_uint32_t imm4_0 = (lo12 & 0x1f) << (11 - 4);
+ *abs_place = (*abs_place & 0x1fff07f) | imm11_5 | imm4_0;
+ }
+ break;
+
+ case R_RISCV_RELAX:
+ break;
+ default:
+ {
+ char rel_info[17]; /* log16(2^64) = 16, plus NUL. */
+
+ grub_snprintf (rel_info, sizeof (rel_info) - 1, "%" PRIxGRUB_UINT64_T,
+ (grub_uint64_t) ELF_R_TYPE (rel->r_info));
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("relocation 0x%s is not implemented yet"), rel_info);
+ }
+ }
+ }
+
+ return GRUB_ERR_NONE;
+}
Index: radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/grub-2.06-new/util/grub-mkimagexx.c
===================================================================
--- radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/grub-2.06-new/util/grub-mkimagexx.c (nonexistent)
+++ radix-1.9/sources/GNU/grub/create-2.06-riscv-relocation-patch/grub-2.06-new/util/grub-mkimagexx.c (revision 216)
@@ -0,0 +1,2454 @@
+/* grub-mkimage.c - make a bootable image */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <grub/types.h>
+#include <grub/elf.h>
+#include <grub/aout.h>
+#include <grub/i18n.h>
+#include <grub/kernel.h>
+#include <grub/disk.h>
+#include <grub/emu/misc.h>
+#include <grub/util/misc.h>
+#include <grub/util/resolve.h>
+#include <grub/misc.h>
+#include <grub/offsets.h>
+#include <grub/crypto.h>
+#include <grub/dl.h>
+#include <time.h>
+#include <multiboot.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <grub/efi/pe32.h>
+#include <grub/uboot/image.h>
+#include <grub/arm/reloc.h>
+#include <grub/arm64/reloc.h>
+#include <grub/ia64/reloc.h>
+#include <grub/osdep/hostfile.h>
+#include <grub/util/install.h>
+#include <grub/util/mkimage.h>
+
+#include <xen/elfnote.h>
+
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+#define GRUB_MKIMAGEXX
+#if !defined(MKIMAGE_ELF32) && !defined(MKIMAGE_ELF64)
+#if __SIZEOF_POINTER__ == 8
+#include "grub-mkimage64.c"
+#else
+#include "grub-mkimage32.c"
+#endif
+#endif
+
+/* These structures are defined according to the CHRP binding to IEEE1275,
+ "Client Program Format" section. */
+
+struct grub_ieee1275_note_desc
+{
+ grub_uint32_t real_mode;
+ grub_uint32_t real_base;
+ grub_uint32_t real_size;
+ grub_uint32_t virt_base;
+ grub_uint32_t virt_size;
+ grub_uint32_t load_base;
+};
+
+#define GRUB_IEEE1275_NOTE_NAME "PowerPC"
+#define GRUB_IEEE1275_NOTE_TYPE 0x1275
+
+struct grub_ieee1275_note
+{
+ Elf32_Nhdr header;
+ char name[ALIGN_UP(sizeof (GRUB_IEEE1275_NOTE_NAME), 4)];
+ struct grub_ieee1275_note_desc descriptor;
+};
+
+#define GRUB_XEN_NOTE_NAME "Xen"
+
+struct fixup_block_list
+{
+ struct fixup_block_list *next;
+ int state;
+ struct grub_pe32_fixup_block b;
+};
+
+#define ALIGN_ADDR(x) (ALIGN_UP((x), image_target->voidp_sizeof))
+
+struct section_metadata
+{
+ Elf_Half num_sections;
+ Elf_Shdr *sections;
+ Elf_Addr *addrs;
+ Elf_Addr *vaddrs;
+ Elf_Half section_entsize;
+ Elf_Shdr *symtab;
+ const char *strtab;
+};
+
+static int
+is_relocatable (const struct grub_install_image_target_desc *image_target)
+{
+ return image_target->id == IMAGE_EFI || image_target->id == IMAGE_UBOOT
+ || (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_ARM);
+}
+
+#ifdef MKIMAGE_ELF32
+
+/*
+ * R_ARM_THM_CALL/THM_JUMP24
+ *
+ * Relocate Thumb (T32) instruction set relative branches:
+ * B.W, BL and BLX
+ */
+static grub_err_t
+grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
+{
+ grub_int32_t offset;
+
+ offset = grub_arm_thm_call_get_offset (target);
+
+ grub_dprintf ("dl", " sym_addr = 0x%08x", sym_addr);
+
+ offset += sym_addr;
+
+ grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n",
+ target, sym_addr, offset);
+
+ /* Keep traditional (pre-Thumb2) limits on blx. In any case if the kernel
+ is bigger than 2M (currently under 150K) then we probably have a problem
+ somewhere else. */
+ if (offset < -0x200000 || offset >= 0x200000)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "THM_CALL Relocation out of range.");
+
+ grub_dprintf ("dl", " relative destination = %p",
+ (char *) target + offset);
+
+ return grub_arm_thm_call_set_offset (target, offset);
+}
+
+/*
+ * R_ARM_THM_JUMP19
+ *
+ * Relocate conditional Thumb (T32) B<c>.W
+ */
+static grub_err_t
+grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
+{
+ grub_int32_t offset;
+
+ if (!(sym_addr & 1))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "Relocation targeting wrong execution state");
+
+ offset = grub_arm_thm_jump19_get_offset (target);
+
+ /* Adjust and re-truncate offset */
+ offset += sym_addr;
+
+ if (!grub_arm_thm_jump19_check_offset (offset))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "THM_JUMP19 Relocation out of range.");
+
+ grub_arm_thm_jump19_set_offset (target, offset);
+
+ return GRUB_ERR_NONE;
+}
+
+/*
+ * R_ARM_JUMP24
+ *
+ * Relocate ARM (A32) B
+ */
+static grub_err_t
+grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr)
+{
+ grub_int32_t offset;
+
+ if (sym_addr & 1)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "Relocation targeting wrong execution state");
+
+ offset = grub_arm_jump24_get_offset (target);
+ offset += sym_addr;
+
+ if (!grub_arm_jump24_check_offset (offset))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "JUMP24 Relocation out of range.");
+
+
+ grub_arm_jump24_set_offset (target, offset);
+
+ return GRUB_ERR_NONE;
+}
+
+#endif
+
+void
+SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc *image_target,
+ int note, char **core_img, size_t *core_size,
+ Elf_Addr target_addr,
+ struct grub_mkimage_layout *layout)
+{
+ char *elf_img;
+ size_t program_size;
+ Elf_Ehdr *ehdr;
+ Elf_Phdr *phdr;
+ Elf_Shdr *shdr;
+ int header_size, footer_size = 0;
+ int phnum = 1;
+ int shnum = 4;
+ int string_size = sizeof (".text") + sizeof ("mods") + 1;
+
+ if (image_target->id != IMAGE_LOONGSON_ELF)
+ phnum += 2;
+
+ if (note)
+ {
+ phnum++;
+ footer_size += sizeof (struct grub_ieee1275_note);
+ }
+ if (image_target->id == IMAGE_XEN || image_target->id == IMAGE_XEN_PVH)
+ {
+ phnum++;
+ shnum++;
+ string_size += sizeof (".xen");
+ footer_size += (image_target->id == IMAGE_XEN) ? XEN_NOTE_SIZE : XEN_PVH_NOTE_SIZE;
+ }
+ header_size = ALIGN_UP (sizeof (*ehdr) + phnum * sizeof (*phdr)
+ + shnum * sizeof (*shdr) + string_size, layout->align);
+
+ program_size = ALIGN_ADDR (*core_size);
+
+ elf_img = xmalloc (program_size + header_size + footer_size);
+ memset (elf_img, 0, program_size + header_size + footer_size);
+ memcpy (elf_img + header_size, *core_img, *core_size);
+ ehdr = (void *) elf_img;
+ phdr = (void *) (elf_img + sizeof (*ehdr));
+ shdr = (void *) (elf_img + sizeof (*ehdr) + phnum * sizeof (*phdr));
+ memcpy (ehdr->e_ident, ELFMAG, SELFMAG);
+ ehdr->e_ident[EI_CLASS] = ELFCLASSXX;
+ if (!image_target->bigendian)
+ ehdr->e_ident[EI_DATA] = ELFDATA2LSB;
+ else
+ ehdr->e_ident[EI_DATA] = ELFDATA2MSB;
+ ehdr->e_ident[EI_VERSION] = EV_CURRENT;
+ ehdr->e_ident[EI_OSABI] = ELFOSABI_NONE;
+ ehdr->e_type = grub_host_to_target16 (ET_EXEC);
+ ehdr->e_machine = grub_host_to_target16 (image_target->elf_target);
+ ehdr->e_version = grub_host_to_target32 (EV_CURRENT);
+
+ ehdr->e_phoff = grub_host_to_target32 ((char *) phdr - (char *) ehdr);
+ ehdr->e_phentsize = grub_host_to_target16 (sizeof (*phdr));
+ ehdr->e_phnum = grub_host_to_target16 (phnum);
+
+ ehdr->e_shoff = grub_host_to_target32 ((grub_uint8_t *) shdr
+ - (grub_uint8_t *) ehdr);
+ if (image_target->id == IMAGE_LOONGSON_ELF)
+ ehdr->e_shentsize = grub_host_to_target16 (0);
+ else
+ ehdr->e_shentsize = grub_host_to_target16 (sizeof (Elf_Shdr));
+ ehdr->e_shnum = grub_host_to_target16 (shnum);
+ ehdr->e_shstrndx = grub_host_to_target16 (1);
+
+ ehdr->e_ehsize = grub_host_to_target16 (sizeof (*ehdr));
+
+ phdr->p_type = grub_host_to_target32 (PT_LOAD);
+ phdr->p_offset = grub_host_to_target32 (header_size);
+ phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
+
+ ehdr->e_entry = grub_host_to_target32 (target_addr);
+ phdr->p_vaddr = grub_host_to_target32 (target_addr);
+ phdr->p_paddr = grub_host_to_target32 (target_addr);
+ phdr->p_align = grub_host_to_target32 (layout->align > image_target->link_align ?
+ layout->align : image_target->link_align);
+ if (image_target->id == IMAGE_LOONGSON_ELF)
+ ehdr->e_flags = grub_host_to_target32 (0x1000 | EF_MIPS_NOREORDER
+ | EF_MIPS_PIC | EF_MIPS_CPIC);
+ else
+ ehdr->e_flags = 0;
+ if (image_target->id == IMAGE_LOONGSON_ELF)
+ {
+ phdr->p_filesz = grub_host_to_target32 (*core_size);
+ phdr->p_memsz = grub_host_to_target32 (*core_size);
+ }
+ else
+ {
+ grub_uint32_t target_addr_mods;
+ phdr->p_filesz = grub_host_to_target32 (layout->kernel_size);
+ if (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_ARM)
+ phdr->p_memsz = grub_host_to_target32 (layout->kernel_size);
+ else
+ phdr->p_memsz = grub_host_to_target32 (layout->kernel_size + layout->bss_size);
+
+ phdr++;
+ phdr->p_type = grub_host_to_target32 (PT_GNU_STACK);
+ phdr->p_offset = grub_host_to_target32 (header_size + layout->kernel_size);
+ phdr->p_paddr = phdr->p_vaddr = phdr->p_filesz = phdr->p_memsz = 0;
+ phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
+ phdr->p_align = grub_host_to_target32 (image_target->link_align);
+
+ phdr++;
+ phdr->p_type = grub_host_to_target32 (PT_LOAD);
+ phdr->p_offset = grub_host_to_target32 (header_size + layout->kernel_size);
+ phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
+ phdr->p_filesz = phdr->p_memsz
+ = grub_host_to_target32 (*core_size - layout->kernel_size);
+
+ if (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_386)
+ target_addr_mods = GRUB_KERNEL_I386_COREBOOT_MODULES_ADDR;
+ else if (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_ARM)
+ target_addr_mods = ALIGN_UP (target_addr + layout->end
+ + image_target->mod_gap,
+ image_target->mod_align);
+ else
+ target_addr_mods = ALIGN_UP (target_addr + layout->kernel_size + layout->bss_size
+ + image_target->mod_gap,
+ image_target->mod_align);
+ phdr->p_vaddr = grub_host_to_target_addr (target_addr_mods);
+ phdr->p_paddr = grub_host_to_target_addr (target_addr_mods);
+ phdr->p_align = grub_host_to_target32 (image_target->link_align);
+ }
+
+ if (image_target->id == IMAGE_XEN)
+ {
+ char *note_start = (elf_img + program_size + header_size);
+ Elf_Nhdr *note_ptr;
+ char *ptr = (char *) note_start;
+
+ grub_util_info ("adding XEN NOTE segment");
+
+ /* Guest OS. */
+ note_ptr = (Elf_Nhdr *) ptr;
+ note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME));
+ note_ptr->n_descsz = grub_host_to_target32 (sizeof (PACKAGE_NAME));
+ note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_GUEST_OS);
+ ptr += sizeof (Elf_Nhdr);
+ memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME));
+ ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4);
+ memcpy (ptr, PACKAGE_NAME, sizeof (PACKAGE_NAME));
+ ptr += ALIGN_UP (sizeof (PACKAGE_NAME), 4);
+
+ /* Loader. */
+ note_ptr = (Elf_Nhdr *) ptr;
+ note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME));
+ note_ptr->n_descsz = grub_host_to_target32 (sizeof ("generic"));
+ note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_LOADER);
+ ptr += sizeof (Elf_Nhdr);
+ memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME));
+ ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4);
+ memcpy (ptr, "generic", sizeof ("generic"));
+ ptr += ALIGN_UP (sizeof ("generic"), 4);
+
+ /* Version. */
+ note_ptr = (Elf_Nhdr *) ptr;
+ note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME));
+ note_ptr->n_descsz = grub_host_to_target32 (sizeof ("xen-3.0"));
+ note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_XEN_VERSION);
+ ptr += sizeof (Elf_Nhdr);
+ memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME));
+ ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4);
+ memcpy (ptr, "xen-3.0", sizeof ("xen-3.0"));
+ ptr += ALIGN_UP (sizeof ("xen-3.0"), 4);
+
+ /* Entry. */
+ note_ptr = (Elf_Nhdr *) ptr;
+ note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME));
+ note_ptr->n_descsz = grub_host_to_target32 (image_target->voidp_sizeof);
+ note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_ENTRY);
+ ptr += sizeof (Elf_Nhdr);
+ memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME));
+ ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4);
+ memset (ptr, 0, image_target->voidp_sizeof);
+ ptr += image_target->voidp_sizeof;
+
+ /* Virt base. */
+ note_ptr = (Elf_Nhdr *) ptr;
+ note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME));
+ note_ptr->n_descsz = grub_host_to_target32 (image_target->voidp_sizeof);
+ note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_VIRT_BASE);
+ ptr += sizeof (Elf_Nhdr);
+ memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME));
+ ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4);
+ memset (ptr, 0, image_target->voidp_sizeof);
+ ptr += image_target->voidp_sizeof;
+
+ /* PAE. */
+ if (image_target->elf_target == EM_386)
+ {
+ note_ptr = (Elf_Nhdr *) ptr;
+ note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME));
+ note_ptr->n_descsz = grub_host_to_target32 (sizeof ("yes,bimodal"));
+ note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_PAE_MODE);
+ ptr += sizeof (Elf_Nhdr);
+ memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME));
+ ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4);
+ memcpy (ptr, "yes", sizeof ("yes"));
+ ptr += ALIGN_UP (sizeof ("yes"), 4);
+ }
+
+ assert (XEN_NOTE_SIZE == (ptr - note_start));
+
+ phdr++;
+ phdr->p_type = grub_host_to_target32 (PT_NOTE);
+ phdr->p_flags = grub_host_to_target32 (PF_R);
+ phdr->p_align = grub_host_to_target32 (image_target->voidp_sizeof);
+ phdr->p_vaddr = 0;
+ phdr->p_paddr = 0;
+ phdr->p_filesz = grub_host_to_target32 (XEN_NOTE_SIZE);
+ phdr->p_memsz = 0;
+ phdr->p_offset = grub_host_to_target32 (header_size + program_size);
+ }
+
+ if (image_target->id == IMAGE_XEN_PVH)
+ {
+ char *note_start = (elf_img + program_size + header_size);
+ Elf_Nhdr *note_ptr;
+ char *ptr = (char *) note_start;
+
+ grub_util_info ("adding XEN NOTE segment");
+
+ /* Phys32 Entry. */
+ note_ptr = (Elf_Nhdr *) ptr;
+ note_ptr->n_namesz = grub_host_to_target32 (sizeof (GRUB_XEN_NOTE_NAME));
+ note_ptr->n_descsz = grub_host_to_target32 (image_target->voidp_sizeof);
+ note_ptr->n_type = grub_host_to_target32 (XEN_ELFNOTE_PHYS32_ENTRY);
+ ptr += sizeof (Elf_Nhdr);
+ memcpy (ptr, GRUB_XEN_NOTE_NAME, sizeof (GRUB_XEN_NOTE_NAME));
+ ptr += ALIGN_UP (sizeof (GRUB_XEN_NOTE_NAME), 4);
+ memset (ptr, 0, image_target->voidp_sizeof);
+ *(grub_uint32_t *) ptr = GRUB_KERNEL_I386_XEN_PVH_LINK_ADDR;
+ ptr += image_target->voidp_sizeof;
+
+ assert (XEN_PVH_NOTE_SIZE == (ptr - note_start));
+
+ phdr++;
+ phdr->p_type = grub_host_to_target32 (PT_NOTE);
+ phdr->p_flags = grub_host_to_target32 (PF_R);
+ phdr->p_align = grub_host_to_target32 (image_target->voidp_sizeof);
+ phdr->p_vaddr = 0;
+ phdr->p_paddr = 0;
+ phdr->p_filesz = grub_host_to_target32 (XEN_PVH_NOTE_SIZE);
+ phdr->p_memsz = 0;
+ phdr->p_offset = grub_host_to_target32 (header_size + program_size);
+ }
+
+ if (note)
+ {
+ int note_size = sizeof (struct grub_ieee1275_note);
+ struct grub_ieee1275_note *note_ptr = (struct grub_ieee1275_note *)
+ (elf_img + program_size + header_size);
+
+ grub_util_info ("adding CHRP NOTE segment");
+
+ note_ptr->header.n_namesz = grub_host_to_target32 (sizeof (GRUB_IEEE1275_NOTE_NAME));
+ note_ptr->header.n_descsz = grub_host_to_target32 (sizeof (struct grub_ieee1275_note_desc));
+ note_ptr->header.n_type = grub_host_to_target32 (GRUB_IEEE1275_NOTE_TYPE);
+ strcpy (note_ptr->name, GRUB_IEEE1275_NOTE_NAME);
+ note_ptr->descriptor.real_mode = grub_host_to_target32 (0xffffffff);
+ note_ptr->descriptor.real_base = grub_host_to_target32 (0x00c00000);
+ note_ptr->descriptor.real_size = grub_host_to_target32 (0xffffffff);
+ note_ptr->descriptor.virt_base = grub_host_to_target32 (0xffffffff);
+ note_ptr->descriptor.virt_size = grub_host_to_target32 (0xffffffff);
+ note_ptr->descriptor.load_base = grub_host_to_target32 (0x00004000);
+
+ phdr++;
+ phdr->p_type = grub_host_to_target32 (PT_NOTE);
+ phdr->p_flags = grub_host_to_target32 (PF_R);
+ phdr->p_align = grub_host_to_target32 (image_target->voidp_sizeof);
+ phdr->p_vaddr = 0;
+ phdr->p_paddr = 0;
+ phdr->p_filesz = grub_host_to_target32 (note_size);
+ phdr->p_memsz = 0;
+ phdr->p_offset = grub_host_to_target32 (header_size + program_size);
+ }
+
+ {
+ char *str_start = (elf_img + sizeof (*ehdr) + phnum * sizeof (*phdr)
+ + shnum * sizeof (*shdr));
+ char *ptr = str_start + 1;
+
+ shdr++;
+
+ shdr->sh_name = grub_host_to_target32 (0);
+ shdr->sh_type = grub_host_to_target32 (SHT_STRTAB);
+ shdr->sh_addr = grub_host_to_target_addr (0);
+ shdr->sh_offset = grub_host_to_target_addr (str_start - elf_img);
+ shdr->sh_size = grub_host_to_target32 (string_size);
+ shdr->sh_link = grub_host_to_target32 (0);
+ shdr->sh_info = grub_host_to_target32 (0);
+ shdr->sh_addralign = grub_host_to_target32 (layout->align);
+ shdr->sh_entsize = grub_host_to_target32 (0);
+ shdr++;
+
+ memcpy (ptr, ".text", sizeof (".text"));
+
+ shdr->sh_name = grub_host_to_target32 (ptr - str_start);
+ ptr += sizeof (".text");
+ shdr->sh_type = grub_host_to_target32 (SHT_PROGBITS);
+ shdr->sh_addr = grub_host_to_target_addr (target_addr);
+ shdr->sh_offset = grub_host_to_target_addr (header_size);
+ shdr->sh_size = grub_host_to_target32 (layout->kernel_size);
+ shdr->sh_link = grub_host_to_target32 (0);
+ shdr->sh_info = grub_host_to_target32 (0);
+ shdr->sh_addralign = grub_host_to_target32 (layout->align);
+ shdr->sh_entsize = grub_host_to_target32 (0);
+ shdr++;
+
+ memcpy (ptr, "mods", sizeof ("mods"));
+ shdr->sh_name = grub_host_to_target32 (ptr - str_start);
+ ptr += sizeof ("mods");
+ shdr->sh_type = grub_host_to_target32 (SHT_PROGBITS);
+ shdr->sh_addr = grub_host_to_target_addr (target_addr + layout->kernel_size);
+ shdr->sh_offset = grub_host_to_target_addr (header_size + layout->kernel_size);
+ shdr->sh_size = grub_host_to_target32 (*core_size - layout->kernel_size);
+ shdr->sh_link = grub_host_to_target32 (0);
+ shdr->sh_info = grub_host_to_target32 (0);
+ shdr->sh_addralign = grub_host_to_target32 (image_target->voidp_sizeof);
+ shdr->sh_entsize = grub_host_to_target32 (0);
+ shdr++;
+
+ if (image_target->id == IMAGE_XEN || image_target->id == IMAGE_XEN_PVH)
+ {
+ memcpy (ptr, ".xen", sizeof (".xen"));
+ shdr->sh_name = grub_host_to_target32 (ptr - str_start);
+ ptr += sizeof (".xen");
+ shdr->sh_type = grub_host_to_target32 (SHT_PROGBITS);
+ shdr->sh_addr = grub_host_to_target_addr (target_addr + layout->kernel_size);
+ shdr->sh_offset = grub_host_to_target_addr (program_size + header_size);
+ if (image_target->id == IMAGE_XEN)
+ shdr->sh_size = grub_host_to_target32 (XEN_NOTE_SIZE);
+ else
+ shdr->sh_size = grub_host_to_target32 (XEN_PVH_NOTE_SIZE);
+ shdr->sh_link = grub_host_to_target32 (0);
+ shdr->sh_info = grub_host_to_target32 (0);
+ shdr->sh_addralign = grub_host_to_target32 (image_target->voidp_sizeof);
+ shdr->sh_entsize = grub_host_to_target32 (0);
+ shdr++;
+ }
+ }
+
+ free (*core_img);
+ *core_img = elf_img;
+ *core_size = program_size + header_size + footer_size;
+}
+
+/* Relocate symbols; note that this function overwrites the symbol table.
+ Return the address of a start symbol. */
+static Elf_Addr
+SUFFIX (relocate_symbols) (Elf_Ehdr *e, struct section_metadata *smd,
+ void *jumpers, Elf_Addr jumpers_addr,
+ Elf_Addr bss_start, Elf_Addr end,
+ const struct grub_install_image_target_desc *image_target)
+{
+ Elf_Word symtab_size, sym_size, num_syms;
+ Elf_Off symtab_offset;
+ Elf_Addr start_address = (Elf_Addr) -1;
+ Elf_Sym *sym;
+ Elf_Word i;
+ Elf_Shdr *symtab_section;
+ const char *symtab;
+ grub_uint64_t *jptr = jumpers;
+
+ symtab_section = (Elf_Shdr *) ((char *) smd->sections
+ + grub_target_to_host32 (smd->symtab->sh_link)
+ * smd->section_entsize);
+ symtab = (char *) e + grub_target_to_host (symtab_section->sh_offset);
+
+ symtab_size = grub_target_to_host (smd->symtab->sh_size);
+ sym_size = grub_target_to_host (smd->symtab->sh_entsize);
+ symtab_offset = grub_target_to_host (smd->symtab->sh_offset);
+ num_syms = symtab_size / sym_size;
+
+ for (i = 0, sym = (Elf_Sym *) ((char *) e + symtab_offset);
+ i < num_syms;
+ i++, sym = (Elf_Sym *) ((char *) sym + sym_size))
+ {
+ Elf_Section cur_index;
+ const char *name;
+
+ name = symtab + grub_target_to_host32 (sym->st_name);
+
+ cur_index = grub_target_to_host16 (sym->st_shndx);
+ if (cur_index == STN_ABS)
+ {
+ continue;
+ }
+ else if (cur_index == STN_UNDEF)
+ {
+ if (sym->st_name && grub_strcmp (name, "__bss_start") == 0)
+ sym->st_value = bss_start;
+ else if (sym->st_name && grub_strcmp (name, "_end") == 0)
+ sym->st_value = end;
+ else if (sym->st_name)
+ grub_util_error ("undefined symbol %s", name);
+ else
+ continue;
+ }
+ else if (cur_index >= smd->num_sections)
+ grub_util_error ("section %d does not exist", cur_index);
+ else
+ {
+ sym->st_value = (grub_target_to_host (sym->st_value)
+ + smd->vaddrs[cur_index]);
+ }
+
+ if (image_target->elf_target == EM_IA_64 && ELF_ST_TYPE (sym->st_info)
+ == STT_FUNC)
+ {
+ *jptr = grub_host_to_target64 (sym->st_value);
+ sym->st_value = (char *) jptr - (char *) jumpers + jumpers_addr;
+ jptr++;
+ *jptr = 0;
+ jptr++;
+ }
+ grub_util_info ("locating %s at 0x%" GRUB_HOST_PRIxLONG_LONG
+ " (0x%" GRUB_HOST_PRIxLONG_LONG ")", name,
+ (unsigned long long) sym->st_value,
+ (unsigned long long) smd->vaddrs[cur_index]);
+
+ if (start_address == (Elf_Addr)-1)
+ if (strcmp (name, "_start") == 0 || strcmp (name, "start") == 0)
+ start_address = sym->st_value;
+ }
+
+ return start_address;
+}
+
+/* Return the address of a symbol at the index I in the section S. */
+static Elf_Addr
+SUFFIX (get_symbol_address) (Elf_Ehdr *e, Elf_Shdr *s, Elf_Word i,
+ const struct grub_install_image_target_desc *image_target)
+{
+ Elf_Sym *sym;
+
+ sym = (Elf_Sym *) ((char *) e
+ + grub_target_to_host (s->sh_offset)
+ + i * grub_target_to_host (s->sh_entsize));
+ return sym->st_value;
+}
+
+/* Return the address of a modified value. */
+static Elf_Addr *
+SUFFIX (get_target_address) (Elf_Ehdr *e, Elf_Shdr *s, Elf_Addr offset,
+ const struct grub_install_image_target_desc *image_target)
+{
+ return (Elf_Addr *) ((char *) e + grub_target_to_host (s->sh_offset) + offset);
+}
+
+#ifdef MKIMAGE_ELF64
+static Elf_Addr
+SUFFIX (count_funcs) (Elf_Ehdr *e, Elf_Shdr *symtab_section,
+ const struct grub_install_image_target_desc *image_target)
+{
+ Elf_Word symtab_size, sym_size, num_syms;
+ Elf_Off symtab_offset;
+ Elf_Sym *sym;
+ Elf_Word i;
+ int ret = 0;
+
+ symtab_size = grub_target_to_host (symtab_section->sh_size);
+ sym_size = grub_target_to_host (symtab_section->sh_entsize);
+ symtab_offset = grub_target_to_host (symtab_section->sh_offset);
+ num_syms = symtab_size / sym_size;
+
+ for (i = 0, sym = (Elf_Sym *) ((char *) e + symtab_offset);
+ i < num_syms;
+ i++, sym = (Elf_Sym *) ((char *) sym + sym_size))
+ if (ELF_ST_TYPE (sym->st_info) == STT_FUNC)
+ ret++;
+
+ return ret;
+}
+#endif
+
+#ifdef MKIMAGE_ELF32
+/* Deal with relocation information. This function relocates addresses
+ within the virtual address space starting from 0. So only relative
+ addresses can be fully resolved. Absolute addresses must be relocated
+ again by a PE32 relocator when loaded. */
+static grub_size_t
+arm_get_trampoline_size (Elf_Ehdr *e,
+ Elf_Shdr *sections,
+ Elf_Half section_entsize,
+ Elf_Half num_sections,
+ const struct grub_install_image_target_desc *image_target)
+{
+ Elf_Half i;
+ Elf_Shdr *s;
+ grub_size_t ret = 0;
+
+ for (i = 0, s = sections;
+ i < num_sections;
+ i++, s = (Elf_Shdr *) ((char *) s + section_entsize))
+ if ((s->sh_type == grub_host_to_target32 (SHT_REL)) ||
+ (s->sh_type == grub_host_to_target32 (SHT_RELA)))
+ {
+ Elf_Rela *r;
+ Elf_Word rtab_size, r_size, num_rs;
+ Elf_Off rtab_offset;
+ Elf_Shdr *symtab_section;
+ Elf_Word j;
+
+ symtab_section = (Elf_Shdr *) ((char *) sections
+ + (grub_target_to_host32 (s->sh_link)
+ * section_entsize));
+
+ rtab_size = grub_target_to_host (s->sh_size);
+ r_size = grub_target_to_host (s->sh_entsize);
+ rtab_offset = grub_target_to_host (s->sh_offset);
+ num_rs = rtab_size / r_size;
+
+ for (j = 0, r = (Elf_Rela *) ((char *) e + rtab_offset);
+ j < num_rs;
+ j++, r = (Elf_Rela *) ((char *) r + r_size))
+ {
+ Elf_Addr info;
+ Elf_Addr sym_addr;
+
+ info = grub_target_to_host (r->r_info);
+ sym_addr = SUFFIX (get_symbol_address) (e, symtab_section,
+ ELF_R_SYM (info), image_target);
+
+ sym_addr += (s->sh_type == grub_target_to_host32 (SHT_RELA)) ?
+ grub_target_to_host (r->r_addend) : 0;
+
+ switch (ELF_R_TYPE (info))
+ {
+ case R_ARM_ABS32:
+ case R_ARM_V4BX:
+ break;
+ case R_ARM_THM_CALL:
+ case R_ARM_THM_JUMP24:
+ case R_ARM_THM_JUMP19:
+ if (!(sym_addr & 1))
+ ret += 8;
+ break;
+
+ case R_ARM_CALL:
+ case R_ARM_JUMP24:
+ if (sym_addr & 1)
+ ret += 16;
+ break;
+
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ }
+ }
+ return ret;
+}
+#endif
+
+static int
+SUFFIX (is_kept_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target);
+static int
+SUFFIX (is_kept_reloc_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target,
+ struct section_metadata *smd);
+
+/* Deal with relocation information. This function relocates addresses
+ within the virtual address space starting from 0. So only relative
+ addresses can be fully resolved. Absolute addresses must be relocated
+ again by a PE32 relocator when loaded. */
+static void
+SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
+ char *pe_target, Elf_Addr tramp_off, Elf_Addr got_off,
+ const struct grub_install_image_target_desc *image_target)
+{
+ Elf_Half i;
+ Elf_Shdr *s;
+#ifdef MKIMAGE_ELF64
+ struct grub_ia64_trampoline *tr = (void *) (pe_target + tramp_off);
+ grub_uint64_t *gpptr = (void *) (pe_target + got_off);
+ unsigned unmatched_adr_got_page = 0;
+#define MASK19 ((1 << 19) - 1)
+#else
+ grub_uint32_t *tr = (void *) (pe_target + tramp_off);
+#endif
+
+ for (i = 0, s = smd->sections;
+ i < smd->num_sections;
+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize))
+ if ((s->sh_type == grub_host_to_target32 (SHT_REL)) ||
+ (s->sh_type == grub_host_to_target32 (SHT_RELA)))
+ {
+ Elf_Rela *r;
+ Elf_Word rtab_size, r_size, num_rs;
+ Elf_Off rtab_offset;
+ Elf_Word target_section_index;
+ Elf_Addr target_section_addr;
+ Elf_Shdr *target_section;
+ Elf_Word j;
+
+ if (!SUFFIX (is_kept_section) (s, image_target) &&
+ !SUFFIX (is_kept_reloc_section) (s, image_target, smd))
+ {
+ grub_util_info ("not translating relocations for omitted section %s",
+ smd->strtab + grub_le_to_cpu32 (s->sh_name));
+ continue;
+ }
+
+ target_section_index = grub_target_to_host32 (s->sh_info);
+ target_section_addr = smd->addrs[target_section_index];
+ target_section = (Elf_Shdr *) ((char *) smd->sections
+ + (target_section_index
+ * smd->section_entsize));
+
+ grub_util_info ("dealing with the relocation section %s for %s",
+ smd->strtab + grub_target_to_host32 (s->sh_name),
+ smd->strtab + grub_target_to_host32 (target_section->sh_name));
+
+ rtab_size = grub_target_to_host (s->sh_size);
+ r_size = grub_target_to_host (s->sh_entsize);
+ rtab_offset = grub_target_to_host (s->sh_offset);
+ num_rs = rtab_size / r_size;
+
+ for (j = 0, r = (Elf_Rela *) ((char *) e + rtab_offset);
+ j < num_rs;
+ j++, r = (Elf_Rela *) ((char *) r + r_size))
+ {
+ Elf_Addr info;
+ Elf_Addr offset;
+ Elf_Addr sym_addr;
+ Elf_Addr *target;
+ Elf_Addr addend;
+
+ offset = grub_target_to_host (r->r_offset);
+ target = SUFFIX (get_target_address) (e, target_section,
+ offset, image_target);
+ info = grub_target_to_host (r->r_info);
+ sym_addr = SUFFIX (get_symbol_address) (e, smd->symtab,
+ ELF_R_SYM (info), image_target);
+
+ addend = (s->sh_type == grub_target_to_host32 (SHT_RELA)) ?
+ grub_target_to_host (r->r_addend) : 0;
+
+ switch (image_target->elf_target)
+ {
+ case EM_386:
+ switch (ELF_R_TYPE (info))
+ {
+ case R_386_NONE:
+ break;
+
+ case R_386_32:
+ /* This is absolute. */
+ *target = grub_host_to_target32 (grub_target_to_host32 (*target)
+ + addend + sym_addr);
+ grub_util_info ("relocating an R_386_32 entry to 0x%"
+ GRUB_HOST_PRIxLONG_LONG " at the offset 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ (unsigned long long) *target,
+ (unsigned long long) offset);
+ break;
+
+ case R_386_PC32:
+ /* This is relative. */
+ *target = grub_host_to_target32 (grub_target_to_host32 (*target)
+ + addend + sym_addr
+ - target_section_addr - offset
+ - image_target->vaddr_offset);
+ grub_util_info ("relocating an R_386_PC32 entry to 0x%"
+ GRUB_HOST_PRIxLONG_LONG " at the offset 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ (unsigned long long) *target,
+ (unsigned long long) offset);
+ break;
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+#ifdef MKIMAGE_ELF64
+ case EM_X86_64:
+ switch (ELF_R_TYPE (info))
+ {
+
+ case R_X86_64_NONE:
+ break;
+
+ case R_X86_64_64:
+ *target = grub_host_to_target64 (grub_target_to_host64 (*target)
+ + addend + sym_addr);
+ grub_util_info ("relocating an R_X86_64_64 entry to 0x%"
+ GRUB_HOST_PRIxLONG_LONG " at the offset 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ (unsigned long long) *target,
+ (unsigned long long) offset);
+ break;
+
+ case R_X86_64_PC32:
+ case R_X86_64_PLT32:
+ {
+ grub_uint32_t *t32 = (grub_uint32_t *) target;
+ *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32)
+ + addend + sym_addr
+ - target_section_addr - offset
+ - image_target->vaddr_offset);
+ grub_util_info ("relocating an R_X86_64_PC32 entry to 0x%x at the offset 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ *t32, (unsigned long long) offset);
+ break;
+ }
+
+ case R_X86_64_PC64:
+ {
+ *target = grub_host_to_target64 (grub_target_to_host64 (*target)
+ + addend + sym_addr
+ - target_section_addr - offset
+ - image_target->vaddr_offset);
+ grub_util_info ("relocating an R_X86_64_PC64 entry to 0x%"
+ GRUB_HOST_PRIxLONG_LONG " at the offset 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ (unsigned long long) *target,
+ (unsigned long long) offset);
+ break;
+ }
+
+ case R_X86_64_32:
+ case R_X86_64_32S:
+ {
+ grub_uint32_t *t32 = (grub_uint32_t *) target;
+ *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32)
+ + addend + sym_addr);
+ grub_util_info ("relocating an R_X86_64_32(S) entry to 0x%x at the offset 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ *t32, (unsigned long long) offset);
+ break;
+ }
+
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+ case EM_IA_64:
+ switch (ELF_R_TYPE (info))
+ {
+ case R_IA64_PCREL21B:
+ {
+ grub_uint64_t noff;
+ grub_ia64_make_trampoline (tr, addend + sym_addr);
+ noff = ((char *) tr - (char *) pe_target
+ - target_section_addr - (offset & ~3)) >> 4;
+ tr++;
+ if (noff & ~MASK19)
+ grub_util_error ("trampoline offset too big (%"
+ GRUB_HOST_PRIxLONG_LONG ")",
+ (unsigned long long) noff);
+ grub_ia64_add_value_to_slot_20b ((grub_addr_t) target, noff);
+ }
+ break;
+
+ case R_IA64_LTOFF22X:
+ case R_IA64_LTOFF22:
+ {
+ Elf_Sym *sym;
+
+ sym = (Elf_Sym *) ((char *) e
+ + grub_target_to_host (smd->symtab->sh_offset)
+ + ELF_R_SYM (info) * grub_target_to_host (smd->symtab->sh_entsize));
+ if (ELF_ST_TYPE (sym->st_info) == STT_FUNC)
+ sym_addr = grub_target_to_host64 (*(grub_uint64_t *) (pe_target
+ + sym->st_value
+ - image_target->vaddr_offset));
+ }
+ /* FALLTHROUGH */
+ case R_IA64_LTOFF_FPTR22:
+ *gpptr = grub_host_to_target64 (addend + sym_addr);
+ grub_ia64_add_value_to_slot_21 ((grub_addr_t) target,
+ (char *) gpptr - (char *) pe_target
+ + image_target->vaddr_offset);
+ gpptr++;
+ break;
+
+ case R_IA64_GPREL22:
+ grub_ia64_add_value_to_slot_21 ((grub_addr_t) target,
+ addend + sym_addr);
+ break;
+ case R_IA64_GPREL64I:
+ grub_ia64_set_immu64 ((grub_addr_t) target,
+ addend + sym_addr);
+ break;
+ case R_IA64_PCREL64LSB:
+ *target = grub_host_to_target64 (grub_target_to_host64 (*target)
+ + addend + sym_addr
+ - target_section_addr - offset
+ - image_target->vaddr_offset);
+ break;
+
+ case R_IA64_SEGREL64LSB:
+ *target = grub_host_to_target64 (grub_target_to_host64 (*target)
+ + addend + sym_addr - target_section_addr);
+ break;
+ case R_IA64_DIR64LSB:
+ case R_IA64_FPTR64LSB:
+ *target = grub_host_to_target64 (grub_target_to_host64 (*target)
+ + addend + sym_addr);
+ grub_util_info ("relocating a direct entry to 0x%"
+ GRUB_HOST_PRIxLONG_LONG " at the offset 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ (unsigned long long)
+ grub_target_to_host64 (*target),
+ (unsigned long long) offset);
+ break;
+
+ /* We treat LTOFF22X as LTOFF22, so we can ignore LDXMOV. */
+ case R_IA64_LDXMOV:
+ break;
+
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+ case EM_AARCH64:
+ {
+ sym_addr += addend;
+ switch (ELF_R_TYPE (info))
+ {
+ case R_AARCH64_ABS64:
+ {
+ *target = grub_host_to_target64 (grub_target_to_host64 (*target) + sym_addr);
+ }
+ break;
+ case R_AARCH64_PREL32:
+ {
+ grub_uint32_t *t32 = (grub_uint32_t *) target;
+ *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32)
+ + sym_addr
+ - target_section_addr - offset
+ - image_target->vaddr_offset);
+ grub_util_info ("relocating an R_AARCH64_PREL32 entry to 0x%x at the offset 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ *t32, (unsigned long long) offset);
+ break;
+ }
+ case R_AARCH64_ADD_ABS_LO12_NC:
+ grub_arm64_set_abs_lo12 ((grub_uint32_t *) target,
+ sym_addr);
+ break;
+ case R_AARCH64_LDST64_ABS_LO12_NC:
+ grub_arm64_set_abs_lo12_ldst64 ((grub_uint32_t *) target,
+ sym_addr);
+ break;
+ case R_AARCH64_JUMP26:
+ case R_AARCH64_CALL26:
+ {
+ sym_addr -= offset;
+ sym_addr -= target_section_addr + image_target->vaddr_offset;
+ if (!grub_arm_64_check_xxxx26_offset (sym_addr))
+ grub_util_error ("%s", "CALL26 Relocation out of range");
+
+ grub_arm64_set_xxxx26_offset((grub_uint32_t *)target,
+ sym_addr);
+ }
+ break;
+ case R_AARCH64_ADR_GOT_PAGE:
+ {
+ Elf64_Rela *rel2;
+ grub_int64_t gpoffset = (((char *) gpptr - (char *) pe_target + image_target->vaddr_offset) & ~0xfffULL)
+ - ((offset + target_section_addr + image_target->vaddr_offset) & ~0xfffULL);
+ unsigned k;
+ *gpptr = grub_host_to_target64 (sym_addr);
+ unmatched_adr_got_page++;
+ if (!grub_arm64_check_hi21_signed (gpoffset))
+ grub_util_error ("HI21 out of range");
+ grub_arm64_set_hi21((grub_uint32_t *)target,
+ gpoffset);
+ for (k = 0, rel2 = (Elf_Rela *) ((char *) r + r_size);
+ k < num_rs;
+ k++, rel2 = (Elf_Rela *) ((char *) rel2 + r_size))
+ if (ELF_R_SYM (rel2->r_info)
+ == ELF_R_SYM (r->r_info)
+ && r->r_addend == rel2->r_addend
+ && ELF_R_TYPE (rel2->r_info) == R_AARCH64_LD64_GOT_LO12_NC)
+ {
+ grub_arm64_set_abs_lo12_ldst64 ((grub_uint32_t *) SUFFIX (get_target_address) (e, target_section,
+ grub_target_to_host (rel2->r_offset), image_target),
+ ((char *) gpptr - (char *) pe_target + image_target->vaddr_offset));
+ break;
+ }
+ if (k >= num_rs)
+ grub_util_error ("ADR_GOT_PAGE without matching LD64_GOT_LO12_NC");
+ gpptr++;
+ }
+ break;
+ case R_AARCH64_LD64_GOT_LO12_NC:
+ if (unmatched_adr_got_page == 0)
+ grub_util_error ("LD64_GOT_LO12_NC without matching ADR_GOT_PAGE");
+ unmatched_adr_got_page--;
+ break;
+ case R_AARCH64_ADR_PREL_PG_HI21:
+ {
+ sym_addr &= ~0xfffULL;
+ sym_addr -= (offset + target_section_addr + image_target->vaddr_offset) & ~0xfffULL;
+ if (!grub_arm64_check_hi21_signed (sym_addr))
+ grub_util_error ("%s", "CALL26 Relocation out of range");
+
+ grub_arm64_set_hi21((grub_uint32_t *)target,
+ sym_addr);
+ }
+ break;
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+ }
+#endif
+#if defined(MKIMAGE_ELF32)
+ case EM_ARM:
+ {
+ sym_addr += addend;
+ sym_addr -= image_target->vaddr_offset;
+ switch (ELF_R_TYPE (info))
+ {
+ case R_ARM_ABS32:
+ {
+ grub_util_info (" ABS32:\toffset=%d\t(0x%08x)",
+ (int) sym_addr, (int) sym_addr);
+ /* Data will be naturally aligned */
+ if (image_target->id == IMAGE_EFI)
+ sym_addr += GRUB_PE32_SECTION_ALIGNMENT;
+ *target = grub_host_to_target32 (grub_target_to_host32 (*target) + sym_addr);
+ }
+ break;
+ /* Happens when compiled with -march=armv4.
+ Since currently we need at least armv5, keep bx as-is.
+ */
+ case R_ARM_V4BX:
+ break;
+ case R_ARM_THM_CALL:
+ case R_ARM_THM_JUMP24:
+ case R_ARM_THM_JUMP19:
+ {
+ grub_err_t err;
+ Elf_Sym *sym;
+ grub_util_info (" THM_JUMP24:\ttarget=0x%08lx\toffset=(0x%08x)",
+ (unsigned long) ((char *) target
+ - (char *) e),
+ sym_addr);
+ sym = (Elf_Sym *) ((char *) e
+ + grub_target_to_host (smd->symtab->sh_offset)
+ + ELF_R_SYM (info) * grub_target_to_host (smd->symtab->sh_entsize));
+ if (ELF_ST_TYPE (sym->st_info) != STT_FUNC)
+ sym_addr |= 1;
+ if (!(sym_addr & 1))
+ {
+ grub_uint32_t tr_addr;
+ grub_int32_t new_offset;
+ tr_addr = (char *) tr - (char *) pe_target
+ - target_section_addr;
+ new_offset = sym_addr - tr_addr - 12;
+
+ if (!grub_arm_jump24_check_offset (new_offset))
+ return grub_util_error ("jump24 relocation out of range");
+
+ tr[0] = grub_host_to_target32 (0x46c04778); /* bx pc; nop */
+ tr[1] = grub_host_to_target32 (((new_offset >> 2) & 0xffffff) | 0xea000000); /* b new_offset */
+ tr += 2;
+ sym_addr = tr_addr | 1;
+ }
+ sym_addr -= offset;
+ /* Thumb instructions can be 16-bit aligned */
+ if (ELF_R_TYPE (info) == R_ARM_THM_JUMP19)
+ err = grub_arm_reloc_thm_jump19 ((grub_uint16_t *) target, sym_addr);
+ else
+ err = grub_arm_reloc_thm_call ((grub_uint16_t *) target,
+ sym_addr);
+ if (err)
+ grub_util_error ("%s", grub_errmsg);
+ }
+ break;
+
+ case R_ARM_CALL:
+ case R_ARM_JUMP24:
+ {
+ grub_err_t err;
+ grub_util_info (" JUMP24:\ttarget=0x%08lx\toffset=(0x%08x)", (unsigned long) ((char *) target - (char *) e), sym_addr);
+ if (sym_addr & 1)
+ {
+ grub_uint32_t tr_addr;
+ grub_int32_t new_offset;
+ tr_addr = (char *) tr - (char *) pe_target
+ - target_section_addr;
+ new_offset = sym_addr - tr_addr - 12;
+
+ /* There is no immediate version of bx, only register one... */
+ tr[0] = grub_host_to_target32 (0xe59fc004); /* ldr ip, [pc, #4] */
+ tr[1] = grub_host_to_target32 (0xe08cc00f); /* add ip, ip, pc */
+ tr[2] = grub_host_to_target32 (0xe12fff1c); /* bx ip */
+ tr[3] = grub_host_to_target32 (new_offset | 1);
+ tr += 4;
+ sym_addr = tr_addr;
+ }
+ sym_addr -= offset;
+ err = grub_arm_reloc_jump24 (target,
+ sym_addr);
+ if (err)
+ grub_util_error ("%s", grub_errmsg);
+ }
+ break;
+
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+ }
+#endif /* MKIMAGE_ELF32 */
+ case EM_RISCV:
+ {
+ grub_uint64_t *t64 = (grub_uint64_t *) target;
+ grub_uint32_t *t32 = (grub_uint32_t *) target;
+ grub_uint16_t *t16 = (grub_uint16_t *) target;
+ grub_uint8_t *t8 = (grub_uint8_t *) target;
+ grub_int64_t off;
+
+ /*
+ * Instructions and instruction encoding are documented in the RISC-V
+ * specification. This file is based on version 2.2:
+ *
+ * https://github.com/riscv/riscv-isa-manual/blob/master/release/riscv-spec-v2.2.pdf
+ */
+
+ sym_addr += addend;
+ off = sym_addr - target_section_addr - offset - image_target->vaddr_offset;
+
+ switch (ELF_R_TYPE (info))
+ {
+ case R_RISCV_ADD8:
+ *t8 = *t8 + sym_addr;
+ break;
+ case R_RISCV_ADD16:
+ *t16 = grub_host_to_target16 (grub_target_to_host16 (*t16) + sym_addr);
+ break;
+ case R_RISCV_32:
+ case R_RISCV_ADD32:
+ *t32 = grub_host_to_target32 (grub_target_to_host32 (*t32) + sym_addr);
+ break;
+ case R_RISCV_64:
+ case R_RISCV_ADD64:
+ *t64 = grub_host_to_target64 (grub_target_to_host64 (*t64) + sym_addr);
+ break;
+
+ case R_RISCV_SUB8:
+ *t8 = sym_addr - *t8;
+ break;
+ case R_RISCV_SUB16:
+ *t16 = grub_host_to_target16 (grub_target_to_host16 (*t16) - sym_addr);
+ break;
+ case R_RISCV_SUB32:
+ *t32 = grub_host_to_target32 (grub_target_to_host32 (*t32) - sym_addr);
+ break;
+ case R_RISCV_SUB64:
+ *t64 = grub_host_to_target64 (grub_target_to_host64 (*t64) - sym_addr);
+ break;
+ case R_RISCV_BRANCH:
+ {
+ grub_uint32_t imm12 = (off & 0x1000) << (31 - 12);
+ grub_uint32_t imm11 = (off & 0x800) >> (11 - 7);
+ grub_uint32_t imm10_5 = (off & 0x7e0) << (30 - 10);
+ grub_uint32_t imm4_1 = (off & 0x1e) << (11 - 4);
+ *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0x1fff07f)
+ | imm12 | imm11 | imm10_5 | imm4_1);
+ }
+ break;
+ case R_RISCV_JAL:
+ {
+ grub_uint32_t imm20 = (off & 0x100000) << (31 - 20);
+ grub_uint32_t imm19_12 = (off & 0xff000);
+ grub_uint32_t imm11 = (off & 0x800) << (20 - 11);
+ grub_uint32_t imm10_1 = (off & 0x7fe) << (30 - 10);
+ *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfff)
+ | imm20 | imm19_12 | imm11 | imm10_1);
+ }
+ break;
+ case R_RISCV_CALL:
+ case R_RISCV_CALL_PLT:
+ {
+ grub_uint32_t hi20, lo12;
+
+ if (off != (grub_int32_t)off)
+ grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)((char *)target - (char *)e));
+
+ hi20 = (off + 0x800) & 0xfffff000;
+ lo12 = (off - hi20) & 0xfff;
+ t32[0] = grub_host_to_target32 ((grub_target_to_host32 (t32[0]) & 0xfff) | hi20);
+ t32[1] = grub_host_to_target32 ((grub_target_to_host32 (t32[1]) & 0xfffff) | (lo12 << 20));
+ }
+ break;
+ case R_RISCV_RVC_BRANCH:
+ {
+ grub_uint16_t imm8 = (off & 0x100) << (12 - 8);
+ grub_uint16_t imm7_6 = (off & 0xc0) >> (6 - 5);
+ grub_uint16_t imm5 = (off & 0x20) >> (5 - 2);
+ grub_uint16_t imm4_3 = (off & 0x18) << (12 - 5);
+ grub_uint16_t imm2_1 = (off & 0x6) << (12 - 10);
+ *t16 = grub_host_to_target16 ((grub_target_to_host16 (*t16) & 0xe383)
+ | imm8 | imm7_6 | imm5 | imm4_3 | imm2_1);
+ }
+ break;
+ case R_RISCV_RVC_JUMP:
+ {
+ grub_uint16_t imm11 = (off & 0x800) << (12 - 11);
+ grub_uint16_t imm10 = (off & 0x400) >> (10 - 8);
+ grub_uint16_t imm9_8 = (off & 0x300) << (12 - 11);
+ grub_uint16_t imm7 = (off & 0x80) >> (7 - 6);
+ grub_uint16_t imm6 = (off & 0x40) << (12 - 11);
+ grub_uint16_t imm5 = (off & 0x20) >> (5 - 2);
+ grub_uint16_t imm4 = (off & 0x10) << (12 - 5);
+ grub_uint16_t imm3_1 = (off & 0xe) << (12 - 10);
+ *t16 = grub_host_to_target16 ((grub_target_to_host16 (*t16) & 0xe003)
+ | imm11 | imm10 | imm9_8 | imm7 | imm6
+ | imm5 | imm4 | imm3_1);
+ }
+ break;
+ case R_RISCV_PCREL_HI20:
+ {
+ grub_int32_t hi20;
+
+ if (off != (grub_int32_t)off)
+ grub_util_error ("target %lx not reachable from pc=%lx", (long)sym_addr, (long)((char *)target - (char *)e));
+
+ hi20 = (off + 0x800) & 0xfffff000;
+ *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfff) | hi20);
+ }
+ break;
+ case R_RISCV_PCREL_LO12_I:
+ case R_RISCV_PCREL_LO12_S:
+ {
+ Elf_Rela *rel2;
+ Elf_Word k;
+ /* Search backwards for matching HI20 reloc. */
+ for (k = j, rel2 = (Elf_Rela *) ((char *) r - r_size);
+ k > 0;
+ k--, rel2 = (Elf_Rela *) ((char *) rel2 - r_size))
+ {
+ Elf_Addr rel2_info;
+ Elf_Addr rel2_offset;
+ Elf_Addr rel2_sym_addr;
+ Elf_Addr rel2_addend;
+ Elf_Addr rel2_loc;
+ grub_int64_t rel2_off;
+
+ rel2_offset = grub_target_to_host (rel2->r_offset);
+ rel2_info = grub_target_to_host (rel2->r_info);
+ rel2_loc = target_section_addr + rel2_offset + image_target->vaddr_offset;
+
+ if (ELF_R_TYPE (rel2_info) == R_RISCV_PCREL_HI20
+ && rel2_loc == sym_addr)
+ {
+ rel2_sym_addr = SUFFIX (get_symbol_address)
+ (e, smd->symtab, ELF_R_SYM (rel2_info),
+ image_target);
+ rel2_addend = (s->sh_type == grub_target_to_host32 (SHT_RELA)) ?
+ grub_target_to_host (rel2->r_addend) : 0;
+ rel2_off = rel2_sym_addr + rel2_addend - rel2_loc;
+ off = rel2_off - ((rel2_off + 0x800) & 0xfffff000);
+
+ if (ELF_R_TYPE (info) == R_RISCV_PCREL_LO12_I)
+ *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfffff) | (off & 0xfff) << 20);
+ else
+ {
+ grub_uint32_t imm11_5 = (off & 0xfe0) << (31 - 11);
+ grub_uint32_t imm4_0 = (off & 0x1f) << (11 - 4);
+ *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0x1fff07f) | imm11_5 | imm4_0);
+ }
+ break;
+ }
+ }
+ if (k == 0)
+ grub_util_error ("cannot find matching HI20 relocation");
+ }
+ break;
+ case R_RISCV_HI20:
+ *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfff) | (((grub_int32_t) sym_addr + 0x800) & 0xfffff000));
+ break;
+ case R_RISCV_LO12_I:
+ {
+ grub_int32_t lo12 = (grub_int32_t) sym_addr - (((grub_int32_t) sym_addr + 0x800) & 0xfffff000);
+ *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0xfffff) | ((lo12 & 0xfff) << 20));
+ }
+ break;
+ case R_RISCV_LO12_S:
+ {
+ grub_int32_t lo12 = (grub_int32_t) sym_addr - (((grub_int32_t) sym_addr + 0x800) & 0xfffff000);
+ grub_uint32_t imm11_5 = (lo12 & 0xfe0) << (31 - 11);
+ grub_uint32_t imm4_0 = (lo12 & 0x1f) << (11 - 4);
+ *t32 = grub_host_to_target32 ((grub_target_to_host32 (*t32) & 0x1fff07f) | imm11_5 | imm4_0);
+ }
+ break;
+ case R_RISCV_RELAX:
+ break;
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+ }
+ default:
+ grub_util_error ("unknown architecture type %d",
+ image_target->elf_target);
+ }
+ }
+ }
+}
+
+/* Add a PE32's fixup entry for a relocation. Return the resulting address
+ after having written to the file OUT. */
+static Elf_Addr
+add_fixup_entry (struct fixup_block_list **cblock, grub_uint16_t type,
+ Elf_Addr addr, int flush, Elf_Addr current_address,
+ const struct grub_install_image_target_desc *image_target)
+{
+ struct grub_pe32_fixup_block *b;
+
+ b = &((*cblock)->b);
+
+ /* First, check if it is necessary to write out the current block. */
+ if ((*cblock)->state)
+ {
+ if (flush || addr < b->page_rva || b->page_rva + 0x1000 <= addr)
+ {
+ grub_uint32_t size;
+
+ if (flush)
+ {
+ /* Add as much padding as necessary to align the address
+ with a section boundary. */
+ Elf_Addr next_address;
+ unsigned padding_size;
+ size_t cur_index;
+
+ next_address = current_address + b->block_size;
+ padding_size = ((ALIGN_UP (next_address, image_target->section_align)
+ - next_address)
+ >> 1);
+ cur_index = ((b->block_size - sizeof (*b)) >> 1);
+ grub_util_info ("adding %d padding fixup entries", padding_size);
+ while (padding_size--)
+ {
+ b->entries[cur_index++] = 0;
+ b->block_size += 2;
+ }
+ }
+ else while (b->block_size & (8 - 1))
+ {
+ /* If not aligned with a 32-bit boundary, add
+ a padding entry. */
+ size_t cur_index;
+
+ grub_util_info ("adding a padding fixup entry");
+ cur_index = ((b->block_size - sizeof (*b)) >> 1);
+ b->entries[cur_index] = 0;
+ b->block_size += 2;
+ }
+
+ /* Flush it. */
+ grub_util_info ("writing %d bytes of a fixup block starting at 0x%x",
+ b->block_size, b->page_rva);
+ size = b->block_size;
+ current_address += size;
+ b->page_rva = grub_host_to_target32 (b->page_rva);
+ b->block_size = grub_host_to_target32 (b->block_size);
+ (*cblock)->next = xmalloc (sizeof (**cblock) + 2 * 0x1000);
+ memset ((*cblock)->next, 0, sizeof (**cblock) + 2 * 0x1000);
+ *cblock = (*cblock)->next;
+ }
+ }
+
+ b = &((*cblock)->b);
+
+ if (! flush)
+ {
+ grub_uint16_t entry;
+ size_t cur_index;
+
+ /* If not allocated yet, allocate a block with enough entries. */
+ if (! (*cblock)->state)
+ {
+ (*cblock)->state = 1;
+
+ /* The spec does not mention the requirement of a Page RVA.
+ Here, align the address with a 4K boundary for safety. */
+ b->page_rva = (addr & ~(0x1000 - 1));
+ b->block_size = sizeof (*b);
+ }
+
+ /* Sanity check. */
+ if (b->block_size >= sizeof (*b) + 2 * 0x1000)
+ grub_util_error ("too many fixup entries");
+
+ /* Add a new entry. */
+ cur_index = ((b->block_size - sizeof (*b)) >> 1);
+ entry = GRUB_PE32_FIXUP_ENTRY (type, addr - b->page_rva);
+ b->entries[cur_index] = grub_host_to_target16 (entry);
+ b->block_size += 2;
+ }
+
+ return current_address;
+}
+
+struct raw_reloc
+{
+ struct raw_reloc *next;
+ grub_uint32_t offset;
+ enum raw_reloc_type {
+ RAW_RELOC_NONE = -1,
+ RAW_RELOC_32 = 0,
+ RAW_RELOC_MAX = 1,
+ } type;
+};
+
+struct translate_context
+{
+ /* PE */
+ struct fixup_block_list *lst, *lst0;
+ Elf_Addr current_address;
+
+ /* Raw */
+ struct raw_reloc *raw_relocs;
+};
+
+static void
+translate_reloc_start (struct translate_context *ctx,
+ const struct grub_install_image_target_desc *image_target)
+{
+ grub_memset (ctx, 0, sizeof (*ctx));
+ if (image_target->id == IMAGE_EFI)
+ {
+ ctx->lst = ctx->lst0 = xmalloc (sizeof (*ctx->lst) + 2 * 0x1000);
+ memset (ctx->lst, 0, sizeof (*ctx->lst) + 2 * 0x1000);
+ ctx->current_address = 0;
+ }
+}
+
+static void
+translate_relocation_pe (struct translate_context *ctx,
+ Elf_Addr addr,
+ Elf_Addr info,
+ const struct grub_install_image_target_desc *image_target)
+{
+ /* Necessary to relocate only absolute addresses. */
+ switch (image_target->elf_target)
+ {
+ case EM_386:
+ if (ELF_R_TYPE (info) == R_386_32)
+ {
+ grub_util_info ("adding a relocation entry for 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ (unsigned long long) addr);
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_HIGHLOW,
+ addr, 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ case EM_X86_64:
+ if ((ELF_R_TYPE (info) == R_X86_64_32) ||
+ (ELF_R_TYPE (info) == R_X86_64_32S))
+ {
+ grub_util_error ("can\'t add fixup entry for R_X86_64_32(S)");
+ }
+ else if (ELF_R_TYPE (info) == R_X86_64_64)
+ {
+ grub_util_info ("adding a relocation entry for 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ (unsigned long long) addr);
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_DIR64,
+ addr,
+ 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ case EM_IA_64:
+ switch (ELF_R_TYPE (info))
+ {
+ case R_IA64_PCREL64LSB:
+ case R_IA64_LDXMOV:
+ case R_IA64_PCREL21B:
+ case R_IA64_LTOFF_FPTR22:
+ case R_IA64_LTOFF22X:
+ case R_IA64_LTOFF22:
+ case R_IA64_GPREL22:
+ case R_IA64_GPREL64I:
+ case R_IA64_SEGREL64LSB:
+ break;
+
+ case R_IA64_FPTR64LSB:
+ case R_IA64_DIR64LSB:
+#if 1
+ {
+ grub_util_info ("adding a relocation entry for 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ (unsigned long long) addr);
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_DIR64,
+ addr,
+ 0, ctx->current_address,
+ image_target);
+ }
+#endif
+ break;
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+ case EM_AARCH64:
+ switch (ELF_R_TYPE (info))
+ {
+ case R_AARCH64_ABS64:
+ {
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_DIR64,
+ addr, 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ /* Relative relocations do not require fixup entries. */
+ case R_AARCH64_CALL26:
+ case R_AARCH64_JUMP26:
+ case R_AARCH64_PREL32:
+ break;
+ /* Page-relative relocations do not require fixup entries. */
+ case R_AARCH64_ADR_PREL_PG_HI21:
+ /* We page-align the whole kernel, so no need
+ for fixup entries.
+ */
+ case R_AARCH64_ADD_ABS_LO12_NC:
+ case R_AARCH64_LDST64_ABS_LO12_NC:
+ break;
+
+ /* GOT is relocated separately. */
+ case R_AARCH64_ADR_GOT_PAGE:
+ case R_AARCH64_LD64_GOT_LO12_NC:
+ break;
+
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+ break;
+#if defined(MKIMAGE_ELF32)
+ case EM_ARM:
+ switch (ELF_R_TYPE (info))
+ {
+ case R_ARM_V4BX:
+ /* Relative relocations do not require fixup entries. */
+ case R_ARM_JUMP24:
+ case R_ARM_THM_CALL:
+ case R_ARM_THM_JUMP19:
+ case R_ARM_THM_JUMP24:
+ case R_ARM_CALL:
+ {
+ grub_util_info (" %s: not adding fixup: 0x%08x : 0x%08x", __FUNCTION__, (unsigned int) addr, (unsigned int) ctx->current_address);
+ }
+ break;
+ /* Create fixup entry for PE/COFF loader */
+ case R_ARM_ABS32:
+ {
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_HIGHLOW,
+ addr, 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+#endif /* defined(MKIMAGE_ELF32) */
+ case EM_RISCV:
+ switch (ELF_R_TYPE (info))
+ {
+ case R_RISCV_32:
+ {
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_HIGHLOW,
+ addr, 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ case R_RISCV_64:
+ {
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_DIR64,
+ addr, 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ /* Relative relocations do not require fixup entries. */
+ case R_RISCV_BRANCH:
+ case R_RISCV_JAL:
+ case R_RISCV_CALL:
+ case R_RISCV_CALL_PLT:
+ case R_RISCV_PCREL_HI20:
+ case R_RISCV_PCREL_LO12_I:
+ case R_RISCV_PCREL_LO12_S:
+ case R_RISCV_RVC_BRANCH:
+ case R_RISCV_RVC_JUMP:
+ case R_RISCV_ADD32:
+ case R_RISCV_SUB32:
+ grub_util_info (" %s: not adding fixup: 0x%08x : 0x%08x", __FUNCTION__, (unsigned int) addr, (unsigned int) ctx->current_address);
+ break;
+ case R_RISCV_HI20:
+ {
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_RISCV_HI20,
+ addr, 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ case R_RISCV_LO12_I:
+ {
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_RISCV_LOW12I,
+ addr, 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ case R_RISCV_LO12_S:
+ {
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_RISCV_LOW12S,
+ addr, 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ case R_RISCV_RELAX:
+ break;
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+ default:
+ grub_util_error ("unknown machine type 0x%x", image_target->elf_target);
+ }
+}
+
+static enum raw_reloc_type
+classify_raw_reloc (Elf_Addr info,
+ const struct grub_install_image_target_desc *image_target)
+{
+ /* Necessary to relocate only absolute addresses. */
+ switch (image_target->elf_target)
+ {
+ case EM_ARM:
+ switch (ELF_R_TYPE (info))
+ {
+ case R_ARM_V4BX:
+ case R_ARM_JUMP24:
+ case R_ARM_THM_CALL:
+ case R_ARM_THM_JUMP19:
+ case R_ARM_THM_JUMP24:
+ case R_ARM_CALL:
+ return RAW_RELOC_NONE;
+ case R_ARM_ABS32:
+ return RAW_RELOC_32;
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+ default:
+ grub_util_error ("unknown machine type 0x%x", image_target->elf_target);
+ }
+}
+
+static void
+translate_relocation_raw (struct translate_context *ctx,
+ Elf_Addr addr,
+ Elf_Addr info,
+ const struct grub_install_image_target_desc *image_target)
+{
+ enum raw_reloc_type class = classify_raw_reloc (info, image_target);
+ struct raw_reloc *rel;
+ if (class == RAW_RELOC_NONE)
+ return;
+ rel = xmalloc (sizeof (*rel));
+ rel->next = ctx->raw_relocs;
+ rel->type = class;
+ rel->offset = addr;
+ ctx->raw_relocs = rel;
+}
+
+static void
+translate_relocation (struct translate_context *ctx,
+ Elf_Addr addr,
+ Elf_Addr info,
+ const struct grub_install_image_target_desc *image_target)
+{
+ if (image_target->id == IMAGE_EFI)
+ translate_relocation_pe (ctx, addr, info, image_target);
+ else
+ translate_relocation_raw (ctx, addr, info, image_target);
+}
+
+static void
+finish_reloc_translation_pe (struct translate_context *ctx, struct grub_mkimage_layout *layout,
+ const struct grub_install_image_target_desc *image_target)
+{
+ ctx->current_address = add_fixup_entry (&ctx->lst, 0, 0, 1, ctx->current_address, image_target);
+
+ {
+ grub_uint8_t *ptr;
+ layout->reloc_section = ptr = xmalloc (ctx->current_address);
+ for (ctx->lst = ctx->lst0; ctx->lst; ctx->lst = ctx->lst->next)
+ if (ctx->lst->state)
+ {
+ memcpy (ptr, &ctx->lst->b, grub_target_to_host32 (ctx->lst->b.block_size));
+ ptr += grub_target_to_host32 (ctx->lst->b.block_size);
+ }
+ assert ((ctx->current_address + (grub_uint8_t *) layout->reloc_section) == ptr);
+ }
+
+ for (ctx->lst = ctx->lst0; ctx->lst; )
+ {
+ struct fixup_block_list *next;
+ next = ctx->lst->next;
+ free (ctx->lst);
+ ctx->lst = next;
+ }
+
+ layout->reloc_size = ctx->current_address;
+ if (image_target->elf_target == EM_ARM && layout->reloc_size > GRUB_KERNEL_ARM_STACK_SIZE)
+ grub_util_error ("Reloc section (%d) is bigger than stack size (%d). "
+ "This breaks assembly assumptions. Please increase stack size",
+ (int) layout->reloc_size,
+ (int) GRUB_KERNEL_ARM_STACK_SIZE);
+}
+
+/*
+ Layout:
+ <type 0 relocations>
+ <fffffffe>
+ <type 1 relocations>
+ <fffffffe>
+ ...
+ <type n relocations>
+ <ffffffff>
+ each relocation starts with 32-bit offset. Rest depends on relocation.
+ mkimage stops when it sees first unknown type or end marker.
+ This allows images to be created with mismatched mkimage and
+ kernel as long as no relocations are present in kernel that mkimage
+ isn't aware of (in which case mkimage aborts).
+ This also allows simple assembly to do the relocs.
+*/
+
+#define RAW_SEPARATOR 0xfffffffe
+#define RAW_END_MARKER 0xffffffff
+
+static void
+finish_reloc_translation_raw (struct translate_context *ctx, struct grub_mkimage_layout *layout,
+ const struct grub_install_image_target_desc *image_target)
+{
+ size_t count = 0, sz;
+ enum raw_reloc_type highest = RAW_RELOC_NONE;
+ enum raw_reloc_type curtype;
+ struct raw_reloc *cur;
+ grub_uint32_t *p;
+ if (!ctx->raw_relocs)
+ {
+ layout->reloc_section = p = xmalloc (sizeof (grub_uint32_t));
+ p[0] = RAW_END_MARKER;
+ layout->reloc_size = sizeof (grub_uint32_t);
+ return;
+ }
+ for (cur = ctx->raw_relocs; cur; cur = cur->next)
+ {
+ count++;
+ if (cur->type > highest)
+ highest = cur->type;
+ }
+ /* highest separators, count relocations and one end marker. */
+ sz = (highest + count + 1) * sizeof (grub_uint32_t);
+ layout->reloc_section = p = xmalloc (sz);
+ for (curtype = 0; curtype <= highest; curtype++)
+ {
+ /* Support for special cases would go here. */
+ for (cur = ctx->raw_relocs; cur; cur = cur->next)
+ if (cur->type == curtype)
+ {
+ *p++ = cur->offset;
+ }
+ *p++ = RAW_SEPARATOR;
+ }
+ *--p = RAW_END_MARKER;
+ layout->reloc_size = sz;
+}
+
+static void
+finish_reloc_translation (struct translate_context *ctx, struct grub_mkimage_layout *layout,
+ const struct grub_install_image_target_desc *image_target)
+{
+ if (image_target->id == IMAGE_EFI)
+ finish_reloc_translation_pe (ctx, layout, image_target);
+ else
+ finish_reloc_translation_raw (ctx, layout, image_target);
+}
+
+
+static void
+create_u64_fixups (struct translate_context *ctx,
+ Elf_Addr jumpers, grub_size_t njumpers,
+ const struct grub_install_image_target_desc *image_target)
+{
+ unsigned i;
+ assert (image_target->id == IMAGE_EFI);
+ for (i = 0; i < njumpers; i++)
+ ctx->current_address = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_DIR64,
+ jumpers + 8 * i,
+ 0, ctx->current_address,
+ image_target);
+}
+
+/* Make a .reloc section. */
+static void
+make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout,
+ struct section_metadata *smd,
+ const struct grub_install_image_target_desc *image_target)
+{
+ unsigned i;
+ Elf_Shdr *s;
+ struct translate_context ctx;
+
+ translate_reloc_start (&ctx, image_target);
+
+ for (i = 0, s = smd->sections; i < smd->num_sections;
+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize))
+ if ((grub_target_to_host32 (s->sh_type) == SHT_REL) ||
+ (grub_target_to_host32 (s->sh_type) == SHT_RELA))
+ {
+ Elf_Rel *r;
+ Elf_Word rtab_size, r_size, num_rs;
+ Elf_Off rtab_offset;
+ Elf_Addr section_address;
+ Elf_Word j;
+
+ if (!SUFFIX (is_kept_reloc_section) (s, image_target, smd))
+ {
+ grub_util_info ("not translating the skipped relocation section %s",
+ smd->strtab + grub_le_to_cpu32 (s->sh_name));
+ continue;
+ }
+
+ grub_util_info ("translating the relocation section %s",
+ smd->strtab + grub_le_to_cpu32 (s->sh_name));
+
+ rtab_size = grub_target_to_host (s->sh_size);
+ r_size = grub_target_to_host (s->sh_entsize);
+ rtab_offset = grub_target_to_host (s->sh_offset);
+ num_rs = rtab_size / r_size;
+
+ section_address = smd->vaddrs[grub_le_to_cpu32 (s->sh_info)];
+
+ for (j = 0, r = (Elf_Rel *) ((char *) e + rtab_offset);
+ j < num_rs;
+ j++, r = (Elf_Rel *) ((char *) r + r_size))
+ {
+ Elf_Addr info;
+ Elf_Addr offset;
+ Elf_Addr addr;
+
+ offset = grub_target_to_host (r->r_offset);
+ info = grub_target_to_host (r->r_info);
+
+ addr = section_address + offset;
+
+ translate_relocation (&ctx, addr, info, image_target);
+ }
+ }
+
+ if (image_target->elf_target == EM_IA_64)
+ create_u64_fixups (&ctx,
+ layout->ia64jmp_off
+ + image_target->vaddr_offset,
+ 2 * layout->ia64jmpnum,
+ image_target);
+ if (image_target->elf_target == EM_IA_64 || image_target->elf_target == EM_AARCH64)
+ create_u64_fixups (&ctx,
+ layout->got_off
+ + image_target->vaddr_offset,
+ (layout->got_size / 8),
+ image_target);
+
+ finish_reloc_translation (&ctx, layout, image_target);
+}
+
+/* Determine if this section is a text section. Return false if this
+ section is not allocated. */
+static int
+SUFFIX (is_text_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target)
+{
+ if (!is_relocatable (image_target)
+ && grub_target_to_host32 (s->sh_type) != SHT_PROGBITS)
+ return 0;
+ return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC))
+ == (SHF_EXECINSTR | SHF_ALLOC));
+}
+
+/* Determine if this section is a data section. */
+static int
+SUFFIX (is_data_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target)
+{
+ if (!is_relocatable (image_target)
+ && grub_target_to_host32 (s->sh_type) != SHT_PROGBITS)
+ return 0;
+ return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC))
+ == SHF_ALLOC) && !(grub_target_to_host32 (s->sh_type) == SHT_NOBITS);
+}
+
+static int
+SUFFIX (is_bss_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target)
+{
+ if (!is_relocatable (image_target))
+ return 0;
+ return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC))
+ == SHF_ALLOC) && (grub_target_to_host32 (s->sh_type) == SHT_NOBITS);
+}
+
+/* Determine if a section is going to be in the final output */
+static int
+SUFFIX (is_kept_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target)
+{
+ /* We keep .text and .data */
+ if (SUFFIX (is_text_section) (s, image_target)
+ || SUFFIX (is_data_section) (s, image_target))
+ return 1;
+
+ /*
+ * And we keep .bss if we're producing PE binaries or the target doesn't
+ * have a relocating loader. Platforms other than EFI and U-boot shouldn't
+ * have .bss in their binaries as we build with -Wl,-Ttext.
+ */
+ if (SUFFIX (is_bss_section) (s, image_target)
+ && (image_target->id == IMAGE_EFI || !is_relocatable (image_target)))
+ return 1;
+
+ /* Otherwise this is not a section we're keeping in the final output. */
+ return 0;
+}
+
+static int
+SUFFIX (is_kept_reloc_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target,
+ struct section_metadata *smd)
+{
+ int i;
+ int r = 0;
+ const char *name = smd->strtab + grub_host_to_target32 (s->sh_name);
+
+ if (!strncmp (name, ".rela.", 6))
+ name += 5;
+ else if (!strncmp (name, ".rel.", 5))
+ name += 4;
+ else
+ return 1;
+
+ for (i = 0, s = smd->sections; i < smd->num_sections;
+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize))
+ {
+ const char *sname = smd->strtab + grub_host_to_target32 (s->sh_name);
+ if (strcmp (sname, name))
+ continue;
+
+ return SUFFIX (is_kept_section) (s, image_target);
+ }
+
+ return r;
+}
+
+/* Return if the ELF header is valid. */
+static int
+SUFFIX (check_elf_header) (Elf_Ehdr *e, size_t size, const struct grub_install_image_target_desc *image_target)
+{
+ if (size < sizeof (*e)
+ || e->e_ident[EI_MAG0] != ELFMAG0
+ || e->e_ident[EI_MAG1] != ELFMAG1
+ || e->e_ident[EI_MAG2] != ELFMAG2
+ || e->e_ident[EI_MAG3] != ELFMAG3
+ || e->e_ident[EI_VERSION] != EV_CURRENT
+ || e->e_ident[EI_CLASS] != ELFCLASSXX
+ || e->e_version != grub_host_to_target32 (EV_CURRENT))
+ return 0;
+
+ return 1;
+}
+
+static Elf_Addr
+SUFFIX (put_section) (Elf_Shdr *s, int i,
+ Elf_Addr current_address,
+ struct section_metadata *smd,
+ const struct grub_install_image_target_desc *image_target)
+{
+ Elf_Word align = grub_host_to_target_addr (s->sh_addralign);
+ const char *name = smd->strtab + grub_host_to_target32 (s->sh_name);
+
+ if (align)
+ current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
+ align)
+ - image_target->vaddr_offset;
+
+ grub_util_info ("locating the section %s at 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ name, (unsigned long long) current_address);
+ if (!is_relocatable (image_target))
+ current_address = grub_host_to_target_addr (s->sh_addr)
+ - image_target->link_addr;
+ smd->addrs[i] = current_address;
+ current_address += grub_host_to_target_addr (s->sh_size);
+ return current_address;
+}
+
+/*
+ * Locate section addresses by merging code sections and data sections
+ * into .text and .data, respectively.
+ */
+static void
+SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path,
+ struct section_metadata *smd,
+ struct grub_mkimage_layout *layout,
+ const struct grub_install_image_target_desc *image_target)
+{
+ int i;
+ Elf_Shdr *s;
+
+ layout->align = 1;
+ /* Page-aligning simplifies relocation handling. */
+ if (image_target->elf_target == EM_AARCH64)
+ layout->align = 4096;
+
+ layout->kernel_size = 0;
+
+ for (i = 0, s = smd->sections;
+ i < smd->num_sections;
+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize))
+ if ((grub_target_to_host (s->sh_flags) & SHF_ALLOC)
+ && grub_host_to_target32 (s->sh_addralign) > layout->align)
+ layout->align = grub_host_to_target32 (s->sh_addralign);
+
+ /* .text */
+ for (i = 0, s = smd->sections;
+ i < smd->num_sections;
+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize))
+ if (SUFFIX (is_text_section) (s, image_target))
+ {
+ layout->kernel_size = SUFFIX (put_section) (s, i, layout->kernel_size,
+ smd, image_target);
+ if (!is_relocatable (image_target) &&
+ grub_host_to_target_addr (s->sh_addr) != image_target->link_addr)
+ {
+ char *msg
+ = grub_xasprintf (_("`%s' is miscompiled: its start address is 0x%llx"
+ " instead of 0x%llx: ld.gold bug?"),
+ kernel_path,
+ (unsigned long long) grub_host_to_target_addr (s->sh_addr),
+ (unsigned long long) image_target->link_addr);
+ grub_util_error ("%s", msg);
+ }
+ }
+
+#ifdef MKIMAGE_ELF32
+ if (image_target->elf_target == EM_ARM)
+ {
+ grub_size_t tramp;
+
+ layout->kernel_size = ALIGN_UP (layout->kernel_size, 16);
+
+ tramp = arm_get_trampoline_size (e, smd->sections, smd->section_entsize,
+ smd->num_sections, image_target);
+
+ layout->tramp_off = layout->kernel_size;
+ layout->kernel_size += ALIGN_UP (tramp, 16);
+ }
+#endif
+
+ layout->kernel_size = ALIGN_UP (layout->kernel_size + image_target->vaddr_offset,
+ image_target->section_align)
+ - image_target->vaddr_offset;
+ layout->exec_size = layout->kernel_size;
+
+ /* .data */
+ for (i = 0, s = smd->sections;
+ i < smd->num_sections;
+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize))
+ if (SUFFIX (is_data_section) (s, image_target))
+ layout->kernel_size = SUFFIX (put_section) (s, i, layout->kernel_size, smd,
+ image_target);
+
+ layout->bss_start = layout->kernel_size;
+ layout->end = layout->kernel_size;
+
+ /* .bss */
+ for (i = 0, s = smd->sections;
+ i < smd->num_sections;
+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize))
+ {
+ if (SUFFIX (is_bss_section) (s, image_target))
+ layout->end = SUFFIX (put_section) (s, i, layout->end, smd, image_target);
+
+ /*
+ * This must to be in the last time this function passes through the loop.
+ */
+ smd->vaddrs[i] = smd->addrs[i] + image_target->vaddr_offset;
+ }
+
+ layout->end = ALIGN_UP (layout->end + image_target->vaddr_offset,
+ image_target->section_align) - image_target->vaddr_offset;
+ /* Explicitly initialize BSS
+ when producing PE32 to avoid a bug in EFI implementations.
+ Platforms other than EFI and U-boot shouldn't have .bss in
+ their binaries as we build with -Wl,-Ttext.
+ */
+ if (image_target->id == IMAGE_EFI || !is_relocatable (image_target))
+ layout->kernel_size = layout->end;
+}
+
+char *
+SUFFIX (grub_mkimage_load_image) (const char *kernel_path,
+ size_t total_module_size,
+ struct grub_mkimage_layout *layout,
+ const struct grub_install_image_target_desc *image_target)
+{
+ char *kernel_img, *out_img;
+ struct section_metadata smd = { 0, 0, 0, 0, 0, 0, 0 };
+ Elf_Ehdr *e;
+ int i;
+ Elf_Shdr *s;
+ Elf_Off section_offset;
+ grub_size_t kernel_size;
+
+ grub_memset (layout, 0, sizeof (*layout));
+
+ layout->start_address = 0;
+
+ kernel_size = grub_util_get_image_size (kernel_path);
+ kernel_img = xmalloc (kernel_size);
+ grub_util_load_image (kernel_path, kernel_img);
+
+ e = (Elf_Ehdr *) kernel_img;
+ if (! SUFFIX (check_elf_header) (e, kernel_size, image_target))
+ grub_util_error ("invalid ELF header");
+
+ section_offset = grub_target_to_host (e->e_shoff);
+ smd.section_entsize = grub_target_to_host16 (e->e_shentsize);
+ smd.num_sections = grub_target_to_host16 (e->e_shnum);
+
+ if (kernel_size < section_offset
+ + (grub_uint32_t) smd.section_entsize * smd.num_sections)
+ grub_util_error (_("premature end of file %s"), kernel_path);
+
+ smd.sections = (Elf_Shdr *) (kernel_img + section_offset);
+
+ /* Relocate sections then symbols in the virtual address space. */
+ s = (Elf_Shdr *) ((char *) smd.sections
+ + grub_host_to_target16 (e->e_shstrndx) * smd.section_entsize);
+ smd.strtab = (char *) e + grub_host_to_target_addr (s->sh_offset);
+
+ smd.addrs = xcalloc (smd.num_sections, sizeof (*smd.addrs));
+ smd.vaddrs = xcalloc (smd.num_sections, sizeof (*smd.vaddrs));
+
+ SUFFIX (locate_sections) (e, kernel_path, &smd, layout, image_target);
+
+ if (!is_relocatable (image_target))
+ {
+ Elf_Addr current_address = layout->kernel_size;
+
+ for (i = 0, s = smd.sections;
+ i < smd.num_sections;
+ i++, s = (Elf_Shdr *) ((char *) s + smd.section_entsize))
+ if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS)
+ {
+ Elf_Word sec_align = grub_host_to_target_addr (s->sh_addralign);
+ const char *name = smd.strtab + grub_host_to_target32 (s->sh_name);
+
+ if (sec_align)
+ current_address = ALIGN_UP (current_address
+ + image_target->vaddr_offset,
+ sec_align)
+ - image_target->vaddr_offset;
+
+ grub_util_info ("locating the section %s at 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ name, (unsigned long long) current_address);
+ if (!is_relocatable (image_target))
+ current_address = grub_host_to_target_addr (s->sh_addr)
+ - image_target->link_addr;
+
+ smd.vaddrs[i] = current_address
+ + image_target->vaddr_offset;
+ current_address += grub_host_to_target_addr (s->sh_size);
+ }
+ current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
+ image_target->section_align)
+ - image_target->vaddr_offset;
+ layout->bss_size = current_address - layout->kernel_size;
+ }
+ else
+ layout->bss_size = 0;
+
+ if (image_target->id == IMAGE_SPARC64_AOUT
+ || image_target->id == IMAGE_SPARC64_RAW
+ || image_target->id == IMAGE_UBOOT
+ || image_target->id == IMAGE_COREBOOT
+ || image_target->id == IMAGE_SPARC64_CDCORE)
+ layout->kernel_size = ALIGN_UP (layout->kernel_size, image_target->mod_align);
+
+ if (is_relocatable (image_target))
+ {
+ smd.symtab = NULL;
+ for (i = 0, s = smd.sections;
+ i < smd.num_sections;
+ i++, s = (Elf_Shdr *) ((char *) s + smd.section_entsize))
+ if (s->sh_type == grub_host_to_target32 (SHT_SYMTAB))
+ {
+ smd.symtab = s;
+ break;
+ }
+ if (! smd.symtab)
+ grub_util_error ("%s", _("no symbol table"));
+#ifdef MKIMAGE_ELF64
+ if (image_target->elf_target == EM_IA_64)
+ {
+ grub_size_t tramp;
+
+ layout->kernel_size = ALIGN_UP (layout->kernel_size, 16);
+
+ grub_ia64_dl_get_tramp_got_size (e, &tramp, &layout->got_size);
+
+ layout->tramp_off = layout->kernel_size;
+ layout->kernel_size += ALIGN_UP (tramp, 16);
+
+ layout->ia64jmp_off = layout->kernel_size;
+ layout->ia64jmpnum = SUFFIX (count_funcs) (e, smd.symtab,
+ image_target);
+ layout->kernel_size += 16 * layout->ia64jmpnum;
+
+ layout->got_off = layout->kernel_size;
+ layout->kernel_size += ALIGN_UP (layout->got_size, 16);
+ }
+ if (image_target->elf_target == EM_AARCH64)
+ {
+ grub_size_t tramp;
+
+ layout->kernel_size = ALIGN_UP (layout->kernel_size, 16);
+
+ grub_arm64_dl_get_tramp_got_size (e, &tramp, &layout->got_size);
+
+ layout->got_off = layout->kernel_size;
+ layout->kernel_size += ALIGN_UP (layout->got_size, 16);
+ }
+#endif
+
+ if (image_target->id == IMAGE_EFI)
+ layout->kernel_size = ALIGN_UP (layout->kernel_size,
+ GRUB_PE32_FILE_ALIGNMENT);
+ }
+ else
+ {
+ layout->reloc_size = 0;
+ layout->reloc_section = NULL;
+ }
+
+ out_img = xmalloc (layout->kernel_size + total_module_size);
+ memset (out_img, 0, layout->kernel_size + total_module_size);
+
+ if (is_relocatable (image_target))
+ {
+ layout->start_address = SUFFIX (relocate_symbols) (e, &smd,
+ (char *) out_img + layout->ia64jmp_off,
+ layout->ia64jmp_off + image_target->vaddr_offset,
+ layout->bss_start, layout->end, image_target);
+
+ if (layout->start_address == (Elf_Addr) -1)
+ grub_util_error ("start symbol is not defined");
+
+ /* Resolve addrs in the virtual address space. */
+ SUFFIX (relocate_addrs) (e, &smd, out_img, layout->tramp_off,
+ layout->got_off, image_target);
+
+ make_reloc_section (e, layout, &smd, image_target);
+ if (image_target->id != IMAGE_EFI)
+ {
+ out_img = xrealloc (out_img, layout->kernel_size + total_module_size
+ + ALIGN_UP (layout->reloc_size, image_target->mod_align));
+ memcpy (out_img + layout->kernel_size, layout->reloc_section, layout->reloc_size);
+ memset (out_img + layout->kernel_size + layout->reloc_size, 0,
+ total_module_size + ALIGN_UP (layout->reloc_size, image_target->mod_align) - layout->reloc_size);
+ layout->kernel_size += ALIGN_UP (layout->reloc_size, image_target->mod_align);
+ }
+ }
+
+ for (i = 0, s = smd.sections;
+ i < smd.num_sections;
+ i++, s = (Elf_Shdr *) ((char *) s + smd.section_entsize))
+ if (SUFFIX (is_kept_section) (s, image_target))
+ {
+ if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS)
+ memset (out_img + smd.addrs[i], 0,
+ grub_host_to_target_addr (s->sh_size));
+ else
+ memcpy (out_img + smd.addrs[i],
+ kernel_img + grub_host_to_target_addr (s->sh_offset),
+ grub_host_to_target_addr (s->sh_size));
+ }
+ free (kernel_img);
+
+ free (smd.vaddrs);
+ smd.vaddrs = NULL;
+ free (smd.addrs);
+ smd.addrs = NULL;
+
+ return out_img;
+}