summaryrefslogtreecommitdiffstats
path: root/include/grub/util
diff options
context:
space:
mode:
Diffstat (limited to 'include/grub/util')
-rw-r--r--include/grub/util/install.h299
-rw-r--r--include/grub/util/libnvpair.h38
-rw-r--r--include/grub/util/libzfs.h47
-rw-r--r--include/grub/util/misc.h52
-rw-r--r--include/grub/util/mkimage.h187
-rw-r--r--include/grub/util/ofpath.h6
-rw-r--r--include/grub/util/resolve.h36
-rw-r--r--include/grub/util/windows.h33
8 files changed, 698 insertions, 0 deletions
diff --git a/include/grub/util/install.h b/include/grub/util/install.h
new file mode 100644
index 0000000..7df3191
--- /dev/null
+++ b/include/grub/util/install.h
@@ -0,0 +1,299 @@
+/*
+ * 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/>.
+ */
+
+#ifndef GRUB_UTIL_INSTALL_HEADER
+#define GRUB_UTIL_INSTALL_HEADER 1
+
+#include <sys/types.h>
+#include <stdio.h>
+
+#include <grub/device.h>
+#include <grub/disk.h>
+#include <grub/emu/hostfile.h>
+
+#define GRUB_INSTALL_OPTIONS \
+ { "modules", GRUB_INSTALL_OPTIONS_MODULES, N_("MODULES"), \
+ 0, N_("pre-load specified modules MODULES"), 1 }, \
+ { "dtb", GRUB_INSTALL_OPTIONS_DTB, N_("FILE"), \
+ 0, N_("embed a specific DTB"), 1 }, \
+ { "install-modules", GRUB_INSTALL_OPTIONS_INSTALL_MODULES, \
+ N_("MODULES"), 0, \
+ N_("install only MODULES and their dependencies [default=all]"), 1 }, \
+ { "themes", GRUB_INSTALL_OPTIONS_INSTALL_THEMES, N_("THEMES"), \
+ 0, N_("install THEMES [default=%s]"), 1 }, \
+ { "fonts", GRUB_INSTALL_OPTIONS_INSTALL_FONTS, N_("FONTS"), \
+ 0, N_("install FONTS [default=%s]"), 1 }, \
+ { "locales", GRUB_INSTALL_OPTIONS_INSTALL_LOCALES, N_("LOCALES"),\
+ 0, N_("install only LOCALES [default=all]"), 1 }, \
+ { "compress", GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS, \
+ "no|xz|gz|lzo", 0, \
+ N_("compress GRUB files [optional]"), 1 }, \
+ {"core-compress", GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS, \
+ "xz|none|auto", \
+ 0, N_("choose the compression to use for core image"), 2}, \
+ /* TRANSLATORS: platform here isn't identifier. It can be translated. */ \
+ { "directory", 'd', N_("DIR"), 0, \
+ N_("use images and modules under DIR [default=%s/<platform>]"), 1 }, \
+ { "override-directory", GRUB_INSTALL_OPTIONS_DIRECTORY2, \
+ N_("DIR"), OPTION_HIDDEN, \
+ N_("use images and modules under DIR [default=%s/<platform>]"), 1 }, \
+ { "locale-directory", GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY, \
+ N_("DIR"), 0, \
+ N_("use translations under DIR [default=%s]"), 1 }, \
+ { "themes-directory", GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY, \
+ N_("DIR"), OPTION_HIDDEN, \
+ N_("use themes under DIR [default=%s]"), 1 }, \
+ { "grub-mkimage", GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE, \
+ "FILE", OPTION_HIDDEN, 0, 1 }, \
+ /* TRANSLATORS: "embed" is a verb (command description). "*/ \
+ { "pubkey", 'k', N_("FILE"), 0, \
+ N_("embed FILE as public key for signature checking"), 0}, \
+ { "sbat", GRUB_INSTALL_OPTIONS_SBAT, N_("FILE"), 0, \
+ N_("SBAT metadata"), 0 }, \
+ { "disable-shim-lock", GRUB_INSTALL_OPTIONS_DISABLE_SHIM_LOCK, 0, 0, \
+ N_("disable shim_lock verifier"), 0 }, \
+ { "verbose", 'v', 0, 0, \
+ N_("print verbose messages."), 1 }
+
+int
+grub_install_parse (int key, char *arg);
+
+void
+grub_install_push_module (const char *val);
+
+void
+grub_install_pop_module (void);
+
+char *
+grub_install_help_filter (int key, const char *text,
+ void *input __attribute__ ((unused)));
+
+enum grub_install_plat
+ {
+ GRUB_INSTALL_PLATFORM_I386_PC,
+ GRUB_INSTALL_PLATFORM_I386_EFI,
+ GRUB_INSTALL_PLATFORM_I386_QEMU,
+ GRUB_INSTALL_PLATFORM_I386_COREBOOT,
+ GRUB_INSTALL_PLATFORM_I386_MULTIBOOT,
+ GRUB_INSTALL_PLATFORM_I386_IEEE1275,
+ GRUB_INSTALL_PLATFORM_X86_64_EFI,
+ GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON,
+ GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275,
+ GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275,
+ GRUB_INSTALL_PLATFORM_MIPSEL_ARC,
+ GRUB_INSTALL_PLATFORM_MIPS_ARC,
+ GRUB_INSTALL_PLATFORM_IA64_EFI,
+ GRUB_INSTALL_PLATFORM_ARM_UBOOT,
+ GRUB_INSTALL_PLATFORM_ARM_EFI,
+ GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS,
+ GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS,
+ GRUB_INSTALL_PLATFORM_I386_XEN,
+ GRUB_INSTALL_PLATFORM_X86_64_XEN,
+ GRUB_INSTALL_PLATFORM_I386_XEN_PVH,
+ GRUB_INSTALL_PLATFORM_ARM64_EFI,
+ GRUB_INSTALL_PLATFORM_ARM_COREBOOT,
+ GRUB_INSTALL_PLATFORM_RISCV32_EFI,
+ GRUB_INSTALL_PLATFORM_RISCV64_EFI,
+ GRUB_INSTALL_PLATFORM_MAX
+ };
+
+enum grub_install_options {
+ GRUB_INSTALL_OPTIONS_DIRECTORY = 'd',
+ GRUB_INSTALL_OPTIONS_VERBOSITY = 'v',
+ GRUB_INSTALL_OPTIONS_MODULES = 0x201,
+ GRUB_INSTALL_OPTIONS_INSTALL_MODULES,
+ GRUB_INSTALL_OPTIONS_INSTALL_THEMES,
+ GRUB_INSTALL_OPTIONS_INSTALL_FONTS,
+ GRUB_INSTALL_OPTIONS_INSTALL_LOCALES,
+ GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS,
+ GRUB_INSTALL_OPTIONS_DIRECTORY2,
+ GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY,
+ GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY,
+ GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE,
+ GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS,
+ GRUB_INSTALL_OPTIONS_DTB,
+ GRUB_INSTALL_OPTIONS_SBAT,
+ GRUB_INSTALL_OPTIONS_DISABLE_SHIM_LOCK
+};
+
+extern char *grub_install_source_directory;
+
+enum grub_install_plat
+grub_install_get_target (const char *src);
+void
+grub_install_mkdir_p (const char *dst);
+
+void
+grub_install_copy_files (const char *src,
+ const char *dst,
+ enum grub_install_plat platid);
+char *
+grub_install_get_platform_name (enum grub_install_plat platid);
+
+const char *
+grub_install_get_platform_cpu (enum grub_install_plat platid);
+
+const char *
+grub_install_get_platform_platform (enum grub_install_plat platid);
+
+char *
+grub_install_get_platforms_string (void);
+
+typedef enum {
+ GRUB_COMPRESSION_AUTO,
+ GRUB_COMPRESSION_NONE,
+ GRUB_COMPRESSION_XZ,
+ GRUB_COMPRESSION_LZMA
+} grub_compression_t;
+
+void
+grub_install_make_image_wrap (const char *dir, const char *prefix,
+ const char *outname, char *memdisk_path,
+ char *config_path,
+ const char *format, int note);
+void
+grub_install_make_image_wrap_file (const char *dir, const char *prefix,
+ FILE *fp, const char *outname,
+ char *memdisk_path,
+ char *config_path,
+ const char *mkimage_target, int note);
+
+int
+grub_install_copy_file (const char *src,
+ const char *dst,
+ int is_critical);
+
+struct grub_install_image_target_desc;
+
+void
+grub_install_generate_image (const char *dir, const char *prefix,
+ FILE *out,
+ const char *outname, char *mods[],
+ char *memdisk_path, char **pubkey_paths,
+ size_t npubkeys,
+ char *config_path,
+ const struct grub_install_image_target_desc *image_target,
+ int note,
+ grub_compression_t comp, const char *dtb_file,
+ const char *sbat_path, const int disable_shim_lock);
+
+const struct grub_install_image_target_desc *
+grub_install_get_image_target (const char *arg);
+
+void
+grub_util_bios_setup (const char *dir,
+ const char *boot_file, const char *core_file,
+ const char *dest, int force,
+ int fs_probe, int allow_floppy,
+ int add_rs_codes, int warn_short_mbr_gap);
+void
+grub_util_sparc_setup (const char *dir,
+ const char *boot_file, const char *core_file,
+ const char *dest, int force,
+ int fs_probe, int allow_floppy,
+ int add_rs_codes, int warn_short_mbr_gap);
+
+char *
+grub_install_get_image_targets_string (void);
+
+const char *
+grub_util_get_target_dirname (const struct grub_install_image_target_desc *t);
+
+void
+grub_install_create_envblk_file (const char *name);
+
+const char *
+grub_install_get_default_arm_platform (void);
+
+const char *
+grub_install_get_default_x86_platform (void);
+
+int
+grub_install_register_efi (grub_device_t efidir_grub_dev,
+ const char *efifile_path,
+ const char *efi_distributor);
+
+void
+grub_install_register_ieee1275 (int is_prep, const char *install_device,
+ int partno, const char *relpath);
+
+void
+grub_install_sgi_setup (const char *install_device,
+ const char *imgfile, const char *destname);
+
+int
+grub_install_compress_gzip (const char *src, const char *dest);
+int
+grub_install_compress_lzop (const char *src, const char *dest);
+int
+grub_install_compress_xz (const char *src, const char *dest);
+
+void
+grub_install_get_blocklist (grub_device_t root_dev,
+ const char *core_path, const char *core_img,
+ size_t core_size,
+ void (*callback) (grub_disk_addr_t sector,
+ unsigned offset,
+ unsigned length,
+ void *data),
+ void *hook_data);
+
+void
+grub_util_create_envblk_file (const char *name);
+
+void
+grub_util_glue_efi (const char *file32, const char *file64, const char *out);
+
+void
+grub_util_render_label (const char *label_font,
+ const char *label_bgcolor,
+ const char *label_color,
+ const char *label_string,
+ const char *label);
+
+const char *
+grub_util_get_target_name (const struct grub_install_image_target_desc *t);
+
+extern char *grub_install_copy_buffer;
+#define GRUB_INSTALL_COPY_BUFFER_SIZE 1048576
+
+int
+grub_install_is_short_mbrgap_supported (void);
+
+/*
+ * grub-install-common tries to make backups of modules & auxiliary files,
+ * and restore the backup upon failure to install core.img. There are
+ * platforms with additional actions after modules & core got installed
+ * in place. It is a point of no return, as core.img cannot be reverted
+ * from this point onwards, and new modules should be kept installed.
+ * Before performing these additional actions call grub_set_install_backup_ponr()
+ * to set the grub_install_backup_ponr flag. This way failure to perform
+ * subsequent actions will not result in reverting new modules to the
+ * old ones, e.g. in case efivars updates fails.
+ */
+#ifdef HAVE_ATEXIT
+extern void
+grub_set_install_backup_ponr (void);
+#else
+static inline void
+grub_set_install_backup_ponr (void)
+{
+}
+#endif
+
+#endif
diff --git a/include/grub/util/libnvpair.h b/include/grub/util/libnvpair.h
new file mode 100644
index 0000000..573c7ea
--- /dev/null
+++ b/include/grub/util/libnvpair.h
@@ -0,0 +1,38 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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/>.
+ */
+
+#ifndef GRUB_LIBNVPAIR_UTIL_HEADER
+#define GRUB_LIBNVPAIR_UTIL_HEADER 1
+
+#include <config.h>
+
+#ifdef HAVE_LIBNVPAIR_H
+#include <libnvpair.h>
+#else /* ! HAVE_LIBNVPAIR_H */
+
+#include <stdio.h> /* FILE */
+
+typedef void nvlist_t;
+
+int nvlist_lookup_string (nvlist_t *, const char *, char **);
+int nvlist_lookup_nvlist (nvlist_t *, const char *, nvlist_t **);
+int nvlist_lookup_nvlist_array (nvlist_t *, const char *, nvlist_t ***, unsigned int *);
+
+#endif /* ! HAVE_LIBNVPAIR_H */
+
+#endif
diff --git a/include/grub/util/libzfs.h b/include/grub/util/libzfs.h
new file mode 100644
index 0000000..a02caa3
--- /dev/null
+++ b/include/grub/util/libzfs.h
@@ -0,0 +1,47 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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/>.
+ */
+
+#ifndef GRUB_LIBZFS_UTIL_HEADER
+#define GRUB_LIBZFS_UTIL_HEADER 1
+
+#include <config.h>
+
+#ifdef HAVE_LIBZFS_H
+#include <libzfs.h>
+#else /* ! HAVE_LIBZFS_H */
+
+#include <grub/util/libnvpair.h>
+
+typedef void libzfs_handle_t;
+typedef void zpool_handle_t;
+
+extern libzfs_handle_t *libzfs_init (void);
+extern void libzfs_fini (libzfs_handle_t *);
+
+extern zpool_handle_t *zpool_open (libzfs_handle_t *, const char *);
+extern void zpool_close (zpool_handle_t *);
+
+extern int zpool_get_physpath (zpool_handle_t *, const char *);
+
+extern nvlist_t *zpool_get_config (zpool_handle_t *, nvlist_t **);
+
+#endif /* ! HAVE_LIBZFS_H */
+
+libzfs_handle_t *grub_get_libzfs_handle (void);
+
+#endif
diff --git a/include/grub/util/misc.h b/include/grub/util/misc.h
new file mode 100644
index 0000000..e9e0a67
--- /dev/null
+++ b/include/grub/util/misc.h
@@ -0,0 +1,52 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,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/>.
+ */
+
+#ifndef GRUB_UTIL_MISC_HEADER
+#define GRUB_UTIL_MISC_HEADER 1
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <setjmp.h>
+#include <unistd.h>
+
+#include <config.h>
+#include <grub/types.h>
+#include <grub/symbol.h>
+#include <grub/emu/misc.h>
+
+char *grub_util_get_path (const char *dir, const char *file);
+size_t grub_util_get_image_size (const char *path);
+char *grub_util_read_image (const char *path);
+void grub_util_load_image (const char *path, char *buf);
+void grub_util_write_image (const char *img, size_t size, FILE *out,
+ const char *name);
+void grub_util_write_image_at (const void *img, size_t size, off_t offset,
+ FILE *out, const char *name);
+
+char *make_system_path_relative_to_its_root (const char *path);
+
+char *grub_canonicalize_file_name (const char *path);
+
+void grub_util_init_nls (void);
+
+void grub_util_host_init (int *argc, char ***argv);
+
+int grub_qsort_strcmp (const void *, const void *);
+
+#endif /* ! GRUB_UTIL_MISC_HEADER */
diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h
new file mode 100644
index 0000000..3819a67
--- /dev/null
+++ b/include/grub/util/mkimage.h
@@ -0,0 +1,187 @@
+/*
+ * 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/>.
+ */
+
+#ifndef GRUB_UTIL_MKIMAGE_HEADER
+#define GRUB_UTIL_MKIMAGE_HEADER 1
+
+struct grub_mkimage_layout
+{
+ size_t exec_size;
+ size_t kernel_size;
+ size_t bss_size;
+ size_t sbat_size;
+ grub_uint64_t start_address;
+ void *reloc_section;
+ size_t reloc_size;
+ size_t align;
+ grub_size_t ia64jmp_off;
+ grub_size_t tramp_off;
+ grub_size_t got_off;
+ grub_size_t got_size;
+ unsigned ia64jmpnum;
+ grub_uint32_t bss_start;
+ grub_uint32_t end;
+};
+
+/* Private header. Use only in mkimage-related sources. */
+char *
+grub_mkimage_load_image32 (const char *kernel_path,
+ size_t total_module_size,
+ struct grub_mkimage_layout *layout,
+ const struct grub_install_image_target_desc *image_target);
+char *
+grub_mkimage_load_image64 (const char *kernel_path,
+ size_t total_module_size,
+ struct grub_mkimage_layout *layout,
+ const struct grub_install_image_target_desc *image_target);
+void
+grub_mkimage_generate_elf32 (const struct grub_install_image_target_desc *image_target,
+ int note, char **core_img, size_t *core_size,
+ Elf32_Addr target_addr,
+ struct grub_mkimage_layout *layout);
+void
+grub_mkimage_generate_elf64 (const struct grub_install_image_target_desc *image_target,
+ int note, char **core_img, size_t *core_size,
+ Elf64_Addr target_addr,
+ struct grub_mkimage_layout *layout);
+
+struct grub_install_image_target_desc
+{
+ const char *dirname;
+ const char *names[6];
+ grub_size_t voidp_sizeof;
+ int bigendian;
+ enum {
+ IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT,
+ IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_SPARC64_CDCORE,
+ IMAGE_I386_IEEE1275,
+ IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH,
+ IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC,
+ IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT, IMAGE_XEN, IMAGE_I386_PC_ELTORITO,
+ IMAGE_XEN_PVH
+ } id;
+ enum
+ {
+ PLATFORM_FLAGS_NONE = 0,
+ PLATFORM_FLAGS_DECOMPRESSORS = 2,
+ PLATFORM_FLAGS_MODULES_BEFORE_KERNEL = 4,
+ } flags;
+ unsigned total_module_size;
+ unsigned decompressor_compressed_size;
+ unsigned decompressor_uncompressed_size;
+ unsigned decompressor_uncompressed_addr;
+ unsigned reloc_table_offset;
+ unsigned link_align;
+ grub_uint16_t elf_target;
+ unsigned section_align;
+ signed vaddr_offset;
+ grub_uint64_t link_addr;
+ unsigned mod_gap, mod_align;
+ grub_compression_t default_compression;
+ grub_uint16_t pe_target;
+};
+
+#define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x)))
+#define grub_host_to_target32(x) (grub_host_to_target32_real (image_target, (x)))
+#define grub_target_to_host64(x) (grub_target_to_host64_real (image_target, (x)))
+#define grub_host_to_target64(x) (grub_host_to_target64_real (image_target, (x)))
+#define grub_host_to_target_addr(x) (grub_host_to_target_addr_real (image_target, (x)))
+#define grub_target_to_host16(x) (grub_target_to_host16_real (image_target, (x)))
+#define grub_host_to_target16(x) (grub_host_to_target16_real (image_target, (x)))
+
+static inline grub_uint32_t
+grub_target_to_host32_real (const struct grub_install_image_target_desc *image_target,
+ grub_uint32_t in)
+{
+ if (image_target->bigendian)
+ return grub_be_to_cpu32 (in);
+ else
+ return grub_le_to_cpu32 (in);
+}
+
+static inline grub_uint64_t
+grub_target_to_host64_real (const struct grub_install_image_target_desc *image_target,
+ grub_uint64_t in)
+{
+ if (image_target->bigendian)
+ return grub_be_to_cpu64 (in);
+ else
+ return grub_le_to_cpu64 (in);
+}
+
+static inline grub_uint64_t
+grub_host_to_target64_real (const struct grub_install_image_target_desc *image_target,
+ grub_uint64_t in)
+{
+ if (image_target->bigendian)
+ return grub_cpu_to_be64 (in);
+ else
+ return grub_cpu_to_le64 (in);
+}
+
+static inline grub_uint32_t
+grub_host_to_target32_real (const struct grub_install_image_target_desc *image_target,
+ grub_uint32_t in)
+{
+ if (image_target->bigendian)
+ return grub_cpu_to_be32 (in);
+ else
+ return grub_cpu_to_le32 (in);
+}
+
+static inline grub_uint16_t
+grub_target_to_host16_real (const struct grub_install_image_target_desc *image_target,
+ grub_uint16_t in)
+{
+ if (image_target->bigendian)
+ return grub_be_to_cpu16 (in);
+ else
+ return grub_le_to_cpu16 (in);
+}
+
+static inline grub_uint16_t
+grub_host_to_target16_real (const struct grub_install_image_target_desc *image_target,
+ grub_uint16_t in)
+{
+ if (image_target->bigendian)
+ return grub_cpu_to_be16 (in);
+ else
+ return grub_cpu_to_le16 (in);
+}
+
+static inline grub_uint64_t
+grub_host_to_target_addr_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in)
+{
+ if (image_target->voidp_sizeof == 8)
+ return grub_host_to_target64_real (image_target, in);
+ else
+ return grub_host_to_target32_real (image_target, in);
+}
+
+static inline grub_uint64_t
+grub_target_to_host_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in)
+{
+ if (image_target->voidp_sizeof == 8)
+ return grub_target_to_host64_real (image_target, in);
+ else
+ return grub_target_to_host32_real (image_target, in);
+}
+
+#define grub_target_to_host(val) grub_target_to_host_real(image_target, (val))
+
+#endif
diff --git a/include/grub/util/ofpath.h b/include/grub/util/ofpath.h
new file mode 100644
index 0000000..b43c523
--- /dev/null
+++ b/include/grub/util/ofpath.h
@@ -0,0 +1,6 @@
+#ifndef GRUB_OFPATH_MACHINE_UTIL_HEADER
+#define GRUB_OFPATH_MACHINE_UTIL_HEADER 1
+
+char *grub_util_devname_to_ofpath (const char *devname);
+
+#endif /* ! GRUB_OFPATH_MACHINE_UTIL_HEADER */
diff --git a/include/grub/util/resolve.h b/include/grub/util/resolve.h
new file mode 100644
index 0000000..8923a6e
--- /dev/null
+++ b/include/grub/util/resolve.h
@@ -0,0 +1,36 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2007 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_UTIL_RESOLVE_HEADER
+#define GRUB_UTIL_RESOLVE_HEADER 1
+
+struct grub_util_path_list
+{
+ const char *name;
+ struct grub_util_path_list *next;
+};
+
+/* Resolve the dependencies of the modules MODULES using the information
+ in the file DEP_LIST_FILE. The directory PREFIX is used to find files. */
+struct grub_util_path_list *
+grub_util_resolve_dependencies (const char *prefix,
+ const char *dep_list_file,
+ char *modules[]);
+void grub_util_free_path_list (struct grub_util_path_list *path_list);
+
+#endif /* ! GRUB_UTIL_RESOLVE_HEADER */
diff --git a/include/grub/util/windows.h b/include/grub/util/windows.h
new file mode 100644
index 0000000..6309483
--- /dev/null
+++ b/include/grub/util/windows.h
@@ -0,0 +1,33 @@
+/*
+ * 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/>.
+ */
+
+#ifndef GRUB_WINDOWS_UTIL_HEADER
+#define GRUB_WINDOWS_UTIL_HEADER 1
+
+#include <windows.h>
+
+LPTSTR
+grub_util_get_windows_path (const char *unix_path);
+
+char *
+grub_util_tchar_to_utf8 (LPCTSTR in);
+
+TCHAR *
+grub_get_mount_point (const TCHAR *path);
+
+#endif