aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJames <james.mckenzie@citrix.com>2012-11-16 10:41:01 +0000
committerJames <james.mckenzie@citrix.com>2012-11-16 10:41:01 +0000
commit041d1ea37802bf7178a31a53f96c26efa6b8fb7b (patch)
treec193e84ad1237f25a79d0f6a267722e44c73f56a /include
downloadgrub-1.99-041d1ea37802bf7178a31a53f96c26efa6b8fb7b.tar.gz
grub-1.99-041d1ea37802bf7178a31a53f96c26efa6b8fb7b.tar.bz2
grub-1.99-041d1ea37802bf7178a31a53f96c26efa6b8fb7b.zip
fish
Diffstat (limited to 'include')
-rw-r--r--include/grub/acorn_filecore.h53
-rw-r--r--include/grub/acpi.h176
-rw-r--r--include/grub/aout.h128
-rw-r--r--include/grub/at_keyboard.h38
-rw-r--r--include/grub/ata.h177
-rw-r--r--include/grub/auth.h37
-rw-r--r--include/grub/autoefi.h64
-rw-r--r--include/grub/bitmap.h70
-rw-r--r--include/grub/bitmap_scale.h49
-rw-r--r--include/grub/boot.h27
-rw-r--r--include/grub/bsdlabel.h91
-rw-r--r--include/grub/bufio.h28
-rw-r--r--include/grub/cache.h50
-rw-r--r--include/grub/charset.h134
-rw-r--r--include/grub/cmos.h72
-rw-r--r--include/grub/command.h123
-rw-r--r--include/grub/crypto.h277
-rw-r--r--include/grub/cs5536.h190
-rw-r--r--include/grub/datetime.h55
-rw-r--r--include/grub/decompressor.h34
-rw-r--r--include/grub/deflate.h26
-rw-r--r--include/grub/device.h41
-rw-r--r--include/grub/disk.h189
-rw-r--r--include/grub/dl.h171
-rw-r--r--include/grub/efi/api.h1296
-rw-r--r--include/grub/efi/console.h31
-rw-r--r--include/grub/efi/console_control.h57
-rw-r--r--include/grub/efi/disk.h33
-rw-r--r--include/grub/efi/efi.h77
-rw-r--r--include/grub/efi/graphics_output.h96
-rw-r--r--include/grub/efi/memory.h38
-rw-r--r--include/grub/efi/pe32.h315
-rw-r--r--include/grub/efi/time.h30
-rw-r--r--include/grub/efi/uga_draw.h76
-rw-r--r--include/grub/efiemu/efiemu.h289
-rw-r--r--include/grub/efiemu/runtime.h37
-rw-r--r--include/grub/elf.h2378
-rw-r--r--include/grub/elfload.h66
-rw-r--r--include/grub/emu/console.h28
-rw-r--r--include/grub/emu/getroot.h38
-rw-r--r--include/grub/emu/hostdisk.h33
-rw-r--r--include/grub/emu/misc.h83
-rw-r--r--include/grub/env.h69
-rw-r--r--include/grub/env_private.h46
-rw-r--r--include/grub/err.h75
-rw-r--r--include/grub/extcmd.h79
-rw-r--r--include/grub/fbblit.h182
-rw-r--r--include/grub/fbfill.h75
-rw-r--r--include/grub/fbutil.h43
-rw-r--r--include/grub/file.h129
-rw-r--r--include/grub/font.h125
-rw-r--r--include/grub/fontformat.h38
-rw-r--r--include/grub/fs.h112
-rw-r--r--include/grub/fshelp.h82
-rw-r--r--include/grub/gfxmenu_model.h1
-rw-r--r--include/grub/gfxmenu_view.h115
-rw-r--r--include/grub/gfxterm.h44
-rw-r--r--include/grub/gfxwidgets.h50
-rw-r--r--include/grub/gpt_partition.h71
-rw-r--r--include/grub/gui.h275
-rw-r--r--include/grub/gui_string_util.h37
-rw-r--r--include/grub/hfs.h61
-rw-r--r--include/grub/i18n.h68
-rw-r--r--include/grub/i386/at_keyboard.h25
-rw-r--r--include/grub/i386/bsd.h122
-rw-r--r--include/grub/i386/cmos.h28
-rw-r--r--include/grub/i386/coreboot/boot.h1
-rw-r--r--include/grub/i386/coreboot/console.h25
-rw-r--r--include/grub/i386/coreboot/lbio.h49
-rw-r--r--include/grub/i386/coreboot/memory.h56
-rw-r--r--include/grub/i386/coreboot/serial.h24
-rw-r--r--include/grub/i386/coreboot/time.h1
-rw-r--r--include/grub/i386/cpuid.h24
-rw-r--r--include/grub/i386/efi/memory.h1
-rw-r--r--include/grub/i386/efi/serial.h1
-rw-r--r--include/grub/i386/efi/time.h24
-rw-r--r--include/grub/i386/efiemu.h33
-rw-r--r--include/grub/i386/floppy.h36
-rw-r--r--include/grub/i386/freebsd_linker.h74
-rw-r--r--include/grub/i386/freebsd_reboot.h77
-rw-r--r--include/grub/i386/ieee1275/ieee1275.h1
-rw-r--r--include/grub/i386/ieee1275/memory.h1
-rw-r--r--include/grub/i386/ieee1275/serial.h1
-rw-r--r--include/grub/i386/ieee1275/time.h1
-rw-r--r--include/grub/i386/io.h72
-rw-r--r--include/grub/i386/linux.h285
-rw-r--r--include/grub/i386/macho.h46
-rw-r--r--include/grub/i386/memory.h63
-rw-r--r--include/grub/i386/multiboot.h36
-rw-r--r--include/grub/i386/multiboot/boot.h1
-rw-r--r--include/grub/i386/multiboot/console.h1
-rw-r--r--include/grub/i386/multiboot/kernel.h1
-rw-r--r--include/grub/i386/multiboot/memory.h1
-rw-r--r--include/grub/i386/multiboot/serial.h1
-rw-r--r--include/grub/i386/multiboot/time.h1
-rw-r--r--include/grub/i386/netbsd_bootinfo.h138
-rw-r--r--include/grub/i386/netbsd_reboot.h81
-rw-r--r--include/grub/i386/openbsd_bootarg.h82
-rw-r--r--include/grub/i386/openbsd_reboot.h79
-rw-r--r--include/grub/i386/pc/apm.h48
-rw-r--r--include/grub/i386/pc/biosdisk.h109
-rw-r--r--include/grub/i386/pc/biosnum.h6
-rw-r--r--include/grub/i386/pc/boot.h73
-rw-r--r--include/grub/i386/pc/chainloader.h30
-rw-r--r--include/grub/i386/pc/console.h47
-rw-r--r--include/grub/i386/pc/int.h53
-rw-r--r--include/grub/i386/pc/kernel.h49
-rw-r--r--include/grub/i386/pc/loader.h27
-rw-r--r--include/grub/i386/pc/memory.h97
-rw-r--r--include/grub/i386/pc/pxe.h328
-rw-r--r--include/grub/i386/pc/time.h29
-rw-r--r--include/grub/i386/pc/vbe.h217
-rw-r--r--include/grub/i386/pc/vesa_modes_table.h19
-rw-r--r--include/grub/i386/pc/vga.h28
-rw-r--r--include/grub/i386/pci.h89
-rw-r--r--include/grub/i386/pit.h27
-rw-r--r--include/grub/i386/qemu/boot.h25
-rw-r--r--include/grub/i386/qemu/console.h1
-rw-r--r--include/grub/i386/qemu/kernel.h41
-rw-r--r--include/grub/i386/qemu/memory.h42
-rw-r--r--include/grub/i386/qemu/serial.h1
-rw-r--r--include/grub/i386/qemu/time.h1
-rw-r--r--include/grub/i386/relocator.h74
-rw-r--r--include/grub/i386/setjmp.h33
-rw-r--r--include/grub/i386/time.h29
-rw-r--r--include/grub/i386/tsc.h141
-rw-r--r--include/grub/i386/types.h31
-rw-r--r--include/grub/i386/vga_common.h32
-rw-r--r--include/grub/i386/xnu.h118
-rw-r--r--include/grub/icon_manager.h41
-rw-r--r--include/grub/ieee1275/console.h31
-rw-r--r--include/grub/ieee1275/ieee1275.h201
-rw-r--r--include/grub/ieee1275/ofdisk.h25
-rw-r--r--include/grub/kernel.h96
-rw-r--r--include/grub/keyboard_layouts.h142
-rw-r--r--include/grub/legacy_parse.h27
-rw-r--r--include/grub/lib/LzFind.h130
-rw-r--r--include/grub/lib/LzHash.h77
-rw-r--r--include/grub/lib/LzmaDec.h246
-rw-r--r--include/grub/lib/LzmaEnc.h95
-rw-r--r--include/grub/lib/LzmaTypes.h151
-rw-r--r--include/grub/lib/arg.h79
-rw-r--r--include/grub/lib/cmdline.h31
-rw-r--r--include/grub/lib/crc.h25
-rw-r--r--include/grub/lib/envblk.h55
-rw-r--r--include/grub/lib/hexdump.h25
-rw-r--r--include/grub/libgcc.h85
-rw-r--r--include/grub/libpciaccess.h26
-rw-r--r--include/grub/libusb.h29
-rw-r--r--include/grub/list.h117
-rw-r--r--include/grub/loader.h66
-rw-r--r--include/grub/lvm.h137
-rw-r--r--include/grub/macho.h124
-rw-r--r--include/grub/machoload.h73
-rw-r--r--include/grub/memory.h73
-rw-r--r--include/grub/menu.h103
-rw-r--r--include/grub/menu_viewer.h48
-rw-r--r--include/grub/mips/at_keyboard.h1
-rw-r--r--include/grub/mips/cache.h27
-rw-r--r--include/grub/mips/cmos.h1
-rw-r--r--include/grub/mips/io.h62
-rw-r--r--include/grub/mips/loongson.h90
-rw-r--r--include/grub/mips/memory.h1
-rw-r--r--include/grub/mips/multiboot.h31
-rw-r--r--include/grub/mips/pci.h1
-rw-r--r--include/grub/mips/qemu-mips/kernel.h32
-rw-r--r--include/grub/mips/qemu-mips/loader.h0
-rw-r--r--include/grub/mips/qemu-mips/memory.h52
-rw-r--r--include/grub/mips/qemu-mips/serial.h24
-rw-r--r--include/grub/mips/qemu-mips/time.h34
-rw-r--r--include/grub/mips/relocator.h38
-rw-r--r--include/grub/mips/setjmp.h27
-rw-r--r--include/grub/mips/time.h6
-rw-r--r--include/grub/mips/types.h38
-rw-r--r--include/grub/mips/yeeloong/at_keyboard.h25
-rw-r--r--include/grub/mips/yeeloong/cmos.h28
-rw-r--r--include/grub/mips/yeeloong/ec.h41
-rw-r--r--include/grub/mips/yeeloong/kernel.h31
-rw-r--r--include/grub/mips/yeeloong/memory.h81
-rw-r--r--include/grub/mips/yeeloong/pci.h121
-rw-r--r--include/grub/mips/yeeloong/serial.h30
-rw-r--r--include/grub/mips/yeeloong/time.h37
-rw-r--r--include/grub/misc.h368
-rw-r--r--include/grub/mm.h75
-rw-r--r--include/grub/mm_private.h64
-rw-r--r--include/grub/msdos_partition.h124
-rw-r--r--include/grub/multiboot.h92
-rw-r--r--include/grub/multiboot_loader.h28
-rw-r--r--include/grub/net.h72
-rw-r--r--include/grub/normal.h138
-rw-r--r--include/grub/ns8250.h80
-rw-r--r--include/grub/ntfs.h183
-rw-r--r--include/grub/offsets.h182
-rw-r--r--include/grub/parser.h91
-rw-r--r--include/grub/partition.h134
-rw-r--r--include/grub/parttool.h58
-rw-r--r--include/grub/pci.h137
-rw-r--r--include/grub/pciutils.h103
-rw-r--r--include/grub/powerpc/ieee1275/biosdisk.h46
-rw-r--r--include/grub/powerpc/ieee1275/ieee1275.h28
-rw-r--r--include/grub/powerpc/ieee1275/time.h29
-rw-r--r--include/grub/powerpc/ieee1275/util/biosdisk.h27
-rw-r--r--include/grub/powerpc/kernel.h22
-rw-r--r--include/grub/powerpc/memory.h47
-rw-r--r--include/grub/powerpc/relocator.h37
-rw-r--r--include/grub/powerpc/setjmp.h27
-rw-r--r--include/grub/powerpc/time.h28
-rw-r--r--include/grub/powerpc/types.h32
-rw-r--r--include/grub/raid.h96
-rw-r--r--include/grub/reader.h29
-rw-r--r--include/grub/reed_solomon.h30
-rw-r--r--include/grub/relocator.h58
-rw-r--r--include/grub/relocator_private.h113
-rw-r--r--include/grub/script_sh.h405
-rw-r--r--include/grub/scsi.h106
-rw-r--r--include/grub/scsicmd.h166
-rw-r--r--include/grub/sdl.h24
-rw-r--r--include/grub/search.h29
-rw-r--r--include/grub/serial.h123
-rw-r--r--include/grub/setjmp.h33
-rw-r--r--include/grub/smbus.h70
-rw-r--r--include/grub/sparc64/ieee1275/boot.h64
-rw-r--r--include/grub/sparc64/ieee1275/ieee1275.h48
-rw-r--r--include/grub/sparc64/ieee1275/kernel.h37
-rw-r--r--include/grub/sparc64/ieee1275/time.h29
-rw-r--r--include/grub/sparc64/setjmp.h29
-rw-r--r--include/grub/sparc64/time.h28
-rw-r--r--include/grub/sparc64/types.h32
-rw-r--r--include/grub/symbol.h52
-rw-r--r--include/grub/term.h471
-rw-r--r--include/grub/terminfo.h81
-rw-r--r--include/grub/test.h85
-rw-r--r--include/grub/time.h47
-rw-r--r--include/grub/tparm.h26
-rw-r--r--include/grub/trig.h44
-rw-r--r--include/grub/types.h218
-rw-r--r--include/grub/unicode.h272
-rw-r--r--include/grub/usb.h288
-rw-r--r--include/grub/usbdesc.h125
-rw-r--r--include/grub/usbserial.h34
-rw-r--r--include/grub/usbtrans.h153
-rw-r--r--include/grub/util/deviceiter.h11
-rw-r--r--include/grub/util/libnvpair.h39
-rw-r--r--include/grub/util/libzfs.h47
-rw-r--r--include/grub/util/lvm.h27
-rw-r--r--include/grub/util/misc.h63
-rw-r--r--include/grub/util/ofpath.h6
-rw-r--r--include/grub/util/raid.h27
-rw-r--r--include/grub/util/resolve.h35
-rw-r--r--include/grub/vga.h371
-rw-r--r--include/grub/video.h431
-rw-r--r--include/grub/video_fb.h136
-rw-r--r--include/grub/x86_64/at_keyboard.h1
-rw-r--r--include/grub/x86_64/efi/boot.h0
-rw-r--r--include/grub/x86_64/efi/loader.h26
-rw-r--r--include/grub/x86_64/efi/memory.h1
-rw-r--r--include/grub/x86_64/efi/serial.h1
-rw-r--r--include/grub/x86_64/efi/time.h24
-rw-r--r--include/grub/x86_64/io.h19
-rw-r--r--include/grub/x86_64/linux.h19
-rw-r--r--include/grub/x86_64/macho.h1
-rw-r--r--include/grub/x86_64/memory.h1
-rw-r--r--include/grub/x86_64/multiboot.h1
-rw-r--r--include/grub/x86_64/pci.h19
-rw-r--r--include/grub/x86_64/relocator.h1
-rw-r--r--include/grub/x86_64/setjmp.h27
-rw-r--r--include/grub/x86_64/time.h29
-rw-r--r--include/grub/x86_64/types.h31
-rw-r--r--include/grub/x86_64/xnu.h1
-rw-r--r--include/grub/xnu.h116
-rw-r--r--include/grub/zfs/dmu.h119
-rw-r--r--include/grub/zfs/dmu_objset.h43
-rw-r--r--include/grub/zfs/dnode.h80
-rw-r--r--include/grub/zfs/dsl_dataset.h52
-rw-r--r--include/grub/zfs/dsl_dir.h48
-rw-r--r--include/grub/zfs/sa_impl.h34
-rw-r--r--include/grub/zfs/spa.h310
-rw-r--r--include/grub/zfs/uberblock_impl.h60
-rw-r--r--include/grub/zfs/vdev_impl.h69
-rw-r--r--include/grub/zfs/zap_impl.h111
-rw-r--r--include/grub/zfs/zap_leaf.h103
-rw-r--r--include/grub/zfs/zfs.h123
-rw-r--r--include/grub/zfs/zfs_acl.h59
-rw-r--r--include/grub/zfs/zfs_znode.h70
-rw-r--r--include/grub/zfs/zil.h56
-rw-r--r--include/grub/zfs/zio.h84
-rw-r--r--include/grub/zfs/zio_checksum.h49
-rw-r--r--include/multiboot.h274
-rw-r--r--include/multiboot2.h366
289 files changed, 24951 insertions, 0 deletions
diff --git a/include/grub/acorn_filecore.h b/include/grub/acorn_filecore.h
new file mode 100644
index 0000000..6cda6cf
--- /dev/null
+++ b/include/grub/acorn_filecore.h
@@ -0,0 +1,53 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2005,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_ACORN_FILECORE_HEADER
+#define GRUB_ACORN_FILECORE_HEADER 1
+
+#include <grub/types.h>
+
+struct grub_filecore_disc_record
+{
+ grub_uint8_t log2secsize;
+ grub_uint8_t secspertrack;
+ grub_uint8_t heads;
+ grub_uint8_t density;
+ grub_uint8_t idlen;
+ grub_uint8_t log2bpmb;
+ grub_uint8_t skew;
+ grub_uint8_t bootoption;
+ /* In bits 0-5, flags in bits 6 and 7. */
+ grub_uint8_t lowsector;
+ grub_uint8_t nzones;
+ grub_uint16_t zone_spare;
+ grub_uint32_t root_address;
+ /* Disc size in bytes. */
+ grub_uint32_t disc_size;
+ grub_uint16_t cycle_id;
+ char disc_name[10];
+ /* Yes, it is 32 bits! */
+ grub_uint32_t disctype;
+ /* Most significant part of the disc size. */
+ grub_uint32_t disc_size2;
+ grub_uint8_t share_size;
+ grub_uint8_t big_flag;
+ grub_uint8_t reserved[18];
+};
+
+
+#endif /* ! GRUB_ACORN_FILECORE_HEADER */
diff --git a/include/grub/acpi.h b/include/grub/acpi.h
new file mode 100644
index 0000000..c843a06
--- /dev/null
+++ b/include/grub/acpi.h
@@ -0,0 +1,176 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_ACPI_HEADER
+#define GRUB_ACPI_HEADER 1
+
+#ifndef GRUB_DSDT_TEST
+#include <grub/types.h>
+#include <grub/err.h>
+#endif
+
+struct grub_acpi_rsdp_v10
+{
+ grub_uint8_t signature[8];
+ grub_uint8_t checksum;
+ grub_uint8_t oemid[6];
+ grub_uint8_t revision;
+ grub_uint32_t rsdt_addr;
+} __attribute__ ((packed));
+
+struct grub_acpi_rsdp_v20
+{
+ struct grub_acpi_rsdp_v10 rsdpv1;
+ grub_uint32_t length;
+ grub_uint64_t xsdt_addr;
+ grub_uint8_t checksum;
+ grub_uint8_t reserved[3];
+} __attribute__ ((packed));
+
+struct grub_acpi_table_header
+{
+ grub_uint8_t signature[4];
+ grub_uint32_t length;
+ grub_uint8_t revision;
+ grub_uint8_t checksum;
+ grub_uint8_t oemid[6];
+ grub_uint8_t oemtable[8];
+ grub_uint32_t oemrev;
+ grub_uint8_t creator_id[4];
+ grub_uint32_t creator_rev;
+} __attribute__ ((packed));
+
+#define GRUB_ACPI_FADT_SIGNATURE "FACP"
+
+struct grub_acpi_fadt
+{
+ struct grub_acpi_table_header hdr;
+ grub_uint32_t facs_addr;
+ grub_uint32_t dsdt_addr;
+ grub_uint8_t somefields1[20];
+ grub_uint32_t pm1a;
+ grub_uint8_t somefields2[64];
+ grub_uint64_t facs_xaddr;
+ grub_uint64_t dsdt_xaddr;
+ grub_uint8_t somefields3[96];
+} __attribute__ ((packed));
+
+#define GRUB_ACPI_MADT_SIGNATURE "APIC"
+
+struct grub_acpi_madt_entry_header
+{
+ grub_uint8_t type;
+ grub_uint8_t len;
+};
+
+struct grub_acpi_madt
+{
+ struct grub_acpi_table_header hdr;
+ grub_uint32_t lapic_addr;
+ grub_uint32_t flags;
+ struct grub_acpi_madt_entry_header entries[0];
+};
+
+enum
+ {
+ GRUB_ACPI_MADT_ENTRY_TYPE_INTERRUPT_OVERRIDE = 2,
+ GRUB_ACPI_MADT_ENTRY_TYPE_SAPIC = 6,
+ GRUB_ACPI_MADT_ENTRY_TYPE_LSAPIC = 7,
+ GRUB_ACPI_MADT_ENTRY_TYPE_PLATFORM_INT_SOURCE = 8
+ };
+
+struct grub_acpi_madt_entry_interrupt_override
+{
+ struct grub_acpi_madt_entry_header hdr;
+ grub_uint8_t bus;
+ grub_uint8_t source;
+ grub_uint32_t global_sys_interrupt;
+ grub_uint16_t flags;
+};
+
+struct grub_acpi_madt_entry_sapic
+{
+ struct grub_acpi_madt_entry_header hdr;
+ grub_uint8_t id;
+ grub_uint8_t pad;
+ grub_uint32_t global_sys_interrupt_base;
+ grub_uint64_t addr;
+};
+
+struct grub_acpi_madt_entry_lsapic
+{
+ struct grub_acpi_madt_entry_header hdr;
+ grub_uint8_t cpu_id;
+ grub_uint8_t id;
+ grub_uint8_t eid;
+ grub_uint8_t pad[3];
+ grub_uint32_t flags;
+ grub_uint32_t cpu_uid;
+ grub_uint8_t cpu_uid_str[0];
+};
+
+struct grub_acpi_madt_entry_platform_int_source
+{
+ struct grub_acpi_madt_entry_header hdr;
+ grub_uint16_t flags;
+ grub_uint8_t inttype;
+ grub_uint8_t cpu_id;
+ grub_uint8_t cpu_eid;
+ grub_uint8_t sapic_vector;
+ grub_uint32_t global_sys_int;
+ grub_uint32_t src_flags;
+};
+
+enum
+ {
+ GRUB_ACPI_MADT_ENTRY_SAPIC_FLAGS_ENABLED = 1
+ };
+
+#ifndef GRUB_DSDT_TEST
+struct grub_acpi_rsdp_v10 *grub_acpi_get_rsdpv1 (void);
+struct grub_acpi_rsdp_v20 *grub_acpi_get_rsdpv2 (void);
+struct grub_acpi_rsdp_v10 *grub_machine_acpi_get_rsdpv1 (void);
+struct grub_acpi_rsdp_v20 *grub_machine_acpi_get_rsdpv2 (void);
+grub_uint8_t grub_byte_checksum (void *base, grub_size_t size);
+
+grub_err_t grub_acpi_create_ebda (void);
+
+void grub_acpi_halt (void);
+#endif
+
+#define GRUB_ACPI_SLP_EN (1 << 13)
+#define GRUB_ACPI_SLP_TYP_OFFSET 10
+
+enum
+ {
+ GRUB_ACPI_OPCODE_ZERO = 0, GRUB_ACPI_OPCODE_ONE = 1,
+ GRUB_ACPI_OPCODE_NAME = 8, GRUB_ACPI_OPCODE_BYTE_CONST = 0x0a,
+ GRUB_ACPI_OPCODE_WORD_CONST = 0x0b, GRUB_ACPI_OPCODE_DWORD_CONST = 0x0c,
+ GRUB_ACPI_OPCODE_SCOPE = 0x10, GRUB_ACPI_OPCODE_PACKAGE = 0x12,
+ GRUB_ACPI_OPCODE_METHOD = 0x14, GRUB_ACPI_OPCODE_EXTOP = 0x5b,
+ GRUB_ACPI_OPCODE_IF = 0xa0, GRUB_ACPI_OPCODE_ONES = 0xff
+ };
+enum
+ {
+ GRUB_ACPI_EXTOPCODE_MUTEX = 0x01,
+ GRUB_ACPI_EXTOPCODE_OPERATION_REGION = 0x80,
+ GRUB_ACPI_EXTOPCODE_FIELD_OP = 0x81,
+ GRUB_ACPI_EXTOPCODE_INDEX_FIELD_OP = 0x86,
+ };
+
+#endif /* ! GRUB_ACPI_HEADER */
diff --git a/include/grub/aout.h b/include/grub/aout.h
new file mode 100644
index 0000000..10d7dde
--- /dev/null
+++ b/include/grub/aout.h
@@ -0,0 +1,128 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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/>.
+ */
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)exec.h 8.1 (Berkeley) 6/11/93
+ * $FreeBSD$
+ */
+
+#ifndef GRUB_AOUT_HEADER
+#define GRUB_AOUT_HEADER 1
+
+#include <grub/types.h>
+
+struct grub_aout32_header
+{
+ grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
+ grub_uint32_t a_text; /* text segment size */
+ grub_uint32_t a_data; /* initialized data size */
+ grub_uint32_t a_bss; /* uninitialized data size */
+ grub_uint32_t a_syms; /* symbol table size */
+ grub_uint32_t a_entry; /* entry point */
+ grub_uint32_t a_trsize; /* text relocation size */
+ grub_uint32_t a_drsize; /* data relocation size */
+};
+
+struct grub_aout64_header
+{
+ grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
+ grub_uint64_t a_text; /* text segment size */
+ grub_uint64_t a_data; /* initialized data size */
+ grub_uint64_t a_bss; /* uninitialized data size */
+ grub_uint64_t a_syms; /* symbol table size */
+ grub_uint64_t a_entry; /* entry point */
+ grub_uint64_t a_trsize; /* text relocation size */
+ grub_uint64_t a_drsize; /* data relocation size */
+};
+
+union grub_aout_header
+{
+ struct grub_aout32_header aout32;
+ struct grub_aout64_header aout64;
+};
+
+#define AOUT_TYPE_NONE 0
+#define AOUT_TYPE_AOUT32 1
+#define AOUT_TYPE_AOUT64 6
+
+#define AOUT32_OMAGIC 0x107 /* 0407 old impure format */
+#define AOUT32_NMAGIC 0x108 /* 0410 read-only text */
+#define AOUT32_ZMAGIC 0x10b /* 0413 demand load format */
+#define AOUT32_QMAGIC 0xcc /* 0314 "compact" demand load format */
+
+#define AOUT64_OMAGIC 0x1001
+#define AOUT64_ZMAGIC 0x1002
+#define AOUT64_NMAGIC 0x1003
+
+#define AOUT_MID_ZERO 0 /* unknown - implementation dependent */
+#define AOUT_MID_SUN010 1 /* sun 68010/68020 binary */
+#define AOUT_MID_SUN020 2 /* sun 68020-only binary */
+#define AOUT_MID_I386 134 /* i386 BSD binary */
+#define AOUT_MID_SPARC 138 /* sparc */
+#define AOUT_MID_HP200 200 /* hp200 (68010) BSD binary */
+#define AOUT_MID_SUN 0x103
+#define AOUT_MID_HP300 300 /* hp300 (68020+68881) BSD binary */
+#define AOUT_MID_HPUX 0x20C /* hp200/300 HP-UX binary */
+#define AOUT_MID_HPUX800 0x20B /* hp800 HP-UX binary */
+
+#define AOUT_FLAG_PIC 0x10 /* contains position independent code */
+#define AOUT_FLAG_DYNAMIC 0x20 /* contains run-time link-edit info */
+#define AOUT_FLAG_DPMASK 0x30 /* mask for the above */
+
+#define AOUT_GETMAGIC(header) ((header).a_midmag & 0xffff)
+#define AOUT_GETMID(header) ((header).a_midmag >> 16) & 0x03ff)
+#define AOUT_GETFLAG(header) ((header).a_midmag >> 26) & 0x3f)
+
+#ifndef GRUB_UTIL
+
+int EXPORT_FUNC(grub_aout_get_type) (union grub_aout_header *header);
+
+grub_err_t EXPORT_FUNC(grub_aout_load) (grub_file_t file, int offset,
+ void *load_addr, int load_size,
+ grub_size_t bss_size);
+
+#endif
+
+#endif /* ! GRUB_AOUT_HEADER */
diff --git a/include/grub/at_keyboard.h b/include/grub/at_keyboard.h
new file mode 100644
index 0000000..65cf8a2
--- /dev/null
+++ b/include/grub/at_keyboard.h
@@ -0,0 +1,38 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_AT_KEYBOARD_HEADER
+#define GRUB_AT_KEYBOARD_HEADER 1
+
+/* Used for sending commands to the controller. */
+#define KEYBOARD_COMMAND_ISREADY(x) !((x) & 0x02)
+#define KEYBOARD_COMMAND_READ 0x20
+#define KEYBOARD_COMMAND_WRITE 0x60
+#define KEYBOARD_COMMAND_REBOOT 0xfe
+
+#define KEYBOARD_AT_TRANSLATE 0x40
+
+#define GRUB_AT_ACK 0xfa
+#define GRUB_AT_NACK 0xfe
+#define GRUB_AT_TRIES 5
+
+#define KEYBOARD_ISMAKE(x) !((x) & 0x80)
+#define KEYBOARD_ISREADY(x) ((x) & 0x01)
+#define KEYBOARD_SCANCODE(x) ((x) & 0x7f)
+
+#endif
diff --git a/include/grub/ata.h b/include/grub/ata.h
new file mode 100644
index 0000000..c8f4e5e
--- /dev/null
+++ b/include/grub/ata.h
@@ -0,0 +1,177 @@
+/* ata.h - ATA disk access. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_ATA_HEADER
+#define GRUB_ATA_HEADER 1
+
+#include <grub/misc.h>
+#include <grub/symbol.h>
+/* XXX: For now this only works on i386. */
+#include <grub/cpu/io.h>
+
+typedef enum
+ {
+ GRUB_ATA_CHS,
+ GRUB_ATA_LBA,
+ GRUB_ATA_LBA48
+ } grub_ata_addressing_t;
+
+#define GRUB_ATA_CH0_PORT1 0x1f0
+#define GRUB_ATA_CH1_PORT1 0x170
+
+#define GRUB_ATA_CH0_PORT2 0x3f6
+#define GRUB_ATA_CH1_PORT2 0x376
+
+#define GRUB_ATA_REG_DATA 0
+#define GRUB_ATA_REG_ERROR 1
+#define GRUB_ATA_REG_FEATURES 1
+#define GRUB_ATA_REG_SECTORS 2
+#define GRUB_ATAPI_REG_IREASON 2
+#define GRUB_ATA_REG_SECTNUM 3
+#define GRUB_ATA_REG_CYLLSB 4
+#define GRUB_ATA_REG_CYLMSB 5
+#define GRUB_ATA_REG_LBALOW 3
+#define GRUB_ATA_REG_LBAMID 4
+#define GRUB_ATAPI_REG_CNTLOW 4
+#define GRUB_ATA_REG_LBAHIGH 5
+#define GRUB_ATAPI_REG_CNTHIGH 5
+#define GRUB_ATA_REG_DISK 6
+#define GRUB_ATA_REG_CMD 7
+#define GRUB_ATA_REG_STATUS 7
+
+#define GRUB_ATA_REG2_CONTROL 0
+
+#define GRUB_ATA_STATUS_ERR 0x01
+#define GRUB_ATA_STATUS_INDEX 0x02
+#define GRUB_ATA_STATUS_ECC 0x04
+#define GRUB_ATA_STATUS_DRQ 0x08
+#define GRUB_ATA_STATUS_SEEK 0x10
+#define GRUB_ATA_STATUS_WRERR 0x20
+#define GRUB_ATA_STATUS_READY 0x40
+#define GRUB_ATA_STATUS_BUSY 0x80
+
+/* ATAPI interrupt reason values (I/O, D/C bits). */
+#define GRUB_ATAPI_IREASON_MASK 0x3
+#define GRUB_ATAPI_IREASON_DATA_OUT 0x0
+#define GRUB_ATAPI_IREASON_CMD_OUT 0x1
+#define GRUB_ATAPI_IREASON_DATA_IN 0x2
+#define GRUB_ATAPI_IREASON_ERROR 0x3
+
+enum grub_ata_commands
+ {
+ GRUB_ATA_CMD_CHECK_POWER_MODE = 0xe5,
+ GRUB_ATA_CMD_IDENTIFY_DEVICE = 0xec,
+ GRUB_ATA_CMD_IDENTIFY_PACKET_DEVICE = 0xa1,
+ GRUB_ATA_CMD_IDLE = 0xe3,
+ GRUB_ATA_CMD_PACKET = 0xa0,
+ GRUB_ATA_CMD_READ_SECTORS = 0x20,
+ GRUB_ATA_CMD_READ_SECTORS_EXT = 0x24,
+ GRUB_ATA_CMD_SECURITY_FREEZE_LOCK = 0xf5,
+ GRUB_ATA_CMD_SET_FEATURES = 0xef,
+ GRUB_ATA_CMD_SLEEP = 0xe6,
+ GRUB_ATA_CMD_SMART = 0xb0,
+ GRUB_ATA_CMD_STANDBY_IMMEDIATE = 0xe0,
+ GRUB_ATA_CMD_WRITE_SECTORS = 0x30,
+ GRUB_ATA_CMD_WRITE_SECTORS_EXT = 0x34,
+ };
+
+enum grub_ata_timeout_milliseconds
+ {
+ GRUB_ATA_TOUT_STD = 1000, /* 1s standard timeout. */
+ GRUB_ATA_TOUT_DATA = 10000, /* 10s DATA I/O timeout. */
+ GRUB_ATA_TOUT_DEV_INIT = 10000, /* Give the device 10s on first try to spinon. */
+ };
+
+struct grub_ata_device
+{
+ /* IDE port to use. */
+ int port;
+
+ /* IO addresses on which the registers for this device can be
+ found. */
+ grub_port_t ioaddress;
+ grub_port_t ioaddress2;
+
+ /* Two devices can be connected to a single cable. Use this field
+ to select device 0 (commonly known as "master") or device 1
+ (commonly known as "slave"). */
+ int device;
+
+ /* Addressing methods available for accessing this device. If CHS
+ is only available, use that. Otherwise use LBA, except for the
+ high sectors. In that case use LBA48. */
+ grub_ata_addressing_t addr;
+
+ /* Sector count. */
+ grub_uint64_t size;
+
+ /* CHS maximums. */
+ grub_uint16_t cylinders;
+ grub_uint16_t heads;
+ grub_uint16_t sectors_per_track;
+
+ /* Set to 0 for ATA, set to 1 for ATAPI. */
+ int atapi;
+
+ int present;
+
+ struct grub_ata_device *next;
+};
+
+grub_err_t EXPORT_FUNC(grub_ata_wait_not_busy) (struct grub_ata_device *dev,
+ int milliseconds);
+grub_err_t EXPORT_FUNC(grub_ata_wait_drq) (struct grub_ata_device *dev,
+ int rw, int milliseconds);
+void EXPORT_FUNC(grub_ata_pio_read) (struct grub_ata_device *dev,
+ char *buf, grub_size_t size);
+
+static inline void
+grub_ata_regset (struct grub_ata_device *dev, int reg, int val)
+{
+ grub_outb (val, dev->ioaddress + reg);
+}
+
+static inline grub_uint8_t
+grub_ata_regget (struct grub_ata_device *dev, int reg)
+{
+ return grub_inb (dev->ioaddress + reg);
+}
+
+static inline void
+grub_ata_regset2 (struct grub_ata_device *dev, int reg, int val)
+{
+ grub_outb (val, dev->ioaddress2 + reg);
+}
+
+static inline grub_uint8_t
+grub_ata_regget2 (struct grub_ata_device *dev, int reg)
+{
+ return grub_inb (dev->ioaddress2 + reg);
+}
+
+static inline grub_err_t
+grub_ata_check_ready (struct grub_ata_device *dev)
+{
+ if (grub_ata_regget (dev, GRUB_ATA_REG_STATUS) & GRUB_ATA_STATUS_BUSY)
+ return grub_ata_wait_not_busy (dev, GRUB_ATA_TOUT_STD);
+
+ return GRUB_ERR_NONE;
+}
+
+#endif /* ! GRUB_ATA_HEADER */
diff --git a/include/grub/auth.h b/include/grub/auth.h
new file mode 100644
index 0000000..7473344
--- /dev/null
+++ b/include/grub/auth.h
@@ -0,0 +1,37 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_AUTH_HEADER
+#define GRUB_AUTH_HEADER 1
+
+#include <grub/err.h>
+#include <grub/crypto.h>
+
+#define GRUB_AUTH_MAX_PASSLEN 1024
+
+typedef grub_err_t (*grub_auth_callback_t) (const char *, const char *, void *);
+
+grub_err_t grub_auth_register_authentication (const char *user,
+ grub_auth_callback_t callback,
+ void *arg);
+grub_err_t grub_auth_unregister_authentication (const char *user);
+
+grub_err_t grub_auth_authenticate (const char *user);
+grub_err_t grub_auth_deauthenticate (const char *user);
+grub_err_t grub_auth_check_authentication (const char *userlist);
+
+#endif /* ! GRUB_AUTH_HEADER */
diff --git a/include/grub/autoefi.h b/include/grub/autoefi.h
new file mode 100644
index 0000000..b755911
--- /dev/null
+++ b/include/grub/autoefi.h
@@ -0,0 +1,64 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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/>.
+ */
+/* This file provides some abstractions so that the same code compiles with
+ both efi and efiemu
+ */
+#ifndef GRUB_AUTOEFI_HEADER
+#define GRUB_AUTOEFI_HEADER 1
+
+
+#ifdef GRUB_MACHINE_EFI
+# include <grub/efi/efi.h>
+# define grub_autoefi_get_memory_map grub_efi_get_memory_map
+# define grub_autoefi_finish_boot_services grub_efi_finish_boot_services
+# define grub_autoefi_exit_boot_services grub_efi_exit_boot_services
+# define grub_autoefi_system_table grub_efi_system_table
+# define grub_autoefi_mmap_iterate grub_machine_mmap_iterate
+# define grub_autoefi_set_virtual_address_map grub_efi_set_virtual_address_map
+static inline grub_err_t grub_autoefi_prepare (void)
+{
+ return GRUB_ERR_NONE;
+};
+# define SYSTEM_TABLE_SIZEOF(x) (sizeof(grub_efi_system_table->x))
+# define SYSTEM_TABLE_VAR(x) ((void *)&(grub_efi_system_table->x))
+# define SYSTEM_TABLE_PTR(x) ((void *)(grub_efi_system_table->x))
+# define SIZEOF_OF_UINTN sizeof (grub_efi_uintn_t)
+# define SYSTEM_TABLE(x) (grub_efi_system_table->x)
+# define grub_autoefi_finish_boot_services grub_efi_finish_boot_services
+# define EFI_PRESENT 1
+#else
+# include <grub/efiemu/efiemu.h>
+# define grub_autoefi_get_memory_map grub_efiemu_get_memory_map
+# define grub_autoefi_finish_boot_services grub_efiemu_finish_boot_services
+# define grub_autoefi_exit_boot_services grub_efiemu_exit_boot_services
+# define grub_autoefi_system_table grub_efiemu_system_table
+# define grub_autoefi_mmap_iterate grub_efiemu_mmap_iterate
+# define grub_autoefi_prepare grub_efiemu_prepare
+# define grub_autoefi_set_virtual_address_map grub_efiemu_set_virtual_address_map
+# define SYSTEM_TABLE_SIZEOF GRUB_EFIEMU_SYSTEM_TABLE_SIZEOF
+# define SYSTEM_TABLE_VAR GRUB_EFIEMU_SYSTEM_TABLE_VAR
+# define SYSTEM_TABLE_PTR GRUB_EFIEMU_SYSTEM_TABLE_PTR
+# define SIZEOF_OF_UINTN GRUB_EFIEMU_SIZEOF_OF_UINTN
+# define SYSTEM_TABLE GRUB_EFIEMU_SYSTEM_TABLE
+# define grub_efi_allocate_pages(x,y) (x)
+# define grub_efi_free_pages(x,y) GRUB_EFI_SUCCESS
+# define grub_autoefi_finish_boot_services grub_efiemu_finish_boot_services
+# define EFI_PRESENT 1
+#endif
+
+#endif
diff --git a/include/grub/bitmap.h b/include/grub/bitmap.h
new file mode 100644
index 0000000..6e30039
--- /dev/null
+++ b/include/grub/bitmap.h
@@ -0,0 +1,70 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,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_BITMAP_HEADER
+#define GRUB_BITMAP_HEADER 1
+
+#include <grub/err.h>
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/video.h>
+
+struct grub_video_bitmap
+{
+ /* Bitmap format description. */
+ struct grub_video_mode_info mode_info;
+
+ /* Pointer to bitmap data formatted according to mode_info. */
+ void *data;
+};
+
+struct grub_video_bitmap_reader
+{
+ /* File extension for this bitmap type (including dot). */
+ const char *extension;
+
+ /* Reader function to load bitmap. */
+ grub_err_t (*reader) (struct grub_video_bitmap **bitmap,
+ const char *filename);
+
+ /* Next reader. */
+ struct grub_video_bitmap_reader *next;
+};
+typedef struct grub_video_bitmap_reader *grub_video_bitmap_reader_t;
+
+void EXPORT_FUNC (grub_video_bitmap_reader_register) (grub_video_bitmap_reader_t reader);
+void EXPORT_FUNC (grub_video_bitmap_reader_unregister) (grub_video_bitmap_reader_t reader);
+
+grub_err_t EXPORT_FUNC (grub_video_bitmap_create) (struct grub_video_bitmap **bitmap,
+ unsigned int width, unsigned int height,
+ enum grub_video_blit_format blit_format);
+
+grub_err_t EXPORT_FUNC (grub_video_bitmap_destroy) (struct grub_video_bitmap *bitmap);
+
+grub_err_t EXPORT_FUNC (grub_video_bitmap_load) (struct grub_video_bitmap **bitmap,
+ const char *filename);
+
+unsigned int EXPORT_FUNC (grub_video_bitmap_get_width) (struct grub_video_bitmap *bitmap);
+unsigned int EXPORT_FUNC (grub_video_bitmap_get_height) (struct grub_video_bitmap *bitmap);
+
+void EXPORT_FUNC (grub_video_bitmap_get_mode_info) (struct grub_video_bitmap *bitmap,
+ struct grub_video_mode_info *mode_info);
+
+void *EXPORT_FUNC (grub_video_bitmap_get_data) (struct grub_video_bitmap *bitmap);
+
+#endif /* ! GRUB_BITMAP_HEADER */
diff --git a/include/grub/bitmap_scale.h b/include/grub/bitmap_scale.h
new file mode 100644
index 0000000..dce9fbb
--- /dev/null
+++ b/include/grub/bitmap_scale.h
@@ -0,0 +1,49 @@
+/* bitmap_scale.h - Bitmap scaling functions. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_BITMAP_SCALE_HEADER
+#define GRUB_BITMAP_SCALE_HEADER 1
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/bitmap_scale.h>
+
+enum grub_video_bitmap_scale_method
+{
+ /* Choose the fastest interpolation algorithm. */
+ GRUB_VIDEO_BITMAP_SCALE_METHOD_FASTEST,
+ /* Choose the highest quality interpolation algorithm. */
+ GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST,
+
+ /* Specific algorithms: */
+ /* Nearest neighbor interpolation. */
+ GRUB_VIDEO_BITMAP_SCALE_METHOD_NEAREST,
+ /* Bilinear interpolation. */
+ GRUB_VIDEO_BITMAP_SCALE_METHOD_BILINEAR
+};
+
+grub_err_t
+EXPORT_FUNC (grub_video_bitmap_create_scaled) (struct grub_video_bitmap **dst,
+ int dst_width, int dst_height,
+ struct grub_video_bitmap *src,
+ enum
+ grub_video_bitmap_scale_method
+ scale_method);
+
+#endif /* ! GRUB_BITMAP_SCALE_HEADER */
diff --git a/include/grub/boot.h b/include/grub/boot.h
new file mode 100644
index 0000000..2357748
--- /dev/null
+++ b/include/grub/boot.h
@@ -0,0 +1,27 @@
+/*
+ * 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_BOOT_HEADER
+#define GRUB_BOOT_HEADER 1
+
+#define GRUB_BOOT_VERSION_MAJOR 4
+#define GRUB_BOOT_VERSION_MINOR 0
+#define GRUB_BOOT_VERSION ((GRUB_BOOT_VERSION_MINOR << 8) \
+ | GRUB_BOOT_VERSION_MAJOR)
+
+#endif /* ! GRUB_BOOT_HEADER */
diff --git a/include/grub/bsdlabel.h b/include/grub/bsdlabel.h
new file mode 100644
index 0000000..636bd41
--- /dev/null
+++ b/include/grub/bsdlabel.h
@@ -0,0 +1,91 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2004,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_BSDLABEL_PARTITION_HEADER
+#define GRUB_BSDLABEL_PARTITION_HEADER 1
+
+/* Constants for BSD disk label. */
+#define GRUB_PC_PARTITION_BSD_LABEL_SECTOR 1
+#define GRUB_PC_PARTITION_BSD_LABEL_MAGIC 0x82564557
+
+/* BSD partition types. */
+#define GRUB_PC_PARTITION_BSD_TYPE_UNUSED 0
+#define GRUB_PC_PARTITION_BSD_TYPE_SWAP 1
+#define GRUB_PC_PARTITION_BSD_TYPE_V6 2
+#define GRUB_PC_PARTITION_BSD_TYPE_V7 3
+#define GRUB_PC_PARTITION_BSD_TYPE_SYSV 4
+#define GRUB_PC_PARTITION_BSD_TYPE_V71K 5
+#define GRUB_PC_PARTITION_BSD_TYPE_V8 6
+#define GRUB_PC_PARTITION_BSD_TYPE_BSDFFS 7
+#define GRUB_PC_PARTITION_BSD_TYPE_MSDOS 8
+#define GRUB_PC_PARTITION_BSD_TYPE_BSDLFS 9
+#define GRUB_PC_PARTITION_BSD_TYPE_OTHER 10
+#define GRUB_PC_PARTITION_BSD_TYPE_HPFS 11
+#define GRUB_PC_PARTITION_BSD_TYPE_ISO9660 12
+#define GRUB_PC_PARTITION_BSD_TYPE_BOOT 13
+
+/* FreeBSD-specific types. */
+#define GRUB_PC_PARTITION_FREEBSD_TYPE_VINUM 14
+#define GRUB_PC_PARTITION_FREEBSD_TYPE_RAID 15
+#define GRUB_PC_PARTITION_FREEBSD_TYPE_JFS2 21
+
+/* NetBSD-specific types. */
+#define GRUB_PC_PARTITION_NETBSD_TYPE_ADOS 14
+#define GRUB_PC_PARTITION_NETBSD_TYPE_HFS 15
+#define GRUB_PC_PARTITION_NETBSD_TYPE_FILECORE 16
+#define GRUB_PC_PARTITION_NETBSD_TYPE_EXT2FS 17
+#define GRUB_PC_PARTITION_NETBSD_TYPE_NTFS 18
+#define GRUB_PC_PARTITION_NETBSD_TYPE_RAID 19
+#define GRUB_PC_PARTITION_NETBSD_TYPE_CCD 20
+#define GRUB_PC_PARTITION_NETBSD_TYPE_JFS2 21
+#define GRUB_PC_PARTITION_NETBSD_TYPE_APPLEUFS 22
+
+/* OpenBSD-specific types. */
+#define GRUB_PC_PARTITION_OPENBSD_TYPE_ADOS 14
+#define GRUB_PC_PARTITION_OPENBSD_TYPE_HFS 15
+#define GRUB_PC_PARTITION_OPENBSD_TYPE_FILECORE 16
+#define GRUB_PC_PARTITION_OPENBSD_TYPE_EXT2FS 17
+#define GRUB_PC_PARTITION_OPENBSD_TYPE_NTFS 18
+#define GRUB_PC_PARTITION_OPENBSD_TYPE_RAID 19
+
+#define GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION 2
+
+/* The BSD partition entry. */
+struct grub_partition_bsd_entry
+{
+ grub_uint32_t size;
+ grub_uint32_t offset;
+ grub_uint32_t fragment_size;
+ grub_uint8_t fs_type;
+ grub_uint8_t fs_fragments;
+ grub_uint16_t fs_cylinders;
+} __attribute__ ((packed));
+
+/* The BSD disk label. Only define members useful for GRUB. */
+struct grub_partition_bsd_disk_label
+{
+ grub_uint32_t magic;
+ grub_uint8_t padding[128];
+ grub_uint32_t magic2;
+ grub_uint16_t checksum;
+ grub_uint16_t num_partitions;
+ grub_uint32_t boot_size;
+ grub_uint32_t superblock_size;
+} __attribute__ ((packed));
+
+#endif /* ! GRUB_PC_PARTITION_HEADER */
diff --git a/include/grub/bufio.h b/include/grub/bufio.h
new file mode 100644
index 0000000..acdd0c8
--- /dev/null
+++ b/include/grub/bufio.h
@@ -0,0 +1,28 @@
+/* bufio.h - prototypes for bufio */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_BUFIO_H
+#define GRUB_BUFIO_H 1
+
+#include <grub/file.h>
+
+grub_file_t EXPORT_FUNC (grub_bufio_open) (grub_file_t io, int size);
+grub_file_t EXPORT_FUNC (grub_buffile_open) (const char *name, int size);
+
+#endif /* ! GRUB_BUFIO_H */
diff --git a/include/grub/cache.h b/include/grub/cache.h
new file mode 100644
index 0000000..2928305
--- /dev/null
+++ b/include/grub/cache.h
@@ -0,0 +1,50 @@
+/* cache.h - Flush the processor's cache. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,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_CACHE_H
+#define GRUB_CACHE_H 1
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+#ifdef _mips
+#include <grub/mips/cache.h>
+#endif
+
+#if defined (__i386__) || defined (__x86_64__)
+static inline void
+grub_arch_sync_caches (void *address __attribute__ ((unused)),
+ grub_size_t len __attribute__ ((unused)))
+{
+}
+#else
+void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len);
+#endif
+
+#ifdef _mips
+void EXPORT_FUNC(grub_arch_sync_dma_caches) (void *address, grub_size_t len);
+#else
+static inline void
+grub_arch_sync_dma_caches (void *address __attribute__ ((unused)),
+ grub_size_t len __attribute__ ((unused)))
+{
+}
+#endif
+
+#endif /* ! GRUB_CACHE_HEADER */
diff --git a/include/grub/charset.h b/include/grub/charset.h
new file mode 100644
index 0000000..c8247f7
--- /dev/null
+++ b/include/grub/charset.h
@@ -0,0 +1,134 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,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_CHARSET_HEADER
+#define GRUB_CHARSET_HEADER 1
+
+#include <grub/types.h>
+
+#define GRUB_UINT8_1_LEADINGBIT 0x80
+#define GRUB_UINT8_2_LEADINGBITS 0xc0
+#define GRUB_UINT8_3_LEADINGBITS 0xe0
+#define GRUB_UINT8_4_LEADINGBITS 0xf0
+#define GRUB_UINT8_5_LEADINGBITS 0xf8
+#define GRUB_UINT8_6_LEADINGBITS 0xfc
+#define GRUB_UINT8_7_LEADINGBITS 0xfe
+
+#define GRUB_UINT8_1_TRAILINGBIT 0x01
+#define GRUB_UINT8_2_TRAILINGBITS 0x03
+#define GRUB_UINT8_3_TRAILINGBITS 0x07
+#define GRUB_UINT8_4_TRAILINGBITS 0x0f
+#define GRUB_UINT8_5_TRAILINGBITS 0x1f
+#define GRUB_UINT8_6_TRAILINGBITS 0x3f
+
+#define GRUB_UCS2_LIMIT 0x10000
+#define GRUB_UTF16_UPPER_SURROGATE(code) \
+ (0xD800 + ((((code) - GRUB_UCS2_LIMIT) >> 12) & 0xfff))
+#define GRUB_UTF16_LOWER_SURROGATE(code) \
+ (0xDC00 + (((code) - GRUB_UCS2_LIMIT) & 0xfff))
+
+grub_ssize_t
+grub_utf8_to_utf16 (grub_uint16_t *dest, grub_size_t destsize,
+ const grub_uint8_t *src, grub_size_t srcsize,
+ const grub_uint8_t **srcend);
+
+/* Convert UTF-16 to UTF-8. */
+static inline grub_uint8_t *
+grub_utf16_to_utf8 (grub_uint8_t *dest, grub_uint16_t *src,
+ grub_size_t size)
+{
+ grub_uint32_t code_high = 0;
+
+ while (size--)
+ {
+ grub_uint32_t code = *src++;
+
+ if (code_high)
+ {
+ if (code >= 0xDC00 && code <= 0xDFFF)
+ {
+ /* Surrogate pair. */
+ code = ((code_high - 0xD800) << 12) + (code - 0xDC00) + 0x10000;
+
+ *dest++ = (code >> 18) | 0xF0;
+ *dest++ = ((code >> 12) & 0x3F) | 0x80;
+ *dest++ = ((code >> 6) & 0x3F) | 0x80;
+ *dest++ = (code & 0x3F) | 0x80;
+ }
+ else
+ {
+ /* Error... */
+ *dest++ = '?';
+ }
+
+ code_high = 0;
+ }
+ else
+ {
+ if (code <= 0x007F)
+ *dest++ = code;
+ else if (code <= 0x07FF)
+ {
+ *dest++ = (code >> 6) | 0xC0;
+ *dest++ = (code & 0x3F) | 0x80;
+ }
+ else if (code >= 0xD800 && code <= 0xDBFF)
+ {
+ code_high = code;
+ continue;
+ }
+ else if (code >= 0xDC00 && code <= 0xDFFF)
+ {
+ /* Error... */
+ *dest++ = '?';
+ }
+ else if (code < 0x10000)
+ {
+ *dest++ = (code >> 12) | 0xE0;
+ *dest++ = ((code >> 6) & 0x3F) | 0x80;
+ *dest++ = (code & 0x3F) | 0x80;
+ }
+ else
+ {
+ *dest++ = (code >> 18) | 0xF0;
+ *dest++ = ((code >> 12) & 0x3F) | 0x80;
+ *dest++ = ((code >> 6) & 0x3F) | 0x80;
+ *dest++ = (code & 0x3F) | 0x80;
+ }
+ }
+ }
+
+ return dest;
+}
+
+/* Convert UCS-4 to UTF-8. */
+char *grub_ucs4_to_utf8_alloc (grub_uint32_t *src, grub_size_t size);
+
+int
+grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize);
+
+int grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg,
+ grub_uint32_t **last_position);
+void
+grub_ucs4_to_utf8 (grub_uint32_t *src, grub_size_t size,
+ grub_uint8_t *dest, grub_size_t destsize);
+grub_size_t grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize,
+ const grub_uint8_t *src, grub_size_t srcsize,
+ const grub_uint8_t **srcend);
+
+#endif
diff --git a/include/grub/cmos.h b/include/grub/cmos.h
new file mode 100644
index 0000000..f508e3b
--- /dev/null
+++ b/include/grub/cmos.h
@@ -0,0 +1,72 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_CMOS_H
+#define GRUB_CMOS_H 1
+
+#include <grub/types.h>
+#include <grub/cpu/io.h>
+#include <grub/cpu/cmos.h>
+
+#define GRUB_CMOS_INDEX_SECOND 0
+#define GRUB_CMOS_INDEX_SECOND_ALARM 1
+#define GRUB_CMOS_INDEX_MINUTE 2
+#define GRUB_CMOS_INDEX_MINUTE_ALARM 3
+#define GRUB_CMOS_INDEX_HOUR 4
+#define GRUB_CMOS_INDEX_HOUR_ALARM 5
+#define GRUB_CMOS_INDEX_DAY_OF_WEEK 6
+#define GRUB_CMOS_INDEX_DAY_OF_MONTH 7
+#define GRUB_CMOS_INDEX_MONTH 8
+#define GRUB_CMOS_INDEX_YEAR 9
+
+#define GRUB_CMOS_INDEX_STATUS_A 0xA
+#define GRUB_CMOS_INDEX_STATUS_B 0xB
+#define GRUB_CMOS_INDEX_STATUS_C 0xC
+#define GRUB_CMOS_INDEX_STATUS_D 0xD
+
+#define GRUB_CMOS_STATUS_B_DAYLIGHT 1
+#define GRUB_CMOS_STATUS_B_24HOUR 2
+#define GRUB_CMOS_STATUS_B_BINARY 4
+
+static inline grub_uint8_t
+grub_bcd_to_num (grub_uint8_t a)
+{
+ return ((a >> 4) * 10 + (a & 0xF));
+}
+
+static inline grub_uint8_t
+grub_num_to_bcd (grub_uint8_t a)
+{
+ return (((a / 10) << 4) + (a % 10));
+}
+
+static inline grub_uint8_t
+grub_cmos_read (grub_uint8_t index)
+{
+ grub_outb (index, GRUB_CMOS_ADDR_REG);
+ return grub_inb (GRUB_CMOS_DATA_REG);
+}
+
+static inline void
+grub_cmos_write (grub_uint8_t index, grub_uint8_t value)
+{
+ grub_outb (index, GRUB_CMOS_ADDR_REG);
+ grub_outb (value, GRUB_CMOS_DATA_REG);
+}
+
+#endif /* GRUB_CMOS_H */
diff --git a/include/grub/command.h b/include/grub/command.h
new file mode 100644
index 0000000..1962275
--- /dev/null
+++ b/include/grub/command.h
@@ -0,0 +1,123 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_COMMAND_HEADER
+#define GRUB_COMMAND_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/err.h>
+#include <grub/list.h>
+
+typedef enum grub_command_flags
+ {
+ /* This is an extended command. */
+ GRUB_COMMAND_FLAG_EXTCMD = 0x10,
+ /* This is an dynamic command. */
+ GRUB_COMMAND_FLAG_DYNCMD = 0x20,
+ /* This command accepts block arguments. */
+ GRUB_COMMAND_FLAG_BLOCKS = 0x40,
+ /* This command accepts unknown arguments as direct parameters. */
+ GRUB_COMMAND_ACCEPT_DASH = 0x80,
+ /* This command accepts only options preceding direct arguments. */
+ GRUB_COMMAND_OPTIONS_AT_START = 0x100,
+ /* Can be executed in an entries extractor. */
+ GRUB_COMMAND_FLAG_EXTRACTOR = 0x200
+ } grub_command_flags_t;
+
+struct grub_command;
+
+typedef grub_err_t (*grub_command_func_t) (struct grub_command *cmd,
+ int argc, char **argv);
+
+/* The command description. */
+struct grub_command
+{
+ /* The next element. */
+ struct grub_command *next;
+
+ /* The name. */
+ const char *name;
+
+ /* The priority. */
+ int prio;
+
+ /* The callback function. */
+ grub_command_func_t func;
+
+ /* The flags. */
+ grub_command_flags_t flags;
+
+ /* The summary of the command usage. */
+ const char *summary;
+
+ /* The description of the command. */
+ const char *description;
+
+ /* Arbitrary data. */
+ void *data;
+};
+typedef struct grub_command *grub_command_t;
+
+extern grub_command_t EXPORT_VAR(grub_command_list);
+
+grub_command_t
+EXPORT_FUNC(grub_register_command_prio) (const char *name,
+ grub_command_func_t func,
+ const char *summary,
+ const char *description,
+ int prio);
+void EXPORT_FUNC(grub_unregister_command) (grub_command_t cmd);
+
+static inline grub_command_t
+grub_register_command (const char *name,
+ grub_command_func_t func,
+ const char *summary,
+ const char *description)
+{
+ return grub_register_command_prio (name, func, summary, description, 0);
+}
+
+static inline grub_command_t
+grub_register_command_p1 (const char *name,
+ grub_command_func_t func,
+ const char *summary,
+ const char *description)
+{
+ return grub_register_command_prio (name, func, summary, description, 1);
+}
+
+static inline grub_command_t
+grub_command_find (const char *name)
+{
+ return grub_named_list_find (GRUB_AS_NAMED_LIST (grub_command_list), name);
+}
+
+static inline grub_err_t
+grub_command_execute (const char *name, int argc, char **argv)
+{
+ grub_command_t cmd;
+
+ cmd = grub_command_find (name);
+ return (cmd) ? cmd->func (cmd, argc, argv) : GRUB_ERR_FILE_NOT_FOUND;
+}
+
+#define FOR_COMMANDS(var) FOR_LIST_ELEMENTS((var), grub_command_list)
+
+void grub_register_core_commands (void);
+
+#endif /* ! GRUB_COMMAND_HEADER */
diff --git a/include/grub/crypto.h b/include/grub/crypto.h
new file mode 100644
index 0000000..ebe78e7
--- /dev/null
+++ b/include/grub/crypto.h
@@ -0,0 +1,277 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 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/>.
+ */
+
+/* Contains elements based on gcrypt-module.h and gcrypt.h.in.
+ If it's changed please update this file. */
+
+#ifndef GRUB_CRYPTO_HEADER
+#define GRUB_CRYPTO_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/err.h>
+
+typedef enum
+ {
+ GPG_ERR_NO_ERROR,
+ GPG_ERR_BAD_MPI,
+ GPG_ERR_BAD_SECKEY,
+ GPG_ERR_BAD_SIGNATURE,
+ GPG_ERR_CIPHER_ALGO,
+ GPG_ERR_CONFLICT,
+ GPG_ERR_DECRYPT_FAILED,
+ GPG_ERR_DIGEST_ALGO,
+ GPG_ERR_GENERAL,
+ GPG_ERR_INTERNAL,
+ GPG_ERR_INV_ARG,
+ GPG_ERR_INV_CIPHER_MODE,
+ GPG_ERR_INV_FLAG,
+ GPG_ERR_INV_KEYLEN,
+ GPG_ERR_INV_OBJ,
+ GPG_ERR_INV_OP,
+ GPG_ERR_INV_SEXP,
+ GPG_ERR_INV_VALUE,
+ GPG_ERR_MISSING_VALUE,
+ GPG_ERR_NO_ENCRYPTION_SCHEME,
+ GPG_ERR_NO_OBJ,
+ GPG_ERR_NO_PRIME,
+ GPG_ERR_NO_SIGNATURE_SCHEME,
+ GPG_ERR_NOT_FOUND,
+ GPG_ERR_NOT_IMPLEMENTED,
+ GPG_ERR_NOT_SUPPORTED,
+ GPG_ERROR_CFLAGS,
+ GPG_ERR_PUBKEY_ALGO,
+ GPG_ERR_SELFTEST_FAILED,
+ GPG_ERR_TOO_SHORT,
+ GPG_ERR_UNSUPPORTED,
+ GPG_ERR_WEAK_KEY,
+ GPG_ERR_WRONG_KEY_USAGE,
+ GPG_ERR_WRONG_PUBKEY_ALGO,
+ GPG_ERR_OUT_OF_MEMORY
+ } gcry_err_code_t;
+#define gpg_err_code_t gcry_err_code_t
+#define gpg_error_t gcry_err_code_t
+
+enum gcry_cipher_modes
+ {
+ GCRY_CIPHER_MODE_NONE = 0, /* Not yet specified. */
+ GCRY_CIPHER_MODE_ECB = 1, /* Electronic codebook. */
+ GCRY_CIPHER_MODE_CFB = 2, /* Cipher feedback. */
+ GCRY_CIPHER_MODE_CBC = 3, /* Cipher block chaining. */
+ GCRY_CIPHER_MODE_STREAM = 4, /* Used with stream ciphers. */
+ GCRY_CIPHER_MODE_OFB = 5, /* Outer feedback. */
+ GCRY_CIPHER_MODE_CTR = 6 /* Counter. */
+ };
+
+/* Type for the cipher_setkey function. */
+typedef gcry_err_code_t (*gcry_cipher_setkey_t) (void *c,
+ const unsigned char *key,
+ unsigned keylen);
+
+/* Type for the cipher_encrypt function. */
+typedef void (*gcry_cipher_encrypt_t) (void *c,
+ unsigned char *outbuf,
+ const unsigned char *inbuf);
+
+/* Type for the cipher_decrypt function. */
+typedef void (*gcry_cipher_decrypt_t) (void *c,
+ unsigned char *outbuf,
+ const unsigned char *inbuf);
+
+/* Type for the cipher_stencrypt function. */
+typedef void (*gcry_cipher_stencrypt_t) (void *c,
+ unsigned char *outbuf,
+ const unsigned char *inbuf,
+ unsigned int n);
+
+/* Type for the cipher_stdecrypt function. */
+typedef void (*gcry_cipher_stdecrypt_t) (void *c,
+ unsigned char *outbuf,
+ const unsigned char *inbuf,
+ unsigned int n);
+
+typedef struct gcry_cipher_oid_spec
+{
+ const char *oid;
+ int mode;
+} gcry_cipher_oid_spec_t;
+
+/* Module specification structure for ciphers. */
+typedef struct gcry_cipher_spec
+{
+ const char *name;
+ const char **aliases;
+ gcry_cipher_oid_spec_t *oids;
+ grub_size_t blocksize;
+ grub_size_t keylen;
+ grub_size_t contextsize;
+ gcry_cipher_setkey_t setkey;
+ gcry_cipher_encrypt_t encrypt;
+ gcry_cipher_decrypt_t decrypt;
+ gcry_cipher_stencrypt_t stencrypt;
+ gcry_cipher_stdecrypt_t stdecrypt;
+ struct gcry_cipher_spec *next;
+} gcry_cipher_spec_t;
+
+/* Type for the md_init function. */
+typedef void (*gcry_md_init_t) (void *c);
+
+/* Type for the md_write function. */
+typedef void (*gcry_md_write_t) (void *c, const void *buf, grub_size_t nbytes);
+
+/* Type for the md_final function. */
+typedef void (*gcry_md_final_t) (void *c);
+
+/* Type for the md_read function. */
+typedef unsigned char *(*gcry_md_read_t) (void *c);
+
+typedef struct gcry_md_oid_spec
+{
+ const char *oidstring;
+} gcry_md_oid_spec_t;
+
+/* Module specification structure for message digests. */
+typedef struct gcry_md_spec
+{
+ const char *name;
+ unsigned char *asnoid;
+ int asnlen;
+ gcry_md_oid_spec_t *oids;
+ grub_size_t mdlen;
+ gcry_md_init_t init;
+ gcry_md_write_t write;
+ gcry_md_final_t final;
+ gcry_md_read_t read;
+ grub_size_t contextsize; /* allocate this amount of context */
+ /* Block size, needed for HMAC. */
+ grub_size_t blocksize;
+ struct gcry_md_spec *next;
+} gcry_md_spec_t;
+
+struct grub_crypto_cipher_handle
+{
+ const struct gcry_cipher_spec *cipher;
+ char ctx[0];
+};
+
+typedef struct grub_crypto_cipher_handle *grub_crypto_cipher_handle_t;
+
+struct grub_crypto_hmac_handle;
+
+const gcry_cipher_spec_t *
+grub_crypto_lookup_cipher_by_name (const char *name);
+
+grub_crypto_cipher_handle_t
+grub_crypto_cipher_open (const struct gcry_cipher_spec *cipher);
+
+gcry_err_code_t
+grub_crypto_cipher_set_key (grub_crypto_cipher_handle_t cipher,
+ const unsigned char *key,
+ unsigned keylen);
+
+void
+grub_crypto_cipher_close (grub_crypto_cipher_handle_t cipher);
+
+void
+grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size);
+
+gcry_err_code_t
+grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher,
+ void *out, void *in, grub_size_t size);
+
+gcry_err_code_t
+grub_crypto_ecb_encrypt (grub_crypto_cipher_handle_t cipher,
+ void *out, void *in, grub_size_t size);
+gcry_err_code_t
+grub_crypto_cbc_encrypt (grub_crypto_cipher_handle_t cipher,
+ void *out, void *in, grub_size_t size,
+ void *iv_in);
+gcry_err_code_t
+grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher,
+ void *out, void *in, grub_size_t size,
+ void *iv);
+void
+grub_cipher_register (gcry_cipher_spec_t *cipher);
+void
+grub_cipher_unregister (gcry_cipher_spec_t *cipher);
+void
+grub_md_register (gcry_md_spec_t *digest);
+void
+grub_md_unregister (gcry_md_spec_t *cipher);
+void
+grub_crypto_hash (const gcry_md_spec_t *hash, void *out, const void *in,
+ grub_size_t inlen);
+const gcry_md_spec_t *
+grub_crypto_lookup_md_by_name (const char *name);
+
+grub_err_t
+grub_crypto_gcry_error (gcry_err_code_t in);
+
+void grub_burn_stack (grub_size_t size);
+
+struct grub_crypto_hmac_handle *
+grub_crypto_hmac_init (const struct gcry_md_spec *md,
+ const void *key, grub_size_t keylen);
+void
+grub_crypto_hmac_write (struct grub_crypto_hmac_handle *hnd, void *data,
+ grub_size_t datalen);
+gcry_err_code_t
+grub_crypto_hmac_fini (struct grub_crypto_hmac_handle *hnd, void *out);
+
+gcry_err_code_t
+grub_crypto_hmac_buffer (const struct gcry_md_spec *md,
+ const void *key, grub_size_t keylen,
+ void *data, grub_size_t datalen, void *out);
+
+extern gcry_md_spec_t _gcry_digest_spec_md5;
+extern gcry_md_spec_t _gcry_digest_spec_sha1;
+extern gcry_md_spec_t _gcry_digest_spec_sha256;
+extern gcry_md_spec_t _gcry_digest_spec_sha512;
+extern gcry_md_spec_t _gcry_digest_spec_crc32;
+#define GRUB_MD_MD5 ((const gcry_md_spec_t *) &_gcry_digest_spec_md5)
+#define GRUB_MD_SHA1 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha1)
+#define GRUB_MD_SHA256 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha256)
+#define GRUB_MD_SHA512 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha512)
+#define GRUB_MD_CRC32 ((const gcry_md_spec_t *) &_gcry_digest_spec_crc32)
+
+/* Implement PKCS#5 PBKDF2 as per RFC 2898. The PRF to use is HMAC variant
+ of digest supplied by MD. Inputs are the password P of length PLEN,
+ the salt S of length SLEN, the iteration counter C (> 0), and the
+ desired derived output length DKLEN. Output buffer is DK which
+ must have room for at least DKLEN octets. The output buffer will
+ be filled with the derived data. */
+gcry_err_code_t
+grub_crypto_pbkdf2 (const struct gcry_md_spec *md,
+ const grub_uint8_t *P, grub_size_t Plen,
+ const grub_uint8_t *S, grub_size_t Slen,
+ unsigned int c,
+ grub_uint8_t *DK, grub_size_t dkLen);
+
+int
+grub_crypto_memcmp (const void *a, const void *b, grub_size_t n);
+
+int
+grub_password_get (char buf[], unsigned buf_size);
+
+/* For indistinguishibility. */
+#define GRUB_ACCESS_DENIED grub_error (GRUB_ERR_ACCESS_DENIED, "Access denied.")
+
+extern void (*grub_crypto_autoload_hook) (const char *name);
+
+#endif
diff --git a/include/grub/cs5536.h b/include/grub/cs5536.h
new file mode 100644
index 0000000..cd17e11
--- /dev/null
+++ b/include/grub/cs5536.h
@@ -0,0 +1,190 @@
+/*
+ * 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_CS5536_HEADER
+#define GRUB_CS5536_HEADER 1
+
+#ifndef ASM_FILE
+#include <grub/pci.h>
+#include <grub/err.h>
+#include <grub/smbus.h>
+#endif
+
+#define GRUB_CS5536_PCIID 0x208f1022
+#define GRUB_CS5536_MSR_MAILBOX_ADDR 0xf4
+#define GRUB_CS5536_MSR_MAILBOX_DATA0 0xf8
+#define GRUB_CS5536_MSR_MAILBOX_DATA1 0xfc
+#define GRUB_CS5536_MSR_IRQ_MAP_BAR 0x80000008
+#define GRUB_CS5536_MSR_SMB_BAR 0x8000000b
+
+#define GRUB_CS5536_SMBUS_REGS_SIZE 8
+#define GRUB_CS5536_GPIO_REGS_SIZE 256
+#define GRUB_CS5536_MFGPT_REGS_SIZE 64
+#define GRUB_CS5536_IRQ_MAP_REGS_SIZE 32
+#define GRUB_CS5536_PM_REGS_SIZE 128
+#define GRUB_CS5536_ACPI_REGS_SIZE 32
+
+#define GRUB_CS5536_USB_OPTION_REGS_SIZE 0x1c
+#define GRUB_CS5536_USB_OPTION_REG_UOCMUX 1
+#define GRUB_CS5536_USB_OPTION_REG_UOCMUX_PMUX_MASK 0x03
+#define GRUB_CS5536_USB_OPTION_REG_UOCMUX_PMUX_HC 0x02
+
+#define GRUB_CS5536_DESTINATION_GLIU 0
+#define GRUB_CS5536_DESTINATION_GLPCI_SB 1
+#define GRUB_CS5536_DESTINATION_USB 2
+#define GRUB_CS5536_DESTINATION_IDE 3
+#define GRUB_CS5536_DESTINATION_DD 4
+#define GRUB_CS5536_DESTINATION_ACC 5
+#define GRUB_CS5536_DESTINATION_GLCP 7
+
+#define GRUB_CS5536_P2D_DEST_SHIFT 61
+#define GRUB_CS5536_P2D_LOG_ALIGN 12
+#define GRUB_CS5536_P2D_ALIGN (1 << GRUB_CS5536_P2D_LOG_ALIGN)
+#define GRUB_CS5536_P2D_BASE_SHIFT 20
+#define GRUB_CS5536_P2D_MASK_SHIFT 0
+
+#define GRUB_CS5536_MSR_GL_IOD_START 0x000100e0
+#define GRUB_CS5536_IOD_DEST_SHIFT 61
+#define GRUB_CS5536_IOD_BASE_SHIFT 20
+#define GRUB_CS5536_IOD_MASK_SHIFT 0
+#define GRUB_CS5536_IOD_ADDR_MASK 0xfffff
+
+#define GRUB_CS5536_MSR_GPIO_BAR 0x8000000c
+#define GRUB_CS5536_MSR_MFGPT_BAR 0x8000000d
+#define GRUB_CS5536_MSR_ACPI_BAR 0x8000000e
+#define GRUB_CS5536_MSR_PM_BAR 0x8000000f
+#define GRUB_CS5536_MSR_DIVIL_LEG_IO 0x80000014
+#define GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0 0x00000001
+#define GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1 0x00000002
+#define GRUB_CS5536_MSR_DIVIL_LEG_IO_MODE_X86 0x10000000
+#define GRUB_CS5536_MSR_DIVIL_LEG_IO_F_REMAP 0x04000000
+#define GRUB_CS5536_MSR_DIVIL_IRQ_MAPPER_PRIMARY_MASK 0x80000024
+#define GRUB_CS5536_MSR_DIVIL_IRQ_MAPPER_LPC_MASK 0x80000025
+#define GRUB_CS5536_DIVIL_LPC_INTERRUPTS 0x1002
+#define GRUB_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL 0x8000004e
+#define GRUB_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL_ENABLE 0x80
+
+#define GRUB_CS5536_MSR_USB_OHCI_BASE 0x40000008
+#define GRUB_CS5536_MSR_USB_EHCI_BASE 0x40000009
+#define GRUB_CS5536_MSR_USB_CONTROLLER_BASE 0x4000000a
+#define GRUB_CS5536_MSR_USB_OPTION_CONTROLLER_BASE 0x4000000b
+#define GRUB_CS5536_MSR_USB_BASE_ADDR_MASK 0x00ffffff00ULL
+#define GRUB_CS5536_MSR_USB_BASE_BUS_MASTER 0x0400000000ULL
+#define GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE 0x0200000000ULL
+#define GRUB_CS5536_MSR_USB_BASE_PME_ENABLED 0x0800000000ULL
+#define GRUB_CS5536_MSR_USB_BASE_PME_STATUS 0x1000000000ULL
+#define GRUB_CS5536_MSR_USB_EHCI_BASE_FLDJ_SHIFT 40
+
+#define GRUB_CS5536_MSR_IDE_IO_BAR 0x60000008
+#define GRUB_CS5536_MSR_IDE_IO_BAR_UNITS 1
+#define GRUB_CS5536_MSR_IDE_IO_BAR_ADDR_MASK 0xfffffff0
+#define GRUB_CS5536_MSR_IDE_CFG 0x60000010
+#define GRUB_CS5536_MSR_IDE_CFG_CHANNEL_ENABLE 2
+#define GRUB_CS5536_MSR_IDE_TIMING 0x60000012
+#define GRUB_CS5536_MSR_IDE_TIMING_PIO0 0x98
+#define GRUB_CS5536_MSR_IDE_TIMING_DRIVE0_SHIFT 24
+#define GRUB_CS5536_MSR_IDE_TIMING_DRIVE1_SHIFT 16
+#define GRUB_CS5536_MSR_IDE_CAS_TIMING 0x60000013
+#define GRUB_CS5536_MSR_IDE_CAS_TIMING_CMD_PIO0 0x99
+#define GRUB_CS5536_MSR_IDE_CAS_TIMING_CMD_SHIFT 24
+#define GRUB_CS5536_MSR_IDE_CAS_TIMING_DRIVE0_SHIFT 6
+#define GRUB_CS5536_MSR_IDE_CAS_TIMING_DRIVE1_SHIFT 4
+#define GRUB_CS5536_MSR_IDE_CAS_TIMING_PIO0 2
+
+#define GRUB_CS5536_MSR_GL_PCI_CTRL 0x00000010
+#define GRUB_CS5536_MSR_GL_PCI_CTRL_MEMORY_ENABLE 1
+#define GRUB_CS5536_MSR_GL_PCI_CTRL_IO_ENABLE 2
+#define GRUB_CS5536_MSR_GL_PCI_CTRL_LATENCY_SHIFT 35
+#define GRUB_CS5536_MSR_GL_PCI_CTRL_OUT_THR_SHIFT 60
+#define GRUB_CS5536_MSR_GL_PCI_CTRL_IN_THR_SHIFT 56
+
+#define GRUB_CS5536_MSR_GL_REGIONS_START 0x00000020
+#define GRUB_CS5536_MSR_GL_REGIONS_NUM 16
+#define GRUB_CS5536_MSR_GL_REGION_ENABLE 1
+#define GRUB_CS5536_MSR_GL_REGION_IO 0x100000000ULL
+#define GRUB_CS5536_MSR_GL_REGION_BASE_MASK 0xfffff000ULL
+#define GRUB_CS5536_MSR_GL_REGION_IO_BASE_SHIFT 12
+#define GRUB_CS5536_MSR_GL_REGION_TOP_MASK 0xfffff00000000000ULL
+#define GRUB_CS5536_MSR_GL_REGION_IO_TOP_SHIFT 44
+
+#define GRUB_CS5536_MSR_GL_P2D_START 0x00010020
+
+#define GRUB_CS5536_SMB_REG_DATA 0x0
+#define GRUB_CS5536_SMB_REG_STATUS 0x1
+#define GRUB_CS5536_SMB_REG_STATUS_SDAST (1 << 6)
+#define GRUB_CS5536_SMB_REG_STATUS_BER (1 << 5)
+#define GRUB_CS5536_SMB_REG_STATUS_NACK (1 << 4)
+#define GRUB_CS5536_SMB_REG_CTRL1 0x3
+#define GRUB_CS5536_SMB_REG_CTRL1_START 0x01
+#define GRUB_CS5536_SMB_REG_CTRL1_STOP 0x02
+#define GRUB_CS5536_SMB_REG_CTRL1_ACK 0x10
+#define GRUB_CS5536_SMB_REG_ADDR 0x4
+#define GRUB_CS5536_SMB_REG_ADDR_MASTER 0x0
+#define GRUB_CS5536_SMB_REG_CTRL2 0x5
+#define GRUB_CS5536_SMB_REG_CTRL2_ENABLE 0x1
+#define GRUB_CS5536_SMB_REG_CTRL3 0x6
+
+#ifdef ASM_FILE
+#define GRUB_ULL(x) x
+#else
+#define GRUB_ULL(x) x ## ULL
+#endif
+
+#define GRUB_CS5536_LBAR_ADDR_MASK GRUB_ULL (0x000000000000fff8)
+#define GRUB_CS5536_LBAR_ENABLE GRUB_ULL (0x0000000100000000)
+#define GRUB_CS5536_LBAR_MASK_MASK GRUB_ULL (0x0000f00000000000)
+#define GRUB_CS5536_LBAR_TURN_ON (GRUB_CS5536_LBAR_ENABLE | GRUB_CS5536_LBAR_MASK_MASK)
+
+/* PMON-compatible LBARs. */
+#define GRUB_CS5536_LBAR_GPIO 0xb000
+#define GRUB_CS5536_LBAR_ACC 0xb200
+#define GRUB_CS5536_LBAR_PM 0xb280
+#define GRUB_CS5536_LBAR_MFGPT 0xb300
+#define GRUB_CS5536_LBAR_ACPI 0xb340
+#define GRUB_CS5536_LBAR_IRQ_MAP 0xb360
+#define GRUB_CS5536_LBAR_IDE 0xb380
+#define GRUB_CS5536_LBAR_SMBUS 0xb390
+
+#define GRUB_GPIO_SMBUS_PINS ((1 << 14) | (1 << 15))
+#define GRUB_GPIO_REG_OUT_EN 0x4
+#define GRUB_GPIO_REG_OUT_AUX1 0x10
+#define GRUB_GPIO_REG_IN_EN 0x20
+#define GRUB_GPIO_REG_IN_AUX1 0x34
+
+#ifndef ASM_FILE
+int EXPORT_FUNC (grub_cs5536_find) (grub_pci_device_t *devp);
+
+grub_uint64_t EXPORT_FUNC (grub_cs5536_read_msr) (grub_pci_device_t dev,
+ grub_uint32_t addr);
+void EXPORT_FUNC (grub_cs5536_write_msr) (grub_pci_device_t dev,
+ grub_uint32_t addr,
+ grub_uint64_t val);
+grub_err_t grub_cs5536_read_spd_byte (grub_port_t smbbase, grub_uint8_t dev,
+ grub_uint8_t addr, grub_uint8_t *res);
+grub_err_t EXPORT_FUNC (grub_cs5536_read_spd) (grub_port_t smbbase,
+ grub_uint8_t dev,
+ struct grub_smbus_spd *res);
+grub_err_t grub_cs5536_smbus_wait (grub_port_t smbbase);
+grub_err_t EXPORT_FUNC (grub_cs5536_init_smbus) (grub_pci_device_t dev,
+ grub_uint16_t divisor,
+ grub_port_t *smbbase);
+
+void grub_cs5536_init_geode (grub_pci_device_t dev);
+#endif
+
+#endif
diff --git a/include/grub/datetime.h b/include/grub/datetime.h
new file mode 100644
index 0000000..e721e89
--- /dev/null
+++ b/include/grub/datetime.h
@@ -0,0 +1,55 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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 KERNEL_DATETIME_HEADER
+#define KERNEL_DATETIME_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+
+struct grub_datetime
+{
+ grub_uint16_t year;
+ grub_uint8_t month;
+ grub_uint8_t day;
+ grub_uint8_t hour;
+ grub_uint8_t minute;
+ grub_uint8_t second;
+};
+
+/* Return date and time. */
+#ifdef GRUB_MACHINE_EMU
+grub_err_t EXPORT_FUNC(grub_get_datetime) (struct grub_datetime *datetime);
+
+/* Set date and time. */
+grub_err_t EXPORT_FUNC(grub_set_datetime) (struct grub_datetime *datetime);
+#else
+grub_err_t grub_get_datetime (struct grub_datetime *datetime);
+
+/* Set date and time. */
+grub_err_t grub_set_datetime (struct grub_datetime *datetime);
+#endif
+
+int grub_get_weekday (struct grub_datetime *datetime);
+char *grub_get_weekday_name (struct grub_datetime *datetime);
+
+void grub_unixtime2datetime (grub_int32_t nix,
+ struct grub_datetime *datetime);
+
+
+#endif /* ! KERNEL_DATETIME_HEADER */
diff --git a/include/grub/decompressor.h b/include/grub/decompressor.h
new file mode 100644
index 0000000..a6eefb0
--- /dev/null
+++ b/include/grub/decompressor.h
@@ -0,0 +1,34 @@
+/*
+ * 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_DECOMPRESSOR_HEADER
+#define GRUB_DECOMPRESSOR_HEADER 1
+
+void
+grub_decompress_core (void *src, void *dst, unsigned long srcsize,
+ unsigned long dstsize);
+
+void
+find_scratch (void *src, void *dst, unsigned long srcsize,
+ unsigned long dstsize);
+
+#define GRUB_DECOMPRESSOR_DICT_SIZE (1 << 16)
+
+extern void *grub_decompressor_scratch;
+
+#endif
diff --git a/include/grub/deflate.h b/include/grub/deflate.h
new file mode 100644
index 0000000..6ec4eaa
--- /dev/null
+++ b/include/grub/deflate.h
@@ -0,0 +1,26 @@
+/*
+ * 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_DEFLATE_HEADER
+#define GRUB_DEFLATE_HEADER 1
+
+grub_ssize_t
+grub_zlib_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
+ char *outbuf, grub_size_t outsize);
+
+#endif
diff --git a/include/grub/device.h b/include/grub/device.h
new file mode 100644
index 0000000..f0e8a8c
--- /dev/null
+++ b/include/grub/device.h
@@ -0,0 +1,41 @@
+/* device.h - device manager */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,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_DEVICE_HEADER
+#define GRUB_DEVICE_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/err.h>
+
+struct grub_disk;
+struct grub_net;
+struct grub_fs;
+
+struct grub_device
+{
+ struct grub_disk *disk;
+ struct grub_net *net;
+};
+typedef struct grub_device *grub_device_t;
+
+grub_device_t EXPORT_FUNC(grub_device_open) (const char *name);
+grub_err_t EXPORT_FUNC(grub_device_close) (grub_device_t device);
+int EXPORT_FUNC(grub_device_iterate) (int (*hook) (const char *name));
+
+#endif /* ! GRUB_DEVICE_HEADER */
diff --git a/include/grub/disk.h b/include/grub/disk.h
new file mode 100644
index 0000000..66db114
--- /dev/null
+++ b/include/grub/disk.h
@@ -0,0 +1,189 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2005,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_DISK_HEADER
+#define GRUB_DISK_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/device.h>
+
+/* These are used to set a device id. When you add a new disk device,
+ you must define a new id for it here. */
+enum grub_disk_dev_id
+ {
+ GRUB_DISK_DEVICE_BIOSDISK_ID,
+ GRUB_DISK_DEVICE_OFDISK_ID,
+ GRUB_DISK_DEVICE_LOOPBACK_ID,
+ GRUB_DISK_DEVICE_EFIDISK_ID,
+ GRUB_DISK_DEVICE_RAID_ID,
+ GRUB_DISK_DEVICE_LVM_ID,
+ GRUB_DISK_DEVICE_HOST_ID,
+ GRUB_DISK_DEVICE_ATA_ID,
+ GRUB_DISK_DEVICE_MEMDISK_ID,
+ GRUB_DISK_DEVICE_NAND_ID,
+ GRUB_DISK_DEVICE_UUID_ID,
+ GRUB_DISK_DEVICE_PXE_ID,
+ GRUB_DISK_DEVICE_SCSI_ID,
+ GRUB_DISK_DEVICE_FILE_ID,
+ GRUB_DISK_DEVICE_LUKS_ID
+ };
+
+struct grub_disk;
+#ifdef GRUB_UTIL
+struct grub_disk_memberlist;
+#endif
+
+/* Disk device. */
+struct grub_disk_dev
+{
+ /* The device name. */
+ const char *name;
+
+ /* The device id used by the cache manager. */
+ enum grub_disk_dev_id id;
+
+ /* Call HOOK with each device name, until HOOK returns non-zero. */
+ int (*iterate) (int (*hook) (const char *name));
+
+ /* Open the device named NAME, and set up DISK. */
+ grub_err_t (*open) (const char *name, struct grub_disk *disk);
+
+ /* Close the disk DISK. */
+ void (*close) (struct grub_disk *disk);
+
+ /* Read SIZE sectors from the sector SECTOR of the disk DISK into BUF. */
+ grub_err_t (*read) (struct grub_disk *disk, grub_disk_addr_t sector,
+ grub_size_t size, char *buf);
+
+ /* Write SIZE sectors from BUF into the sector SECTOR of the disk DISK. */
+ grub_err_t (*write) (struct grub_disk *disk, grub_disk_addr_t sector,
+ grub_size_t size, const char *buf);
+
+#ifdef GRUB_UTIL
+ struct grub_disk_memberlist *(*memberlist) (struct grub_disk *disk);
+ const char * (*raidname) (struct grub_disk *disk);
+#endif
+
+ /* The next disk device. */
+ struct grub_disk_dev *next;
+};
+typedef struct grub_disk_dev *grub_disk_dev_t;
+
+struct grub_partition;
+
+/* Disk. */
+struct grub_disk
+{
+ /* The disk name. */
+ const char *name;
+
+ /* The underlying disk device. */
+ grub_disk_dev_t dev;
+
+ /* The total number of sectors. */
+ grub_uint64_t total_sectors;
+
+ /* The id used by the disk cache manager. */
+ unsigned long id;
+
+ /* The partition information. This is machine-specific. */
+ struct grub_partition *partition;
+
+ /* Called when a sector was read. OFFSET is between 0 and
+ the sector size minus 1, and LENGTH is between 0 and the sector size. */
+ void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
+ unsigned offset, unsigned length);
+
+ /* Device-specific data. */
+ void *data;
+};
+typedef struct grub_disk *grub_disk_t;
+
+#ifdef GRUB_UTIL
+struct grub_disk_memberlist
+{
+ grub_disk_t disk;
+ struct grub_disk_memberlist *next;
+};
+typedef struct grub_disk_memberlist *grub_disk_memberlist_t;
+#endif
+
+/* The sector size. */
+#define GRUB_DISK_SECTOR_SIZE 0x200
+#define GRUB_DISK_SECTOR_BITS 9
+
+/* The maximum number of disk caches. */
+#define GRUB_DISK_CACHE_NUM 1021
+
+/* The size of a disk cache in sector units. */
+#define GRUB_DISK_CACHE_SIZE 8
+#define GRUB_DISK_CACHE_BITS 3
+
+/* Return value of grub_disk_get_size() in case disk size is unknown. */
+#define GRUB_DISK_SIZE_UNKNOWN 0xffffffffffffffffULL
+
+/* This is called from the memory manager. */
+void grub_disk_cache_invalidate_all (void);
+
+void EXPORT_FUNC(grub_disk_dev_register) (grub_disk_dev_t dev);
+void EXPORT_FUNC(grub_disk_dev_unregister) (grub_disk_dev_t dev);
+int EXPORT_FUNC(grub_disk_dev_iterate) (int (*hook) (const char *name));
+
+grub_disk_t EXPORT_FUNC(grub_disk_open) (const char *name);
+void EXPORT_FUNC(grub_disk_close) (grub_disk_t disk);
+grub_err_t EXPORT_FUNC(grub_disk_read) (grub_disk_t disk,
+ grub_disk_addr_t sector,
+ grub_off_t offset,
+ grub_size_t size,
+ void *buf);
+grub_err_t EXPORT_FUNC(grub_disk_write) (grub_disk_t disk,
+ grub_disk_addr_t sector,
+ grub_off_t offset,
+ grub_size_t size,
+ const void *buf);
+
+grub_uint64_t EXPORT_FUNC(grub_disk_get_size) (grub_disk_t disk);
+
+extern void (* EXPORT_VAR(grub_disk_firmware_fini)) (void);
+extern int EXPORT_VAR(grub_disk_firmware_is_tainted);
+
+/* ATA pass through parameters and function. */
+struct grub_disk_ata_pass_through_parms
+{
+ grub_uint8_t taskfile[8];
+ void * buffer;
+ int size;
+};
+
+extern grub_err_t (* EXPORT_VAR(grub_disk_ata_pass_through)) (grub_disk_t,
+ struct grub_disk_ata_pass_through_parms *);
+
+#if defined (GRUB_UTIL) || defined (GRUB_MACHINE_EMU)
+void grub_lvm_init (void);
+void grub_mdraid09_init (void);
+void grub_mdraid1x_init (void);
+void grub_raid_init (void);
+void grub_lvm_fini (void);
+void grub_mdraid09_fini (void);
+void grub_mdraid1x_fini (void);
+void grub_raid_fini (void);
+#endif
+
+#endif /* ! GRUB_DISK_HEADER */
diff --git a/include/grub/dl.h b/include/grub/dl.h
new file mode 100644
index 0000000..6f23f7d
--- /dev/null
+++ b/include/grub/dl.h
@@ -0,0 +1,171 @@
+/* dl.h - types and prototypes for loadable module support */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2005,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_DL_H
+#define GRUB_DL_H 1
+
+#include <grub/symbol.h>
+#ifndef ASM_FILE
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/elf.h>
+#endif
+
+/*
+ * Macros GRUB_MOD_INIT and GRUB_MOD_FINI are also used by build rules
+ * to collect module names, so we define them only when they are not
+ * defined already.
+ */
+#ifndef ASM_FILE
+
+#ifndef GRUB_MOD_INIT
+#define GRUB_MOD_INIT(name) \
+static void grub_mod_init (grub_dl_t mod __attribute__ ((unused))) __attribute__ ((used)); \
+void grub_##name##_init (void); \
+void \
+grub_##name##_init (void) { grub_mod_init (0); } \
+static void \
+grub_mod_init (grub_dl_t mod __attribute__ ((unused)))
+#endif
+
+#ifndef GRUB_MOD_FINI
+#define GRUB_MOD_FINI(name) \
+static void grub_mod_fini (void) __attribute__ ((used)); \
+void grub_##name##_fini (void); \
+void \
+grub_##name##_fini (void) { grub_mod_fini (); } \
+static void \
+grub_mod_fini (void)
+#endif
+
+#ifdef APPLE_CC
+#define GRUB_MOD_NAME(name) \
+static char grub_modname[] __attribute__ ((section ("_modname, _modname"), used)) = #name;
+
+#define GRUB_MOD_DEP(name) \
+__asm__ (".section _moddeps, _moddeps\n.asciz \"" #name "\"\n")
+#else
+#define GRUB_MOD_NAME(name) \
+__asm__ (".section .modname\n.asciz \"" #name "\"\n")
+
+#define GRUB_MOD_DEP(name) \
+__asm__ (".section .moddeps\n.asciz \"" #name "\"\n")
+
+#endif
+
+#endif
+
+#ifndef ASM_FILE
+#ifdef APPLE_CC
+#define GRUB_MOD_SECTION(x) "_" #x ", _" #x ""
+#else
+#define GRUB_MOD_SECTION(x) "." #x
+#endif
+#else
+#ifdef APPLE_CC
+#define GRUB_MOD_SECTION(x) _ ## x , _ ##x
+#else
+#define GRUB_MOD_SECTION(x) . ## x
+#endif
+#endif
+
+/* Me, Vladimir Serbinenko, hereby I add this module check as per new
+ GNU module policy. Note that this license check is informative only.
+ Modules have to be licensed under GPLv3 or GPLv3+ (optionally
+ multi-licensed under other licences as well) independently of the
+ presence of this check and solely by linking (module loading in GRUB
+ constitutes linking) and GRUB core being licensed under GPLv3+.
+ Be sure to understand your license obligations.
+*/
+#ifndef ASM_FILE
+#define GRUB_MOD_LICENSE(license) \
+ static char grub_module_license[] __attribute__ ((section (GRUB_MOD_SECTION (module_license)), used)) = "LICENSE=" license;
+#else
+#define GRUB_MOD_LICENSE(license) \
+ .section GRUB_MOD_SECTION(module_license), "a"; \
+ .ascii "LICENSE="; \
+ .ascii license; \
+ .byte 0
+#endif
+
+/* Under GPL license obligations you have to distribute your module
+ under GPLv3(+). However, you can also distribute the same code under
+ another license as long as GPLv3(+) version is provided.
+*/
+#define GRUB_MOD_DUAL_LICENSE(x)
+
+#ifndef ASM_FILE
+
+struct grub_dl_segment
+{
+ struct grub_dl_segment *next;
+ void *addr;
+ grub_size_t size;
+ unsigned section;
+};
+typedef struct grub_dl_segment *grub_dl_segment_t;
+
+struct grub_dl;
+
+struct grub_dl_dep
+{
+ struct grub_dl_dep *next;
+ struct grub_dl *mod;
+};
+typedef struct grub_dl_dep *grub_dl_dep_t;
+
+struct grub_dl
+{
+ char *name;
+ int ref_count;
+ grub_dl_dep_t dep;
+ grub_dl_segment_t segment;
+ Elf_Sym *symtab;
+ void (*init) (struct grub_dl *mod);
+ void (*fini) (void);
+ struct grub_dl *next;
+};
+typedef struct grub_dl *grub_dl_t;
+
+grub_dl_t EXPORT_FUNC(grub_dl_load_file) (const char *filename);
+grub_dl_t EXPORT_FUNC(grub_dl_load) (const char *name);
+grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
+int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
+void grub_dl_unload_unneeded (void);
+int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
+int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
+extern grub_dl_t EXPORT_VAR(grub_dl_head);
+
+#define FOR_DL_MODULES(var) FOR_LIST_ELEMENTS ((var), (grub_dl_head))
+
+grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name);
+grub_err_t grub_dl_register_symbol (const char *name, void *addr,
+ grub_dl_t mod);
+
+grub_err_t grub_arch_dl_check_header (void *ehdr);
+grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
+
+#if defined (_mips)
+#define GRUB_LINKER_HAVE_INIT 1
+void grub_arch_dl_init_linker (void);
+#endif
+
+#endif
+
+#endif /* ! GRUB_DL_H */
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
new file mode 100644
index 0000000..cb6b111
--- /dev/null
+++ b/include/grub/efi/api.h
@@ -0,0 +1,1296 @@
+/* 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_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_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_DEVICE_PATH_GUID \
+ { 0x09576e91, 0x6d3f, 0x11d2, \
+ { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
+ }
+
+#define GRUB_EFI_MPS_TABLE_GUID \
+ { 0xeb9d2d2f, 0x2d88, 0x11d3, \
+ { 0x9a, 0x16, 0x0, 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_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 } \
+ }
+
+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,
+ };
+
+/* 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_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;
+typedef long grub_efi_intn_t;
+typedef unsigned long grub_efi_uintn_t;
+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;
+
+#define PRIxGRUB_EFI_UINTN_T "lx"
+
+typedef grub_efi_intn_t grub_efi_status_t;
+
+#define GRUB_EFI_ERROR_CODE(value) \
+ ((1L << (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;
+
+/* 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;
+};
+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_uint8_t length[2];
+};
+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[0] | ((grub_efi_uint16_t) ((dp)->length[1]) << 8))
+
+/* 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_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_t *) ((char *) (dp) \
+ + GRUB_EFI_DEVICE_PATH_LENGTH (dp)))
+
+/* 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;
+};
+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;
+};
+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_memory_type_t memory_type;
+ grub_efi_physical_address_t start_address;
+ grub_efi_physical_address_t end_address;
+};
+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_guid_t vendor_guid;
+ grub_efi_uint8_t vendor_defined_data[0];
+};
+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;
+};
+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;
+};
+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[1];
+};
+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;
+};
+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;
+};
+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;
+};
+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;
+};
+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 interface;
+};
+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;
+};
+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;
+};
+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;
+};
+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;
+};
+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;
+};
+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;
+};
+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;
+};
+typedef struct grub_efi_uart_device_path grub_efi_uart_device_path_t;
+
+#define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10
+
+struct grub_efi_vendor_messaging_device_path
+{
+ grub_efi_device_path_t header;
+ grub_efi_guid_t vendor_guid;
+ grub_efi_uint8_t vendor_defined_data[0];
+};
+typedef struct grub_efi_vendor_messaging_device_path grub_efi_vendor_messaging_device_path_t;
+
+/* 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[8];
+ grub_efi_uint8_t mbr_type;
+ grub_efi_uint8_t signature_type;
+};
+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;
+};
+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_guid_t vendor_guid;
+ grub_efi_uint8_t vendor_defined_data[0];
+};
+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];
+};
+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_guid_t guid;
+};
+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_guid_t guid __attribute__ ((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];
+};
+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;
+} __attribute__ ((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;
+
+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 interface_type,
+ void *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 *interface);
+
+ grub_efi_status_t
+ (*handle_protocol) (grub_efi_handle_t handle,
+ grub_efi_guid_t *protocol,
+ void **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 **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_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 **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);
+
+ grub_efi_status_t
+ (*get_variable) (grub_efi_char16_t *variable_name,
+ 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,
+ 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_guid_t vendor_guid;
+ void *vendor_table;
+} __attribute__ ((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_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_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;
+
+#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;
+
+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;
+
+#if GRUB_TARGET_SIZEOF_VOID_P == 4
+
+#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_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_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_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 */
diff --git a/include/grub/efi/console.h b/include/grub/efi/console.h
new file mode 100644
index 0000000..f90b5b7
--- /dev/null
+++ b/include/grub/efi/console.h
@@ -0,0 +1,31 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2006,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_EFI_CONSOLE_HEADER
+#define GRUB_EFI_CONSOLE_HEADER 1
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+
+/* Initialize the console system. */
+void grub_console_init (void);
+
+/* Finish the console system. */
+void grub_console_fini (void);
+
+#endif /* ! GRUB_EFI_CONSOLE_HEADER */
diff --git a/include/grub/efi/console_control.h b/include/grub/efi/console_control.h
new file mode 100644
index 0000000..7c358fc
--- /dev/null
+++ b/include/grub/efi/console_control.h
@@ -0,0 +1,57 @@
+/* console_control.h - definitions of the console control protocol */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,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/>.
+ */
+
+/* The console control protocol is not a part of the EFI spec,
+ but defined in Intel's Sample Implementation. */
+
+#ifndef GRUB_EFI_CONSOLE_CONTROL_HEADER
+#define GRUB_EFI_CONSOLE_CONTROL_HEADER 1
+
+#define GRUB_EFI_CONSOLE_CONTROL_GUID \
+ { 0xf42f7782, 0x12e, 0x4c12, \
+ { 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21 } \
+ }
+
+enum grub_efi_screen_mode
+ {
+ GRUB_EFI_SCREEN_TEXT,
+ GRUB_EFI_SCREEN_GRAPHICS,
+ GRUB_EFI_SCREEN_TEXT_MAX_VALUE
+ };
+typedef enum grub_efi_screen_mode grub_efi_screen_mode_t;
+
+struct grub_efi_console_control_protocol
+{
+ grub_efi_status_t
+ (*get_mode) (struct grub_efi_console_control_protocol *this,
+ grub_efi_screen_mode_t *mode,
+ grub_efi_boolean_t *uga_exists,
+ grub_efi_boolean_t *std_in_locked);
+
+ grub_efi_status_t
+ (*set_mode) (struct grub_efi_console_control_protocol *this,
+ grub_efi_screen_mode_t mode);
+
+ grub_efi_status_t
+ (*lock_std_in) (struct grub_efi_console_control_protocol *this,
+ grub_efi_char16_t *password);
+};
+typedef struct grub_efi_console_control_protocol grub_efi_console_control_protocol_t;
+
+#endif /* ! GRUB_EFI_CONSOLE_CONTROL_HEADER */
diff --git a/include/grub/efi/disk.h b/include/grub/efi/disk.h
new file mode 100644
index 0000000..254475c
--- /dev/null
+++ b/include/grub/efi/disk.h
@@ -0,0 +1,33 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,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_EFI_DISK_HEADER
+#define GRUB_EFI_DISK_HEADER 1
+
+#include <grub/efi/api.h>
+#include <grub/symbol.h>
+#include <grub/disk.h>
+
+grub_efi_handle_t
+EXPORT_FUNC(grub_efidisk_get_device_handle) (grub_disk_t disk);
+char *EXPORT_FUNC(grub_efidisk_get_device_name) (grub_efi_handle_t *handle);
+
+void grub_efidisk_init (void);
+void grub_efidisk_fini (void);
+
+#endif /* ! GRUB_EFI_DISK_HEADER */
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
new file mode 100644
index 0000000..e9c57dd
--- /dev/null
+++ b/include/grub/efi/efi.h
@@ -0,0 +1,77 @@
+/* efi.h - declare variables and functions for EFI support */
+/*
+ * 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_EFI_HEADER
+#define GRUB_EFI_EFI_HEADER 1
+
+#include <grub/types.h>
+#include <grub/dl.h>
+#include <grub/efi/api.h>
+
+/* Functions. */
+void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_efi_guid_t *protocol,
+ void *registration);
+grub_efi_handle_t *
+EXPORT_FUNC(grub_efi_locate_handle) (grub_efi_locate_search_type_t search_type,
+ grub_efi_guid_t *protocol,
+ void *search_key,
+ grub_efi_uintn_t *num_handles);
+void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle,
+ grub_efi_guid_t *protocol,
+ grub_efi_uint32_t attributes);
+int EXPORT_FUNC(grub_efi_set_text_mode) (int on);
+void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds);
+void *
+EXPORT_FUNC(grub_efi_allocate_pages) (grub_efi_physical_address_t address,
+ grub_efi_uintn_t pages);
+void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address,
+ grub_efi_uintn_t pages);
+int
+EXPORT_FUNC(grub_efi_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_loaded_image_t *EXPORT_FUNC(grub_efi_get_loaded_image) (grub_efi_handle_t image_handle);
+void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp);
+char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp);
+grub_efi_device_path_t *
+EXPORT_FUNC(grub_efi_get_device_path) (grub_efi_handle_t handle);
+grub_err_t EXPORT_FUNC (grub_efi_finish_boot_services) (grub_efi_uintn_t *outbuf_size, void *outbuf,
+ grub_efi_uintn_t *map_key,
+ grub_efi_uintn_t *efi_desc_size,
+ grub_efi_uint32_t *efi_desc_version);
+grub_err_t EXPORT_FUNC (grub_efi_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);
+
+void grub_efi_mm_init (void);
+void grub_efi_mm_fini (void);
+void grub_efi_init (void);
+void grub_efi_fini (void);
+void grub_efi_set_prefix (void);
+
+/* Variables. */
+extern grub_efi_system_table_t *EXPORT_VAR(grub_efi_system_table);
+extern grub_efi_handle_t EXPORT_VAR(grub_efi_image_handle);
+
+extern int EXPORT_VAR(grub_efi_is_finished);
+
+#endif /* ! GRUB_EFI_EFI_HEADER */
diff --git a/include/grub/efi/graphics_output.h b/include/grub/efi/graphics_output.h
new file mode 100644
index 0000000..a292219
--- /dev/null
+++ b/include/grub/efi/graphics_output.h
@@ -0,0 +1,96 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_GOP_HEADER
+#define GRUB_EFI_GOP_HEADER 1
+
+/* Based on UEFI specification. */
+
+#define GRUB_EFI_GOP_GUID \
+ { 0x9042a9de, 0x23dc, 0x4a38, { 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a }}
+
+typedef enum
+ {
+ GRUB_EFI_GOT_RGBA8,
+ GRUB_EFI_GOT_BGRA8,
+ GRUB_EFI_GOT_BITMASK
+ }
+ grub_efi_gop_pixel_format_t;
+
+struct grub_efi_gop_pixel_bitmask
+{
+ grub_uint32_t r;
+ grub_uint32_t g;
+ grub_uint32_t b;
+ grub_uint32_t a;
+};
+
+struct grub_efi_gop_mode_info
+{
+ grub_efi_uint32_t version;
+ grub_efi_uint32_t width;
+ grub_efi_uint32_t height;
+ grub_efi_gop_pixel_format_t pixel_format;
+ struct grub_efi_gop_pixel_bitmask pixel_bitmask;
+ grub_efi_uint32_t pixels_per_scanline;
+};
+
+struct grub_efi_gop_mode
+{
+ grub_efi_uint32_t max_mode;
+ grub_efi_uint32_t mode;
+ struct grub_efi_gop_mode_info *info;
+ grub_efi_uintn_t info_size;
+ grub_efi_physical_address_t fb_base;
+ grub_efi_uintn_t fb_size;
+};
+
+/* Forward declaration. */
+struct grub_efi_gop;
+
+typedef grub_efi_status_t
+(*grub_efi_gop_query_mode_t) (struct grub_efi_gop *this,
+ grub_efi_uint32_t mode_number,
+ grub_efi_uintn_t *size_of_info,
+ struct grub_efi_gop_mode_info **info);
+
+typedef grub_efi_status_t
+(*grub_efi_gop_set_mode_t) (struct grub_efi_gop *this,
+ grub_efi_uint32_t mode_number);
+
+typedef grub_efi_status_t
+(*grub_efi_gop_blt_t) (struct grub_efi_gop *this,
+ void *buffer,
+ grub_efi_uintn_t operation,
+ grub_efi_uintn_t sx,
+ grub_efi_uintn_t sy,
+ grub_efi_uintn_t dx,
+ grub_efi_uintn_t dy,
+ grub_efi_uintn_t width,
+ grub_efi_uintn_t height,
+ grub_efi_uintn_t delta);
+
+struct grub_efi_gop
+{
+ grub_efi_gop_query_mode_t query_mode;
+ grub_efi_gop_set_mode_t set_mode;
+ grub_efi_gop_blt_t blt;
+ struct grub_efi_gop_mode *mode;
+};
+
+#endif
diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h
new file mode 100644
index 0000000..133f950
--- /dev/null
+++ b/include/grub/efi/memory.h
@@ -0,0 +1,38 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_MEMORY_MACHINE_HEADER
+#define GRUB_MEMORY_MACHINE_HEADER 1
+
+#include <grub/err.h>
+#include <grub/types.h>
+
+#define GRUB_MMAP_REGISTER_BY_FIRMWARE 1
+
+grub_err_t grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
+ grub_uint64_t,
+ grub_uint32_t));
+grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
+ int type, int handle);
+grub_err_t grub_machine_mmap_unregister (int handle);
+
+grub_uint64_t grub_mmap_get_post64 (void);
+grub_uint64_t grub_mmap_get_upper (void);
+grub_uint64_t grub_mmap_get_lower (void);
+
+#endif /* ! GRUB_MEMORY_MACHINE_HEADER */
diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h
new file mode 100644
index 0000000..81a1a57
--- /dev/null
+++ b/include/grub/efi/pe32.h
@@ -0,0 +1,315 @@
+/*
+ * 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_PE32_HEADER
+#define GRUB_EFI_PE32_HEADER 1
+
+#include <grub/types.h>
+
+/* The MSDOS compatibility stub. This was copied from the output of
+ objcopy, and it is not necessary to care about what this means. */
+#define GRUB_PE32_MSDOS_STUB \
+ { \
+ 0x4d, 0x5a, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00, \
+ 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, \
+ 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, \
+ 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, \
+ 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, \
+ 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, \
+ 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, \
+ 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, \
+ 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, \
+ 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, \
+ 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 \
+ }
+
+#define GRUB_PE32_MSDOS_STUB_SIZE 0x80
+
+/* According to the spec, the minimal alignment is 512 bytes...
+ But some examples (such as EFI drivers in the Intel
+ Sample Implementation) use 32 bytes (0x20) instead, and it seems
+ to be working. For now, GRUB uses 512 bytes for safety. */
+#define GRUB_PE32_SECTION_ALIGNMENT 0x200
+#define GRUB_PE32_FILE_ALIGNMENT GRUB_PE32_SECTION_ALIGNMENT
+
+struct grub_pe32_coff_header
+{
+ grub_uint16_t machine;
+ grub_uint16_t num_sections;
+ grub_uint32_t time;
+ grub_uint32_t symtab_offset;
+ grub_uint32_t num_symbols;
+ grub_uint16_t optional_header_size;
+ grub_uint16_t characteristics;
+};
+
+#define GRUB_PE32_MACHINE_I386 0x14c
+#define GRUB_PE32_MACHINE_X86_64 0x8664
+
+#define GRUB_PE32_RELOCS_STRIPPED 0x0001
+#define GRUB_PE32_EXECUTABLE_IMAGE 0x0002
+#define GRUB_PE32_LINE_NUMS_STRIPPED 0x0004
+#define GRUB_PE32_LOCAL_SYMS_STRIPPED 0x0008
+#define GRUB_PE32_AGGRESSIVE_WS_TRIM 0x0010
+#define GRUB_PE32_LARGE_ADDRESS_AWARE 0x0020
+#define GRUB_PE32_16BIT_MACHINE 0x0040
+#define GRUB_PE32_BYTES_REVERSED_LO 0x0080
+#define GRUB_PE32_32BIT_MACHINE 0x0100
+#define GRUB_PE32_DEBUG_STRIPPED 0x0200
+#define GRUB_PE32_REMOVABLE_RUN_FROM_SWAP 0x0400
+#define GRUB_PE32_SYSTEM 0x1000
+#define GRUB_PE32_DLL 0x2000
+#define GRUB_PE32_UP_SYSTEM_ONLY 0x4000
+#define GRUB_PE32_BYTES_REVERSED_HI 0x8000
+
+struct grub_pe32_data_directory
+{
+ grub_uint32_t rva;
+ grub_uint32_t size;
+};
+
+struct grub_pe32_optional_header
+{
+ grub_uint16_t magic;
+ grub_uint8_t major_linker_version;
+ grub_uint8_t minor_linker_version;
+ grub_uint32_t code_size;
+ grub_uint32_t data_size;
+ grub_uint32_t bss_size;
+ grub_uint32_t entry_addr;
+ grub_uint32_t code_base;
+
+ grub_uint32_t data_base;
+ grub_uint32_t image_base;
+
+ grub_uint32_t section_alignment;
+ grub_uint32_t file_alignment;
+ grub_uint16_t major_os_version;
+ grub_uint16_t minor_os_version;
+ grub_uint16_t major_image_version;
+ grub_uint16_t minor_image_version;
+ grub_uint16_t major_subsystem_version;
+ grub_uint16_t minor_subsystem_version;
+ grub_uint32_t reserved;
+ grub_uint32_t image_size;
+ grub_uint32_t header_size;
+ grub_uint32_t checksum;
+ grub_uint16_t subsystem;
+ grub_uint16_t dll_characteristics;
+
+ grub_uint32_t stack_reserve_size;
+ grub_uint32_t stack_commit_size;
+ grub_uint32_t heap_reserve_size;
+ grub_uint32_t heap_commit_size;
+
+ grub_uint32_t loader_flags;
+ grub_uint32_t num_data_directories;
+
+ /* Data directories. */
+ struct grub_pe32_data_directory export_table;
+ struct grub_pe32_data_directory import_table;
+ struct grub_pe32_data_directory resource_table;
+ struct grub_pe32_data_directory exception_table;
+ struct grub_pe32_data_directory certificate_table;
+ struct grub_pe32_data_directory base_relocation_table;
+ struct grub_pe32_data_directory debug;
+ struct grub_pe32_data_directory architecture;
+ struct grub_pe32_data_directory global_ptr;
+ struct grub_pe32_data_directory tls_table;
+ struct grub_pe32_data_directory load_config_table;
+ struct grub_pe32_data_directory bound_import;
+ struct grub_pe32_data_directory iat;
+ struct grub_pe32_data_directory delay_import_descriptor;
+ struct grub_pe32_data_directory com_runtime_header;
+ struct grub_pe32_data_directory reserved_entry;
+};
+
+struct grub_pe64_optional_header
+{
+ grub_uint16_t magic;
+ grub_uint8_t major_linker_version;
+ grub_uint8_t minor_linker_version;
+ grub_uint32_t code_size;
+ grub_uint32_t data_size;
+ grub_uint32_t bss_size;
+ grub_uint32_t entry_addr;
+ grub_uint32_t code_base;
+
+ grub_uint64_t image_base;
+
+ grub_uint32_t section_alignment;
+ grub_uint32_t file_alignment;
+ grub_uint16_t major_os_version;
+ grub_uint16_t minor_os_version;
+ grub_uint16_t major_image_version;
+ grub_uint16_t minor_image_version;
+ grub_uint16_t major_subsystem_version;
+ grub_uint16_t minor_subsystem_version;
+ grub_uint32_t reserved;
+ grub_uint32_t image_size;
+ grub_uint32_t header_size;
+ grub_uint32_t checksum;
+ grub_uint16_t subsystem;
+ grub_uint16_t dll_characteristics;
+
+ grub_uint64_t stack_reserve_size;
+ grub_uint64_t stack_commit_size;
+ grub_uint64_t heap_reserve_size;
+ grub_uint64_t heap_commit_size;
+
+ grub_uint32_t loader_flags;
+ grub_uint32_t num_data_directories;
+
+ /* Data directories. */
+ struct grub_pe32_data_directory export_table;
+ struct grub_pe32_data_directory import_table;
+ struct grub_pe32_data_directory resource_table;
+ struct grub_pe32_data_directory exception_table;
+ struct grub_pe32_data_directory certificate_table;
+ struct grub_pe32_data_directory base_relocation_table;
+ struct grub_pe32_data_directory debug;
+ struct grub_pe32_data_directory architecture;
+ struct grub_pe32_data_directory global_ptr;
+ struct grub_pe32_data_directory tls_table;
+ struct grub_pe32_data_directory load_config_table;
+ struct grub_pe32_data_directory bound_import;
+ struct grub_pe32_data_directory iat;
+ struct grub_pe32_data_directory delay_import_descriptor;
+ struct grub_pe32_data_directory com_runtime_header;
+ struct grub_pe32_data_directory reserved_entry;
+};
+
+#define GRUB_PE32_PE32_MAGIC 0x10b
+#define GRUB_PE32_PE64_MAGIC 0x20b
+
+#define GRUB_PE32_SUBSYSTEM_EFI_APPLICATION 10
+
+#define GRUB_PE32_NUM_DATA_DIRECTORIES 16
+
+struct grub_pe32_section_table
+{
+ char name[8];
+ grub_uint32_t virtual_size;
+ grub_uint32_t virtual_address;
+ grub_uint32_t raw_data_size;
+ grub_uint32_t raw_data_offset;
+ grub_uint32_t relocations_offset;
+ grub_uint32_t line_numbers_offset;
+ grub_uint16_t num_relocations;
+ grub_uint16_t num_line_numbers;
+ grub_uint32_t characteristics;
+};
+
+#define GRUB_PE32_SCN_CNT_CODE 0x00000020
+#define GRUB_PE32_SCN_CNT_INITIALIZED_DATA 0x00000040
+#define GRUB_PE32_SCN_MEM_DISCARDABLE 0x02000000
+#define GRUB_PE32_SCN_MEM_EXECUTE 0x20000000
+#define GRUB_PE32_SCN_MEM_READ 0x40000000
+#define GRUB_PE32_SCN_MEM_WRITE 0x80000000
+
+#define GRUB_PE32_SCN_ALIGN_1BYTES 0x00100000
+#define GRUB_PE32_SCN_ALIGN_2BYTES 0x00200000
+#define GRUB_PE32_SCN_ALIGN_4BYTES 0x00300000
+#define GRUB_PE32_SCN_ALIGN_8BYTES 0x00400000
+#define GRUB_PE32_SCN_ALIGN_16BYTES 0x00500000
+#define GRUB_PE32_SCN_ALIGN_32BYTES 0x00600000
+#define GRUB_PE32_SCN_ALIGN_64BYTES 0x00700000
+
+#define GRUB_PE32_SCN_ALIGN_SHIFT 20
+#define GRUB_PE32_SCN_ALIGN_MASK 7
+
+#define GRUB_PE32_SIGNATURE_SIZE 4
+
+struct grub_pe32_header
+{
+ /* This should be filled in with GRUB_PE32_MSDOS_STUB. */
+ grub_uint8_t msdos_stub[GRUB_PE32_MSDOS_STUB_SIZE];
+
+ /* This is always PE\0\0. */
+ char signature[GRUB_PE32_SIGNATURE_SIZE];
+
+ /* The COFF file header. */
+ struct grub_pe32_coff_header coff_header;
+
+#if GRUB_TARGET_SIZEOF_VOID_P == 8
+ /* The Optional header. */
+ struct grub_pe64_optional_header optional_header;
+#else
+ /* The Optional header. */
+ struct grub_pe32_optional_header optional_header;
+#endif
+};
+
+struct grub_pe32_fixup_block
+{
+ grub_uint32_t page_rva;
+ grub_uint32_t block_size;
+ grub_uint16_t entries[0];
+};
+
+#define GRUB_PE32_FIXUP_ENTRY(type, offset) (((type) << 12) | (offset))
+
+#define GRUB_PE32_REL_BASED_ABSOLUTE 0
+#define GRUB_PE32_REL_BASED_HIGH 1
+#define GRUB_PE32_REL_BASED_LOW 2
+#define GRUB_PE32_REL_BASED_HIGHLOW 3
+#define GRUB_PE32_REL_BASED_HIGHADJ 4
+#define GRUB_PE32_REL_BASED_MIPS_JMPADDR 5
+#define GRUB_PE32_REL_BASED_SECTION 6
+#define GRUB_PE32_REL_BASED_REL 7
+#define GRUB_PE32_REL_BASED_IA64_IMM64 9
+#define GRUB_PE32_REL_BASED_DIR64 10
+#define GRUB_PE32_REL_BASED_HIGH3ADJ 11
+
+struct grub_pe32_symbol
+{
+ union
+ {
+ char short_name[8];
+ grub_uint32_t long_name[2];
+ };
+
+ grub_uint32_t value;
+ grub_uint16_t section;
+ grub_uint16_t type;
+ grub_uint8_t storage_class;
+ grub_uint8_t num_aux;
+} __attribute__ ((packed));
+
+#define GRUB_PE32_SYM_CLASS_EXTERNAL 2
+#define GRUB_PE32_SYM_CLASS_STATIC 3
+#define GRUB_PE32_SYM_CLASS_FILE 0x67
+
+#define GRUB_PE32_DT_FUNCTION 0x20
+
+struct grub_pe32_reloc
+{
+ grub_uint32_t offset;
+ grub_uint32_t symtab_index;
+ grub_uint16_t type;
+} __attribute__ ((packed));
+
+#define GRUB_PE32_REL_I386_DIR32 0x6
+#define GRUB_PE32_REL_I386_REL32 0x14
+
+#endif /* ! GRUB_EFI_PE32_HEADER */
diff --git a/include/grub/efi/time.h b/include/grub/efi/time.h
new file mode 100644
index 0000000..540f6fc
--- /dev/null
+++ b/include/grub/efi/time.h
@@ -0,0 +1,30 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008 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_TIME_HEADER
+#define GRUB_EFI_TIME_HEADER 1
+
+#include <grub/symbol.h>
+
+/* This is destined to overflow when one hour passes by. */
+#define GRUB_TICKS_PER_SECOND ((1UL << 31) / 60 / 60 * 2)
+
+/* Return the real time in ticks. */
+grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void);
+
+#endif /* ! GRUB_EFI_TIME_HEADER */
diff --git a/include/grub/efi/uga_draw.h b/include/grub/efi/uga_draw.h
new file mode 100644
index 0000000..a31f267
--- /dev/null
+++ b/include/grub/efi/uga_draw.h
@@ -0,0 +1,76 @@
+/* uga_draw.h - definitions of the uga draw protocol */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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/>.
+ */
+
+/* The console control protocol is not a part of the EFI spec,
+ but defined in Intel's Sample Implementation. */
+
+#ifndef GRUB_EFI_UGA_DRAW_HEADER
+#define GRUB_EFI_UGA_DRAW_HEADER 1
+
+#define GRUB_EFI_UGA_DRAW_GUID \
+ { 0x982c298b, 0xf4fa, 0x41cb, { 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 }}
+
+enum grub_efi_uga_blt_operation
+{
+ GRUB_EFI_UGA_VIDEO_FILL,
+ GRUB_EFI_UGA_VIDEO_TO_BLT,
+ GRUB_EFI_UGA_BLT_TO_VIDEO,
+ GRUB_EFI_UGA_VIDEO_TO_VIDEO,
+ GRUB_EFI_UGA_BLT_MAX
+};
+
+struct grub_efi_uga_pixel
+{
+ grub_uint8_t Blue;
+ grub_uint8_t Green;
+ grub_uint8_t Red;
+ grub_uint8_t Reserved;
+};
+
+struct grub_efi_uga_draw_protocol
+{
+ grub_efi_status_t
+ (*get_mode) (struct grub_efi_uga_draw_protocol *this,
+ grub_uint32_t *width,
+ grub_uint32_t *height,
+ grub_uint32_t *depth,
+ grub_uint32_t *refresh_rate);
+
+ grub_efi_status_t
+ (*set_mode) (struct grub_efi_uga_draw_protocol *this,
+ grub_uint32_t width,
+ grub_uint32_t height,
+ grub_uint32_t depth,
+ grub_uint32_t refresh_rate);
+
+ grub_efi_status_t
+ (*blt) (struct grub_efi_uga_draw_protocol *this,
+ struct grub_efi_uga_pixel *blt_buffer,
+ enum grub_efi_uga_blt_operation blt_operation,
+ grub_efi_uintn_t src_x,
+ grub_efi_uintn_t src_y,
+ grub_efi_uintn_t dest_x,
+ grub_efi_uintn_t dest_y,
+ grub_efi_uintn_t width,
+ grub_efi_uintn_t height,
+ grub_efi_uintn_t delta);
+};
+typedef struct grub_efi_uga_draw_protocol grub_efi_uga_draw_protocol_t;
+
+#endif /* ! GRUB_EFI_UGA_DRAW_HEADER */
diff --git a/include/grub/efiemu/efiemu.h b/include/grub/efiemu/efiemu.h
new file mode 100644
index 0000000..9cedc32
--- /dev/null
+++ b/include/grub/efiemu/efiemu.h
@@ -0,0 +1,289 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_EMU_HEADER
+#define GRUB_EFI_EMU_HEADER 1
+
+#include <grub/efi/api.h>
+#include <grub/file.h>
+#include <grub/memory.h>
+
+#define GRUB_EFIEMU_PAGESIZE 4096
+
+/* EFI api defined in 32-bit and 64-bit version*/
+struct grub_efi_system_table32
+{
+ grub_efi_table_header_t hdr;
+ grub_efi_uint32_t firmware_vendor;
+ grub_efi_uint32_t firmware_revision;
+ grub_efi_uint32_t console_in_handler;
+ grub_efi_uint32_t con_in;
+ grub_efi_uint32_t console_out_handler;
+ grub_efi_uint32_t con_out;
+ grub_efi_uint32_t standard_error_handle;
+ grub_efi_uint32_t std_err;
+ grub_efi_uint32_t runtime_services;
+ grub_efi_uint32_t boot_services;
+ grub_efi_uint32_t num_table_entries;
+ grub_efi_uint32_t configuration_table;
+} __attribute__ ((packed));
+typedef struct grub_efi_system_table32 grub_efi_system_table32_t;
+
+struct grub_efi_system_table64
+{
+ grub_efi_table_header_t hdr;
+ grub_efi_uint64_t firmware_vendor;
+ grub_efi_uint32_t firmware_revision;
+ grub_efi_uint32_t pad;
+ grub_efi_uint64_t console_in_handler;
+ grub_efi_uint64_t con_in;
+ grub_efi_uint64_t console_out_handler;
+ grub_efi_uint64_t con_out;
+ grub_efi_uint64_t standard_error_handle;
+ grub_efi_uint64_t std_err;
+ grub_efi_uint64_t runtime_services;
+ grub_efi_uint64_t boot_services;
+ grub_efi_uint64_t num_table_entries;
+ grub_efi_uint64_t configuration_table;
+} __attribute__ ((packed));
+typedef struct grub_efi_system_table64 grub_efi_system_table64_t;
+
+struct grub_efiemu_runtime_services32
+{
+ grub_efi_table_header_t hdr;
+ grub_efi_uint32_t get_time;
+ grub_efi_uint32_t set_time;
+ grub_efi_uint32_t get_wakeup_time;
+ grub_efi_uint32_t set_wakeup_time;
+ grub_efi_uint32_t set_virtual_address_map;
+ grub_efi_uint32_t convert_pointer;
+ grub_efi_uint32_t get_variable;
+ grub_efi_uint32_t get_next_variable_name;
+ grub_efi_uint32_t set_variable;
+ grub_efi_uint32_t get_next_high_monotonic_count;
+ grub_efi_uint32_t reset_system;
+} __attribute__ ((packed));
+typedef struct grub_efiemu_runtime_services32 grub_efiemu_runtime_services32_t;
+
+struct grub_efiemu_runtime_services64
+{
+ grub_efi_table_header_t hdr;
+ grub_efi_uint64_t get_time;
+ grub_efi_uint64_t set_time;
+ grub_efi_uint64_t get_wakeup_time;
+ grub_efi_uint64_t set_wakeup_time;
+ grub_efi_uint64_t set_virtual_address_map;
+ grub_efi_uint64_t convert_pointer;
+ grub_efi_uint64_t get_variable;
+ grub_efi_uint64_t get_next_variable_name;
+ grub_efi_uint64_t set_variable;
+ grub_efi_uint64_t get_next_high_monotonic_count;
+ grub_efi_uint64_t reset_system;
+} __attribute__ ((packed));
+typedef struct grub_efiemu_runtime_services64 grub_efiemu_runtime_services64_t;
+
+extern grub_efi_system_table32_t *grub_efiemu_system_table32;
+extern grub_efi_system_table64_t *grub_efiemu_system_table64;
+
+/* Convenience macros to access currently loaded efiemu */
+#define grub_efiemu_system_table ((grub_efiemu_sizeof_uintn_t () == 8) \
+ ? (void *) grub_efiemu_system_table64 \
+ : (void *) grub_efiemu_system_table32)
+#define GRUB_EFIEMU_SIZEOF_OF_UINTN (grub_efiemu_sizeof_uintn_t ())
+#define GRUB_EFIEMU_SYSTEM_TABLE(x) ((grub_efiemu_sizeof_uintn_t () == 8) \
+ ? grub_efiemu_system_table64->x \
+ : grub_efiemu_system_table32->x)
+#define GRUB_EFIEMU_SYSTEM_TABLE_SET(x,y) ((grub_efiemu_sizeof_uintn_t () == 8)\
+ ? (grub_efiemu_system_table64->x \
+ = (y)) \
+ : (grub_efiemu_system_table32->x \
+ = (y)))
+#define GRUB_EFIEMU_SYSTEM_TABLE_PTR(x) ((grub_efiemu_sizeof_uintn_t () == 8)\
+ ? UINT_TO_PTR \
+ (grub_efiemu_system_table64->x) \
+ : UINT_TO_PTR \
+ (grub_efiemu_system_table32->x))
+#define GRUB_EFIEMU_SYSTEM_TABLE_VAR(x) ((grub_efiemu_sizeof_uintn_t () == 8) \
+ ? (void *) \
+ &(grub_efiemu_system_table64->x) \
+ : (void *) \
+ &(grub_efiemu_system_table32->x))
+#define GRUB_EFIEMU_SYSTEM_TABLE_SIZEOF(x) \
+ ((grub_efiemu_sizeof_uintn_t () == 8) \
+ ? sizeof(grub_efiemu_system_table64->x)\
+ : sizeof(grub_efiemu_system_table32->x))
+#define GRUB_EFIEMU_SYSTEM_TABLE_SIZEOF_TOTAL ((grub_efiemu_sizeof_uintn_t () == 8) ? sizeof(*grub_efiemu_system_table64):sizeof(*grub_efiemu_system_table32))
+
+/* ELF management definitions and functions */
+
+struct grub_efiemu_segment
+{
+ struct grub_efiemu_segment *next;
+ grub_size_t size;
+ unsigned section;
+ int handle;
+ int ptv_rel_needed;
+ grub_off_t off;
+ void *srcptr;
+};
+typedef struct grub_efiemu_segment *grub_efiemu_segment_t;
+
+struct grub_efiemu_elf_sym
+{
+ int handle;
+ grub_off_t off;
+ unsigned section;
+};
+
+int grub_efiemu_check_header32 (void *ehdr, grub_size_t size);
+int grub_efiemu_check_header64 (void *ehdr, grub_size_t size);
+grub_err_t grub_efiemu_loadcore_init32 (void *core, grub_size_t core_size,
+ grub_efiemu_segment_t *segments);
+grub_err_t grub_efiemu_loadcore_init64 (void *core, grub_size_t core_size,
+ grub_efiemu_segment_t *segments);
+grub_err_t grub_efiemu_loadcore_load32 (void *core,
+ grub_size_t core_size,
+ grub_efiemu_segment_t segments);
+grub_err_t grub_efiemu_loadcore_load64 (void *core,
+ grub_size_t core_size,
+ grub_efiemu_segment_t segments);
+grub_err_t grub_efiemu_loadcore_unload32 (void);
+grub_err_t grub_efiemu_loadcore_unload64 (void);
+grub_err_t grub_efiemu_loadcore_unload(void);
+grub_err_t grub_efiemu_loadcore_init (grub_file_t file);
+grub_err_t grub_efiemu_loadcore_load (void);
+
+/* Configuration tables manipulation. Definitions and functions */
+struct grub_efiemu_configuration_table
+{
+ struct grub_efiemu_configuration_table *next;
+ grub_efi_guid_t guid;
+ void * (*get_table) (void *data);
+ void (*unload) (void *data);
+ void *data;
+};
+struct grub_efiemu_configuration_table32
+{
+ grub_efi_guid_t vendor_guid;
+ grub_efi_uint32_t vendor_table;
+} __attribute__ ((packed));
+typedef struct grub_efiemu_configuration_table32 grub_efiemu_configuration_table32_t;
+struct grub_efiemu_configuration_table64
+{
+ grub_efi_guid_t vendor_guid;
+ grub_efi_uint64_t vendor_table;
+} __attribute__ ((packed));
+typedef struct grub_efiemu_configuration_table64 grub_efiemu_configuration_table64_t;
+grub_err_t grub_efiemu_unregister_configuration_table (grub_efi_guid_t guid);
+grub_err_t
+grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
+ void * (*get_table) (void *data),
+ void (*unload) (void *data),
+ void *data);
+
+/* Memory management functions */
+int grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
+ grub_efi_memory_type_t type);
+void *grub_efiemu_mm_obtain_request (int handle);
+int grub_efiemu_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_err_t grub_efiemu_mm_unload (void);
+grub_err_t grub_efiemu_mm_do_alloc (void);
+grub_err_t grub_efiemu_mm_init (void);
+void *grub_efiemu_mm_obtain_request (int handle);
+void grub_efiemu_mm_return_request (int handle);
+grub_efi_memory_type_t grub_efiemu_mm_get_type (int handle);
+
+/* Drop-in replacements for grub_efi_* and grub_machine_* */
+int grub_efiemu_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_err_t
+grub_efiemu_finish_boot_services (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_err_t
+grub_efiemu_mmap_iterate (grub_memory_hook_t hook);
+int grub_efiemu_sizeof_uintn_t (void);
+grub_err_t
+grub_efiemu_get_lower_upper_memory (grub_uint64_t *lower, grub_uint64_t *upper);
+
+/* efiemu main control definitions and functions*/
+typedef enum {GRUB_EFIEMU_NOTLOADED,
+ GRUB_EFIEMU32, GRUB_EFIEMU64} grub_efiemu_mode_t;
+struct grub_efiemu_prepare_hook
+{
+ struct grub_efiemu_prepare_hook *next;
+ grub_err_t (*hook) (void *data);
+ void (*unload) (void *data);
+ void *data;
+};
+grub_err_t grub_efiemu_prepare32 (struct grub_efiemu_prepare_hook
+ *prepare_hooks,
+ struct grub_efiemu_configuration_table
+ *config_tables);
+grub_err_t grub_efiemu_prepare64 (struct grub_efiemu_prepare_hook
+ *prepare_hooks,
+ struct grub_efiemu_configuration_table
+ *config_tables);
+grub_err_t grub_efiemu_unload (void);
+grub_err_t grub_efiemu_prepare (void);
+grub_err_t
+grub_efiemu_register_prepare_hook (grub_err_t (*hook) (void *data),
+ void (*unload) (void *data),
+ void *data);
+
+/* symbols and pointers */
+grub_err_t grub_efiemu_alloc_syms (void);
+grub_err_t grub_efiemu_request_symbols (int num);
+grub_err_t grub_efiemu_resolve_symbol (const char *name,
+ int *handle, grub_off_t *off);
+grub_err_t grub_efiemu_register_symbol (const char *name,
+ int handle, grub_off_t off);
+void grub_efiemu_free_syms (void);
+grub_err_t grub_efiemu_write_value (void * addr, grub_uint32_t value,
+ int plus_handle,
+ int minus_handle, int ptv_needed, int size);
+grub_err_t grub_efiemu_write_sym_markers (void);
+grub_err_t grub_efiemu_pnvram (void);
+grub_err_t grub_efiemu_prepare (void);
+char *grub_efiemu_get_default_core_name (void);
+void grub_efiemu_pnvram_cmd_unregister (void);
+grub_err_t grub_efiemu_autocore (void);
+grub_err_t grub_efiemu_crc32 (void);
+grub_err_t grub_efiemu_crc64 (void);
+grub_err_t
+grub_efiemu_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
+ grub_efi_uintn_t descriptor_size,
+ grub_efi_uint32_t descriptor_version
+ __attribute__ ((unused)),
+ grub_efi_memory_descriptor_t *virtual_map);
+
+grub_err_t grub_machine_efiemu_init_tables (void);
+
+#endif /* ! GRUB_EFI_EMU_HEADER */
diff --git a/include/grub/efiemu/runtime.h b/include/grub/efiemu/runtime.h
new file mode 100644
index 0000000..1eb474a
--- /dev/null
+++ b/include/grub/efiemu/runtime.h
@@ -0,0 +1,37 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_EMU_RUNTIME_HEADER
+#define GRUB_EFI_EMU_RUNTIME_HEADER 1
+
+struct grub_efiemu_ptv_rel
+{
+ grub_uint64_t addr;
+ grub_efi_memory_type_t plustype;
+ grub_efi_memory_type_t minustype;
+ grub_uint32_t size;
+} __attribute__ ((packed));
+
+struct efi_variable
+{
+ grub_efi_guid_t guid;
+ grub_uint32_t namelen;
+ grub_uint32_t size;
+ grub_efi_uint32_t attributes;
+} __attribute__ ((packed));
+#endif /* ! GRUB_EFI_EMU_RUNTIME_HEADER */
diff --git a/include/grub/elf.h b/include/grub/elf.h
new file mode 100644
index 0000000..b9401f2
--- /dev/null
+++ b/include/grub/elf.h
@@ -0,0 +1,2378 @@
+/* This file defines standard ELF types, structures, and macros.
+ Copyright (C) 1995-1999,2000,2001,2002,2008,2009 Free Software Foundation, Inc.
+ This file was part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef GRUB_ELF_H
+#define GRUB_ELF_H 1
+
+/* Standard ELF types. */
+
+#include <grub/types.h>
+
+/* Type for a 16-bit quantity. */
+typedef grub_uint16_t Elf32_Half;
+typedef grub_uint16_t Elf64_Half;
+
+/* Types for signed and unsigned 32-bit quantities. */
+typedef grub_uint32_t Elf32_Word;
+typedef grub_int32_t Elf32_Sword;
+typedef grub_uint32_t Elf64_Word;
+typedef grub_int32_t Elf64_Sword;
+
+/* Types for signed and unsigned 64-bit quantities. */
+typedef grub_uint64_t Elf32_Xword;
+typedef grub_int64_t Elf32_Sxword;
+typedef grub_uint64_t Elf64_Xword;
+typedef grub_int64_t Elf64_Sxword;
+
+/* Type of addresses. */
+typedef grub_uint32_t Elf32_Addr;
+typedef grub_uint64_t Elf64_Addr;
+
+/* Type of file offsets. */
+typedef grub_uint32_t Elf32_Off;
+typedef grub_uint64_t Elf64_Off;
+
+/* Type for section indices, which are 16-bit quantities. */
+typedef grub_uint16_t Elf32_Section;
+typedef grub_uint16_t Elf64_Section;
+
+/* Type for version symbol information. */
+typedef Elf32_Half Elf32_Versym;
+typedef Elf64_Half Elf64_Versym;
+
+
+/* The ELF file header. This appears at the start of every ELF file. */
+
+#define EI_NIDENT (16)
+
+typedef struct
+{
+ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
+ Elf32_Half e_type; /* Object file type */
+ Elf32_Half e_machine; /* Architecture */
+ Elf32_Word e_version; /* Object file version */
+ Elf32_Addr e_entry; /* Entry point virtual address */
+ Elf32_Off e_phoff; /* Program header table file offset */
+ Elf32_Off e_shoff; /* Section header table file offset */
+ Elf32_Word e_flags; /* Processor-specific flags */
+ Elf32_Half e_ehsize; /* ELF header size in bytes */
+ Elf32_Half e_phentsize; /* Program header table entry size */
+ Elf32_Half e_phnum; /* Program header table entry count */
+ Elf32_Half e_shentsize; /* Section header table entry size */
+ Elf32_Half e_shnum; /* Section header table entry count */
+ Elf32_Half e_shstrndx; /* Section header string table index */
+} Elf32_Ehdr;
+
+typedef struct
+{
+ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
+ Elf64_Half e_type; /* Object file type */
+ Elf64_Half e_machine; /* Architecture */
+ Elf64_Word e_version; /* Object file version */
+ Elf64_Addr e_entry; /* Entry point virtual address */
+ Elf64_Off e_phoff; /* Program header table file offset */
+ Elf64_Off e_shoff; /* Section header table file offset */
+ Elf64_Word e_flags; /* Processor-specific flags */
+ Elf64_Half e_ehsize; /* ELF header size in bytes */
+ Elf64_Half e_phentsize; /* Program header table entry size */
+ Elf64_Half e_phnum; /* Program header table entry count */
+ Elf64_Half e_shentsize; /* Section header table entry size */
+ Elf64_Half e_shnum; /* Section header table entry count */
+ Elf64_Half e_shstrndx; /* Section header string table index */
+} Elf64_Ehdr;
+
+/* Fields in the e_ident array. The EI_* macros are indices into the
+ array. The macros under each EI_* macro are the values the byte
+ may have. */
+
+#define EI_MAG0 0 /* File identification byte 0 index */
+#define ELFMAG0 0x7f /* Magic number byte 0 */
+
+#define EI_MAG1 1 /* File identification byte 1 index */
+#define ELFMAG1 'E' /* Magic number byte 1 */
+
+#define EI_MAG2 2 /* File identification byte 2 index */
+#define ELFMAG2 'L' /* Magic number byte 2 */
+
+#define EI_MAG3 3 /* File identification byte 3 index */
+#define ELFMAG3 'F' /* Magic number byte 3 */
+
+/* Conglomeration of the identification bytes, for easy testing as a word. */
+#define ELFMAG "\177ELF"
+#define SELFMAG 4
+
+#define EI_CLASS 4 /* File class byte index */
+#define ELFCLASSNONE 0 /* Invalid class */
+#define ELFCLASS32 1 /* 32-bit objects */
+#define ELFCLASS64 2 /* 64-bit objects */
+#define ELFCLASSNUM 3
+
+#define EI_DATA 5 /* Data encoding byte index */
+#define ELFDATANONE 0 /* Invalid data encoding */
+#define ELFDATA2LSB 1 /* 2's complement, little endian */
+#define ELFDATA2MSB 2 /* 2's complement, big endian */
+#define ELFDATANUM 3
+
+#define EI_VERSION 6 /* File version byte index */
+ /* Value must be EV_CURRENT */
+
+#define EI_OSABI 7 /* OS ABI identification */
+#define ELFOSABI_NONE 0 /* UNIX System V ABI */
+#define ELFOSABI_SYSV 0 /* Alias. */
+#define ELFOSABI_HPUX 1 /* HP-UX */
+#define ELFOSABI_NETBSD 2 /* NetBSD. */
+#define ELFOSABI_LINUX 3 /* Linux. */
+#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
+#define ELFOSABI_AIX 7 /* IBM AIX. */
+#define ELFOSABI_IRIX 8 /* SGI Irix. */
+#define ELFOSABI_FREEBSD 9 /* FreeBSD. */
+#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */
+#define ELFOSABI_MODESTO 11 /* Novell Modesto. */
+#define ELFOSABI_OPENBSD 12 /* OpenBSD. */
+#define ELFOSABI_ARM 97 /* ARM */
+#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
+
+#define EI_ABIVERSION 8 /* ABI version */
+
+#define EI_PAD 9 /* Byte index of padding bytes */
+
+/* Legal values for e_type (object file type). */
+
+#define ET_NONE 0 /* No file type */
+#define ET_REL 1 /* Relocatable file */
+#define ET_EXEC 2 /* Executable file */
+#define ET_DYN 3 /* Shared object file */
+#define ET_CORE 4 /* Core file */
+#define ET_NUM 5 /* Number of defined types */
+#define ET_LOOS 0xfe00 /* OS-specific range start */
+#define ET_HIOS 0xfeff /* OS-specific range end */
+#define ET_LOPROC 0xff00 /* Processor-specific range start */
+#define ET_HIPROC 0xffff /* Processor-specific range end */
+
+/* Legal values for e_machine (architecture). */
+
+#define EM_NONE 0 /* No machine */
+#define EM_M32 1 /* AT&T WE 32100 */
+#define EM_SPARC 2 /* SUN SPARC */
+#define EM_386 3 /* Intel 80386 */
+#define EM_68K 4 /* Motorola m68k family */
+#define EM_88K 5 /* Motorola m88k family */
+#define EM_860 7 /* Intel 80860 */
+#define EM_MIPS 8 /* MIPS R3000 big-endian */
+#define EM_S370 9 /* IBM System/370 */
+#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
+
+#define EM_PARISC 15 /* HPPA */
+#define EM_VPP500 17 /* Fujitsu VPP500 */
+#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
+#define EM_960 19 /* Intel 80960 */
+#define EM_PPC 20 /* PowerPC */
+#define EM_PPC64 21 /* PowerPC 64-bit */
+#define EM_S390 22 /* IBM S390 */
+
+#define EM_V800 36 /* NEC V800 series */
+#define EM_FR20 37 /* Fujitsu FR20 */
+#define EM_RH32 38 /* TRW RH-32 */
+#define EM_RCE 39 /* Motorola RCE */
+#define EM_ARM 40 /* ARM */
+#define EM_FAKE_ALPHA 41 /* Digital Alpha */
+#define EM_SH 42 /* Hitachi SH */
+#define EM_SPARCV9 43 /* SPARC v9 64-bit */
+#define EM_TRICORE 44 /* Siemens Tricore */
+#define EM_ARC 45 /* Argonaut RISC Core */
+#define EM_H8_300 46 /* Hitachi H8/300 */
+#define EM_H8_300H 47 /* Hitachi H8/300H */
+#define EM_H8S 48 /* Hitachi H8S */
+#define EM_H8_500 49 /* Hitachi H8/500 */
+#define EM_IA_64 50 /* Intel Merced */
+#define EM_MIPS_X 51 /* Stanford MIPS-X */
+#define EM_COLDFIRE 52 /* Motorola Coldfire */
+#define EM_68HC12 53 /* Motorola M68HC12 */
+#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
+#define EM_PCP 55 /* Siemens PCP */
+#define EM_NCPU 56 /* Sony nCPU embedded RISC */
+#define EM_NDR1 57 /* Denso NDR1 microprocessor */
+#define EM_STARCORE 58 /* Motorola Start*Core processor */
+#define EM_ME16 59 /* Toyota ME16 processor */
+#define EM_ST100 60 /* STMicroelectronics ST100 processor */
+#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
+#define EM_X86_64 62 /* AMD x86-64 architecture */
+#define EM_PDSP 63 /* Sony DSP Processor */
+
+#define EM_FX66 66 /* Siemens FX66 microcontroller */
+#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
+#define EM_ST7 68 /* STMicroelectronics ST7 8 bit mc */
+#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
+#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
+#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
+#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
+#define EM_SVX 73 /* Silicon Graphics SVx */
+#define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */
+#define EM_VAX 75 /* Digital VAX */
+#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
+#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
+#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
+#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
+#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
+#define EM_HUANY 81 /* Harvard University machine-independent object files */
+#define EM_PRISM 82 /* SiTera Prism */
+#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
+#define EM_FR30 84 /* Fujitsu FR30 */
+#define EM_D10V 85 /* Mitsubishi D10V */
+#define EM_D30V 86 /* Mitsubishi D30V */
+#define EM_V850 87 /* NEC v850 */
+#define EM_M32R 88 /* Mitsubishi M32R */
+#define EM_MN10300 89 /* Matsushita MN10300 */
+#define EM_MN10200 90 /* Matsushita MN10200 */
+#define EM_PJ 91 /* picoJava */
+#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
+#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
+#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
+#define EM_NUM 95
+
+/* If it is necessary to assign new unofficial EM_* values, please
+ pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
+ chances of collision with official or non-GNU unofficial values. */
+
+#define EM_ALPHA 0x9026
+
+/* Legal values for e_version (version). */
+
+#define EV_NONE 0 /* Invalid ELF version */
+#define EV_CURRENT 1 /* Current version */
+#define EV_NUM 2
+
+/* Section header. */
+
+typedef struct
+{
+ Elf32_Word sh_name; /* Section name (string tbl index) */
+ Elf32_Word sh_type; /* Section type */
+ Elf32_Word sh_flags; /* Section flags */
+ Elf32_Addr sh_addr; /* Section virtual addr at execution */
+ Elf32_Off sh_offset; /* Section file offset */
+ Elf32_Word sh_size; /* Section size in bytes */
+ Elf32_Word sh_link; /* Link to another section */
+ Elf32_Word sh_info; /* Additional section information */
+ Elf32_Word sh_addralign; /* Section alignment */
+ Elf32_Word sh_entsize; /* Entry size if section holds table */
+} Elf32_Shdr;
+
+typedef struct
+{
+ Elf64_Word sh_name; /* Section name (string tbl index) */
+ Elf64_Word sh_type; /* Section type */
+ Elf64_Xword sh_flags; /* Section flags */
+ Elf64_Addr sh_addr; /* Section virtual addr at execution */
+ Elf64_Off sh_offset; /* Section file offset */
+ Elf64_Xword sh_size; /* Section size in bytes */
+ Elf64_Word sh_link; /* Link to another section */
+ Elf64_Word sh_info; /* Additional section information */
+ Elf64_Xword sh_addralign; /* Section alignment */
+ Elf64_Xword sh_entsize; /* Entry size if section holds table */
+} Elf64_Shdr;
+
+/* Special section indices. */
+
+#define SHN_UNDEF 0 /* Undefined section */
+#define SHN_LORESERVE 0xff00 /* Start of reserved indices */
+#define SHN_LOPROC 0xff00 /* Start of processor-specific */
+#define SHN_HIPROC 0xff1f /* End of processor-specific */
+#define SHN_LOOS 0xff20 /* Start of OS-specific */
+#define SHN_HIOS 0xff3f /* End of OS-specific */
+#define SHN_ABS 0xfff1 /* Associated symbol is absolute */
+#define SHN_COMMON 0xfff2 /* Associated symbol is common */
+#define SHN_XINDEX 0xffff /* Index is in extra table. */
+#define SHN_HIRESERVE 0xffff /* End of reserved indices */
+
+/* Legal values for sh_type (section type). */
+
+#define SHT_NULL 0 /* Section header table entry unused */
+#define SHT_PROGBITS 1 /* Program data */
+#define SHT_SYMTAB 2 /* Symbol table */
+#define SHT_STRTAB 3 /* String table */
+#define SHT_RELA 4 /* Relocation entries with addends */
+#define SHT_HASH 5 /* Symbol hash table */
+#define SHT_DYNAMIC 6 /* Dynamic linking information */
+#define SHT_NOTE 7 /* Notes */
+#define SHT_NOBITS 8 /* Program space with no data (bss) */
+#define SHT_REL 9 /* Relocation entries, no addends */
+#define SHT_SHLIB 10 /* Reserved */
+#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
+#define SHT_INIT_ARRAY 14 /* Array of constructors */
+#define SHT_FINI_ARRAY 15 /* Array of destructors */
+#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
+#define SHT_GROUP 17 /* Section group */
+#define SHT_SYMTAB_SHNDX 18 /* Extended section indices */
+#define SHT_NUM 19 /* Number of defined types. */
+#define SHT_LOOS 0x60000000 /* Start OS-specific */
+#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */
+#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */
+#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */
+#define SHT_SUNW_move 0x6ffffffa
+#define SHT_SUNW_COMDAT 0x6ffffffb
+#define SHT_SUNW_syminfo 0x6ffffffc
+#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
+#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
+#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
+#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
+#define SHT_HIOS 0x6fffffff /* End OS-specific type */
+#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
+#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
+#define SHT_LOUSER 0x80000000 /* Start of application-specific */
+#define SHT_HIUSER 0x8fffffff /* End of application-specific */
+
+/* Legal values for sh_flags (section flags). */
+
+#define SHF_WRITE (1 << 0) /* Writable */
+#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
+#define SHF_EXECINSTR (1 << 2) /* Executable */
+#define SHF_MERGE (1 << 4) /* Might be merged */
+#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
+#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
+#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
+#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling
+ required */
+#define SHF_GROUP (1 << 9) /* Section is member of a group. */
+#define SHF_TLS (1 << 10) /* Section hold thread-local data. */
+#define SHF_MASKOS 0x0ff00000 /* OS-specific. */
+#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
+
+/* Section group handling. */
+#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */
+
+/* Symbol table entry. */
+
+typedef struct
+{
+ Elf32_Word st_name; /* Symbol name (string tbl index) */
+ Elf32_Addr st_value; /* Symbol value */
+ Elf32_Word st_size; /* Symbol size */
+ unsigned char st_info; /* Symbol type and binding */
+ unsigned char st_other; /* Symbol visibility */
+ Elf32_Section st_shndx; /* Section index */
+} Elf32_Sym;
+
+typedef struct
+{
+ Elf64_Word st_name; /* Symbol name (string tbl index) */
+ unsigned char st_info; /* Symbol type and binding */
+ unsigned char st_other; /* Symbol visibility */
+ Elf64_Section st_shndx; /* Section index */
+ Elf64_Addr st_value; /* Symbol value */
+ Elf64_Xword st_size; /* Symbol size */
+} Elf64_Sym;
+
+/* The syminfo section if available contains additional information about
+ every dynamic symbol. */
+
+typedef struct
+{
+ Elf32_Half si_boundto; /* Direct bindings, symbol bound to */
+ Elf32_Half si_flags; /* Per symbol flags */
+} Elf32_Syminfo;
+
+typedef struct
+{
+ Elf64_Half si_boundto; /* Direct bindings, symbol bound to */
+ Elf64_Half si_flags; /* Per symbol flags */
+} Elf64_Syminfo;
+
+/* Possible values for si_boundto. */
+#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */
+#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */
+#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */
+
+/* Possible bitmasks for si_flags. */
+#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */
+#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */
+#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */
+#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy
+ loaded */
+/* Syminfo version values. */
+#define SYMINFO_NONE 0
+#define SYMINFO_CURRENT 1
+#define SYMINFO_NUM 2
+
+
+/* How to extract and insert information held in the st_info field. */
+
+#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
+#define ELF32_ST_TYPE(val) ((val) & 0xf)
+#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
+
+/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
+#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
+#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
+#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
+
+/* Legal values for ST_BIND subfield of st_info (symbol binding). */
+
+#define STB_LOCAL 0 /* Local symbol */
+#define STB_GLOBAL 1 /* Global symbol */
+#define STB_WEAK 2 /* Weak symbol */
+#define STB_NUM 3 /* Number of defined types. */
+#define STB_LOOS 10 /* Start of OS-specific */
+#define STB_HIOS 12 /* End of OS-specific */
+#define STB_LOPROC 13 /* Start of processor-specific */
+#define STB_HIPROC 15 /* End of processor-specific */
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
+
+#define STT_NOTYPE 0 /* Symbol type is unspecified */
+#define STT_OBJECT 1 /* Symbol is a data object */
+#define STT_FUNC 2 /* Symbol is a code object */
+#define STT_SECTION 3 /* Symbol associated with a section */
+#define STT_FILE 4 /* Symbol's name is file name */
+#define STT_COMMON 5 /* Symbol is a common data object */
+#define STT_TLS 6 /* Symbol is thread-local data object*/
+#define STT_NUM 7 /* Number of defined types. */
+#define STT_LOOS 10 /* Start of OS-specific */
+#define STT_HIOS 12 /* End of OS-specific */
+#define STT_LOPROC 13 /* Start of processor-specific */
+#define STT_HIPROC 15 /* End of processor-specific */
+
+
+/* Symbol table indices are found in the hash buckets and chain table
+ of a symbol hash table section. This special index value indicates
+ the end of a chain, meaning no further symbols are found in that bucket. */
+
+#define STN_UNDEF 0 /* End of a chain. */
+#define STN_ABS 65521
+
+
+/* How to extract and insert information held in the st_other field. */
+
+#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
+
+/* For ELF64 the definitions are the same. */
+#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
+
+/* Symbol visibility specification encoded in the st_other field. */
+#define STV_DEFAULT 0 /* Default symbol visibility rules */
+#define STV_INTERNAL 1 /* Processor specific hidden class */
+#define STV_HIDDEN 2 /* Sym unavailable in other modules */
+#define STV_PROTECTED 3 /* Not preemptible, not exported */
+
+
+/* Relocation table entry without addend (in section of type SHT_REL). */
+
+typedef struct
+{
+ Elf32_Addr r_offset; /* Address */
+ Elf32_Word r_info; /* Relocation type and symbol index */
+} Elf32_Rel;
+
+/* I have seen two different definitions of the Elf64_Rel and
+ Elf64_Rela structures, so we'll leave them out until Novell (or
+ whoever) gets their act together. */
+/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */
+
+typedef struct
+{
+ Elf64_Addr r_offset; /* Address */
+ Elf64_Xword r_info; /* Relocation type and symbol index */
+} Elf64_Rel;
+
+/* Relocation table entry with addend (in section of type SHT_RELA). */
+
+typedef struct
+{
+ Elf32_Addr r_offset; /* Address */
+ Elf32_Word r_info; /* Relocation type and symbol index */
+ Elf32_Sword r_addend; /* Addend */
+} Elf32_Rela;
+
+typedef struct
+{
+ Elf64_Addr r_offset; /* Address */
+ Elf64_Xword r_info; /* Relocation type and symbol index */
+ Elf64_Sxword r_addend; /* Addend */
+} Elf64_Rela;
+
+/* How to extract and insert information held in the r_info field. */
+
+#define ELF32_R_SYM(val) ((val) >> 8)
+#define ELF32_R_TYPE(val) ((val) & 0xff)
+#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
+
+#define ELF64_R_SYM(i) ((i) >> 32)
+#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
+#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
+
+/* Program segment header. */
+
+typedef struct
+{
+ Elf32_Word p_type; /* Segment type */
+ Elf32_Off p_offset; /* Segment file offset */
+ Elf32_Addr p_vaddr; /* Segment virtual address */
+ Elf32_Addr p_paddr; /* Segment physical address */
+ Elf32_Word p_filesz; /* Segment size in file */
+ Elf32_Word p_memsz; /* Segment size in memory */
+ Elf32_Word p_flags; /* Segment flags */
+ Elf32_Word p_align; /* Segment alignment */
+} Elf32_Phdr;
+
+typedef struct
+{
+ Elf64_Word p_type; /* Segment type */
+ Elf64_Word p_flags; /* Segment flags */
+ Elf64_Off p_offset; /* Segment file offset */
+ Elf64_Addr p_vaddr; /* Segment virtual address */
+ Elf64_Addr p_paddr; /* Segment physical address */
+ Elf64_Xword p_filesz; /* Segment size in file */
+ Elf64_Xword p_memsz; /* Segment size in memory */
+ Elf64_Xword p_align; /* Segment alignment */
+} Elf64_Phdr;
+
+/* Legal values for p_type (segment type). */
+
+#define PT_NULL 0 /* Program header table entry unused */
+#define PT_LOAD 1 /* Loadable program segment */
+#define PT_DYNAMIC 2 /* Dynamic linking information */
+#define PT_INTERP 3 /* Program interpreter */
+#define PT_NOTE 4 /* Auxiliary information */
+#define PT_SHLIB 5 /* Reserved */
+#define PT_PHDR 6 /* Entry for header table itself */
+#define PT_TLS 7 /* Thread-local storage segment */
+#define PT_NUM 8 /* Number of defined types */
+#define PT_LOOS 0x60000000 /* Start of OS-specific */
+#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
+#define PT_GNU_STACK 0x6474e551 /* GCC stack segment */
+#define PT_LOSUNW 0x6ffffffa
+#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
+#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */
+#define PT_HISUNW 0x6fffffff
+#define PT_HIOS 0x6fffffff /* End of OS-specific */
+#define PT_LOPROC 0x70000000 /* Start of processor-specific */
+#define PT_HIPROC 0x7fffffff /* End of processor-specific */
+
+/* Legal values for p_flags (segment flags). */
+
+#define PF_X (1 << 0) /* Segment is executable */
+#define PF_W (1 << 1) /* Segment is writable */
+#define PF_R (1 << 2) /* Segment is readable */
+#define PF_MASKOS 0x0ff00000 /* OS-specific */
+#define PF_MASKPROC 0xf0000000 /* Processor-specific */
+
+/* Legal values for note segment descriptor types for core files. */
+
+#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
+#define NT_FPREGSET 2 /* Contains copy of fpregset struct */
+#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
+#define NT_PRXREG 4 /* Contains copy of prxregset struct */
+#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */
+#define NT_AUXV 6 /* Contains copy of auxv array */
+#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */
+#define NT_ASRS 8 /* Contains copy of asrset struct */
+#define NT_PSTATUS 10 /* Contains copy of pstatus struct */
+#define NT_PSINFO 13 /* Contains copy of psinfo struct */
+#define NT_PRCRED 14 /* Contains copy of prcred struct */
+#define NT_UTSNAME 15 /* Contains copy of utsname struct */
+#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */
+#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */
+#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/
+
+/* Legal values for the note segment descriptor types for object files. */
+
+#define NT_VERSION 1 /* Contains a version string. */
+
+
+/* Dynamic section entry. */
+
+typedef struct
+{
+ Elf32_Sword d_tag; /* Dynamic entry type */
+ union
+ {
+ Elf32_Word d_val; /* Integer value */
+ Elf32_Addr d_ptr; /* Address value */
+ } d_un;
+} Elf32_Dyn;
+
+typedef struct
+{
+ Elf64_Sxword d_tag; /* Dynamic entry type */
+ union
+ {
+ Elf64_Xword d_val; /* Integer value */
+ Elf64_Addr d_ptr; /* Address value */
+ } d_un;
+} Elf64_Dyn;
+
+/* Legal values for d_tag (dynamic entry type). */
+
+#define DT_NULL 0 /* Marks end of dynamic section */
+#define DT_NEEDED 1 /* Name of needed library */
+#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */
+#define DT_PLTGOT 3 /* Processor defined value */
+#define DT_HASH 4 /* Address of symbol hash table */
+#define DT_STRTAB 5 /* Address of string table */
+#define DT_SYMTAB 6 /* Address of symbol table */
+#define DT_RELA 7 /* Address of Rela relocs */
+#define DT_RELASZ 8 /* Total size of Rela relocs */
+#define DT_RELAENT 9 /* Size of one Rela reloc */
+#define DT_STRSZ 10 /* Size of string table */
+#define DT_SYMENT 11 /* Size of one symbol table entry */
+#define DT_INIT 12 /* Address of init function */
+#define DT_FINI 13 /* Address of termination function */
+#define DT_SONAME 14 /* Name of shared object */
+#define DT_RPATH 15 /* Library search path (deprecated) */
+#define DT_SYMBOLIC 16 /* Start symbol search here */
+#define DT_REL 17 /* Address of Rel relocs */
+#define DT_RELSZ 18 /* Total size of Rel relocs */
+#define DT_RELENT 19 /* Size of one Rel reloc */
+#define DT_PLTREL 20 /* Type of reloc in PLT */
+#define DT_DEBUG 21 /* For debugging; unspecified */
+#define DT_TEXTREL 22 /* Reloc might modify .text */
+#define DT_JMPREL 23 /* Address of PLT relocs */
+#define DT_BIND_NOW 24 /* Process relocations of object */
+#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
+#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
+#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
+#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
+#define DT_RUNPATH 29 /* Library search path */
+#define DT_FLAGS 30 /* Flags for the object being loaded */
+#define DT_ENCODING 32 /* Start of encoded range */
+#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
+#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
+#define DT_NUM 34 /* Number used */
+#define DT_LOOS 0x6000000d /* Start of OS-specific */
+#define DT_HIOS 0x6ffff000 /* End of OS-specific */
+#define DT_LOPROC 0x70000000 /* Start of processor-specific */
+#define DT_HIPROC 0x7fffffff /* End of processor-specific */
+#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */
+
+/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
+ Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
+ approach. */
+#define DT_VALRNGLO 0x6ffffd00
+#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */
+#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */
+#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */
+#define DT_CHECKSUM 0x6ffffdf8
+#define DT_PLTPADSZ 0x6ffffdf9
+#define DT_MOVEENT 0x6ffffdfa
+#define DT_MOVESZ 0x6ffffdfb
+#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */
+#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting
+ the following DT_* entry. */
+#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */
+#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */
+#define DT_VALRNGHI 0x6ffffdff
+#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */
+#define DT_VALNUM 12
+
+/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
+ Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
+
+ If any adjustment is made to the ELF object after it has been
+ built these entries will need to be adjusted. */
+#define DT_ADDRRNGLO 0x6ffffe00
+#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */
+#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */
+#define DT_CONFIG 0x6ffffefa /* Configuration information. */
+#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */
+#define DT_AUDIT 0x6ffffefc /* Object auditing. */
+#define DT_PLTPAD 0x6ffffefd /* PLT padding. */
+#define DT_MOVETAB 0x6ffffefe /* Move table. */
+#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */
+#define DT_ADDRRNGHI 0x6ffffeff
+#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */
+#define DT_ADDRNUM 10
+
+/* The versioning entry types. The next are defined as part of the
+ GNU extension. */
+#define DT_VERSYM 0x6ffffff0
+
+#define DT_RELACOUNT 0x6ffffff9
+#define DT_RELCOUNT 0x6ffffffa
+
+/* These were chosen by Sun. */
+#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
+#define DT_VERDEF 0x6ffffffc /* Address of version definition
+ table */
+#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
+#define DT_VERNEED 0x6ffffffe /* Address of table with needed
+ versions */
+#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
+#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
+#define DT_VERSIONTAGNUM 16
+
+/* Sun added these machine-independent extensions in the "processor-specific"
+ range. Be compatible. */
+#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
+#define DT_FILTER 0x7fffffff /* Shared object to get values from */
+#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
+#define DT_EXTRANUM 3
+
+/* Values of `d_un.d_val' in the DT_FLAGS entry. */
+#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */
+#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */
+#define DF_TEXTREL 0x00000004 /* Object contains text relocations */
+#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */
+#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */
+
+/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
+ entry in the dynamic section. */
+#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */
+#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */
+#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */
+#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/
+#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/
+#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/
+#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */
+#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */
+#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */
+#define DF_1_TRANS 0x00000200
+#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */
+#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */
+#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */
+#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/
+#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */
+#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */
+#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */
+
+/* Flags for the feature selection in DT_FEATURE_1. */
+#define DTF_1_PARINIT 0x00000001
+#define DTF_1_CONFEXP 0x00000002
+
+/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */
+#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */
+#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not
+ generally available. */
+
+/* Version definition sections. */
+
+typedef struct
+{
+ Elf32_Half vd_version; /* Version revision */
+ Elf32_Half vd_flags; /* Version information */
+ Elf32_Half vd_ndx; /* Version Index */
+ Elf32_Half vd_cnt; /* Number of associated aux entries */
+ Elf32_Word vd_hash; /* Version name hash value */
+ Elf32_Word vd_aux; /* Offset in bytes to verdaux array */
+ Elf32_Word vd_next; /* Offset in bytes to next verdef
+ entry */
+} Elf32_Verdef;
+
+typedef struct
+{
+ Elf64_Half vd_version; /* Version revision */
+ Elf64_Half vd_flags; /* Version information */
+ Elf64_Half vd_ndx; /* Version Index */
+ Elf64_Half vd_cnt; /* Number of associated aux entries */
+ Elf64_Word vd_hash; /* Version name hash value */
+ Elf64_Word vd_aux; /* Offset in bytes to verdaux array */
+ Elf64_Word vd_next; /* Offset in bytes to next verdef
+ entry */
+} Elf64_Verdef;
+
+
+/* Legal values for vd_version (version revision). */
+#define VER_DEF_NONE 0 /* No version */
+#define VER_DEF_CURRENT 1 /* Current version */
+#define VER_DEF_NUM 2 /* Given version number */
+
+/* Legal values for vd_flags (version information flags). */
+#define VER_FLG_BASE 0x1 /* Version definition of file itself */
+#define VER_FLG_WEAK 0x2 /* Weak version identifier */
+
+/* Versym symbol index values. */
+#define VER_NDX_LOCAL 0 /* Symbol is local. */
+#define VER_NDX_GLOBAL 1 /* Symbol is global. */
+#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */
+#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */
+
+/* Auxiliary version information. */
+
+typedef struct
+{
+ Elf32_Word vda_name; /* Version or dependency names */
+ Elf32_Word vda_next; /* Offset in bytes to next verdaux
+ entry */
+} Elf32_Verdaux;
+
+typedef struct
+{
+ Elf64_Word vda_name; /* Version or dependency names */
+ Elf64_Word vda_next; /* Offset in bytes to next verdaux
+ entry */
+} Elf64_Verdaux;
+
+
+/* Version dependency section. */
+
+typedef struct
+{
+ Elf32_Half vn_version; /* Version of structure */
+ Elf32_Half vn_cnt; /* Number of associated aux entries */
+ Elf32_Word vn_file; /* Offset of filename for this
+ dependency */
+ Elf32_Word vn_aux; /* Offset in bytes to vernaux array */
+ Elf32_Word vn_next; /* Offset in bytes to next verneed
+ entry */
+} Elf32_Verneed;
+
+typedef struct
+{
+ Elf64_Half vn_version; /* Version of structure */
+ Elf64_Half vn_cnt; /* Number of associated aux entries */
+ Elf64_Word vn_file; /* Offset of filename for this
+ dependency */
+ Elf64_Word vn_aux; /* Offset in bytes to vernaux array */
+ Elf64_Word vn_next; /* Offset in bytes to next verneed
+ entry */
+} Elf64_Verneed;
+
+
+/* Legal values for vn_version (version revision). */
+#define VER_NEED_NONE 0 /* No version */
+#define VER_NEED_CURRENT 1 /* Current version */
+#define VER_NEED_NUM 2 /* Given version number */
+
+/* Auxiliary needed version information. */
+
+typedef struct
+{
+ Elf32_Word vna_hash; /* Hash value of dependency name */
+ Elf32_Half vna_flags; /* Dependency specific information */
+ Elf32_Half vna_other; /* Unused */
+ Elf32_Word vna_name; /* Dependency name string offset */
+ Elf32_Word vna_next; /* Offset in bytes to next vernaux
+ entry */
+} Elf32_Vernaux;
+
+typedef struct
+{
+ Elf64_Word vna_hash; /* Hash value of dependency name */
+ Elf64_Half vna_flags; /* Dependency specific information */
+ Elf64_Half vna_other; /* Unused */
+ Elf64_Word vna_name; /* Dependency name string offset */
+ Elf64_Word vna_next; /* Offset in bytes to next vernaux
+ entry */
+} Elf64_Vernaux;
+
+
+/* Legal values for vna_flags. */
+#define VER_FLG_WEAK 0x2 /* Weak version identifier */
+
+
+/* Auxiliary vector. */
+
+/* This vector is normally only used by the program interpreter. The
+ usual definition in an ABI supplement uses the name auxv_t. The
+ vector is not usually defined in a standard <elf.h> file, but it
+ can't hurt. We rename it to avoid conflicts. The sizes of these
+ types are an arrangement between the exec server and the program
+ interpreter, so we don't fully specify them here. */
+
+typedef struct
+{
+ int a_type; /* Entry type */
+ union
+ {
+ long int a_val; /* Integer value */
+ void *a_ptr; /* Pointer value */
+ void (*a_fcn) (void); /* Function pointer value */
+ } a_un;
+} Elf32_auxv_t;
+
+typedef struct
+{
+ long int a_type; /* Entry type */
+ union
+ {
+ long int a_val; /* Integer value */
+ void *a_ptr; /* Pointer value */
+ void (*a_fcn) (void); /* Function pointer value */
+ } a_un;
+} Elf64_auxv_t;
+
+/* Legal values for a_type (entry type). */
+
+#define AT_NULL 0 /* End of vector */
+#define AT_IGNORE 1 /* Entry should be ignored */
+#define AT_EXECFD 2 /* File descriptor of program */
+#define AT_PHDR 3 /* Program headers for program */
+#define AT_PHENT 4 /* Size of program header entry */
+#define AT_PHNUM 5 /* Number of program headers */
+#define AT_PAGESZ 6 /* System page size */
+#define AT_BASE 7 /* Base address of interpreter */
+#define AT_FLAGS 8 /* Flags */
+#define AT_ENTRY 9 /* Entry point of program */
+#define AT_NOTELF 10 /* Program is not ELF */
+#define AT_UID 11 /* Real uid */
+#define AT_EUID 12 /* Effective uid */
+#define AT_GID 13 /* Real gid */
+#define AT_EGID 14 /* Effective gid */
+#define AT_CLKTCK 17 /* Frequency of times() */
+
+/* Some more special a_type values describing the hardware. */
+#define AT_PLATFORM 15 /* String identifying platform. */
+#define AT_HWCAP 16 /* Machine dependent hints about
+ processor capabilities. */
+
+/* This entry gives some information about the FPU initialization
+ performed by the kernel. */
+#define AT_FPUCW 18 /* Used FPU control word. */
+
+/* Cache block sizes. */
+#define AT_DCACHEBSIZE 19 /* Data cache block size. */
+#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */
+#define AT_UCACHEBSIZE 21 /* Unified cache block size. */
+
+/* A special ignored value for PPC, used by the kernel to control the
+ interpretation of the AUXV. Must be > 16. */
+#define AT_IGNOREPPC 22 /* Entry should be ignored */
+
+
+/* Note section contents. Each entry in the note section begins with
+ a header of a fixed form. */
+
+typedef struct
+{
+ Elf32_Word n_namesz; /* Length of the note's name. */
+ Elf32_Word n_descsz; /* Length of the note's descriptor. */
+ Elf32_Word n_type; /* Type of the note. */
+} Elf32_Nhdr;
+
+typedef struct
+{
+ Elf64_Word n_namesz; /* Length of the note's name. */
+ Elf64_Word n_descsz; /* Length of the note's descriptor. */
+ Elf64_Word n_type; /* Type of the note. */
+} Elf64_Nhdr;
+
+/* Known names of notes. */
+
+/* Solaris entries in the note section have this name. */
+#define ELF_NOTE_SOLARIS "SUNW Solaris"
+
+/* Note entries for GNU systems have this name. */
+#define ELF_NOTE_GNU "GNU"
+
+
+/* Defined types of notes for Solaris. */
+
+/* Value of descriptor (one word) is desired pagesize for the binary. */
+#define ELF_NOTE_PAGESIZE_HINT 1
+
+
+/* Defined note types for GNU systems. */
+
+/* ABI information. The descriptor consists of words:
+ word 0: OS descriptor
+ word 1: major version of the ABI
+ word 2: minor version of the ABI
+ word 3: subminor version of the ABI
+*/
+#define ELF_NOTE_ABI 1
+
+/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI
+ note section entry. */
+#define ELF_NOTE_OS_LINUX 0
+#define ELF_NOTE_OS_GNU 1
+#define ELF_NOTE_OS_SOLARIS2 2
+
+
+/* Move records. */
+typedef struct
+{
+ Elf32_Xword m_value; /* Symbol value. */
+ Elf32_Word m_info; /* Size and index. */
+ Elf32_Word m_poffset; /* Symbol offset. */
+ Elf32_Half m_repeat; /* Repeat count. */
+ Elf32_Half m_stride; /* Stride info. */
+} Elf32_Move;
+
+typedef struct
+{
+ Elf64_Xword m_value; /* Symbol value. */
+ Elf64_Xword m_info; /* Size and index. */
+ Elf64_Xword m_poffset; /* Symbol offset. */
+ Elf64_Half m_repeat; /* Repeat count. */
+ Elf64_Half m_stride; /* Stride info. */
+} Elf64_Move;
+
+/* Macro to construct move records. */
+#define ELF32_M_SYM(info) ((info) >> 8)
+#define ELF32_M_SIZE(info) ((unsigned char) (info))
+#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size))
+
+#define ELF64_M_SYM(info) ELF32_M_SYM (info)
+#define ELF64_M_SIZE(info) ELF32_M_SIZE (info)
+#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size)
+
+
+/* Motorola 68k specific definitions. */
+
+/* Values for Elf32_Ehdr.e_flags. */
+#define EF_CPU32 0x00810000
+
+/* m68k relocs. */
+
+#define R_68K_NONE 0 /* No reloc */
+#define R_68K_32 1 /* Direct 32 bit */
+#define R_68K_16 2 /* Direct 16 bit */
+#define R_68K_8 3 /* Direct 8 bit */
+#define R_68K_PC32 4 /* PC relative 32 bit */
+#define R_68K_PC16 5 /* PC relative 16 bit */
+#define R_68K_PC8 6 /* PC relative 8 bit */
+#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */
+#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */
+#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */
+#define R_68K_GOT32O 10 /* 32 bit GOT offset */
+#define R_68K_GOT16O 11 /* 16 bit GOT offset */
+#define R_68K_GOT8O 12 /* 8 bit GOT offset */
+#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */
+#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */
+#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */
+#define R_68K_PLT32O 16 /* 32 bit PLT offset */
+#define R_68K_PLT16O 17 /* 16 bit PLT offset */
+#define R_68K_PLT8O 18 /* 8 bit PLT offset */
+#define R_68K_COPY 19 /* Copy symbol at runtime */
+#define R_68K_GLOB_DAT 20 /* Create GOT entry */
+#define R_68K_JMP_SLOT 21 /* Create PLT entry */
+#define R_68K_RELATIVE 22 /* Adjust by program base */
+/* Keep this the last entry. */
+#define R_68K_NUM 23
+
+/* Intel 80386 specific definitions. */
+
+/* i386 relocs. */
+
+#define R_386_NONE 0 /* No reloc */
+#define R_386_32 1 /* Direct 32 bit */
+#define R_386_PC32 2 /* PC relative 32 bit */
+#define R_386_GOT32 3 /* 32 bit GOT entry */
+#define R_386_PLT32 4 /* 32 bit PLT address */
+#define R_386_COPY 5 /* Copy symbol at runtime */
+#define R_386_GLOB_DAT 6 /* Create GOT entry */
+#define R_386_JMP_SLOT 7 /* Create PLT entry */
+#define R_386_RELATIVE 8 /* Adjust by program base */
+#define R_386_GOTOFF 9 /* 32 bit offset to GOT */
+#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */
+#define R_386_32PLT 11
+#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */
+#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS
+ block offset */
+#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block
+ offset */
+#define R_386_TLS_LE 17 /* Offset relative to static TLS
+ block */
+#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of
+ general dynamic thread local data */
+#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of
+ local dynamic thread local data
+ in LE code */
+#define R_386_16 20
+#define R_386_PC16 21
+#define R_386_8 22
+#define R_386_PC8 23
+#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic
+ thread local data */
+#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */
+#define R_386_TLS_GD_CALL 26 /* Relocation for call to
+ __tls_get_addr() */
+#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */
+#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic
+ thread local data in LE code */
+#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */
+#define R_386_TLS_LDM_CALL 30 /* Relocation for call to
+ __tls_get_addr() in LDM code */
+#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */
+#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */
+#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS
+ block offset */
+#define R_386_TLS_LE_32 34 /* Negated offset relative to static
+ TLS block */
+#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */
+#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */
+#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */
+/* Keep this the last entry. */
+#define R_386_NUM 38
+
+
+/* SUN SPARC specific definitions. */
+
+/* x86_64 specific definitions. */
+#define R_X86_64_NONE 0
+#define R_X86_64_64 1
+#define R_X86_64_PC32 2
+#define R_X86_64_GOT32 3
+#define R_X86_64_PLT32 4
+#define R_X86_64_COPY 5
+#define R_X86_64_GLOB_DAT 6
+#define R_X86_64_JUMP_SLOT 7
+#define R_X86_64_RELATIVE 8
+#define R_X86_64_GOTPCREL 9
+#define R_X86_64_32 10
+#define R_X86_64_32S 11
+#define R_X86_64_16 12
+#define R_X86_64_PC16 13
+#define R_X86_64_8 14
+#define R_X86_64_PC8 15
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
+
+#define STT_REGISTER 13 /* Global register reserved to app. */
+
+/* Values for Elf64_Ehdr.e_flags. */
+
+#define EF_SPARCV9_MM 3
+#define EF_SPARCV9_TSO 0
+#define EF_SPARCV9_PSO 1
+#define EF_SPARCV9_RMO 2
+#define EF_SPARC_LEDATA 0x800000 /* little endian data */
+#define EF_SPARC_EXT_MASK 0xFFFF00
+#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */
+#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */
+#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */
+#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */
+
+/* SPARC relocs. */
+
+#define R_SPARC_NONE 0 /* No reloc */
+#define R_SPARC_8 1 /* Direct 8 bit */
+#define R_SPARC_16 2 /* Direct 16 bit */
+#define R_SPARC_32 3 /* Direct 32 bit */
+#define R_SPARC_DISP8 4 /* PC relative 8 bit */
+#define R_SPARC_DISP16 5 /* PC relative 16 bit */
+#define R_SPARC_DISP32 6 /* PC relative 32 bit */
+#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */
+#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */
+#define R_SPARC_HI22 9 /* High 22 bit */
+#define R_SPARC_22 10 /* Direct 22 bit */
+#define R_SPARC_13 11 /* Direct 13 bit */
+#define R_SPARC_LO10 12 /* Truncated 10 bit */
+#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */
+#define R_SPARC_GOT13 14 /* 13 bit GOT entry */
+#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */
+#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */
+#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */
+#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */
+#define R_SPARC_COPY 19 /* Copy symbol at runtime */
+#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */
+#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */
+#define R_SPARC_RELATIVE 22 /* Adjust by program base */
+#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */
+
+/* Additional Sparc64 relocs. */
+
+#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */
+#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */
+#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */
+#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */
+#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */
+#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */
+#define R_SPARC_10 30 /* Direct 10 bit */
+#define R_SPARC_11 31 /* Direct 11 bit */
+#define R_SPARC_64 32 /* Direct 64 bit */
+#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */
+#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */
+#define R_SPARC_HM10 35 /* High middle 10 bits of ... */
+#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */
+#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */
+#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */
+#define R_SPARC_PC_LM22 39 /* Low middle 22 bits of ... */
+#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */
+#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */
+#define R_SPARC_7 43 /* Direct 7 bit */
+#define R_SPARC_5 44 /* Direct 5 bit */
+#define R_SPARC_6 45 /* Direct 6 bit */
+#define R_SPARC_DISP64 46 /* PC relative 64 bit */
+#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */
+#define R_SPARC_HIX22 48 /* High 22 bit complemented */
+#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */
+#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */
+#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */
+#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */
+#define R_SPARC_REGISTER 53 /* Global register usage */
+#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */
+#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */
+#define R_SPARC_TLS_GD_HI22 56
+#define R_SPARC_TLS_GD_LO10 57
+#define R_SPARC_TLS_GD_ADD 58
+#define R_SPARC_TLS_GD_CALL 59
+#define R_SPARC_TLS_LDM_HI22 60
+#define R_SPARC_TLS_LDM_LO10 61
+#define R_SPARC_TLS_LDM_ADD 62
+#define R_SPARC_TLS_LDM_CALL 63
+#define R_SPARC_TLS_LDO_HIX22 64
+#define R_SPARC_TLS_LDO_LOX10 65
+#define R_SPARC_TLS_LDO_ADD 66
+#define R_SPARC_TLS_IE_HI22 67
+#define R_SPARC_TLS_IE_LO10 68
+#define R_SPARC_TLS_IE_LD 69
+#define R_SPARC_TLS_IE_LDX 70
+#define R_SPARC_TLS_IE_ADD 71
+#define R_SPARC_TLS_LE_HIX22 72
+#define R_SPARC_TLS_LE_LOX10 73
+#define R_SPARC_TLS_DTPMOD32 74
+#define R_SPARC_TLS_DTPMOD64 75
+#define R_SPARC_TLS_DTPOFF32 76
+#define R_SPARC_TLS_DTPOFF64 77
+#define R_SPARC_TLS_TPOFF32 78
+#define R_SPARC_TLS_TPOFF64 79
+/* Keep this the last entry. */
+#define R_SPARC_NUM 80
+
+/* For Sparc64, legal values for d_tag of Elf64_Dyn. */
+
+#define DT_SPARC_REGISTER 0x70000001
+#define DT_SPARC_NUM 2
+
+/* Bits present in AT_HWCAP, primarily for Sparc32. */
+
+#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */
+#define HWCAP_SPARC_STBAR 2
+#define HWCAP_SPARC_SWAP 4
+#define HWCAP_SPARC_MULDIV 8
+#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */
+#define HWCAP_SPARC_ULTRA3 32
+
+/* MIPS R3000 specific definitions. */
+
+/* Legal values for e_flags field of Elf32_Ehdr. */
+
+#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */
+#define EF_MIPS_PIC 2 /* Contains PIC code */
+#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */
+#define EF_MIPS_XGOT 8
+#define EF_MIPS_64BIT_WHIRL 16
+#define EF_MIPS_ABI2 32
+#define EF_MIPS_ABI_ON32 64
+#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */
+
+/* Legal values for MIPS architecture level. */
+
+#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
+#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
+#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
+#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
+#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
+#define EF_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */
+#define EF_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */
+
+/* The following are non-official names and should not be used. */
+
+#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
+#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
+#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
+#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
+#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
+#define E_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */
+#define E_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */
+
+/* Special section indices. */
+
+#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */
+#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */
+#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */
+#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */
+#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */
+
+/* Legal values for sh_type field of Elf32_Shdr. */
+
+#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */
+#define SHT_MIPS_MSYM 0x70000001
+#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */
+#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */
+#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */
+#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/
+#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */
+#define SHT_MIPS_PACKAGE 0x70000007
+#define SHT_MIPS_PACKSYM 0x70000008
+#define SHT_MIPS_RELD 0x70000009
+#define SHT_MIPS_IFACE 0x7000000b
+#define SHT_MIPS_CONTENT 0x7000000c
+#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */
+#define SHT_MIPS_SHDR 0x70000010
+#define SHT_MIPS_FDESC 0x70000011
+#define SHT_MIPS_EXTSYM 0x70000012
+#define SHT_MIPS_DENSE 0x70000013
+#define SHT_MIPS_PDESC 0x70000014
+#define SHT_MIPS_LOCSYM 0x70000015
+#define SHT_MIPS_AUXSYM 0x70000016
+#define SHT_MIPS_OPTSYM 0x70000017
+#define SHT_MIPS_LOCSTR 0x70000018
+#define SHT_MIPS_LINE 0x70000019
+#define SHT_MIPS_RFDESC 0x7000001a
+#define SHT_MIPS_DELTASYM 0x7000001b
+#define SHT_MIPS_DELTAINST 0x7000001c
+#define SHT_MIPS_DELTACLASS 0x7000001d
+#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */
+#define SHT_MIPS_DELTADECL 0x7000001f
+#define SHT_MIPS_SYMBOL_LIB 0x70000020
+#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */
+#define SHT_MIPS_TRANSLATE 0x70000022
+#define SHT_MIPS_PIXIE 0x70000023
+#define SHT_MIPS_XLATE 0x70000024
+#define SHT_MIPS_XLATE_DEBUG 0x70000025
+#define SHT_MIPS_WHIRL 0x70000026
+#define SHT_MIPS_EH_REGION 0x70000027
+#define SHT_MIPS_XLATE_OLD 0x70000028
+#define SHT_MIPS_PDR_EXCEPTION 0x70000029
+
+/* Legal values for sh_flags field of Elf32_Shdr. */
+
+#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */
+#define SHF_MIPS_MERGE 0x20000000
+#define SHF_MIPS_ADDR 0x40000000
+#define SHF_MIPS_STRINGS 0x80000000
+#define SHF_MIPS_NOSTRIP 0x08000000
+#define SHF_MIPS_LOCAL 0x04000000
+#define SHF_MIPS_NAMES 0x02000000
+#define SHF_MIPS_NODUPE 0x01000000
+
+
+/* Symbol tables. */
+
+/* MIPS specific values for `st_other'. */
+#define STO_MIPS_DEFAULT 0x0
+#define STO_MIPS_INTERNAL 0x1
+#define STO_MIPS_HIDDEN 0x2
+#define STO_MIPS_PROTECTED 0x3
+#define STO_MIPS_SC_ALIGN_UNUSED 0xff
+
+/* MIPS specific values for `st_info'. */
+#define STB_MIPS_SPLIT_COMMON 13
+
+/* Entries found in sections of type SHT_MIPS_GPTAB. */
+
+typedef union
+{
+ struct
+ {
+ Elf32_Word gt_current_g_value; /* -G value used for compilation */
+ Elf32_Word gt_unused; /* Not used */
+ } gt_header; /* First entry in section */
+ struct
+ {
+ Elf32_Word gt_g_value; /* If this value were used for -G */
+ Elf32_Word gt_bytes; /* This many bytes would be used */
+ } gt_entry; /* Subsequent entries in section */
+} Elf32_gptab;
+
+/* Entry found in sections of type SHT_MIPS_REGINFO. */
+
+typedef struct
+{
+ Elf32_Word ri_gprmask; /* General registers used */
+ Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */
+ Elf32_Sword ri_gp_value; /* $gp register value */
+} Elf32_RegInfo;
+
+/* Entries found in sections of type SHT_MIPS_OPTIONS. */
+
+typedef struct
+{
+ unsigned char kind; /* Determines interpretation of the
+ variable part of descriptor. */
+ unsigned char size; /* Size of descriptor, including header. */
+ Elf32_Section section; /* Section header index of section affected,
+ 0 for global options. */
+ Elf32_Word info; /* Kind-specific information. */
+} Elf_Options;
+
+/* Values for `kind' field in Elf_Options. */
+
+#define ODK_NULL 0 /* Undefined. */
+#define ODK_REGINFO 1 /* Register usage information. */
+#define ODK_EXCEPTIONS 2 /* Exception processing options. */
+#define ODK_PAD 3 /* Section padding options. */
+#define ODK_HWPATCH 4 /* Hardware workarounds performed */
+#define ODK_FILL 5 /* record the fill value used by the linker. */
+#define ODK_TAGS 6 /* reserve space for desktop tools to write. */
+#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */
+#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */
+
+/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */
+
+#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */
+#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */
+#define OEX_PAGE0 0x10000 /* page zero must be mapped. */
+#define OEX_SMM 0x20000 /* Force sequential memory mode? */
+#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */
+#define OEX_PRECISEFP OEX_FPDBUG
+#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */
+
+#define OEX_FPU_INVAL 0x10
+#define OEX_FPU_DIV0 0x08
+#define OEX_FPU_OFLO 0x04
+#define OEX_FPU_UFLO 0x02
+#define OEX_FPU_INEX 0x01
+
+/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */
+
+#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */
+#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */
+#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */
+#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */
+
+#define OPAD_PREFIX 0x1
+#define OPAD_POSTFIX 0x2
+#define OPAD_SYMBOL 0x4
+
+/* Entry found in `.options' section. */
+
+typedef struct
+{
+ Elf32_Word hwp_flags1; /* Extra flags. */
+ Elf32_Word hwp_flags2; /* Extra flags. */
+} Elf_Options_Hw;
+
+/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */
+
+#define OHWA0_R4KEOP_CHECKED 0x00000001
+#define OHWA1_R4KEOP_CLEAN 0x00000002
+
+/* MIPS relocs. */
+
+#define R_MIPS_NONE 0 /* No reloc */
+#define R_MIPS_16 1 /* Direct 16 bit */
+#define R_MIPS_32 2 /* Direct 32 bit */
+#define R_MIPS_REL32 3 /* PC relative 32 bit */
+#define R_MIPS_26 4 /* Direct 26 bit shifted */
+#define R_MIPS_HI16 5 /* High 16 bit */
+#define R_MIPS_LO16 6 /* Low 16 bit */
+#define R_MIPS_GPREL16 7 /* GP relative 16 bit */
+#define R_MIPS_LITERAL 8 /* 16 bit literal entry */
+#define R_MIPS_GOT16 9 /* 16 bit GOT entry */
+#define R_MIPS_PC16 10 /* PC relative 16 bit */
+#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */
+#define R_MIPS_GPREL32 12 /* GP relative 32 bit */
+
+#define R_MIPS_SHIFT5 16
+#define R_MIPS_SHIFT6 17
+#define R_MIPS_64 18
+#define R_MIPS_GOT_DISP 19
+#define R_MIPS_GOT_PAGE 20
+#define R_MIPS_GOT_OFST 21
+#define R_MIPS_GOT_HI16 22
+#define R_MIPS_GOT_LO16 23
+#define R_MIPS_SUB 24
+#define R_MIPS_INSERT_A 25
+#define R_MIPS_INSERT_B 26
+#define R_MIPS_DELETE 27
+#define R_MIPS_HIGHER 28
+#define R_MIPS_HIGHEST 29
+#define R_MIPS_CALL_HI16 30
+#define R_MIPS_CALL_LO16 31
+#define R_MIPS_SCN_DISP 32
+#define R_MIPS_REL16 33
+#define R_MIPS_ADD_IMMEDIATE 34
+#define R_MIPS_PJUMP 35
+#define R_MIPS_RELGOT 36
+#define R_MIPS_JALR 37
+/* Keep this the last entry. */
+#define R_MIPS_NUM 38
+
+/* Legal values for p_type field of Elf32_Phdr. */
+
+#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */
+#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */
+#define PT_MIPS_OPTIONS 0x70000002
+
+/* Special program header types. */
+
+#define PF_MIPS_LOCAL 0x10000000
+
+/* Legal values for d_tag field of Elf32_Dyn. */
+
+#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */
+#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */
+#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */
+#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */
+#define DT_MIPS_FLAGS 0x70000005 /* Flags */
+#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */
+#define DT_MIPS_MSYM 0x70000007
+#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */
+#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */
+#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */
+#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */
+#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */
+#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */
+#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */
+#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */
+#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */
+#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */
+#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */
+#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in
+ DT_MIPS_DELTA_CLASS. */
+#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */
+#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
+ DT_MIPS_DELTA_INSTANCE. */
+#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */
+#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
+ DT_MIPS_DELTA_RELOC. */
+#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta
+ relocations refer to. */
+#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
+ DT_MIPS_DELTA_SYM. */
+#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
+ class declaration. */
+#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
+ DT_MIPS_DELTA_CLASSSYM. */
+#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */
+#define DT_MIPS_PIXIE_INIT 0x70000023
+#define DT_MIPS_SYMBOL_LIB 0x70000024
+#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
+#define DT_MIPS_LOCAL_GOTIDX 0x70000026
+#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
+#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
+#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */
+#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */
+#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
+#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
+#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
+ function stored in GOT. */
+#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added
+ by rld on dlopen() calls. */
+#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
+#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */
+#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
+#define DT_MIPS_NUM 0x32
+
+/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
+
+#define RHF_NONE 0 /* No flags */
+#define RHF_QUICKSTART (1 << 0) /* Use quickstart */
+#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */
+#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */
+#define RHF_NO_MOVE (1 << 3)
+#define RHF_SGI_ONLY (1 << 4)
+#define RHF_GUARANTEE_INIT (1 << 5)
+#define RHF_DELTA_C_PLUS_PLUS (1 << 6)
+#define RHF_GUARANTEE_START_INIT (1 << 7)
+#define RHF_PIXIE (1 << 8)
+#define RHF_DEFAULT_DELAY_LOAD (1 << 9)
+#define RHF_REQUICKSTART (1 << 10)
+#define RHF_REQUICKSTARTED (1 << 11)
+#define RHF_CORD (1 << 12)
+#define RHF_NO_UNRES_UNDEF (1 << 13)
+#define RHF_RLD_ORDER_SAFE (1 << 14)
+
+/* Entries found in sections of type SHT_MIPS_LIBLIST. */
+
+typedef struct
+{
+ Elf32_Word l_name; /* Name (string table index) */
+ Elf32_Word l_time_stamp; /* Timestamp */
+ Elf32_Word l_checksum; /* Checksum */
+ Elf32_Word l_version; /* Interface version */
+ Elf32_Word l_flags; /* Flags */
+} Elf32_Lib;
+
+typedef struct
+{
+ Elf64_Word l_name; /* Name (string table index) */
+ Elf64_Word l_time_stamp; /* Timestamp */
+ Elf64_Word l_checksum; /* Checksum */
+ Elf64_Word l_version; /* Interface version */
+ Elf64_Word l_flags; /* Flags */
+} Elf64_Lib;
+
+
+/* Legal values for l_flags. */
+
+#define LL_NONE 0
+#define LL_EXACT_MATCH (1 << 0) /* Require exact match */
+#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */
+#define LL_REQUIRE_MINOR (1 << 2)
+#define LL_EXPORTS (1 << 3)
+#define LL_DELAY_LOAD (1 << 4)
+#define LL_DELTA (1 << 5)
+
+/* Entries found in sections of type SHT_MIPS_CONFLICT. */
+
+typedef Elf32_Addr Elf32_Conflict;
+
+
+/* HPPA specific definitions. */
+
+/* Legal values for e_flags field of Elf32_Ehdr. */
+
+#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */
+#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */
+#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */
+#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */
+#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch
+ prediction. */
+#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */
+#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */
+
+/* Defined values for `e_flags & EF_PARISC_ARCH' are: */
+
+#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */
+#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */
+#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */
+
+/* Additional section indices. */
+
+#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tentatively declared
+ symbols in ANSI C. */
+#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */
+
+/* Legal values for sh_type field of Elf32_Shdr. */
+
+#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */
+#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */
+#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */
+
+/* Legal values for sh_flags field of Elf32_Shdr. */
+
+#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */
+#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */
+#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
+
+#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */
+
+#define STT_HP_OPAQUE (STT_LOOS + 0x1)
+#define STT_HP_STUB (STT_LOOS + 0x2)
+
+/* HPPA relocs. */
+
+#define R_PARISC_NONE 0 /* No reloc. */
+#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */
+#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */
+#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */
+#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */
+#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */
+#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */
+#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */
+#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */
+#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */
+#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */
+#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */
+#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */
+#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */
+#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */
+#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */
+#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */
+#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */
+#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */
+#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */
+#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */
+#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */
+#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */
+#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */
+#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */
+#define R_PARISC_FPTR64 64 /* 64 bits function address. */
+#define R_PARISC_PLABEL32 65 /* 32 bits function address. */
+#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */
+#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */
+#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */
+#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */
+#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */
+#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */
+#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */
+#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */
+#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */
+#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */
+#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */
+#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */
+#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */
+#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */
+#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */
+#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */
+#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */
+#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */
+#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */
+#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */
+#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */
+#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */
+#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */
+#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */
+#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */
+#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */
+#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */
+#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */
+#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */
+#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */
+#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */
+#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */
+#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */
+#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */
+#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */
+#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */
+#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */
+#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */
+#define R_PARISC_LORESERVE 128
+#define R_PARISC_COPY 128 /* Copy relocation. */
+#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */
+#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */
+#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */
+#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */
+#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */
+#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */
+#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/
+#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */
+#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */
+#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */
+#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */
+#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */
+#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */
+#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */
+#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */
+#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/
+#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/
+#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */
+#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */
+#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */
+#define R_PARISC_HIRESERVE 255
+
+/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */
+
+#define PT_HP_TLS (PT_LOOS + 0x0)
+#define PT_HP_CORE_NONE (PT_LOOS + 0x1)
+#define PT_HP_CORE_VERSION (PT_LOOS + 0x2)
+#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3)
+#define PT_HP_CORE_COMM (PT_LOOS + 0x4)
+#define PT_HP_CORE_PROC (PT_LOOS + 0x5)
+#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6)
+#define PT_HP_CORE_STACK (PT_LOOS + 0x7)
+#define PT_HP_CORE_SHM (PT_LOOS + 0x8)
+#define PT_HP_CORE_MMF (PT_LOOS + 0x9)
+#define PT_HP_PARALLEL (PT_LOOS + 0x10)
+#define PT_HP_FASTBIND (PT_LOOS + 0x11)
+#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12)
+#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13)
+#define PT_HP_STACK (PT_LOOS + 0x14)
+
+#define PT_PARISC_ARCHEXT 0x70000000
+#define PT_PARISC_UNWIND 0x70000001
+
+/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */
+
+#define PF_PARISC_SBP 0x08000000
+
+#define PF_HP_PAGE_SIZE 0x00100000
+#define PF_HP_FAR_SHARED 0x00200000
+#define PF_HP_NEAR_SHARED 0x00400000
+#define PF_HP_CODE 0x01000000
+#define PF_HP_MODIFY 0x02000000
+#define PF_HP_LAZYSWAP 0x04000000
+#define PF_HP_SBP 0x08000000
+
+
+/* Alpha specific definitions. */
+
+/* Legal values for e_flags field of Elf64_Ehdr. */
+
+#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */
+#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */
+
+/* Legal values for sh_type field of Elf64_Shdr. */
+
+/* These two are primarily concerned with ECOFF debugging info. */
+#define SHT_ALPHA_DEBUG 0x70000001
+#define SHT_ALPHA_REGINFO 0x70000002
+
+/* Legal values for sh_flags field of Elf64_Shdr. */
+
+#define SHF_ALPHA_GPREL 0x10000000
+
+/* Legal values for st_other field of Elf64_Sym. */
+#define STO_ALPHA_NOPV 0x80 /* No PV required. */
+#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */
+
+/* Alpha relocs. */
+
+#define R_ALPHA_NONE 0 /* No reloc */
+#define R_ALPHA_REFLONG 1 /* Direct 32 bit */
+#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */
+#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */
+#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */
+#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */
+#define R_ALPHA_GPDISP 6 /* Add displacement to GP */
+#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */
+#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */
+#define R_ALPHA_SREL16 9 /* PC relative 16 bit */
+#define R_ALPHA_SREL32 10 /* PC relative 32 bit */
+#define R_ALPHA_SREL64 11 /* PC relative 64 bit */
+#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */
+#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */
+#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */
+#define R_ALPHA_COPY 24 /* Copy symbol at runtime */
+#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */
+#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */
+#define R_ALPHA_RELATIVE 27 /* Adjust by program base */
+#define R_ALPHA_TLS_GD_HI 28
+#define R_ALPHA_TLSGD 29
+#define R_ALPHA_TLS_LDM 30
+#define R_ALPHA_DTPMOD64 31
+#define R_ALPHA_GOTDTPREL 32
+#define R_ALPHA_DTPREL64 33
+#define R_ALPHA_DTPRELHI 34
+#define R_ALPHA_DTPRELLO 35
+#define R_ALPHA_DTPREL16 36
+#define R_ALPHA_GOTTPREL 37
+#define R_ALPHA_TPREL64 38
+#define R_ALPHA_TPRELHI 39
+#define R_ALPHA_TPRELLO 40
+#define R_ALPHA_TPREL16 41
+/* Keep this the last entry. */
+#define R_ALPHA_NUM 46
+
+/* Magic values of the LITUSE relocation addend. */
+#define LITUSE_ALPHA_ADDR 0
+#define LITUSE_ALPHA_BASE 1
+#define LITUSE_ALPHA_BYTOFF 2
+#define LITUSE_ALPHA_JSR 3
+#define LITUSE_ALPHA_TLS_GD 4
+#define LITUSE_ALPHA_TLS_LDM 5
+
+
+/* PowerPC specific declarations */
+
+/* Values for Elf32/64_Ehdr.e_flags. */
+#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */
+
+/* Cygnus local bits below */
+#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/
+#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib
+ flag */
+
+/* PowerPC relocations defined by the ABIs */
+#define R_PPC_NONE 0
+#define R_PPC_ADDR32 1 /* 32bit absolute address */
+#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
+#define R_PPC_ADDR16 3 /* 16bit absolute address */
+#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
+#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
+#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
+#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
+#define R_PPC_ADDR14_BRTAKEN 8
+#define R_PPC_ADDR14_BRNTAKEN 9
+#define R_PPC_REL24 10 /* PC relative 26 bit */
+#define R_PPC_REL14 11 /* PC relative 16 bit */
+#define R_PPC_REL14_BRTAKEN 12
+#define R_PPC_REL14_BRNTAKEN 13
+#define R_PPC_GOT16 14
+#define R_PPC_GOT16_LO 15
+#define R_PPC_GOT16_HI 16
+#define R_PPC_GOT16_HA 17
+#define R_PPC_PLTREL24 18
+#define R_PPC_COPY 19
+#define R_PPC_GLOB_DAT 20
+#define R_PPC_JMP_SLOT 21
+#define R_PPC_RELATIVE 22
+#define R_PPC_LOCAL24PC 23
+#define R_PPC_UADDR32 24
+#define R_PPC_UADDR16 25
+#define R_PPC_REL32 26
+#define R_PPC_PLT32 27
+#define R_PPC_PLTREL32 28
+#define R_PPC_PLT16_LO 29
+#define R_PPC_PLT16_HI 30
+#define R_PPC_PLT16_HA 31
+#define R_PPC_SDAREL16 32
+#define R_PPC_SECTOFF 33
+#define R_PPC_SECTOFF_LO 34
+#define R_PPC_SECTOFF_HI 35
+#define R_PPC_SECTOFF_HA 36
+/* Keep this the last entry. */
+#define R_PPC_NUM 37
+
+/* PowerPC64 relocations defined by the ABIs */
+#define R_PPC64_NONE R_PPC_NONE
+#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address. */
+#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned. */
+#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address. */
+#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of abs. address. */
+#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of abs. address. */
+#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */
+#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned. */
+#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN
+#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN
+#define R_PPC64_REL24 R_PPC_REL24 /* PC relative 26 bit, word aligned. */
+#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit. */
+#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN
+#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN
+#define R_PPC64_GOT16 R_PPC_GOT16
+#define R_PPC64_GOT16_LO R_PPC_GOT16_LO
+#define R_PPC64_GOT16_HI R_PPC_GOT16_HI
+#define R_PPC64_GOT16_HA R_PPC_GOT16_HA
+
+#define R_PPC64_COPY R_PPC_COPY
+#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT
+#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT
+#define R_PPC64_RELATIVE R_PPC_RELATIVE
+
+#define R_PPC64_UADDR32 R_PPC_UADDR32
+#define R_PPC64_UADDR16 R_PPC_UADDR16
+#define R_PPC64_REL32 R_PPC_REL32
+#define R_PPC64_PLT32 R_PPC_PLT32
+#define R_PPC64_PLTREL32 R_PPC_PLTREL32
+#define R_PPC64_PLT16_LO R_PPC_PLT16_LO
+#define R_PPC64_PLT16_HI R_PPC_PLT16_HI
+#define R_PPC64_PLT16_HA R_PPC_PLT16_HA
+
+#define R_PPC64_SECTOFF R_PPC_SECTOFF
+#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO
+#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI
+#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA
+#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2. */
+#define R_PPC64_ADDR64 38 /* doubleword64 S + A. */
+#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A). */
+#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A). */
+#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A). */
+#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A). */
+#define R_PPC64_UADDR64 43 /* doubleword64 S + A. */
+#define R_PPC64_REL64 44 /* doubleword64 S + A - P. */
+#define R_PPC64_PLT64 45 /* doubleword64 L + A. */
+#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P. */
+#define R_PPC64_TOC16 47 /* half16* S + A - .TOC. */
+#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.). */
+#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.). */
+#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.). */
+#define R_PPC64_TOC 51 /* doubleword64 .TOC. */
+#define R_PPC64_PLTGOT16 52 /* half16* M + A. */
+#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A). */
+#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A). */
+#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A). */
+
+#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2. */
+#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2. */
+#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2. */
+#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2. */
+#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2. */
+#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2. */
+#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2. */
+#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2. */
+#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2. */
+#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2. */
+#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2. */
+/* Keep this the last entry. */
+#define R_PPC64_NUM 67
+
+/* The remaining relocs are from the Embedded ELF ABI, and are not
+ in the SVR4 ELF ABI. */
+#define R_PPC_EMB_NADDR32 101
+#define R_PPC_EMB_NADDR16 102
+#define R_PPC_EMB_NADDR16_LO 103
+#define R_PPC_EMB_NADDR16_HI 104
+#define R_PPC_EMB_NADDR16_HA 105
+#define R_PPC_EMB_SDAI16 106
+#define R_PPC_EMB_SDA2I16 107
+#define R_PPC_EMB_SDA2REL 108
+#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */
+#define R_PPC_EMB_MRKREF 110
+#define R_PPC_EMB_RELSEC16 111
+#define R_PPC_EMB_RELST_LO 112
+#define R_PPC_EMB_RELST_HI 113
+#define R_PPC_EMB_RELST_HA 114
+#define R_PPC_EMB_BIT_FLD 115
+#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */
+
+/* Diab tool relocations. */
+#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */
+#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */
+#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */
+#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */
+#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */
+#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
+
+/* This is a phony reloc to handle any old fashioned TOC16 references
+ that may still be in object files. */
+#define R_PPC_TOC16 255
+
+/* PowerPC64 specific values for the Dyn d_tag field. */
+#define DT_PPC64_GLINK (DT_LOPROC + 0)
+#define DT_PPC64_NUM 1
+
+/* ARM specific declarations */
+
+/* Processor specific flags for the ELF header e_flags field. */
+#define EF_ARM_RELEXEC 0x01
+#define EF_ARM_HASENTRY 0x02
+#define EF_ARM_INTERWORK 0x04
+#define EF_ARM_APCS_26 0x08
+#define EF_ARM_APCS_FLOAT 0x10
+#define EF_ARM_PIC 0x20
+#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */
+#define EF_ARM_NEW_ABI 0x80
+#define EF_ARM_OLD_ABI 0x100
+
+/* Other constants defined in the ARM ELF spec. version B-01. */
+/* NB. These conflict with values defined above. */
+#define EF_ARM_SYMSARESORTED 0x04
+#define EF_ARM_DYNSYMSUSESEGIDX 0x08
+#define EF_ARM_MAPSYMSFIRST 0x10
+#define EF_ARM_EABIMASK 0XFF000000
+
+#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
+#define EF_ARM_EABI_UNKNOWN 0x00000000
+#define EF_ARM_EABI_VER1 0x01000000
+#define EF_ARM_EABI_VER2 0x02000000
+
+/* Additional symbol types for Thumb */
+#define STT_ARM_TFUNC 0xd
+
+/* ARM-specific values for sh_flags */
+#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */
+#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined
+ in the input to a link step */
+
+/* ARM-specific program header flags */
+#define PF_ARM_SB 0x10000000 /* Segment contains the location
+ addressed by the static base */
+
+/* ARM relocs. */
+#define R_ARM_NONE 0 /* No reloc */
+#define R_ARM_PC24 1 /* PC relative 26 bit branch */
+#define R_ARM_ABS32 2 /* Direct 32 bit */
+#define R_ARM_REL32 3 /* PC relative 32 bit */
+#define R_ARM_PC13 4
+#define R_ARM_ABS16 5 /* Direct 16 bit */
+#define R_ARM_ABS12 6 /* Direct 12 bit */
+#define R_ARM_THM_ABS5 7
+#define R_ARM_ABS8 8 /* Direct 8 bit */
+#define R_ARM_SBREL32 9
+#define R_ARM_THM_PC22 10
+#define R_ARM_THM_PC8 11
+#define R_ARM_AMP_VCALL9 12
+#define R_ARM_SWI24 13
+#define R_ARM_THM_SWI8 14
+#define R_ARM_XPC25 15
+#define R_ARM_THM_XPC22 16
+#define R_ARM_COPY 20 /* Copy symbol at runtime */
+#define R_ARM_GLOB_DAT 21 /* Create GOT entry */
+#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
+#define R_ARM_RELATIVE 23 /* Adjust by program base */
+#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */
+#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */
+#define R_ARM_GOT32 26 /* 32 bit GOT entry */
+#define R_ARM_PLT32 27 /* 32 bit PLT address */
+#define R_ARM_ALU_PCREL_7_0 32
+#define R_ARM_ALU_PCREL_15_8 33
+#define R_ARM_ALU_PCREL_23_15 34
+#define R_ARM_LDR_SBREL_11_0 35
+#define R_ARM_ALU_SBREL_19_12 36
+#define R_ARM_ALU_SBREL_27_20 37
+#define R_ARM_GNU_VTENTRY 100
+#define R_ARM_GNU_VTINHERIT 101
+#define R_ARM_THM_PC11 102 /* thumb unconditional branch */
+#define R_ARM_THM_PC9 103 /* thumb conditional branch */
+#define R_ARM_RXPC25 249
+#define R_ARM_RSBREL32 250
+#define R_ARM_THM_RPC22 251
+#define R_ARM_RREL32 252
+#define R_ARM_RABS22 253
+#define R_ARM_RPC24 254
+#define R_ARM_RBASE 255
+/* Keep this the last entry. */
+#define R_ARM_NUM 256
+
+/* IA-64 specific declarations. */
+
+/* Processor specific flags for the Ehdr e_flags field. */
+#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */
+#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */
+#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */
+
+/* Processor specific values for the Phdr p_type field. */
+#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */
+#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */
+
+/* Processor specific flags for the Phdr p_flags field. */
+#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */
+
+/* Processor specific values for the Shdr sh_type field. */
+#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */
+#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */
+
+/* Processor specific flags for the Shdr sh_flags field. */
+#define SHF_IA_64_SHORT 0x10000000 /* section near gp */
+#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */
+
+/* Processor specific values for the Dyn d_tag field. */
+#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0)
+#define DT_IA_64_NUM 1
+
+/* IA-64 relocations. */
+#define R_IA64_NONE 0x00 /* none */
+#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */
+#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */
+#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */
+#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */
+#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */
+#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */
+#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */
+#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */
+#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */
+#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */
+#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */
+#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */
+#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */
+#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */
+#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */
+#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */
+#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */
+#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */
+#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */
+#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */
+#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */
+#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */
+#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */
+#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */
+#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */
+#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */
+#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */
+#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */
+#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */
+#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */
+#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */
+#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */
+#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */
+#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */
+#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */
+#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */
+#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */
+#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */
+#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */
+#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */
+#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */
+#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */
+#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */
+#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */
+#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */
+#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */
+#define R_IA64_REL32MSB 0x6c /* data 4 + REL */
+#define R_IA64_REL32LSB 0x6d /* data 4 + REL */
+#define R_IA64_REL64MSB 0x6e /* data 8 + REL */
+#define R_IA64_REL64LSB 0x6f /* data 8 + REL */
+#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */
+#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */
+#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */
+#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */
+#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */
+#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */
+#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */
+#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */
+#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */
+#define R_IA64_COPY 0x84 /* copy relocation */
+#define R_IA64_SUB 0x85 /* Addend and symbol difference */
+#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */
+#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */
+#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */
+#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */
+#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */
+#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */
+#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */
+#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */
+#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */
+#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */
+#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */
+#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */
+#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */
+#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */
+#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */
+#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */
+#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */
+#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */
+#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */
+
+/* SH specific declarations */
+
+/* SH relocs. */
+#define R_SH_NONE 0
+#define R_SH_DIR32 1
+#define R_SH_REL32 2
+#define R_SH_DIR8WPN 3
+#define R_SH_IND12W 4
+#define R_SH_DIR8WPL 5
+#define R_SH_DIR8WPZ 6
+#define R_SH_DIR8BP 7
+#define R_SH_DIR8W 8
+#define R_SH_DIR8L 9
+#define R_SH_SWITCH16 25
+#define R_SH_SWITCH32 26
+#define R_SH_USES 27
+#define R_SH_COUNT 28
+#define R_SH_ALIGN 29
+#define R_SH_CODE 30
+#define R_SH_DATA 31
+#define R_SH_LABEL 32
+#define R_SH_SWITCH8 33
+#define R_SH_GNU_VTINHERIT 34
+#define R_SH_GNU_VTENTRY 35
+#define R_SH_TLS_GD_32 144
+#define R_SH_TLS_LD_32 145
+#define R_SH_TLS_LDO_32 146
+#define R_SH_TLS_IE_32 147
+#define R_SH_TLS_LE_32 148
+#define R_SH_TLS_DTPMOD32 149
+#define R_SH_TLS_DTPOFF32 150
+#define R_SH_TLS_TPOFF32 151
+#define R_SH_TLS_GD_MOV 152
+#define R_SH_TLS_LDM_MOV 153
+#define R_SH_TLS_LDO_MOV 154
+#define R_SH_TLS_IE_MOV 155
+#define R_SH_TLS_LE_MOV 156
+#define R_SH_GOT32 160
+#define R_SH_PLT32 161
+#define R_SH_COPY 162
+#define R_SH_GLOB_DAT 163
+#define R_SH_JMP_SLOT 164
+#define R_SH_RELATIVE 165
+#define R_SH_GOTOFF 166
+#define R_SH_GOTPC 167
+/* Keep this the last entry. */
+#define R_SH_NUM 256
+
+/* Additional s390 relocs */
+
+#define R_390_NONE 0 /* No reloc. */
+#define R_390_8 1 /* Direct 8 bit. */
+#define R_390_12 2 /* Direct 12 bit. */
+#define R_390_16 3 /* Direct 16 bit. */
+#define R_390_32 4 /* Direct 32 bit. */
+#define R_390_PC32 5 /* PC relative 32 bit. */
+#define R_390_GOT12 6 /* 12 bit GOT offset. */
+#define R_390_GOT32 7 /* 32 bit GOT offset. */
+#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */
+#define R_390_COPY 9 /* Copy symbol at runtime. */
+#define R_390_GLOB_DAT 10 /* Create GOT entry. */
+#define R_390_JMP_SLOT 11 /* Create PLT entry. */
+#define R_390_RELATIVE 12 /* Adjust by program base. */
+#define R_390_GOTOFF 13 /* 32 bit offset to GOT. */
+#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */
+#define R_390_GOT16 15 /* 16 bit GOT offset. */
+#define R_390_PC16 16 /* PC relative 16 bit. */
+#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */
+#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */
+#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */
+#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */
+#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */
+#define R_390_64 22 /* Direct 64 bit. */
+#define R_390_PC64 23 /* PC relative 64 bit. */
+#define R_390_GOT64 24 /* 64 bit GOT offset. */
+#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */
+#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */
+
+/* Keep this the last entry. */
+#define R_390_NUM 27
+
+/* CRIS relocations. */
+#define R_CRIS_NONE 0
+#define R_CRIS_8 1
+#define R_CRIS_16 2
+#define R_CRIS_32 3
+#define R_CRIS_8_PCREL 4
+#define R_CRIS_16_PCREL 5
+#define R_CRIS_32_PCREL 6
+#define R_CRIS_GNU_VTINHERIT 7
+#define R_CRIS_GNU_VTENTRY 8
+#define R_CRIS_COPY 9
+#define R_CRIS_GLOB_DAT 10
+#define R_CRIS_JUMP_SLOT 11
+#define R_CRIS_RELATIVE 12
+#define R_CRIS_16_GOT 13
+#define R_CRIS_32_GOT 14
+#define R_CRIS_16_GOTPLT 15
+#define R_CRIS_32_GOTPLT 16
+#define R_CRIS_32_GOTREL 17
+#define R_CRIS_32_PLT_GOTREL 18
+#define R_CRIS_32_PLT_PCREL 19
+
+#define R_CRIS_NUM 20
+
+/* AMD x86-64 relocations. */
+#define R_X86_64_NONE 0 /* No reloc */
+#define R_X86_64_64 1 /* Direct 64 bit */
+#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
+#define R_X86_64_GOT32 3 /* 32 bit GOT entry */
+#define R_X86_64_PLT32 4 /* 32 bit PLT address */
+#define R_X86_64_COPY 5 /* Copy symbol at runtime */
+#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
+#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
+#define R_X86_64_RELATIVE 8 /* Adjust by program base */
+#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative
+ offset to GOT */
+#define R_X86_64_32 10 /* Direct 32 bit zero extended */
+#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
+#define R_X86_64_16 12 /* Direct 16 bit zero extended */
+#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
+#define R_X86_64_8 14 /* Direct 8 bit sign extended */
+#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
+#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */
+#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */
+#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */
+#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset
+ to two GOT entries for GD symbol */
+#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset
+ to two GOT entries for LD symbol */
+#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
+#define r_x86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset
+ to GOT entry for IE symbol */
+#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */
+
+#define R_X86_64_NUM 24
+
+#if GRUB_TARGET_WORDSIZE == 32
+
+typedef Elf32_Addr Elf_Addr;
+typedef Elf32_Ehdr Elf_Ehdr;
+typedef Elf32_Half Elf_Half;
+typedef Elf32_Off Elf_Off;
+typedef Elf32_Rel Elf_Rel;
+typedef Elf32_Rela Elf_Rela;
+typedef Elf32_Section Elf_Section;
+typedef Elf32_Shdr Elf_Shdr;
+typedef Elf32_Sword Elf_Sword;
+typedef Elf32_Sym Elf_Sym;
+typedef Elf32_Word Elf_Word;
+typedef Elf32_Xword Elf_Xword;
+
+#define ELF_ST_BIND(val) ELF32_ST_BIND(val)
+#define ELF_ST_TYPE(val) ELF32_ST_TYPE(val)
+#define ELF_R_SYM(val) ELF32_R_SYM(val)
+#define ELF_R_TYPE(val) ELF32_R_TYPE(val)
+#define ELF_R_INFO(sym, type) ELF32_R_INFO(sym, type)
+
+#elif GRUB_TARGET_WORDSIZE == 64
+
+typedef Elf64_Addr Elf_Addr;
+typedef Elf64_Ehdr Elf_Ehdr;
+typedef Elf64_Half Elf_Half;
+typedef Elf64_Off Elf_Off;
+typedef Elf64_Rel Elf_Rel;
+typedef Elf64_Rela Elf_Rela;
+typedef Elf64_Section Elf_Section;
+typedef Elf64_Shdr Elf_Shdr;
+typedef Elf64_Sword Elf_Sword;
+typedef Elf64_Sym Elf_Sym;
+typedef Elf64_Word Elf_Word;
+typedef Elf64_Xword Elf_Xword;
+
+#define ELF_ST_BIND(val) ELF64_ST_BIND (val)
+#define ELF_ST_TYPE(val) ELF64_ST_TYPE (val)
+#define ELF_R_SYM(val) ELF64_R_SYM(val)
+#define ELF_R_TYPE(val) ELF64_R_TYPE(val)
+#define ELF_R_INFO(sym, type) ELF64_R_INFO(sym, type)
+
+#endif /* GRUB_TARGET_WORDSIZE == 64 */
+
+#endif /* ! GRUB_ELF_H */
diff --git a/include/grub/elfload.h b/include/grub/elfload.h
new file mode 100644
index 0000000..579656f
--- /dev/null
+++ b/include/grub/elfload.h
@@ -0,0 +1,66 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003, 2004, 2005, 2006, 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_ELFLOAD_HEADER
+#define GRUB_ELFLOAD_HEADER 1
+
+#include <grub/err.h>
+#include <grub/elf.h>
+#include <grub/file.h>
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+struct grub_elf_file
+{
+ grub_file_t file;
+ union {
+ Elf64_Ehdr ehdr64;
+ Elf32_Ehdr ehdr32;
+ } ehdr;
+ void *phdrs;
+};
+typedef struct grub_elf_file *grub_elf_t;
+
+typedef grub_err_t (*grub_elf32_load_hook_t)
+ (Elf32_Phdr *phdr, grub_addr_t *addr, int *load);
+typedef grub_err_t (*grub_elf64_load_hook_t)
+ (Elf64_Phdr *phdr, grub_addr_t *addr, int *load);
+
+grub_elf_t grub_elf_open (const char *);
+grub_elf_t grub_elf_file (grub_file_t);
+grub_err_t grub_elf_close (grub_elf_t);
+
+int grub_elf_is_elf32 (grub_elf_t);
+grub_size_t grub_elf32_size (grub_elf_t, Elf32_Addr *, grub_uint32_t *);
+grub_err_t grub_elf32_load (grub_elf_t, grub_elf32_load_hook_t, grub_addr_t *,
+ grub_size_t *);
+
+int grub_elf_is_elf64 (grub_elf_t);
+grub_size_t grub_elf64_size (grub_elf_t, Elf64_Addr *, grub_uint64_t *);
+grub_err_t grub_elf64_load (grub_elf_t, grub_elf64_load_hook_t, grub_addr_t *,
+ grub_size_t *);
+grub_err_t
+grub_elf32_phdr_iterate (grub_elf_t elf,
+ int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf32_Phdr *, void *),
+ void *hook_arg);
+grub_err_t
+grub_elf64_phdr_iterate (grub_elf_t elf,
+ int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf64_Phdr *, void *),
+ void *hook_arg);
+
+#endif /* ! GRUB_ELFLOAD_HEADER */
diff --git a/include/grub/emu/console.h b/include/grub/emu/console.h
new file mode 100644
index 0000000..1e55682
--- /dev/null
+++ b/include/grub/emu/console.h
@@ -0,0 +1,28 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_CONSOLE_UTIL_HEADER
+#define GRUB_CONSOLE_UTIL_HEADER 1
+
+/* Initialize the console system. */
+void grub_console_init (void);
+
+/* Finish the console system. */
+void grub_console_fini (void);
+
+#endif /* ! GRUB_CONSOLE_UTIL_HEADER */
diff --git a/include/grub/emu/getroot.h b/include/grub/emu/getroot.h
new file mode 100644
index 0000000..581ea80
--- /dev/null
+++ b/include/grub/emu/getroot.h
@@ -0,0 +1,38 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003, 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_UTIL_GETROOT_HEADER
+#define GRUB_UTIL_GETROOT_HEADER 1
+
+#include <sys/types.h>
+
+enum grub_dev_abstraction_types {
+ GRUB_DEV_ABSTRACTION_NONE,
+ GRUB_DEV_ABSTRACTION_LVM,
+ GRUB_DEV_ABSTRACTION_RAID,
+};
+
+char *grub_find_device (const char *dir, dev_t dev);
+char *grub_guess_root_device (const char *dir);
+int grub_util_get_dev_abstraction (const char *os_dev);
+char *grub_util_get_grub_dev (const char *os_dev);
+char *grub_make_system_path_relative_to_its_root (const char *path);
+const char *grub_util_check_block_device (const char *blk_dev);
+const char *grub_util_check_char_device (const char *blk_dev);
+
+#endif /* ! GRUB_UTIL_GETROOT_HEADER */
diff --git a/include/grub/emu/hostdisk.h b/include/grub/emu/hostdisk.h
new file mode 100644
index 0000000..842dff4
--- /dev/null
+++ b/include/grub/emu/hostdisk.h
@@ -0,0 +1,33 @@
+/* biosdisk.h - emulate biosdisk */
+/*
+ * 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_BIOSDISK_MACHINE_UTIL_HEADER
+#define GRUB_BIOSDISK_MACHINE_UTIL_HEADER 1
+
+#include <grub/disk.h>
+
+void grub_util_biosdisk_init (const char *dev_map);
+void grub_util_biosdisk_fini (void);
+char *grub_util_biosdisk_get_grub_dev (const char *os_dev);
+const char *grub_util_biosdisk_get_osdev (grub_disk_t disk);
+int grub_util_biosdisk_is_present (const char *name);
+int grub_util_biosdisk_is_floppy (grub_disk_t disk);
+grub_err_t grub_util_biosdisk_flush (struct grub_disk *disk);
+
+#endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */
diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h
new file mode 100644
index 0000000..d4ebcb0
--- /dev/null
+++ b/include/grub/emu/misc.h
@@ -0,0 +1,83 @@
+/*
+ * 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_EMU_MISC_H
+#define GRUB_EMU_MISC_H 1
+
+#include <config.h>
+#include <stdarg.h>
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+#ifdef __CYGWIN__
+# include <sys/fcntl.h>
+# include <sys/cygwin.h>
+# include <limits.h>
+# define DEV_CYGDRIVE_MAJOR 98
+#endif
+
+#ifdef __NetBSD__
+/* NetBSD uses /boot for its boot block. */
+# define DEFAULT_DIRECTORY "/"GRUB_DIR_NAME
+#else
+# define DEFAULT_DIRECTORY "/"GRUB_BOOT_DIR_NAME"/"GRUB_DIR_NAME
+#endif
+
+#define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map"
+
+extern int verbosity;
+extern const char *program_name;
+
+void grub_emu_init (void);
+void grub_init_all (void);
+void grub_fini_all (void);
+void grub_emu_post_init (void);
+
+void grub_find_zpool_from_dir (const char *dir,
+ char **poolname, char **poolfs);
+
+char *grub_make_system_path_relative_to_its_root (const char *path)
+ __attribute__ ((warn_unused_result));
+
+void * EXPORT_FUNC(xmalloc) (grub_size_t size) __attribute__ ((warn_unused_result));
+void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) __attribute__ ((warn_unused_result));
+char * EXPORT_FUNC(xstrdup) (const char *str) __attribute__ ((warn_unused_result));
+char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((warn_unused_result));
+
+void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...);
+void EXPORT_FUNC(grub_util_info) (const char *fmt, ...);
+void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((noreturn));
+
+#ifndef HAVE_VASPRINTF
+int EXPORT_FUNC(vasprintf) (char **buf, const char *fmt, va_list ap);
+#endif
+
+#ifndef HAVE_ASPRINTF
+int EXPORT_FUNC(asprintf) (char **buf, const char *fmt, ...);
+#endif
+
+extern char * canonicalize_file_name (const char *path);
+
+#ifdef HAVE_DEVICE_MAPPER
+int grub_device_mapper_supported (void);
+#endif
+
+char *grub_find_root_device_from_mountinfo (const char *dir, char **relroot);
+
+#endif /* GRUB_EMU_MISC_H */
diff --git a/include/grub/env.h b/include/grub/env.h
new file mode 100644
index 0000000..c0107f1
--- /dev/null
+++ b/include/grub/env.h
@@ -0,0 +1,69 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2006,2007,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_ENV_HEADER
+#define GRUB_ENV_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/menu.h>
+
+struct grub_env_var;
+
+typedef char *(*grub_env_read_hook_t) (struct grub_env_var *var,
+ const char *val);
+typedef char *(*grub_env_write_hook_t) (struct grub_env_var *var,
+ const char *val);
+
+struct grub_env_var
+{
+ char *name;
+ char *value;
+ grub_env_read_hook_t read_hook;
+ grub_env_write_hook_t write_hook;
+ struct grub_env_var *next;
+ struct grub_env_var **prevp;
+ int global;
+};
+
+grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val);
+char *EXPORT_FUNC(grub_env_get) (const char *name);
+void EXPORT_FUNC(grub_env_unset) (const char *name);
+void EXPORT_FUNC(grub_env_iterate) (int (*func) (struct grub_env_var *var));
+struct grub_env_var *EXPORT_FUNC(grub_env_find) (const char *name);
+grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name,
+ grub_env_read_hook_t read_hook,
+ grub_env_write_hook_t write_hook);
+
+grub_err_t grub_env_context_open (void);
+grub_err_t grub_env_context_close (void);
+grub_err_t EXPORT_FUNC(grub_env_export) (const char *name);
+
+void grub_env_unset_menu (void);
+grub_menu_t grub_env_get_menu (void);
+void grub_env_set_menu (grub_menu_t nmenu);
+
+grub_err_t
+grub_env_extractor_open (int source);
+
+grub_err_t
+grub_env_extractor_close (int source);
+
+
+#endif /* ! GRUB_ENV_HEADER */
diff --git a/include/grub/env_private.h b/include/grub/env_private.h
new file mode 100644
index 0000000..bb00153
--- /dev/null
+++ b/include/grub/env_private.h
@@ -0,0 +1,46 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,2006,2007,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_ENV_PRIVATE_HEADER
+#define GRUB_ENV_PRIVATE_HEADER 1
+
+#include <grub/env.h>
+
+/* The size of the hash table. */
+#define HASHSZ 13
+
+/* A hashtable for quick lookup of variables. */
+struct grub_env_context
+{
+ /* A hash table for variables. */
+ struct grub_env_var *vars[HASHSZ];
+
+ /* One level deeper on the stack. */
+ struct grub_env_context *prev;
+};
+
+/* This is used for sorting only. */
+struct grub_env_sorted_var
+{
+ struct grub_env_var *var;
+ struct grub_env_sorted_var *next;
+};
+
+extern struct grub_env_context *EXPORT_VAR(grub_current_context);
+
+#endif /* ! GRUB_ENV_PRIVATE_HEADER */
diff --git a/include/grub/err.h b/include/grub/err.h
new file mode 100644
index 0000000..69bc6ec
--- /dev/null
+++ b/include/grub/err.h
@@ -0,0 +1,75 @@
+/* err.h - error numbers and prototypes */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2007,2008 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_ERR_HEADER
+#define GRUB_ERR_HEADER 1
+
+#include <grub/symbol.h>
+
+typedef enum
+ {
+ GRUB_ERR_NONE = 0,
+ GRUB_ERR_TEST_FAILURE,
+ GRUB_ERR_BAD_MODULE,
+ GRUB_ERR_OUT_OF_MEMORY,
+ GRUB_ERR_BAD_FILE_TYPE,
+ GRUB_ERR_FILE_NOT_FOUND,
+ GRUB_ERR_FILE_READ_ERROR,
+ GRUB_ERR_BAD_FILENAME,
+ GRUB_ERR_UNKNOWN_FS,
+ GRUB_ERR_BAD_FS,
+ GRUB_ERR_BAD_NUMBER,
+ GRUB_ERR_OUT_OF_RANGE,
+ GRUB_ERR_UNKNOWN_DEVICE,
+ GRUB_ERR_BAD_DEVICE,
+ GRUB_ERR_READ_ERROR,
+ GRUB_ERR_WRITE_ERROR,
+ GRUB_ERR_UNKNOWN_COMMAND,
+ GRUB_ERR_INVALID_COMMAND,
+ GRUB_ERR_BAD_ARGUMENT,
+ GRUB_ERR_BAD_PART_TABLE,
+ GRUB_ERR_UNKNOWN_OS,
+ GRUB_ERR_BAD_OS,
+ GRUB_ERR_NO_KERNEL,
+ GRUB_ERR_BAD_FONT,
+ GRUB_ERR_NOT_IMPLEMENTED_YET,
+ GRUB_ERR_SYMLINK_LOOP,
+ GRUB_ERR_BAD_COMPRESSED_DATA,
+ GRUB_ERR_MENU,
+ GRUB_ERR_TIMEOUT,
+ GRUB_ERR_IO,
+ GRUB_ERR_ACCESS_DENIED,
+ GRUB_ERR_EXTRACTOR,
+ GRUB_ERR_BUG
+ }
+grub_err_t;
+
+extern grub_err_t EXPORT_VAR(grub_errno);
+extern char EXPORT_VAR(grub_errmsg)[];
+
+grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *fmt, ...);
+void EXPORT_FUNC(grub_fatal) (const char *fmt, ...) __attribute__ ((noreturn));
+void EXPORT_FUNC(grub_error_push) (void);
+int EXPORT_FUNC(grub_error_pop) (void);
+void EXPORT_FUNC(grub_print_error) (void);
+extern int EXPORT_VAR(grub_err_printed_errors);
+int grub_err_printf (const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
+#endif /* ! GRUB_ERR_HEADER */
diff --git a/include/grub/extcmd.h b/include/grub/extcmd.h
new file mode 100644
index 0000000..19fe592
--- /dev/null
+++ b/include/grub/extcmd.h
@@ -0,0 +1,79 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_EXTCMD_HEADER
+#define GRUB_EXTCMD_HEADER 1
+
+#include <grub/lib/arg.h>
+#include <grub/command.h>
+#include <grub/script_sh.h>
+
+struct grub_extcmd;
+struct grub_extcmd_context;
+
+typedef grub_err_t (*grub_extcmd_func_t) (struct grub_extcmd_context *ctxt,
+ int argc, char **args);
+
+/* The argcmd description. */
+struct grub_extcmd
+{
+ grub_command_t cmd;
+
+ grub_extcmd_func_t func;
+
+ /* The argument parser optionlist. */
+ const struct grub_arg_option *options;
+
+ void *data;
+};
+typedef struct grub_extcmd *grub_extcmd_t;
+
+/* Command context for each instance of execution. */
+struct grub_extcmd_context
+{
+ struct grub_extcmd *extcmd;
+
+ struct grub_arg_list *state;
+
+ /* Script parameter, if any. */
+ struct grub_script *script;
+};
+typedef struct grub_extcmd_context *grub_extcmd_context_t;
+
+grub_extcmd_t EXPORT_FUNC(grub_register_extcmd) (const char *name,
+ grub_extcmd_func_t func,
+ grub_command_flags_t flags,
+ const char *summary,
+ const char *description,
+ const struct grub_arg_option *parser);
+
+grub_extcmd_t EXPORT_FUNC(grub_register_extcmd_prio) (const char *name,
+ grub_extcmd_func_t func,
+ grub_command_flags_t flags,
+ const char *summary,
+ const char *description,
+ const struct grub_arg_option *parser,
+ int prio);
+
+void EXPORT_FUNC(grub_unregister_extcmd) (grub_extcmd_t cmd);
+
+grub_err_t EXPORT_FUNC(grub_extcmd_dispatcher) (struct grub_command *cmd,
+ int argc, char **args,
+ struct grub_script *script);
+
+#endif /* ! GRUB_EXTCMD_HEADER */
diff --git a/include/grub/fbblit.h b/include/grub/fbblit.h
new file mode 100644
index 0000000..af97dfb
--- /dev/null
+++ b/include/grub/fbblit.h
@@ -0,0 +1,182 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008 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_FBBLIT_HEADER
+#define GRUB_FBBLIT_HEADER 1
+
+/* NOTE: This header is private header for fb driver and should not be used
+ in other parts of the code. */
+
+struct grub_video_fbblit_info;
+
+void
+grub_video_fbblit_replace (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y, int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_directN (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y, int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_BGRX8888_RGBX8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y, int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_BGRX8888_RGB888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_BGR888_RGBX8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_BGR888_RGB888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_RGBX8888_RGB888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_RGB888_RGBX8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_index_RGBX8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_index_RGB888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y, int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_blend (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y, int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_blend_BGRA8888_RGBA8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_blend_BGR888_RGBA8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_blend_RGBA8888_RGBA8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_blend_RGB888_RGBA8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_32bit_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_24bit_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_16bit_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_replace_8bit_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_blend_XXXA8888_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_blend_XXX888_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+
+void
+grub_video_fbblit_blend_XXX565_1bit (struct grub_video_fbblit_info *dst,
+ struct grub_video_fbblit_info *src,
+ int x, int y,
+ int width, int height,
+ int offset_x, int offset_y);
+#endif /* ! GRUB_FBBLIT_HEADER */
diff --git a/include/grub/fbfill.h b/include/grub/fbfill.h
new file mode 100644
index 0000000..c85fa12
--- /dev/null
+++ b/include/grub/fbfill.h
@@ -0,0 +1,75 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008 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_FBFILL_HEADER
+#define GRUB_FBFILL_HEADER 1
+
+/* NOTE: This header is private header for fb driver and should not be used
+ in other parts of the code. */
+
+struct grub_video_fbblit_info;
+
+struct grub_video_fbrender_target
+{
+ /* Copy of the screen's mode info structure, except that width, height and
+ mode_type has been re-adjusted to requested render target settings. */
+ struct grub_video_mode_info mode_info;
+
+ struct
+ {
+ unsigned int x;
+ unsigned int y;
+ unsigned int width;
+ unsigned int height;
+ } viewport;
+
+ /* Indicates whether the data has been allocated by us and must be freed
+ when render target is destroyed. */
+ int is_allocated;
+
+ /* Pointer to data. Can either be in video card memory or in local host's
+ memory. */
+ grub_uint8_t *data;
+};
+
+void
+grub_video_fbfill (struct grub_video_fbblit_info *dst,
+ grub_video_color_t color, int x, int y,
+ int width, int height);
+
+void
+grub_video_fbfill_direct32 (struct grub_video_fbblit_info *dst,
+ grub_video_color_t color, int x, int y,
+ int width, int height);
+
+void
+grub_video_fbfill_direct24 (struct grub_video_fbblit_info *dst,
+ grub_video_color_t color, int x, int y,
+ int width, int height);
+
+void
+grub_video_fbfill_direct16 (struct grub_video_fbblit_info *dst,
+ grub_video_color_t color, int x, int y,
+ int width, int height);
+
+void
+grub_video_fbfill_direct8 (struct grub_video_fbblit_info *dst,
+ grub_video_color_t color, int x, int y,
+ int width, int height);
+
+#endif /* ! GRUB_FBFILL_HEADER */
diff --git a/include/grub/fbutil.h b/include/grub/fbutil.h
new file mode 100644
index 0000000..065ccf9
--- /dev/null
+++ b/include/grub/fbutil.h
@@ -0,0 +1,43 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,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/>.
+ */
+
+/* NOTE: This header is private header for vbe driver and should not be used
+ in other parts of the code. */
+
+#ifndef GRUB_VBEUTIL_MACHINE_HEADER
+#define GRUB_VBEUTIL_MACHINE_HEADER 1
+
+#include <grub/types.h>
+#include <grub/video.h>
+
+struct grub_video_fbblit_info
+{
+ struct grub_video_mode_info *mode_info;
+ grub_uint8_t *data;
+};
+
+grub_uint8_t *grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source,
+ unsigned int x, unsigned int y);
+
+grub_video_color_t get_pixel (struct grub_video_fbblit_info *source,
+ unsigned int x, unsigned int y);
+
+void set_pixel (struct grub_video_fbblit_info *source,
+ unsigned int x, unsigned int y, grub_video_color_t color);
+
+#endif /* ! GRUB_VBEUTIL_MACHINE_HEADER */
diff --git a/include/grub/file.h b/include/grub/file.h
new file mode 100644
index 0000000..3adb170
--- /dev/null
+++ b/include/grub/file.h
@@ -0,0 +1,129 @@
+/*
+ * 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_FILE_HEADER
+#define GRUB_FILE_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/device.h>
+#include <grub/fs.h>
+
+/* File description. */
+struct grub_file
+{
+ /* The underlying device. */
+ grub_device_t device;
+
+ /* The underlying filesystem. */
+ grub_fs_t fs;
+
+ /* The current offset. */
+ grub_off_t offset;
+
+ /* The file size. */
+ grub_off_t size;
+
+ /* If file is not easily seekable. Should be set by underlying layer. */
+ int not_easily_seekable;
+
+ /* Filesystem-specific data. */
+ void *data;
+
+ /* This is called when a sector is read. Used only for a disk device. */
+ void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
+ unsigned offset, unsigned length);
+};
+typedef struct grub_file *grub_file_t;
+
+/* Filters with lower ID are executed first. */
+typedef enum grub_file_filter_id
+ {
+ GRUB_FILE_FILTER_GZIO,
+ GRUB_FILE_FILTER_XZIO,
+ GRUB_FILE_FILTER_MAX,
+ GRUB_FILE_FILTER_COMPRESSION_FIRST = GRUB_FILE_FILTER_GZIO,
+ GRUB_FILE_FILTER_COMPRESSION_LAST = GRUB_FILE_FILTER_XZIO,
+ } grub_file_filter_id_t;
+
+typedef grub_file_t (*grub_file_filter_t) (grub_file_t in);
+
+extern grub_file_filter_t EXPORT_VAR(grub_file_filters_all)[GRUB_FILE_FILTER_MAX];
+extern grub_file_filter_t EXPORT_VAR(grub_file_filters_enabled)[GRUB_FILE_FILTER_MAX];
+
+static inline void
+grub_file_filter_register (grub_file_filter_id_t id, grub_file_filter_t filter)
+{
+ grub_file_filters_all[id] = filter;
+ grub_file_filters_enabled[id] = filter;
+};
+
+static inline void
+grub_file_filter_unregister (grub_file_filter_id_t id)
+{
+ grub_file_filters_all[id] = 0;
+ grub_file_filters_enabled[id] = 0;
+};
+
+static inline void
+grub_file_filter_disable (grub_file_filter_id_t id)
+{
+ grub_file_filters_enabled[id] = 0;
+};
+
+static inline void
+grub_file_filter_disable_compression (void)
+{
+ grub_file_filter_id_t id;
+
+ for (id = GRUB_FILE_FILTER_COMPRESSION_FIRST;
+ id <= GRUB_FILE_FILTER_COMPRESSION_LAST; id++)
+ grub_file_filters_enabled[id] = 0;
+};
+
+/* Get a device name from NAME. */
+char *EXPORT_FUNC(grub_file_get_device_name) (const char *name);
+
+grub_file_t EXPORT_FUNC(grub_file_open) (const char *name);
+grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, void *buf,
+ grub_size_t len);
+grub_off_t EXPORT_FUNC(grub_file_seek) (grub_file_t file, grub_off_t offset);
+grub_err_t EXPORT_FUNC(grub_file_close) (grub_file_t file);
+
+/* Return value of grub_file_size() in case file size is unknown. */
+#define GRUB_FILE_SIZE_UNKNOWN 0xffffffffffffffffULL
+
+static inline grub_off_t
+grub_file_size (const grub_file_t file)
+{
+ return file->size;
+}
+
+static inline grub_off_t
+grub_file_tell (const grub_file_t file)
+{
+ return file->offset;
+}
+
+static inline int
+grub_file_seekable (const grub_file_t file)
+{
+ return !file->not_easily_seekable;
+}
+
+#endif /* ! GRUB_FILE_HEADER */
diff --git a/include/grub/font.h b/include/grub/font.h
new file mode 100644
index 0000000..690363f
--- /dev/null
+++ b/include/grub/font.h
@@ -0,0 +1,125 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,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_FONT_HEADER
+#define GRUB_FONT_HEADER 1
+
+#include <grub/types.h>
+#include <grub/video.h>
+#include <grub/file.h>
+#include <grub/unicode.h>
+
+/* Forward declaration of opaque structure grub_font.
+ Users only pass struct grub_font pointers to the font module functions,
+ and do not have knowledge of the structure contents. */
+struct grub_font;
+
+/* Font type used to access font functions. */
+typedef struct grub_font *grub_font_t;
+
+struct grub_font_node
+{
+ struct grub_font_node *next;
+ grub_font_t value;
+};
+
+/* Global font registry. */
+extern struct grub_font_node *grub_font_list;
+
+struct grub_font_glyph
+{
+ /* Reference to the font this glyph belongs to. */
+ grub_font_t font;
+
+ /* Glyph bitmap width in pixels. */
+ grub_uint16_t width;
+
+ /* Glyph bitmap height in pixels. */
+ grub_uint16_t height;
+
+ /* Glyph bitmap x offset in pixels. Add to screen coordinate. */
+ grub_int16_t offset_x;
+
+ /* Glyph bitmap y offset in pixels. Subtract from screen coordinate. */
+ grub_int16_t offset_y;
+
+ /* Number of pixels to advance to start the next character. */
+ grub_uint16_t device_width;
+
+ /* Row-major order, packed bits (no padding; rows can break within a byte).
+ The length of the array is (width * height + 7) / 8. Within a
+ byte, the most significant bit is the first (leftmost/uppermost) pixel.
+ Pixels are coded as bits, value 1 meaning of opaque pixel and 0 is
+ transparent. If the length of the array does not fit byte boundary, it
+ will be padded with 0 bits to make it fit. */
+ grub_uint8_t bitmap[0];
+};
+
+/* Part of code field which is really used as such. */
+#define GRUB_FONT_CODE_CHAR_MASK 0x001fffff
+#define GRUB_FONT_CODE_RIGHT_JOINED 0x80000000
+#define GRUB_FONT_CODE_LEFT_JOINED 0x40000000
+
+/* Initialize the font loader.
+ Must be called before any fonts are loaded or used. */
+void grub_font_loader_init (void);
+
+/* Load a font and add it to the beginning of the global font list.
+ Returns: 0 upon success; nonzero upon failure. */
+int grub_font_load (const char *filename);
+
+/* Get the font that has the specified name. Font names are in the form
+ "Family Name Bold Italic 14", where Bold and Italic are optional.
+ If no font matches the name specified, the most recently loaded font
+ is returned as a fallback. */
+grub_font_t EXPORT_FUNC (grub_font_get) (const char *font_name);
+
+const char *EXPORT_FUNC (grub_font_get_name) (grub_font_t font);
+
+int EXPORT_FUNC (grub_font_get_max_char_width) (grub_font_t font);
+
+int EXPORT_FUNC (grub_font_get_max_char_height) (grub_font_t font);
+
+int EXPORT_FUNC (grub_font_get_ascent) (grub_font_t font);
+
+int EXPORT_FUNC (grub_font_get_descent) (grub_font_t font);
+
+int EXPORT_FUNC (grub_font_get_leading) (grub_font_t font);
+
+int EXPORT_FUNC (grub_font_get_height) (grub_font_t font);
+
+int EXPORT_FUNC (grub_font_get_xheight) (grub_font_t font);
+
+struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph) (grub_font_t font,
+ grub_uint32_t code);
+
+struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph_with_fallback) (grub_font_t font,
+ grub_uint32_t code);
+
+grub_err_t EXPORT_FUNC (grub_font_draw_glyph) (struct grub_font_glyph *glyph,
+ grub_video_color_t color,
+ int left_x, int baseline_y);
+
+int
+EXPORT_FUNC (grub_font_get_constructed_device_width) (grub_font_t hinted_font,
+ const struct grub_unicode_glyph *glyph_id);
+struct grub_font_glyph *
+EXPORT_FUNC (grub_font_construct_glyph) (grub_font_t hinted_font,
+ const struct grub_unicode_glyph *glyph_id);
+
+#endif /* ! GRUB_FONT_HEADER */
diff --git a/include/grub/fontformat.h b/include/grub/fontformat.h
new file mode 100644
index 0000000..b506058
--- /dev/null
+++ b/include/grub/fontformat.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_FONT_FORMAT_HEADER
+#define GRUB_FONT_FORMAT_HEADER 1
+
+/* FONT_FORMAT_PFF2_MAGIC use only 4 relevants bytes and the \0. */
+#define FONT_FORMAT_PFF2_MAGIC "PFF2"
+#define FONT_FORMAT_SECTION_NAMES_FILE "FILE"
+#define FONT_FORMAT_SECTION_NAMES_FONT_NAME "NAME"
+#define FONT_FORMAT_SECTION_NAMES_POINT_SIZE "PTSZ"
+#define FONT_FORMAT_SECTION_NAMES_WEIGHT "WEIG"
+#define FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH "MAXW"
+#define FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT "MAXH"
+#define FONT_FORMAT_SECTION_NAMES_ASCENT "ASCE"
+#define FONT_FORMAT_SECTION_NAMES_DESCENT "DESC"
+#define FONT_FORMAT_SECTION_NAMES_CHAR_INDEX "CHIX"
+#define FONT_FORMAT_SECTION_NAMES_DATA "DATA"
+#define FONT_FORMAT_SECTION_NAMES_FAMILY "FAMI"
+#define FONT_FORMAT_SECTION_NAMES_SLAN "SLAN"
+
+#endif /* ! GRUB_FONT_FORMAT_HEADER */
+
diff --git a/include/grub/fs.h b/include/grub/fs.h
new file mode 100644
index 0000000..2c39332
--- /dev/null
+++ b/include/grub/fs.h
@@ -0,0 +1,112 @@
+/* fs.h - filesystem manager */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,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_FS_HEADER
+#define GRUB_FS_HEADER 1
+
+#include <grub/device.h>
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+#include <grub/list.h>
+
+/* Forward declaration is required, because of mutual reference. */
+struct grub_file;
+
+struct grub_dirhook_info
+{
+ unsigned dir:1;
+ unsigned mtimeset:1;
+ unsigned case_insensitive:1;
+ grub_int32_t mtime;
+};
+
+/* Filesystem descriptor. */
+struct grub_fs
+{
+ /* The next filesystem. */
+ struct grub_fs *next;
+
+ /* My name. */
+ const char *name;
+
+ /* Call HOOK with each file under DIR. */
+ grub_err_t (*dir) (grub_device_t device, const char *path,
+ int (*hook) (const char *filename,
+ const struct grub_dirhook_info *info));
+
+ /* Open a file named NAME and initialize FILE. */
+ grub_err_t (*open) (struct grub_file *file, const char *name);
+
+ /* Read LEN bytes data from FILE into BUF. */
+ grub_ssize_t (*read) (struct grub_file *file, char *buf, grub_size_t len);
+
+ /* Close the file FILE. */
+ grub_err_t (*close) (struct grub_file *file);
+
+ /* Return the label of the device DEVICE in LABEL. The label is
+ returned in a grub_malloc'ed buffer and should be freed by the
+ caller. */
+ grub_err_t (*label) (grub_device_t device, char **label);
+
+ /* Return the uuid of the device DEVICE in UUID. The uuid is
+ returned in a grub_malloc'ed buffer and should be freed by the
+ caller. */
+ grub_err_t (*uuid) (grub_device_t device, char **uuid);
+
+ /* Get writing time of filesystem. */
+ grub_err_t (*mtime) (grub_device_t device, grub_int32_t *timebuf);
+
+#ifdef GRUB_UTIL
+ /* Whether this filesystem reserves first sector for DOS-style boot. */
+ int reserved_first_sector;
+#endif
+};
+typedef struct grub_fs *grub_fs_t;
+
+/* This is special, because block lists are not files in usual sense. */
+extern struct grub_fs grub_fs_blocklist;
+
+/* This hook is used to automatically load filesystem modules.
+ If this hook loads a module, return non-zero. Otherwise return zero.
+ The newly loaded filesystem is assumed to be inserted into the head of
+ the linked list GRUB_FS_LIST through the function grub_fs_register. */
+typedef int (*grub_fs_autoload_hook_t) (void);
+extern grub_fs_autoload_hook_t EXPORT_VAR(grub_fs_autoload_hook);
+extern grub_fs_t EXPORT_VAR (grub_fs_list);
+
+#ifndef GRUB_LST_GENERATOR
+static inline void
+grub_fs_register (grub_fs_t fs)
+{
+ grub_list_push (GRUB_AS_LIST_P (&grub_fs_list), GRUB_AS_LIST (fs));
+}
+#endif
+
+static inline void
+grub_fs_unregister (grub_fs_t fs)
+{
+ grub_list_remove (GRUB_AS_LIST_P (&grub_fs_list), GRUB_AS_LIST (fs));
+}
+
+#define FOR_FILESYSTEMS(var) FOR_LIST_ELEMENTS((var), (grub_fs_list))
+
+grub_fs_t EXPORT_FUNC(grub_fs_probe) (grub_device_t device);
+
+#endif /* ! GRUB_FS_HEADER */
diff --git a/include/grub/fshelp.h b/include/grub/fshelp.h
new file mode 100644
index 0000000..42d8da5
--- /dev/null
+++ b/include/grub/fshelp.h
@@ -0,0 +1,82 @@
+/* fshelp.h -- Filesystem helper functions */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2005,2006,2007,2008 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_FSHELP_HEADER
+#define GRUB_FSHELP_HEADER 1
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+#include <grub/err.h>
+
+typedef struct grub_fshelp_node *grub_fshelp_node_t;
+
+#define GRUB_FSHELP_CASE_INSENSITIVE 0x100
+#define GRUB_FSHELP_TYPE_MASK 0xff
+#define GRUB_FSHELP_FLAGS_MASK 0x100
+
+enum grub_fshelp_filetype
+ {
+ GRUB_FSHELP_UNKNOWN,
+ GRUB_FSHELP_REG,
+ GRUB_FSHELP_DIR,
+ GRUB_FSHELP_SYMLINK
+ };
+
+/* Lookup the node PATH. The node ROOTNODE describes the root of the
+ directory tree. The node found is returned in FOUNDNODE, which is
+ either a ROOTNODE or a new malloc'ed node. ITERATE_DIR is used to
+ iterate over all directory entries in the current node.
+ READ_SYMLINK is used to read the symlink if a node is a symlink.
+ EXPECTTYPE is the type node that is expected by the called, an
+ error is generated if the node is not of the expected type. Make
+ sure you use the NESTED_FUNC_ATTR macro for HOOK, this is required
+ because GCC has a nasty bug when using regparm=3. */
+grub_err_t
+EXPORT_FUNC(grub_fshelp_find_file) (const char *path,
+ grub_fshelp_node_t rootnode,
+ grub_fshelp_node_t *foundnode,
+ int (*iterate_dir) (grub_fshelp_node_t dir,
+ int NESTED_FUNC_ATTR
+ (*hook) (const char *filename,
+ enum grub_fshelp_filetype filetype,
+ grub_fshelp_node_t node)),
+ char *(*read_symlink) (grub_fshelp_node_t node),
+ enum grub_fshelp_filetype expect);
+
+
+/* Read LEN bytes from the file NODE on disk DISK into the buffer BUF,
+ beginning with the block POS. READ_HOOK should be set before
+ reading a block from the file. GET_BLOCK is used to translate file
+ blocks to disk blocks. The file is FILESIZE bytes big and the
+ blocks have a size of LOG2BLOCKSIZE (in log2). */
+grub_ssize_t
+EXPORT_FUNC(grub_fshelp_read_file) (grub_disk_t disk, grub_fshelp_node_t node,
+ void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
+ unsigned offset,
+ unsigned length),
+ grub_off_t pos, grub_size_t len, char *buf,
+ grub_disk_addr_t (*get_block) (grub_fshelp_node_t node,
+ grub_disk_addr_t block),
+ grub_off_t filesize, int log2blocksize);
+
+unsigned int
+EXPORT_FUNC(grub_fshelp_log2blksize) (unsigned int blksize,
+ unsigned int *pow);
+
+#endif /* ! GRUB_FSHELP_HEADER */
diff --git a/include/grub/gfxmenu_model.h b/include/grub/gfxmenu_model.h
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/include/grub/gfxmenu_model.h
@@ -0,0 +1 @@
+
diff --git a/include/grub/gfxmenu_view.h b/include/grub/gfxmenu_view.h
new file mode 100644
index 0000000..c52a3c7
--- /dev/null
+++ b/include/grub/gfxmenu_view.h
@@ -0,0 +1,115 @@
+/* gfxmenu_view.h - gfxmenu view interface. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_GFXMENU_VIEW_HEADER
+#define GRUB_GFXMENU_VIEW_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/menu.h>
+#include <grub/font.h>
+#include <grub/gfxwidgets.h>
+
+struct grub_gfxmenu_view; /* Forward declaration of opaque type. */
+typedef struct grub_gfxmenu_view *grub_gfxmenu_view_t;
+
+
+grub_gfxmenu_view_t grub_gfxmenu_view_new (const char *theme_path,
+ int width, int height);
+
+void grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view);
+
+/* Set properties on the view based on settings from the specified
+ theme file. */
+grub_err_t grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view,
+ const char *theme_path);
+
+grub_err_t grub_gui_recreate_box (grub_gfxmenu_box_t *boxptr,
+ const char *pattern, const char *theme_dir);
+
+void grub_gfxmenu_view_draw (grub_gfxmenu_view_t view);
+
+void
+grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view);
+
+void
+grub_gfxmenu_redraw_timeout (grub_gfxmenu_view_t view);
+
+void
+grub_gfxmenu_view_redraw (grub_gfxmenu_view_t view,
+ const grub_video_rect_t *region);
+
+void
+grub_gfxmenu_clear_timeout (void *data);
+void
+grub_gfxmenu_print_timeout (int timeout, void *data);
+void
+grub_gfxmenu_set_chosen_entry (int entry, void *data);
+
+grub_err_t grub_font_draw_string (const char *str,
+ grub_font_t font,
+ grub_video_color_t color,
+ int left_x, int baseline_y);
+int grub_font_get_string_width (grub_font_t font,
+ const char *str);
+
+
+/* Implementation details -- this should not be used outside of the
+ view itself. */
+
+#include <grub/video.h>
+#include <grub/bitmap.h>
+#include <grub/gui.h>
+#include <grub/gfxwidgets.h>
+#include <grub/icon_manager.h>
+
+/* Definition of the private representation of the view. */
+struct grub_gfxmenu_view
+{
+ grub_video_rect_t screen;
+
+ grub_font_t title_font;
+ grub_font_t message_font;
+ char *terminal_font_name;
+ grub_gui_color_t title_color;
+ grub_gui_color_t message_color;
+ grub_gui_color_t message_bg_color;
+ struct grub_video_bitmap *desktop_image;
+ grub_gui_color_t desktop_color;
+ grub_gfxmenu_box_t terminal_box;
+ char *title_text;
+ char *progress_message_text;
+ char *theme_path;
+
+ grub_gui_container_t canvas;
+
+ int double_repaint;
+
+ int selected;
+
+ grub_video_rect_t progress_message_frame;
+
+ grub_menu_t menu;
+
+ int nested;
+
+ int first_timeout;
+};
+
+#endif /* ! GRUB_GFXMENU_VIEW_HEADER */
diff --git a/include/grub/gfxterm.h b/include/grub/gfxterm.h
new file mode 100644
index 0000000..295354b
--- /dev/null
+++ b/include/grub/gfxterm.h
@@ -0,0 +1,44 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008 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_GFXTERM_HEADER
+#define GRUB_GFXTERM_HEADER 1
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/term.h>
+#include <grub/video.h>
+
+grub_err_t
+EXPORT_FUNC (grub_gfxterm_set_window) (struct grub_video_render_target *target,
+ int x, int y, int width, int height,
+ int double_repaint,
+ const char *font_name, int border_width);
+
+typedef void (*grub_gfxterm_repaint_callback_t)(int x, int y,
+ int width, int height);
+
+void grub_gfxterm_set_repaint_callback (grub_gfxterm_repaint_callback_t func);
+
+void EXPORT_FUNC (grub_gfxterm_schedule_repaint) (void);
+
+grub_err_t EXPORT_FUNC (grub_gfxterm_fullscreen) (void);
+
+extern void (*EXPORT_VAR (grub_gfxterm_decorator_hook)) (void);
+
+#endif /* ! GRUB_GFXTERM_HEADER */
diff --git a/include/grub/gfxwidgets.h b/include/grub/gfxwidgets.h
new file mode 100644
index 0000000..8ce666c
--- /dev/null
+++ b/include/grub/gfxwidgets.h
@@ -0,0 +1,50 @@
+/* gfxwidgets.h - Widgets for the graphical menu (gfxmenu). */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_GFXWIDGETS_HEADER
+#define GRUB_GFXWIDGETS_HEADER 1
+
+#include <grub/video.h>
+
+typedef struct grub_gfxmenu_box *grub_gfxmenu_box_t;
+
+struct grub_gfxmenu_box
+{
+ /* The size of the content. */
+ int content_width;
+ int content_height;
+
+ struct grub_video_bitmap **raw_pixmaps;
+ struct grub_video_bitmap **scaled_pixmaps;
+
+ void (*draw) (grub_gfxmenu_box_t self, int x, int y);
+ void (*set_content_size) (grub_gfxmenu_box_t self,
+ int width, int height);
+ int (*get_border_width) (grub_gfxmenu_box_t self);
+ int (*get_left_pad) (grub_gfxmenu_box_t self);
+ int (*get_top_pad) (grub_gfxmenu_box_t self);
+ int (*get_right_pad) (grub_gfxmenu_box_t self);
+ int (*get_bottom_pad) (grub_gfxmenu_box_t self);
+ void (*destroy) (grub_gfxmenu_box_t self);
+};
+
+grub_gfxmenu_box_t grub_gfxmenu_create_box (const char *pixmaps_prefix,
+ const char *pixmaps_suffix);
+
+#endif /* ! GRUB_GFXWIDGETS_HEADER */
diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h
new file mode 100644
index 0000000..5f8ddea
--- /dev/null
+++ b/include/grub/gpt_partition.h
@@ -0,0 +1,71 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2006,2007,2008 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_GPT_PARTITION_HEADER
+#define GRUB_GPT_PARTITION_HEADER 1
+
+#include <grub/types.h>
+
+struct grub_gpt_part_type
+{
+ grub_uint32_t data1;
+ grub_uint16_t data2;
+ grub_uint16_t data3;
+ grub_uint8_t data4[8];
+} __attribute__ ((aligned(8)));
+typedef struct grub_gpt_part_type grub_gpt_part_type_t;
+
+#define GRUB_GPT_PARTITION_TYPE_EMPTY \
+ { 0x0, 0x0, 0x0, \
+ { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } \
+ }
+
+#define GRUB_GPT_PARTITION_TYPE_BIOS_BOOT \
+ { grub_cpu_to_le32_compile_time (0x21686148), grub_cpu_to_le16_compile_time (0x6449), grub_cpu_to_le16_compile_time (0x6e6f), \
+ { 0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } \
+ }
+
+struct grub_gpt_header
+{
+ grub_uint8_t magic[8];
+ grub_uint32_t version;
+ grub_uint32_t headersize;
+ grub_uint32_t crc32;
+ grub_uint32_t unused1;
+ grub_uint64_t primary;
+ grub_uint64_t backup;
+ grub_uint64_t start;
+ grub_uint64_t end;
+ grub_uint8_t guid[16];
+ grub_uint64_t partitions;
+ grub_uint32_t maxpart;
+ grub_uint32_t partentry_size;
+ grub_uint32_t partentry_crc32;
+} __attribute__ ((packed));
+
+struct grub_gpt_partentry
+{
+ grub_gpt_part_type_t type;
+ grub_uint8_t guid[16];
+ grub_uint64_t start;
+ grub_uint64_t end;
+ grub_uint64_t attrib;
+ char name[72];
+} __attribute__ ((packed));
+
+#endif /* ! GRUB_GPT_PARTITION_HEADER */
diff --git a/include/grub/gui.h b/include/grub/gui.h
new file mode 100644
index 0000000..6e4a11c
--- /dev/null
+++ b/include/grub/gui.h
@@ -0,0 +1,275 @@
+/* gui.h - GUI components header file. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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/types.h>
+#include <grub/err.h>
+#include <grub/video.h>
+#include <grub/bitmap.h>
+#include <grub/gfxmenu_view.h>
+#include <grub/mm.h>
+
+#ifndef GRUB_GUI_H
+#define GRUB_GUI_H 1
+
+/* The component ID identifying GUI components to be updated as the timeout
+ status changes. */
+#define GRUB_GFXMENU_TIMEOUT_COMPONENT_ID "__timeout__"
+
+/* A representation of a color. Unlike grub_video_color_t, this
+ representation is independent of any video mode specifics. */
+typedef struct grub_gui_color
+{
+ grub_uint8_t red;
+ grub_uint8_t green;
+ grub_uint8_t blue;
+ grub_uint8_t alpha;
+} grub_gui_color_t;
+
+typedef struct grub_gui_component *grub_gui_component_t;
+typedef struct grub_gui_container *grub_gui_container_t;
+typedef struct grub_gui_list *grub_gui_list_t;
+
+typedef void (*grub_gui_component_callback) (grub_gui_component_t component,
+ void *userdata);
+
+/* Component interface. */
+
+struct grub_gui_component_ops
+{
+ void (*destroy) (void *self);
+ const char * (*get_id) (void *self);
+ int (*is_instance) (void *self, const char *type);
+ void (*paint) (void *self, const grub_video_rect_t *bounds);
+ void (*set_parent) (void *self, grub_gui_container_t parent);
+ grub_gui_container_t (*get_parent) (void *self);
+ void (*set_bounds) (void *self, const grub_video_rect_t *bounds);
+ void (*get_bounds) (void *self, grub_video_rect_t *bounds);
+ void (*get_minimal_size) (void *self, unsigned *width, unsigned *height);
+ grub_err_t (*set_property) (void *self, const char *name, const char *value);
+ void (*repaint) (void *self, int second_pass);
+};
+
+struct grub_gui_container_ops
+{
+ void (*add) (void *self, grub_gui_component_t comp);
+ void (*remove) (void *self, grub_gui_component_t comp);
+ void (*iterate_children) (void *self,
+ grub_gui_component_callback cb, void *userdata);
+};
+
+struct grub_gui_list_ops
+{
+ void (*set_view_info) (void *self,
+ grub_gfxmenu_view_t view);
+};
+
+struct grub_gui_progress_ops
+{
+ void (*set_state) (void *self, int visible, int start, int current, int end);
+};
+
+typedef void (*grub_gfxmenu_set_state_t) (void *self, int visible, int start,
+ int current, int end);
+
+struct grub_gfxmenu_timeout_notify
+{
+ struct grub_gfxmenu_timeout_notify *next;
+ grub_gfxmenu_set_state_t set_state;
+ grub_gui_component_t self;
+};
+
+extern struct grub_gfxmenu_timeout_notify *grub_gfxmenu_timeout_notifications;
+
+static inline grub_err_t
+grub_gfxmenu_timeout_register (grub_gui_component_t self,
+ grub_gfxmenu_set_state_t set_state)
+{
+ struct grub_gfxmenu_timeout_notify *ne = grub_malloc (sizeof (*ne));
+ if (!ne)
+ return grub_errno;
+ ne->set_state = set_state;
+ ne->self = self;
+ ne->next = grub_gfxmenu_timeout_notifications;
+ grub_gfxmenu_timeout_notifications = ne;
+ return GRUB_ERR_NONE;
+}
+
+static inline void
+grub_gfxmenu_timeout_unregister (grub_gui_component_t self)
+{
+ struct grub_gfxmenu_timeout_notify **p, *q;
+
+ for (p = &grub_gfxmenu_timeout_notifications, q = *p;
+ q; p = &(q->next), q = q->next)
+ if (q->self == self)
+ {
+ *p = q->next;
+ break;
+ }
+}
+
+typedef signed grub_fixed_signed_t;
+#define GRUB_FIXED_1 0x10000
+
+static inline signed
+grub_fixed_sfs_divide (signed a, grub_fixed_signed_t b)
+{
+ return (a * GRUB_FIXED_1) / b;
+}
+
+static inline grub_fixed_signed_t
+grub_fixed_fsf_divide (grub_fixed_signed_t a, signed b)
+{
+ return a / b;
+}
+
+static inline signed
+grub_fixed_sfs_multiply (signed a, grub_fixed_signed_t b)
+{
+ return (a * b) / GRUB_FIXED_1;
+}
+
+static inline signed
+grub_fixed_to_signed (grub_fixed_signed_t in)
+{
+ return in / GRUB_FIXED_1;
+}
+
+static inline grub_fixed_signed_t
+grub_signed_to_fixed (signed in)
+{
+ return in * GRUB_FIXED_1;
+}
+
+struct grub_gui_component
+{
+ struct grub_gui_component_ops *ops;
+ signed x;
+ grub_fixed_signed_t xfrac;
+ signed y;
+ grub_fixed_signed_t yfrac;
+ signed w;
+ grub_fixed_signed_t wfrac;
+ signed h;
+ grub_fixed_signed_t hfrac;
+};
+
+struct grub_gui_progress
+{
+ struct grub_gui_component component;
+ struct grub_gui_progress_ops *ops;
+};
+
+struct grub_gui_container
+{
+ struct grub_gui_component component;
+ struct grub_gui_container_ops *ops;
+};
+
+struct grub_gui_list
+{
+ struct grub_gui_component component;
+ struct grub_gui_list_ops *ops;
+};
+
+
+/* Interfaces to concrete component classes. */
+
+grub_gui_container_t grub_gui_canvas_new (void);
+grub_gui_container_t grub_gui_vbox_new (void);
+grub_gui_container_t grub_gui_hbox_new (void);
+grub_gui_component_t grub_gui_label_new (void);
+grub_gui_component_t grub_gui_image_new (void);
+grub_gui_component_t grub_gui_progress_bar_new (void);
+grub_gui_component_t grub_gui_list_new (void);
+grub_gui_component_t grub_gui_circular_progress_new (void);
+
+/* Manipulation functions. */
+
+/* Visit all components with the specified ID. */
+void grub_gui_find_by_id (grub_gui_component_t root,
+ const char *id,
+ grub_gui_component_callback cb,
+ void *userdata);
+
+/* Visit all components. */
+void grub_gui_iterate_recursively (grub_gui_component_t root,
+ grub_gui_component_callback cb,
+ void *userdata);
+
+/* Helper functions. */
+
+static __inline void
+grub_gui_save_viewport (grub_video_rect_t *r)
+{
+ grub_video_get_viewport ((unsigned *) &r->x,
+ (unsigned *) &r->y,
+ (unsigned *) &r->width,
+ (unsigned *) &r->height);
+}
+
+static __inline void
+grub_gui_restore_viewport (const grub_video_rect_t *r)
+{
+ grub_video_set_viewport (r->x, r->y, r->width, r->height);
+}
+
+/* Set a new viewport relative the the current one, saving the current
+ viewport in OLD so it can be later restored. */
+static __inline void
+grub_gui_set_viewport (const grub_video_rect_t *r, grub_video_rect_t *old)
+{
+ grub_gui_save_viewport (old);
+ grub_video_set_viewport (old->x + r->x,
+ old->y + r->y,
+ r->width,
+ r->height);
+}
+
+static __inline grub_gui_color_t
+grub_gui_color_rgb (int r, int g, int b)
+{
+ grub_gui_color_t c;
+ c.red = r;
+ c.green = g;
+ c.blue = b;
+ c.alpha = 255;
+ return c;
+}
+
+static __inline grub_video_color_t
+grub_gui_map_color (grub_gui_color_t c)
+{
+ return grub_video_map_rgba (c.red, c.green, c.blue, c.alpha);
+}
+
+static inline int
+grub_video_have_common_points (const grub_video_rect_t *a,
+ const grub_video_rect_t *b)
+{
+ if (!((a->x <= b->x && b->x <= a->x + a->width)
+ || (b->x <= a->x && a->x <= b->x + b->width)))
+ return 0;
+ if (!((a->y <= b->y && b->y <= a->y + a->height)
+ || (b->y <= a->y && a->y <= b->y + b->height)))
+ return 0;
+ return 1;
+}
+
+#endif /* ! GRUB_GUI_H */
diff --git a/include/grub/gui_string_util.h b/include/grub/gui_string_util.h
new file mode 100644
index 0000000..1baa2ee
--- /dev/null
+++ b/include/grub/gui_string_util.h
@@ -0,0 +1,37 @@
+/* gui_string_util.h - String utilities for the graphical menu interface. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_GUI_STRING_UTIL_HEADER
+#define GRUB_GUI_STRING_UTIL_HEADER 1
+
+#include <grub/types.h>
+#include <grub/gui.h>
+
+char *grub_new_substring (const char *buf,
+ grub_size_t start, grub_size_t end);
+
+char *grub_resolve_relative_path (const char *base, const char *path);
+
+char *grub_get_dirname (const char *file_path);
+
+int grub_gui_get_named_color (const char *name, grub_gui_color_t *color);
+
+grub_err_t grub_gui_parse_color (const char *s, grub_gui_color_t *color);
+
+#endif /* GRUB_GUI_STRING_UTIL_HEADER */
diff --git a/include/grub/hfs.h b/include/grub/hfs.h
new file mode 100644
index 0000000..d93b9a2
--- /dev/null
+++ b/include/grub/hfs.h
@@ -0,0 +1,61 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,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_HFS_HEADER
+#define GRUB_HFS_HEADER 1
+
+#include <grub/types.h>
+
+#define GRUB_HFS_MAGIC 0x4244
+
+/* A single extent. A file consists of one or more extents. */
+struct grub_hfs_extent
+{
+ /* The first physical block. */
+ grub_uint16_t first_block;
+ grub_uint16_t count;
+};
+
+/* HFS stores extents in groups of 3. */
+typedef struct grub_hfs_extent grub_hfs_datarecord_t[3];
+
+/* The HFS superblock (The official name is `Master Directory
+ Block'). */
+struct grub_hfs_sblock
+{
+ grub_uint16_t magic;
+ grub_uint8_t unused[18];
+ grub_uint32_t blksz;
+ grub_uint8_t unused2[4];
+ grub_uint16_t first_block;
+ grub_uint8_t unused4[6];
+
+ /* A pascal style string that holds the volumename. */
+ grub_uint8_t volname[28];
+
+ grub_uint8_t unused5[52];
+ grub_uint64_t num_serial;
+ grub_uint16_t embed_sig;
+ struct grub_hfs_extent embed_extent;
+ grub_uint8_t unused6[4];
+ grub_hfs_datarecord_t extent_recs;
+ grub_uint32_t catalog_size;
+ grub_hfs_datarecord_t catalog_recs;
+} __attribute__ ((packed));
+
+#endif /* ! GRUB_HFS_HEADER */
diff --git a/include/grub/i18n.h b/include/grub/i18n.h
new file mode 100644
index 0000000..a91d733
--- /dev/null
+++ b/include/grub/i18n.h
@@ -0,0 +1,68 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_I18N_H
+#define GRUB_I18N_H 1
+
+#include <config.h>
+#include <grub/symbol.h>
+
+/* NLS can be disabled through the configure --disable-nls option. */
+#if (defined(ENABLE_NLS) && ENABLE_NLS) || !defined (GRUB_UTIL)
+
+extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s);
+
+# ifdef GRUB_UTIL
+
+# include <locale.h>
+# include <libintl.h>
+
+# endif /* GRUB_UTIL */
+
+#else /* ! (defined(ENABLE_NLS) && ENABLE_NLS) */
+
+/* Disabled NLS.
+ The casts to 'const char *' serve the purpose of producing warnings
+ for invalid uses of the value returned from these functions.
+ On pre-ANSI systems without 'const', the config.h file is supposed to
+ contain "#define const". */
+static inline const char * __attribute__ ((always_inline))
+gettext (const char *str)
+{
+ return str;
+}
+
+#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
+
+#ifdef GRUB_UTIL
+static inline const char * __attribute__ ((always_inline))
+_ (const char *str)
+{
+ return gettext(str);
+}
+#else
+static inline const char * __attribute__ ((always_inline))
+_ (const char *str)
+{
+ return grub_gettext(str);
+}
+#endif /* GRUB_UTIL */
+
+#define N_(str) str
+
+#endif /* GRUB_I18N_H */
diff --git a/include/grub/i386/at_keyboard.h b/include/grub/i386/at_keyboard.h
new file mode 100644
index 0000000..da4e806
--- /dev/null
+++ b/include/grub/i386/at_keyboard.h
@@ -0,0 +1,25 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_CPU_AT_KEYBOARD_HEADER
+#define GRUB_CPU_AT_KEYBOARD_HEADER 1
+
+#define KEYBOARD_REG_DATA 0x60
+#define KEYBOARD_REG_STATUS 0x64
+
+#endif
diff --git a/include/grub/i386/bsd.h b/include/grub/i386/bsd.h
new file mode 100644
index 0000000..53008cd
--- /dev/null
+++ b/include/grub/i386/bsd.h
@@ -0,0 +1,122 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_BSD_CPU_HEADER
+#define GRUB_BSD_CPU_HEADER 1
+
+#include <grub/types.h>
+#include <grub/relocator.h>
+
+#include <grub/i386/freebsd_reboot.h>
+#include <grub/i386/netbsd_reboot.h>
+#include <grub/i386/openbsd_reboot.h>
+#include <grub/i386/freebsd_linker.h>
+#include <grub/i386/netbsd_bootinfo.h>
+#include <grub/i386/openbsd_bootarg.h>
+
+enum bsd_kernel_types
+ {
+ KERNEL_TYPE_NONE,
+ KERNEL_TYPE_FREEBSD,
+ KERNEL_TYPE_OPENBSD,
+ KERNEL_TYPE_NETBSD,
+ };
+
+#define GRUB_BSD_TEMP_BUFFER 0x80000
+
+#define FREEBSD_B_DEVMAGIC OPENBSD_B_DEVMAGIC
+#define FREEBSD_B_SLICESHIFT OPENBSD_B_CTRLSHIFT
+#define FREEBSD_B_UNITSHIFT OPENBSD_B_UNITSHIFT
+#define FREEBSD_B_PARTSHIFT OPENBSD_B_PARTSHIFT
+#define FREEBSD_B_TYPESHIFT OPENBSD_B_TYPESHIFT
+
+#define FREEBSD_MODTYPE_KERNEL "elf kernel"
+#define FREEBSD_MODTYPE_KERNEL64 "elf64 kernel"
+#define FREEBSD_MODTYPE_ELF_MODULE "elf module"
+#define FREEBSD_MODTYPE_ELF_MODULE_OBJ "elf obj module"
+#define FREEBSD_MODTYPE_RAW "raw"
+
+#define FREEBSD_BOOTINFO_VERSION 1
+
+struct grub_freebsd_bootinfo
+{
+ grub_uint32_t version;
+ grub_uint8_t unused1[44];
+ grub_uint32_t length;
+ grub_uint8_t unused2;
+ grub_uint8_t boot_device;
+ grub_uint8_t unused3[18];
+ grub_uint32_t kern_end;
+ grub_uint32_t environment;
+ grub_uint32_t tags;
+} __attribute__ ((packed));
+
+struct freebsd_tag_header
+{
+ grub_uint32_t type;
+ grub_uint32_t len;
+};
+
+grub_err_t grub_freebsd_load_elfmodule32 (struct grub_relocator *relocator,
+ grub_file_t file, int argc,
+ char *argv[], grub_addr_t *kern_end);
+grub_err_t grub_freebsd_load_elfmodule_obj64 (struct grub_relocator *relocator,
+ grub_file_t file, int argc,
+ char *argv[],
+ grub_addr_t *kern_end);
+grub_err_t grub_freebsd_load_elf_meta32 (struct grub_relocator *relocator,
+ grub_file_t file,
+ grub_addr_t *kern_end);
+grub_err_t grub_freebsd_load_elf_meta64 (struct grub_relocator *relocator,
+ grub_file_t file,
+ grub_addr_t *kern_end);
+
+grub_err_t grub_netbsd_load_elf_meta32 (struct grub_relocator *relocator,
+ grub_file_t file,
+ grub_addr_t *kern_end);
+grub_err_t grub_netbsd_load_elf_meta64 (struct grub_relocator *relocator,
+ grub_file_t file,
+ grub_addr_t *kern_end);
+
+grub_err_t grub_bsd_add_meta (grub_uint32_t type,
+ void *data, grub_uint32_t len);
+grub_err_t grub_freebsd_add_meta_module (char *filename, char *type,
+ int argc, char **argv,
+ grub_addr_t addr, grub_uint32_t size);
+
+struct grub_openbsd_ramdisk_descriptor
+{
+ grub_size_t max_size;
+ grub_uint8_t *target;
+ grub_uint32_t *size;
+};
+
+grub_err_t grub_openbsd_find_ramdisk32 (grub_file_t file,
+ grub_addr_t kern_start,
+ void *kern_chunk_src,
+ struct grub_openbsd_ramdisk_descriptor *desc);
+grub_err_t grub_openbsd_find_ramdisk64 (grub_file_t file,
+ grub_addr_t kern_start,
+ void *kern_chunk_src,
+ struct grub_openbsd_ramdisk_descriptor *desc);
+
+extern grub_uint8_t grub_bsd64_trampoline_start, grub_bsd64_trampoline_end;
+extern grub_uint32_t grub_bsd64_trampoline_selfjump;
+extern grub_uint32_t grub_bsd64_trampoline_gdt;
+
+#endif /* ! GRUB_BSD_CPU_HEADER */
diff --git a/include/grub/i386/cmos.h b/include/grub/i386/cmos.h
new file mode 100644
index 0000000..8b1fa35
--- /dev/null
+++ b/include/grub/i386/cmos.h
@@ -0,0 +1,28 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_CPU_CMOS_H
+#define GRUB_CPU_CMOS_H 1
+
+#include <grub/types.h>
+#include <grub/cpu/io.h>
+
+#define GRUB_CMOS_ADDR_REG 0x70
+#define GRUB_CMOS_DATA_REG 0x71
+
+#endif /* GRUB_CPU_CMOS_H */
diff --git a/include/grub/i386/coreboot/boot.h b/include/grub/i386/coreboot/boot.h
new file mode 100644
index 0000000..6cd23aa
--- /dev/null
+++ b/include/grub/i386/coreboot/boot.h
@@ -0,0 +1 @@
+#include <grub/i386/pc/boot.h>
diff --git a/include/grub/i386/coreboot/console.h b/include/grub/i386/coreboot/console.h
new file mode 100644
index 0000000..2ffef73
--- /dev/null
+++ b/include/grub/i386/coreboot/console.h
@@ -0,0 +1,25 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_MACHINE_CONSOLE_HEADER
+#define GRUB_MACHINE_CONSOLE_HEADER 1
+
+void grub_vga_text_init (void);
+void grub_vga_text_fini (void);
+
+#endif /* ! GRUB_MACHINE_CONSOLE_HEADER */
diff --git a/include/grub/i386/coreboot/lbio.h b/include/grub/i386/coreboot/lbio.h
new file mode 100644
index 0000000..aa18539
--- /dev/null
+++ b/include/grub/i386/coreboot/lbio.h
@@ -0,0 +1,49 @@
+/* memory.h - describe the memory map */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2007,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_MACHINE_LBIO_HEADER
+#define _GRUB_MACHINE_LBIO_HEADER 1
+
+struct grub_linuxbios_table_header
+{
+ char signature[4];
+ grub_uint32_t size;
+};
+typedef struct grub_linuxbios_table_header *grub_linuxbios_table_header_t;
+
+struct grub_linuxbios_table_item
+{
+#define GRUB_LINUXBIOS_MEMBER_UNUSED 0x00
+#define GRUB_LINUXBIOS_MEMBER_MEMORY 0x01
+#define GRUB_LINUXBIOS_MEMBER_LINK 0x11
+ grub_uint32_t tag;
+ grub_uint32_t size;
+};
+typedef struct grub_linuxbios_table_item *grub_linuxbios_table_item_t;
+
+struct grub_linuxbios_mem_region
+{
+ grub_uint64_t addr;
+ grub_uint64_t size;
+#define GRUB_MACHINE_MEMORY_AVAILABLE 1
+ grub_uint32_t type;
+};
+typedef struct grub_linuxbios_mem_region *mem_region_t;
+
+#endif
diff --git a/include/grub/i386/coreboot/memory.h b/include/grub/i386/coreboot/memory.h
new file mode 100644
index 0000000..0642280
--- /dev/null
+++ b/include/grub/i386/coreboot/memory.h
@@ -0,0 +1,56 @@
+/* memory.h - describe the memory map */
+/*
+ * 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_MEMORY_MACHINE_LB_HEADER
+#define _GRUB_MEMORY_MACHINE_LB_HEADER 1
+
+#include <grub/symbol.h>
+
+#ifndef ASM_FILE
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/memory.h>
+#endif
+
+#define GRUB_MEMORY_MACHINE_LOWER_USABLE 0x9fc00 /* 640 kiB - 1 kiB */
+
+#define GRUB_MEMORY_MACHINE_UPPER_START 0x100000 /* 1 MiB */
+#define GRUB_MEMORY_MACHINE_LOWER_SIZE GRUB_MEMORY_MACHINE_UPPER_START
+
+#ifndef ASM_FILE
+
+void grub_machine_mmap_init (void);
+
+static inline grub_err_t
+grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)),
+ grub_uint64_t size __attribute__ ((unused)),
+ int type __attribute__ ((unused)),
+ int handle __attribute__ ((unused)))
+{
+ return GRUB_ERR_NONE;
+}
+static inline grub_err_t
+grub_machine_mmap_unregister (int handle __attribute__ ((unused)))
+{
+ return GRUB_ERR_NONE;
+}
+
+#endif
+
+#endif /* ! _GRUB_MEMORY_MACHINE_HEADER */
diff --git a/include/grub/i386/coreboot/serial.h b/include/grub/i386/coreboot/serial.h
new file mode 100644
index 0000000..b6819d5
--- /dev/null
+++ b/include/grub/i386/coreboot/serial.h
@@ -0,0 +1,24 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_MACHINE_SERIAL_HEADER
+#define GRUB_MACHINE_SERIAL_HEADER 1
+
+#define GRUB_MACHINE_SERIAL_PORTS { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }
+
+#endif
diff --git a/include/grub/i386/coreboot/time.h b/include/grub/i386/coreboot/time.h
new file mode 100644
index 0000000..2298ee8
--- /dev/null
+++ b/include/grub/i386/coreboot/time.h
@@ -0,0 +1 @@
+#include <grub/i386/pc/time.h>
diff --git a/include/grub/i386/cpuid.h b/include/grub/i386/cpuid.h
new file mode 100644
index 0000000..09b313b
--- /dev/null
+++ b/include/grub/i386/cpuid.h
@@ -0,0 +1,24 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_CPU_CPUID_HEADER
+#define GRUB_CPU_CPUID_HEADER 1
+
+extern unsigned char grub_cpuid_has_longmode;
+
+#endif
diff --git a/include/grub/i386/efi/memory.h b/include/grub/i386/efi/memory.h
new file mode 100644
index 0000000..c9a61bb
--- /dev/null
+++ b/include/grub/i386/efi/memory.h
@@ -0,0 +1 @@
+#include <grub/efi/memory.h>
diff --git a/include/grub/i386/efi/serial.h b/include/grub/i386/efi/serial.h
new file mode 100644
index 0000000..2d85634
--- /dev/null
+++ b/include/grub/i386/efi/serial.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/serial.h>
diff --git a/include/grub/i386/efi/time.h b/include/grub/i386/efi/time.h
new file mode 100644
index 0000000..7a9241f
--- /dev/null
+++ b/include/grub/i386/efi/time.h
@@ -0,0 +1,24 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,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_MACHINE_TIME_HEADER
+#define GRUB_MACHINE_TIME_HEADER 1
+
+#include <grub/efi/time.h>
+
+#endif /* ! GRUB_MACHINE_TIME_HEADER */
diff --git a/include/grub/i386/efiemu.h b/include/grub/i386/efiemu.h
new file mode 100644
index 0000000..edb13ff
--- /dev/null
+++ b/include/grub/i386/efiemu.h
@@ -0,0 +1,33 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_ARCH_EFI_EMU_HEADER
+#define GRUB_ARCH_EFI_EMU_HEADER 1
+
+grub_err_t
+grub_arch_efiemu_relocate_symbols32 (grub_efiemu_segment_t segs,
+ struct grub_efiemu_elf_sym *elfsyms,
+ void *ehdr);
+grub_err_t
+grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
+ struct grub_efiemu_elf_sym *elfsyms,
+ void *ehdr);
+
+int grub_arch_efiemu_check_header32 (void *ehdr);
+int grub_arch_efiemu_check_header64 (void *ehdr);
+#endif
diff --git a/include/grub/i386/floppy.h b/include/grub/i386/floppy.h
new file mode 100644
index 0000000..0e36905
--- /dev/null
+++ b/include/grub/i386/floppy.h
@@ -0,0 +1,36 @@
+/*
+ * 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/>.
+ */
+
+#ifndef GRUB_FLOPPY_CPU_HEADER
+#define GRUB_FLOPPY_CPU_HEADER 1
+
+#define GRUB_FLOPPY_REG_DIGITAL_OUTPUT 0x3f2
+
+#ifndef ASM_FILE
+#include <grub/cpu/io.h>
+
+/* Stop the floppy drive from spinning, so that other software is
+ jumped to with a known state. */
+static inline void
+grub_stop_floppy (void)
+{
+ grub_outb (0, GRUB_FLOPPY_REG_DIGITAL_OUTPUT);
+}
+#endif
+
+#endif
diff --git a/include/grub/i386/freebsd_linker.h b/include/grub/i386/freebsd_linker.h
new file mode 100644
index 0000000..3c1eb64
--- /dev/null
+++ b/include/grub/i386/freebsd_linker.h
@@ -0,0 +1,74 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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/>.
+ */
+
+/*-
+ * Copyright (c) 1997-2000 Doug Rabson
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: stable/8/sys/sys/linker.h 199583 2009-11-20 15:27:52Z jhb $
+ */
+
+#ifndef GRUB_FREEBSD_LINKER_CPU_HEADER
+#define GRUB_FREEBSD_LINKER_CPU_HEADER 1
+
+#define FREEBSD_MODINFO_END 0x0000 /* End of list */
+#define FREEBSD_MODINFO_NAME 0x0001 /* Name of module (string) */
+#define FREEBSD_MODINFO_TYPE 0x0002 /* Type of module (string) */
+#define FREEBSD_MODINFO_ADDR 0x0003 /* Loaded address */
+#define FREEBSD_MODINFO_SIZE 0x0004 /* Size of module */
+#define FREEBSD_MODINFO_EMPTY 0x0005 /* Has been deleted */
+#define FREEBSD_MODINFO_ARGS 0x0006 /* Parameters string */
+#define FREEBSD_MODINFO_METADATA 0x8000 /* Module-specfic */
+
+#define FREEBSD_MODINFOMD_AOUTEXEC 0x0001 /* a.out exec header */
+#define FREEBSD_MODINFOMD_ELFHDR 0x0002 /* ELF header */
+#define FREEBSD_MODINFOMD_SSYM 0x0003 /* start of symbols */
+#define FREEBSD_MODINFOMD_ESYM 0x0004 /* end of symbols */
+#define FREEBSD_MODINFOMD_DYNAMIC 0x0005 /* _DYNAMIC pointer */
+#define FREEBSD_MODINFOMD_ENVP 0x0006 /* envp[] */
+#define FREEBSD_MODINFOMD_HOWTO 0x0007 /* boothowto */
+#define FREEBSD_MODINFOMD_KERNEND 0x0008 /* kernend */
+#define FREEBSD_MODINFOMD_SHDR 0x0009 /* section header table */
+#define FREEBSD_MODINFOMD_NOCOPY 0x8000 /* don't copy this metadata to the kernel */
+
+#define FREEBSD_MODINFOMD_SMAP 0x1001
+
+#define FREEBSD_MODINFOMD_DEPLIST (0x4001 | FREEBSD_MODINFOMD_NOCOPY) /* depends on */
+
+#endif
diff --git a/include/grub/i386/freebsd_reboot.h b/include/grub/i386/freebsd_reboot.h
new file mode 100644
index 0000000..9c17f6e
--- /dev/null
+++ b/include/grub/i386/freebsd_reboot.h
@@ -0,0 +1,77 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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/>.
+ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1988, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)reboot.h 8.3 (Berkeley) 12/13/94
+ * $FreeBSD: stable/8/sys/sys/reboot.h 199583 2009-11-20 15:27:52Z jhb $
+ */
+
+#ifndef GRUB_FREEBSD_REBOOT_CPU_HEADER
+#define GRUB_FREEBSD_REBOOT_CPU_HEADER 1
+
+#define FREEBSD_RB_ASKNAME (1 << 0) /* ask for file name to reboot from */
+#define FREEBSD_RB_SINGLE (1 << 1) /* reboot to single user only */
+#define FREEBSD_RB_NOSYNC (1 << 2) /* dont sync before reboot */
+#define FREEBSD_RB_HALT (1 << 3) /* don't reboot, just halt */
+#define FREEBSD_RB_INITNAME (1 << 4) /* name given for /etc/init (unused) */
+#define FREEBSD_RB_DFLTROOT (1 << 5) /* use compiled-in rootdev */
+#define FREEBSD_RB_KDB (1 << 6) /* give control to kernel debugger */
+#define FREEBSD_RB_RDONLY (1 << 7) /* mount root fs read-only */
+#define FREEBSD_RB_DUMP (1 << 8) /* dump kernel memory before reboot */
+#define FREEBSD_RB_MINIROOT (1 << 9) /* mini-root present in memory at boot time */
+#define FREEBSD_RB_CONFIG (1 << 10) /* invoke user configuration routing */
+#define FREEBSD_RB_VERBOSE (1 << 11) /* print all potentially useful info */
+#define FREEBSD_RB_SERIAL (1 << 12) /* user serial port as console */
+#define FREEBSD_RB_CDROM (1 << 13) /* use cdrom as root */
+#define FREEBSD_RB_GDB (1 << 15) /* use GDB remote debugger instead of DDB */
+#define FREEBSD_RB_MUTE (1 << 16) /* Come up with the console muted */
+#define FREEBSD_RB_PAUSE (1 << 20)
+#define FREEBSD_RB_QUIET (1 << 21)
+#define FREEBSD_RB_NOINTR (1 << 28)
+#define FREENSD_RB_MULTIPLE (1 << 29) /* Use multiple consoles */
+#define FREEBSD_RB_DUAL FREENSD_RB_MULTIPLE
+#define FREEBSD_RB_BOOTINFO (1 << 31) /* have `struct bootinfo *' arg */
+
+#endif
diff --git a/include/grub/i386/ieee1275/ieee1275.h b/include/grub/i386/ieee1275/ieee1275.h
new file mode 100644
index 0000000..2625f02
--- /dev/null
+++ b/include/grub/i386/ieee1275/ieee1275.h
@@ -0,0 +1 @@
+#include <grub/powerpc/ieee1275/ieee1275.h>
diff --git a/include/grub/i386/ieee1275/memory.h b/include/grub/i386/ieee1275/memory.h
new file mode 100644
index 0000000..8dd6f7c
--- /dev/null
+++ b/include/grub/i386/ieee1275/memory.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/memory.h>
diff --git a/include/grub/i386/ieee1275/serial.h b/include/grub/i386/ieee1275/serial.h
new file mode 100644
index 0000000..2d85634
--- /dev/null
+++ b/include/grub/i386/ieee1275/serial.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/serial.h>
diff --git a/include/grub/i386/ieee1275/time.h b/include/grub/i386/ieee1275/time.h
new file mode 100644
index 0000000..6f474ba
--- /dev/null
+++ b/include/grub/i386/ieee1275/time.h
@@ -0,0 +1 @@
+#include <grub/powerpc/ieee1275/time.h>
diff --git a/include/grub/i386/io.h b/include/grub/i386/io.h
new file mode 100644
index 0000000..ae12a3e
--- /dev/null
+++ b/include/grub/i386/io.h
@@ -0,0 +1,72 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1996,2000,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/>.
+ */
+
+/* Based on sys/io.h from GNU libc. */
+
+#ifndef GRUB_IO_H
+#define GRUB_IO_H 1
+
+typedef unsigned short int grub_port_t;
+
+static __inline unsigned char
+grub_inb (unsigned short int port)
+{
+ unsigned char _v;
+
+ __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port));
+ return _v;
+}
+
+static __inline unsigned short int
+grub_inw (unsigned short int port)
+{
+ unsigned short _v;
+
+ __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port));
+ return _v;
+}
+
+static __inline unsigned int
+grub_inl (unsigned short int port)
+{
+ unsigned int _v;
+
+ __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port));
+ return _v;
+}
+
+static __inline void
+grub_outb (unsigned char value, unsigned short int port)
+{
+ __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port));
+}
+
+static __inline void
+grub_outw (unsigned short int value, unsigned short int port)
+{
+ __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port));
+
+}
+
+static __inline void
+grub_outl (unsigned int value, unsigned short int port)
+{
+ __asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port));
+}
+
+#endif /* _SYS_IO_H */
diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h
new file mode 100644
index 0000000..fed58a6
--- /dev/null
+++ b/include/grub/i386/linux.h
@@ -0,0 +1,285 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,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_LINUX_MACHINE_HEADER
+#define GRUB_LINUX_MACHINE_HEADER 1
+
+#define GRUB_LINUX_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */
+#define GRUB_LINUX_DEFAULT_SETUP_SECTS 4
+#define GRUB_LINUX_INITRD_MAX_ADDRESS 0x37FFFFFF
+#define GRUB_LINUX_MAX_SETUP_SECTS 64
+#define GRUB_LINUX_BOOT_LOADER_TYPE 0x72
+#define GRUB_LINUX_HEAP_END_OFFSET (0x9000 - 0x200)
+
+#define GRUB_LINUX_BZIMAGE_ADDR 0x100000
+#define GRUB_LINUX_ZIMAGE_ADDR 0x10000
+#define GRUB_LINUX_OLD_REAL_MODE_ADDR 0x90000
+#define GRUB_LINUX_SETUP_STACK 0x9000
+
+#define GRUB_LINUX_FLAG_BIG_KERNEL 0x1
+#define GRUB_LINUX_FLAG_QUIET 0x20
+#define GRUB_LINUX_FLAG_CAN_USE_HEAP 0x80
+
+/* Linux's video mode selection support. Actually I hate it! */
+#define GRUB_LINUX_VID_MODE_NORMAL 0xFFFF
+#define GRUB_LINUX_VID_MODE_EXTENDED 0xFFFE
+#define GRUB_LINUX_VID_MODE_ASK 0xFFFD
+#define GRUB_LINUX_VID_MODE_VESA_START 0x0300
+
+#define GRUB_LINUX_SETUP_MOVE_SIZE 0x9100
+#define GRUB_LINUX_CL_MAGIC 0xA33F
+
+#ifdef __x86_64__
+
+#define GRUB_LINUX_EFI_SIGNATURE \
+ ('4' << 24 | '6' << 16 | 'L' << 8 | 'E')
+
+#else
+
+#define GRUB_LINUX_EFI_SIGNATURE \
+ ('2' << 24 | '3' << 16 | 'L' << 8 | 'E')
+
+#endif
+
+#define GRUB_LINUX_EFI_SIGNATURE_0204 \
+ ('L' << 24 | 'I' << 16 | 'F' << 8 | 'E')
+
+#define GRUB_LINUX_OFW_SIGNATURE \
+ (' ' << 24 | 'W' << 16 | 'F' << 8 | 'O')
+
+#ifndef ASM_FILE
+
+#define GRUB_E820_RAM 1
+#define GRUB_E820_RESERVED 2
+#define GRUB_E820_ACPI 3
+#define GRUB_E820_NVS 4
+#define GRUB_E820_BADRAM 5
+
+#define GRUB_E820_MAX_ENTRY 128
+
+struct grub_e820_mmap
+{
+ grub_uint64_t addr;
+ grub_uint64_t size;
+ grub_uint32_t type;
+} __attribute__((packed));
+
+enum
+ {
+ GRUB_VIDEO_LINUX_TYPE_TEXT = 0x01,
+ GRUB_VIDEO_LINUX_TYPE_VESA = 0x23, /* VESA VGA in graphic mode. */
+ GRUB_VIDEO_LINUX_TYPE_EFIFB = 0x70, /* EFI Framebuffer. */
+ GRUB_VIDEO_LINUX_TYPE_SIMPLE = 0x70 /* Linear framebuffer without any additional functions. */
+ };
+
+/* For the Linux/i386 boot protocol version 2.03. */
+struct linux_kernel_header
+{
+ grub_uint8_t code1[0x0020];
+ grub_uint16_t cl_magic; /* Magic number 0xA33F */
+ grub_uint16_t cl_offset; /* The offset of command line */
+ grub_uint8_t code2[0x01F1 - 0x0020 - 2 - 2];
+ grub_uint8_t setup_sects; /* The size of the setup in sectors */
+ grub_uint16_t root_flags; /* If the root is mounted readonly */
+ grub_uint16_t syssize; /* obsolete */
+ grub_uint16_t swap_dev; /* obsolete */
+ grub_uint16_t ram_size; /* obsolete */
+ grub_uint16_t vid_mode; /* Video mode control */
+ grub_uint16_t root_dev; /* Default root device number */
+ grub_uint16_t boot_flag; /* 0xAA55 magic number */
+ grub_uint16_t jump; /* Jump instruction */
+ grub_uint32_t header; /* Magic signature "HdrS" */
+ grub_uint16_t version; /* Boot protocol version supported */
+ grub_uint32_t realmode_swtch; /* Boot loader hook */
+ grub_uint16_t start_sys; /* The load-low segment (obsolete) */
+ grub_uint16_t kernel_version; /* Points to kernel version string */
+ grub_uint8_t type_of_loader; /* Boot loader identifier */
+#define LINUX_LOADER_ID_LILO 0x0
+#define LINUX_LOADER_ID_LOADLIN 0x1
+#define LINUX_LOADER_ID_BOOTSECT 0x2
+#define LINUX_LOADER_ID_SYSLINUX 0x3
+#define LINUX_LOADER_ID_ETHERBOOT 0x4
+#define LINUX_LOADER_ID_ELILO 0x5
+#define LINUX_LOADER_ID_GRUB 0x7
+#define LINUX_LOADER_ID_UBOOT 0x8
+#define LINUX_LOADER_ID_XEN 0x9
+#define LINUX_LOADER_ID_GUJIN 0xa
+#define LINUX_LOADER_ID_QEMU 0xb
+ grub_uint8_t loadflags; /* Boot protocol option flags */
+ grub_uint16_t setup_move_size; /* Move to high memory size */
+ grub_uint32_t code32_start; /* Boot loader hook */
+ grub_uint32_t ramdisk_image; /* initrd load address */
+ grub_uint32_t ramdisk_size; /* initrd size */
+ grub_uint32_t bootsect_kludge; /* obsolete */
+ grub_uint16_t heap_end_ptr; /* Free memory after setup end */
+ grub_uint16_t pad1; /* Unused */
+ grub_uint32_t cmd_line_ptr; /* Points to the kernel command line */
+ grub_uint32_t initrd_addr_max; /* Highest address for initrd */
+} __attribute__ ((packed));
+
+/* Boot parameters for Linux based on 2.6.12. This is used by the setup
+ sectors of Linux, and must be simulated by GRUB on EFI, because
+ the setup sectors depend on BIOS. */
+struct linux_kernel_params
+{
+ grub_uint8_t video_cursor_x; /* 0 */
+ grub_uint8_t video_cursor_y;
+
+ grub_uint16_t ext_mem; /* 2 */
+
+ grub_uint16_t video_page; /* 4 */
+ grub_uint8_t video_mode; /* 6 */
+ grub_uint8_t video_width; /* 7 */
+
+ grub_uint8_t padding1[0xa - 0x8];
+
+ grub_uint16_t video_ega_bx; /* a */
+
+ grub_uint8_t padding2[0xe - 0xc];
+
+ grub_uint8_t video_height; /* e */
+ grub_uint8_t have_vga; /* f */
+ grub_uint16_t font_size; /* 10 */
+
+ grub_uint16_t lfb_width; /* 12 */
+ grub_uint16_t lfb_height; /* 14 */
+ grub_uint16_t lfb_depth; /* 16 */
+ grub_uint32_t lfb_base; /* 18 */
+ grub_uint32_t lfb_size; /* 1c */
+
+ grub_uint16_t cl_magic; /* 20 */
+ grub_uint16_t cl_offset;
+
+ grub_uint16_t lfb_line_len; /* 24 */
+ grub_uint8_t red_mask_size; /* 26 */
+ grub_uint8_t red_field_pos;
+ grub_uint8_t green_mask_size;
+ grub_uint8_t green_field_pos;
+ grub_uint8_t blue_mask_size;
+ grub_uint8_t blue_field_pos;
+ grub_uint8_t reserved_mask_size;
+ grub_uint8_t reserved_field_pos;
+ grub_uint16_t vesapm_segment; /* 2e */
+ grub_uint16_t vesapm_offset; /* 30 */
+ grub_uint16_t lfb_pages; /* 32 */
+ grub_uint16_t vesa_attrib; /* 34 */
+ grub_uint32_t capabilities; /* 36 */
+
+ grub_uint8_t padding3[0x40 - 0x3a];
+
+ grub_uint16_t apm_version; /* 40 */
+ grub_uint16_t apm_code_segment; /* 42 */
+ grub_uint32_t apm_entry; /* 44 */
+ grub_uint16_t apm_16bit_code_segment; /* 48 */
+ grub_uint16_t apm_data_segment; /* 4a */
+ grub_uint16_t apm_flags; /* 4c */
+ grub_uint32_t apm_code_len; /* 4e */
+ grub_uint16_t apm_data_len; /* 52 */
+
+ grub_uint8_t padding4[0x60 - 0x54];
+
+ grub_uint32_t ist_signature; /* 60 */
+ grub_uint32_t ist_command; /* 64 */
+ grub_uint32_t ist_event; /* 68 */
+ grub_uint32_t ist_perf_level; /* 6c */
+
+ grub_uint8_t padding5[0x80 - 0x70];
+
+ grub_uint8_t hd0_drive_info[0x10]; /* 80 */
+ grub_uint8_t hd1_drive_info[0x10]; /* 90 */
+ grub_uint16_t rom_config_len; /* a0 */
+
+ grub_uint8_t padding6[0xb0 - 0xa2];
+
+ grub_uint32_t ofw_signature; /* b0 */
+ grub_uint32_t ofw_num_items; /* b4 */
+ grub_uint32_t ofw_cif_handler; /* b8 */
+ grub_uint32_t ofw_idt; /* bc */
+
+ grub_uint8_t padding7[0x1b8 - 0xc0];
+
+ union
+ {
+ struct
+ {
+ grub_uint32_t efi_system_table; /* 1b8 */
+ grub_uint32_t padding7_1; /* 1bc */
+ grub_uint32_t efi_signature; /* 1c0 */
+ grub_uint32_t efi_mem_desc_size; /* 1c4 */
+ grub_uint32_t efi_mem_desc_version; /* 1c8 */
+ grub_uint32_t efi_mmap_size; /* 1cc */
+ grub_uint32_t efi_mmap; /* 1d0 */
+ } v0204;
+ struct
+ {
+ grub_uint32_t padding7_1; /* 1b8 */
+ grub_uint32_t padding7_2; /* 1bc */
+ grub_uint32_t efi_signature; /* 1c0 */
+ grub_uint32_t efi_system_table; /* 1c4 */
+ grub_uint32_t efi_mem_desc_size; /* 1c8 */
+ grub_uint32_t efi_mem_desc_version; /* 1cc */
+ grub_uint32_t efi_mmap; /* 1d0 */
+ grub_uint32_t efi_mmap_size; /* 1d4 */
+ grub_uint32_t efi_system_table_hi; /* 1d8 */
+ grub_uint32_t efi_mmap_hi; /* 1dc */
+ } v0206;
+ };
+
+ grub_uint32_t alt_mem; /* 1e0 */
+
+ grub_uint8_t padding8[0x1e8 - 0x1e4];
+
+ grub_uint8_t mmap_size; /* 1e8 */
+
+ grub_uint8_t padding9[0x1f1 - 0x1e9];
+
+ grub_uint8_t setup_sects; /* The size of the setup in sectors */
+ grub_uint16_t root_flags; /* If the root is mounted readonly */
+ grub_uint16_t syssize; /* obsolete */
+ grub_uint16_t swap_dev; /* obsolete */
+ grub_uint16_t ram_size; /* obsolete */
+ grub_uint16_t vid_mode; /* Video mode control */
+ grub_uint16_t root_dev; /* Default root device number */
+
+ grub_uint8_t padding10; /* 1fe */
+ grub_uint8_t ps_mouse; /* 1ff */
+
+ grub_uint16_t jump; /* Jump instruction */
+ grub_uint32_t header; /* Magic signature "HdrS" */
+ grub_uint16_t version; /* Boot protocol version supported */
+ grub_uint32_t realmode_swtch; /* Boot loader hook */
+ grub_uint16_t start_sys; /* The load-low segment (obsolete) */
+ grub_uint16_t kernel_version; /* Points to kernel version string */
+ grub_uint8_t type_of_loader; /* Boot loader identifier */
+ grub_uint8_t loadflags; /* Boot protocol option flags */
+ grub_uint16_t setup_move_size; /* Move to high memory size */
+ grub_uint32_t code32_start; /* Boot loader hook */
+ grub_uint32_t ramdisk_image; /* initrd load address */
+ grub_uint32_t ramdisk_size; /* initrd size */
+ grub_uint32_t bootsect_kludge; /* obsolete */
+ grub_uint16_t heap_end_ptr; /* Free memory after setup end */
+ grub_uint16_t pad1; /* Unused */
+ grub_uint32_t cmd_line_ptr; /* Points to the kernel command line */
+
+ grub_uint8_t pad2[164]; /* 22c */
+ struct grub_e820_mmap e820_map[GRUB_E820_MAX_ENTRY]; /* 2d0 */
+
+} __attribute__ ((packed));
+#endif /* ! ASM_FILE */
+
+#endif /* ! GRUB_LINUX_MACHINE_HEADER */
diff --git a/include/grub/i386/macho.h b/include/grub/i386/macho.h
new file mode 100644
index 0000000..f22c211
--- /dev/null
+++ b/include/grub/i386/macho.h
@@ -0,0 +1,46 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_CPU_MACHO_H
+#define GRUB_CPU_MACHO_H 1
+
+#include <grub/macho.h>
+
+#define GRUB_MACHO_CPUTYPE_IS_HOST32(x) ((x)==0x00000007)
+#define GRUB_MACHO_CPUTYPE_IS_HOST64(x) ((x)==0x01000007)
+
+struct grub_macho_thread32
+{
+ grub_uint32_t cmd;
+ grub_uint32_t cmdsize;
+ grub_uint8_t unknown1[48];
+ grub_uint32_t entry_point;
+ grub_uint8_t unknown2[20];
+} __attribute__ ((packed));
+
+
+struct grub_macho_thread64
+{
+ grub_uint32_t cmd;
+ grub_uint32_t cmdsize;
+ grub_uint8_t unknown1[0x88];
+ grub_uint64_t entry_point;
+ grub_uint8_t unknown2[0x20];
+} __attribute__ ((packed));
+
+#endif
diff --git a/include/grub/i386/memory.h b/include/grub/i386/memory.h
new file mode 100644
index 0000000..582226e
--- /dev/null
+++ b/include/grub/i386/memory.h
@@ -0,0 +1,63 @@
+/* memory.h - describe the memory map */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,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_MEMORY_CPU_HEADER
+#define GRUB_MEMORY_CPU_HEADER 1
+
+/* The flag for protected mode. */
+#define GRUB_MEMORY_CPU_CR0_PE_ON 0x1
+#define GRUB_MEMORY_CPU_CR4_PAE_ON 0x00000020
+#define GRUB_MEMORY_CPU_CR4_PSE_ON 0x00000010
+#define GRUB_MEMORY_CPU_CR0_PAGING_ON 0x80000000
+#define GRUB_MEMORY_CPU_AMD64_MSR 0xc0000080
+#define GRUB_MEMORY_CPU_AMD64_MSR_ON 0x00000100
+
+#ifndef ASM_FILE
+
+#define GRUB_MMAP_MALLOC_LOW 1
+
+#include <grub/types.h>
+
+grub_uint64_t grub_mmap_get_upper (void);
+grub_uint64_t grub_mmap_get_lower (void);
+grub_uint64_t grub_mmap_get_post64 (void);
+
+typedef grub_addr_t grub_phys_addr_t;
+
+static inline grub_phys_addr_t
+grub_vtop (void *a)
+{
+ return (grub_phys_addr_t) a;
+}
+
+static inline void *
+grub_map_memory (grub_phys_addr_t a, grub_size_t size __attribute__ ((unused)))
+{
+ return (void *) a;
+}
+
+static inline void
+grub_unmap_memory (void *a __attribute__ ((unused)),
+ grub_size_t size __attribute__ ((unused)))
+{
+}
+
+#endif
+
+#endif /* ! GRUB_MEMORY_CPU_HEADER */
diff --git a/include/grub/i386/multiboot.h b/include/grub/i386/multiboot.h
new file mode 100644
index 0000000..a1b9488
--- /dev/null
+++ b/include/grub/i386/multiboot.h
@@ -0,0 +1,36 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,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_MULTIBOOT_CPU_HEADER
+#define GRUB_MULTIBOOT_CPU_HEADER 1
+
+#define MULTIBOOT_INITIAL_STATE { .eax = MULTIBOOT_BOOTLOADER_MAGIC, \
+ .ecx = 0, \
+ .edx = 0, \
+ /* Set esp to some random location in low memory to avoid breaking */ \
+ /* non-compliant kernels. */ \
+ .esp = 0x7ff00 \
+ }
+#define MULTIBOOT_ENTRY_REGISTER eip
+#define MULTIBOOT_MBI_REGISTER ebx
+#define MULTIBOOT_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_I386
+
+#define MULTIBOOT_ELF32_MACHINE EM_386
+#define MULTIBOOT_ELF64_MACHINE EM_X86_64
+
+#endif /* ! GRUB_MULTIBOOT_CPU_HEADER */
diff --git a/include/grub/i386/multiboot/boot.h b/include/grub/i386/multiboot/boot.h
new file mode 100644
index 0000000..c33f9ba
--- /dev/null
+++ b/include/grub/i386/multiboot/boot.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/boot.h>
diff --git a/include/grub/i386/multiboot/console.h b/include/grub/i386/multiboot/console.h
new file mode 100644
index 0000000..774399a
--- /dev/null
+++ b/include/grub/i386/multiboot/console.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/console.h>
diff --git a/include/grub/i386/multiboot/kernel.h b/include/grub/i386/multiboot/kernel.h
new file mode 100644
index 0000000..b41e86e
--- /dev/null
+++ b/include/grub/i386/multiboot/kernel.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/kernel.h>
diff --git a/include/grub/i386/multiboot/memory.h b/include/grub/i386/multiboot/memory.h
new file mode 100644
index 0000000..8dd6f7c
--- /dev/null
+++ b/include/grub/i386/multiboot/memory.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/memory.h>
diff --git a/include/grub/i386/multiboot/serial.h b/include/grub/i386/multiboot/serial.h
new file mode 100644
index 0000000..2d85634
--- /dev/null
+++ b/include/grub/i386/multiboot/serial.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/serial.h>
diff --git a/include/grub/i386/multiboot/time.h b/include/grub/i386/multiboot/time.h
new file mode 100644
index 0000000..7177c74
--- /dev/null
+++ b/include/grub/i386/multiboot/time.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/time.h>
diff --git a/include/grub/i386/netbsd_bootinfo.h b/include/grub/i386/netbsd_bootinfo.h
new file mode 100644
index 0000000..fd429a2
--- /dev/null
+++ b/include/grub/i386/netbsd_bootinfo.h
@@ -0,0 +1,138 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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/>.
+ */
+
+/* $NetBSD: bootinfo.h,v 1.16 2009/08/24 02:15:46 jmcneill Exp $ */
+
+/*
+ * Copyright (c) 1997
+ * Matthias Drochner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRUB_NETBSD_BOOTINFO_CPU_HEADER
+#define GRUB_NETBSD_BOOTINFO_CPU_HEADER 1
+
+#include <grub/types.h>
+
+#define NETBSD_BTINFO_BOOTPATH 0
+#define NETBSD_BTINFO_ROOTDEVICE 1
+#define NETBSD_BTINFO_CONSOLE 6
+#define NETBSD_BTINFO_SYMTAB 8
+#define NETBSD_BTINFO_MEMMAP 9
+#define NETBSD_BTINFO_MODULES 11
+#define NETBSD_BTINFO_FRAMEBUF 12
+
+struct grub_netbsd_bootinfo
+{
+ grub_uint32_t bi_count;
+ grub_uint32_t bi_data[0];
+};
+
+struct grub_netbsd_btinfo_common
+{
+ grub_uint32_t len;
+ grub_uint32_t type;
+};
+
+#define GRUB_NETBSD_MAX_BOOTPATH_LEN 80
+
+struct grub_netbsd_btinfo_bootdisk
+{
+ grub_uint32_t labelsector; /* label valid if != 0xffffffff */
+ struct
+ {
+ grub_uint16_t type, checksum;
+ char packname[16];
+ } label;
+ grub_uint32_t biosdev;
+ grub_uint32_t partition;
+};
+
+struct grub_netbsd_btinfo_symtab
+{
+ grub_uint32_t nsyms;
+ grub_uint32_t ssyms;
+ grub_uint32_t esyms;
+};
+
+
+struct grub_netbsd_btinfo_serial
+{
+ char devname[16];
+ grub_uint32_t addr;
+ grub_uint32_t speed;
+};
+
+struct grub_netbsd_btinfo_modules
+{
+ grub_uint32_t num;
+ grub_uint32_t last_addr;
+ struct grub_netbsd_btinfo_module
+ {
+ char name[80];
+#define GRUB_NETBSD_MODULE_RAW 0
+#define GRUB_NETBSD_MODULE_ELF 1
+ grub_uint32_t type;
+ grub_uint32_t size;
+ grub_uint32_t addr;
+ } mods[0];
+};
+
+struct grub_netbsd_btinfo_framebuf
+{
+ grub_uint64_t fbaddr;
+ grub_uint32_t flags;
+ grub_uint32_t width;
+ grub_uint32_t height;
+ grub_uint16_t pitch;
+ grub_uint8_t bpp;
+
+ grub_uint8_t red_mask_size;
+ grub_uint8_t green_mask_size;
+ grub_uint8_t blue_mask_size;
+
+ grub_uint8_t red_field_pos;
+ grub_uint8_t green_field_pos;
+ grub_uint8_t blue_field_pos;
+
+ grub_uint8_t reserved[16];
+};
+
+#define GRUB_NETBSD_MAX_ROOTDEVICE_LEN 16
+
+#endif
diff --git a/include/grub/i386/netbsd_reboot.h b/include/grub/i386/netbsd_reboot.h
new file mode 100644
index 0000000..ee82455
--- /dev/null
+++ b/include/grub/i386/netbsd_reboot.h
@@ -0,0 +1,81 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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/>.
+ */
+
+/* $NetBSD: reboot.h,v 1.25 2007/12/25 18:33:48 perry Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)reboot.h 8.3 (Berkeley) 12/13/94
+ */
+
+#ifndef GRUB_NETBSD_REBOOT_CPU_HEADER
+#define GRUB_NETBSD_REBOOT_CPU_HEADER 1
+
+#define NETBSD_RB_AUTOBOOT 0 /* flags for system auto-booting itself */
+
+#define NETBSD_RB_ASKNAME (1 << 0) /* ask for file name to reboot from */
+#define NETBSD_RB_SINGLE (1 << 1) /* reboot to single user only */
+#define NETBSD_RB_NOSYNC (1 << 2) /* dont sync before reboot */
+#define NETBSD_RB_HALT (1 << 3) /* don't reboot, just halt */
+#define NETBSD_RB_INITNAME (1 << 4) /* name given for /etc/init (unused) */
+#define NETBSD_RB_UNUSED1 (1 << 5) /* was RB_DFLTROOT, obsolete */
+#define NETBSD_RB_KDB (1 << 6) /* give control to kernel debugger */
+#define NETBSD_RB_RDONLY (1 << 7) /* mount root fs read-only */
+#define NETBSD_RB_DUMP (1 << 8) /* dump kernel memory before reboot */
+#define NETBSD_RB_MINIROOT (1 << 9) /* mini-root present in memory at boot time */
+#define NETBSD_RB_STRING (1 << 10) /* use provided bootstr */
+#define NETBSD_RB_POWERDOWN ((1 << 11) | RB_HALT) /* turn power off (or at least halt) */
+#define NETBSD_RB_USERCONFIG (1 << 12) /* change configured devices */
+
+#define NETBSD_AB_NORMAL 0 /* boot normally (default) */
+
+#define NETBSD_AB_QUIET (1 << 16) /* boot quietly */
+#define NETBSD_AB_VERBOSE (1 << 17) /* boot verbosely */
+#define NETBSD_AB_SILENT (1 << 18) /* boot silently */
+#define NETBSD_AB_DEBUG (1 << 19) /* boot with debug messages */
+#define NETBSD_AB_NOSMP (1 << 28) /* Boot without SMP support. */
+#define NETBSD_AB_NOACPI (1 << 29) /* Boot without ACPI support. */
+
+
+#endif
diff --git a/include/grub/i386/openbsd_bootarg.h b/include/grub/i386/openbsd_bootarg.h
new file mode 100644
index 0000000..935dfc0
--- /dev/null
+++ b/include/grub/i386/openbsd_bootarg.h
@@ -0,0 +1,82 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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/>.
+ */
+
+/* $OpenBSD: bootarg.h,v 1.11 2003/06/02 20:20:54 mickey Exp $ */
+
+/*
+ * Copyright (c) 1996-1999 Michael Shalayeff
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GRUB_OPENBSD_BOOTARG_CPU_HEADER
+#define GRUB_OPENBSD_BOOTARG_CPU_HEADER 1
+
+#define OPENBSD_BOOTARG_APIVER (OPENBSD_BAPIV_VECTOR | \
+ OPENBSD_BAPIV_ENV | \
+ OPENBSD_BAPIV_BMEMMAP)
+
+#define OPENBSD_BAPIV_ANCIENT 0x0 /* MD old i386 bootblocks */
+#define OPENBSD_BAPIV_VARS 0x1 /* MD structure w/ add info passed */
+#define OPENBSD_BAPIV_VECTOR 0x2 /* MI vector of MD structures passed */
+#define OPENBSD_BAPIV_ENV 0x4 /* MI environment vars vector */
+#define OPENBSD_BAPIV_BMEMMAP 0x8 /* MI memory map passed is in bytes */
+
+#define OPENBSD_BOOTARG_ENV 0x1000
+#define OPENBSD_BOOTARG_END -1
+
+#define OPENBSD_BOOTARG_MMAP 0
+#define OPENBSD_BOOTARG_CONSOLE 5
+
+struct grub_openbsd_bootargs
+{
+ grub_uint32_t ba_type;
+ grub_uint32_t ba_size;
+ grub_uint32_t ba_next;
+} __attribute__ ((packed));
+
+struct grub_openbsd_bootarg_console
+{
+ grub_uint32_t device;
+ grub_uint32_t speed;
+};
+
+#define GRUB_OPENBSD_COM_MAJOR 8
+#define GRUB_OPENBSD_VGA_MAJOR 12
+
+#endif
diff --git a/include/grub/i386/openbsd_reboot.h b/include/grub/i386/openbsd_reboot.h
new file mode 100644
index 0000000..3f6571a
--- /dev/null
+++ b/include/grub/i386/openbsd_reboot.h
@@ -0,0 +1,79 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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/>.
+ */
+
+/* $OpenBSD: reboot.h,v 1.13 2004/03/10 23:02:53 tom Exp $ */
+/* $NetBSD: reboot.h,v 1.9 1996/04/22 01:23:25 christos Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)reboot.h 8.2 (Berkeley) 7/10/94
+ */
+
+#ifndef GRUB_OPENBSD_REBOOT_CPU_HEADER
+#define GRUB_OPENBSD_REBOOT_CPU_HEADER 1
+
+#define OPENBSD_RB_ASKNAME (1 << 0) /* ask for file name to reboot from */
+#define OPENBSD_RB_SINGLE (1 << 1) /* reboot to single user only */
+#define OPENBSD_RB_NOSYNC (1 << 2) /* dont sync before reboot */
+#define OPENBSD_RB_HALT (1 << 3) /* don't reboot, just halt */
+#define OPENBSD_RB_INITNAME (1 << 4) /* name given for /etc/init (unused) */
+#define OPENBSD_RB_DFLTROOT (1 << 5) /* use compiled-in rootdev */
+#define OPENBSD_RB_KDB (1 << 6) /* give control to kernel debugger */
+#define OPENBSD_RB_RDONLY (1 << 7) /* mount root fs read-only */
+#define OPENBSD_RB_DUMP (1 << 8) /* dump kernel memory before reboot */
+#define OPENBSD_RB_MINIROOT (1 << 9) /* mini-root present in memory at boot time */
+#define OPENBSD_RB_CONFIG (1 << 10) /* change configured devices */
+#define OPENBSD_RB_TIMEBAD (1 << 11) /* don't call resettodr() in boot() */
+#define OPENBSD_RB_POWERDOWN (1 << 12) /* attempt to power down machine */
+#define OPENBSD_RB_SERCONS (1 << 13) /* use serial console if available */
+#define OPENBSD_RB_USERREQ (1 << 14) /* boot() called at user request (e.g. ddb) */
+
+#define OPENBSD_B_DEVMAGIC 0xa0000000
+#define OPENBSD_B_ADAPTORSHIFT 24
+#define OPENBSD_B_CTRLSHIFT 20
+#define OPENBSD_B_UNITSHIFT 16
+#define OPENBSD_B_PARTSHIFT 8
+#define OPENBSD_B_TYPESHIFT 0
+
+#endif
diff --git a/include/grub/i386/pc/apm.h b/include/grub/i386/pc/apm.h
new file mode 100644
index 0000000..6d9e8c6
--- /dev/null
+++ b/include/grub/i386/pc/apm.h
@@ -0,0 +1,48 @@
+/*
+ * 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_APM_MACHINE_HEADER
+#define GRUB_APM_MACHINE_HEADER 1
+
+#include <grub/types.h>
+
+struct grub_apm_info
+{
+ grub_uint16_t cseg;
+ grub_uint32_t offset;
+ grub_uint16_t cseg_16;
+ grub_uint16_t dseg;
+ grub_uint16_t flags;
+ grub_uint16_t cseg_len;
+ grub_uint16_t cseg_16_len;
+ grub_uint16_t dseg_len;
+ grub_uint16_t version;
+};
+
+enum
+ {
+ GRUB_APM_FLAGS_16BITPROTECTED_SUPPORTED = 1,
+ GRUB_APM_FLAGS_32BITPROTECTED_SUPPORTED = 2,
+ GRUB_APM_FLAGS_CPUIDLE_SLOWS_DOWN = 4,
+ GRUB_APM_FLAGS_DISABLED = 8,
+ GRUB_APM_FLAGS_DISENGAGED = 16,
+ };
+
+int grub_apm_get_info (struct grub_apm_info *info);
+
+#endif
diff --git a/include/grub/i386/pc/biosdisk.h b/include/grub/i386/pc/biosdisk.h
new file mode 100644
index 0000000..f8a9b46
--- /dev/null
+++ b/include/grub/i386/pc/biosdisk.h
@@ -0,0 +1,109 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2007,2008 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_BIOSDISK_MACHINE_HEADER
+#define GRUB_BIOSDISK_MACHINE_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+#define GRUB_BIOSDISK_FLAG_LBA 1
+#define GRUB_BIOSDISK_FLAG_CDROM 2
+
+#define GRUB_BIOSDISK_CDTYPE_NO_EMUL 0
+#define GRUB_BIOSDISK_CDTYPE_1_2_M 1
+#define GRUB_BIOSDISK_CDTYPE_1_44_M 2
+#define GRUB_BIOSDISK_CDTYPE_2_88_M 3
+#define GRUB_BIOSDISK_CDTYPE_HARDDISK 4
+
+#define GRUB_BIOSDISK_CDTYPE_MASK 0xF
+
+struct grub_biosdisk_data
+{
+ int drive;
+ unsigned long cylinders;
+ unsigned long heads;
+ unsigned long sectors;
+ unsigned long flags;
+};
+
+/* Drive Parameters. */
+struct grub_biosdisk_drp
+{
+ grub_uint16_t size;
+ grub_uint16_t flags;
+ grub_uint32_t cylinders;
+ grub_uint32_t heads;
+ grub_uint32_t sectors;
+ grub_uint64_t total_sectors;
+ grub_uint16_t bytes_per_sector;
+ /* ver 2.0 or higher */
+
+ union
+ {
+ grub_uint32_t EDD_configuration_parameters;
+
+ /* Pointer to the Device Parameter Table Extension (ver 3.0+). */
+ grub_uint32_t dpte_pointer;
+ };
+
+ /* ver 3.0 or higher */
+ grub_uint16_t signature_dpi;
+ grub_uint8_t length_dpi;
+ grub_uint8_t reserved[3];
+ grub_uint8_t name_of_host_bus[4];
+ grub_uint8_t name_of_interface_type[8];
+ grub_uint8_t interface_path[8];
+ grub_uint8_t device_path[8];
+ grub_uint8_t reserved2;
+ grub_uint8_t checksum;
+
+ /* XXX: This is necessary, because the BIOS of Thinkpad X20
+ writes a garbage to the tail of drive parameters,
+ regardless of a size specified in a caller. */
+ grub_uint8_t dummy[16];
+} __attribute__ ((packed));
+
+struct grub_biosdisk_cdrp
+{
+ grub_uint8_t size;
+ grub_uint8_t media_type;
+ grub_uint8_t drive_no;
+ grub_uint8_t controller_no;
+ grub_uint32_t image_lba;
+ grub_uint16_t device_spec;
+ grub_uint16_t cache_seg;
+ grub_uint16_t load_seg;
+ grub_uint16_t length_sec512;
+ grub_uint8_t cylinders;
+ grub_uint8_t sectors;
+ grub_uint8_t heads;
+ grub_uint8_t dummy[16];
+} __attribute__ ((packed));
+
+/* Disk Address Packet. */
+struct grub_biosdisk_dap
+{
+ grub_uint8_t length;
+ grub_uint8_t reserved;
+ grub_uint16_t blocks;
+ grub_uint32_t buffer;
+ grub_uint64_t block;
+} __attribute__ ((packed));
+
+#endif /* ! GRUB_BIOSDISK_MACHINE_HEADER */
diff --git a/include/grub/i386/pc/biosnum.h b/include/grub/i386/pc/biosnum.h
new file mode 100644
index 0000000..29c8ecc
--- /dev/null
+++ b/include/grub/i386/pc/biosnum.h
@@ -0,0 +1,6 @@
+#ifndef GRUB_BIOSNUM_MACHINE_HEADER
+#define GRUB_BIOSNUM_MACHINE_HEADER 1
+
+extern int (*grub_get_root_biosnumber) (void);
+
+#endif
diff --git a/include/grub/i386/pc/boot.h b/include/grub/i386/pc/boot.h
new file mode 100644
index 0000000..a4d42ff
--- /dev/null
+++ b/include/grub/i386/pc/boot.h
@@ -0,0 +1,73 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2002,2005,2006,2007,2008,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_BOOT_MACHINE_HEADER
+#define GRUB_BOOT_MACHINE_HEADER 1
+
+#include <grub/offsets.h>
+
+/* The signature for bootloader. */
+#define GRUB_BOOT_MACHINE_SIGNATURE 0xaa55
+
+/* The offset of the start of BPB (BIOS Parameter Block). */
+#define GRUB_BOOT_MACHINE_BPB_START 0x3
+
+/* The offset of the end of BPB (BIOS Parameter Block). */
+#define GRUB_BOOT_MACHINE_BPB_END 0x5a
+
+/* The offset of KERNEL_SECTOR. */
+#define GRUB_BOOT_MACHINE_KERNEL_SECTOR 0x5c
+
+/* The offset of BOOT_DRIVE. */
+#define GRUB_BOOT_MACHINE_BOOT_DRIVE 0x64
+
+/* The offset of BOOT_DRIVE_CHECK. */
+#define GRUB_BOOT_MACHINE_DRIVE_CHECK 0x66
+
+/* The offset of a magic number used by Windows NT. */
+#define GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC 0x1b8
+
+/* The offset of the start of the partition table. */
+#define GRUB_BOOT_MACHINE_PART_START 0x1be
+
+/* The offset of the end of the partition table. */
+#define GRUB_BOOT_MACHINE_PART_END 0x1fe
+
+/* The stack segment. */
+#define GRUB_BOOT_MACHINE_STACK_SEG 0x2000
+
+/* The segment of disk buffer. The disk buffer MUST be 32K long and
+ cannot straddle a 64K boundary. */
+#define GRUB_BOOT_MACHINE_BUFFER_SEG 0x7000
+
+/* The flag for BIOS drive number to designate a hard disk vs. a
+ floppy. */
+#define GRUB_BOOT_MACHINE_BIOS_HD_FLAG 0x80
+
+/* The address where the kernel is loaded. */
+#define GRUB_BOOT_MACHINE_KERNEL_ADDR (GRUB_BOOT_MACHINE_KERNEL_SEG << 4)
+
+/* The size of a block list used in the kernel startup code. */
+#define GRUB_BOOT_MACHINE_LIST_SIZE 12
+
+#define GRUB_BOOT_MACHINE_PXE_DL 0x7f
+
+/* This is the blocklist used in the diskboot image. */
+#define grub_boot_blocklist grub_pc_bios_boot_blocklist
+
+#endif /* ! BOOT_MACHINE_HEADER */
diff --git a/include/grub/i386/pc/chainloader.h b/include/grub/i386/pc/chainloader.h
new file mode 100644
index 0000000..ca1da23
--- /dev/null
+++ b/include/grub/i386/pc/chainloader.h
@@ -0,0 +1,30 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,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_CHAINLOADER_MACHINE_HEADER
+#define GRUB_CHAINLOADER_MACHINE_HEADER 1
+
+#include <grub/dl.h>
+
+/* Common function for normal and rescue mode commands. */
+typedef enum
+ {
+ GRUB_CHAINLOADER_FORCE = 0x1
+ } grub_chainloader_flags_t;
+
+#endif /* GRUB_CHAINLOADER_MACHINE_HEADER */
diff --git a/include/grub/i386/pc/console.h b/include/grub/i386/pc/console.h
new file mode 100644
index 0000000..1631a40
--- /dev/null
+++ b/include/grub/i386/pc/console.h
@@ -0,0 +1,47 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2007,2008 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_CONSOLE_MACHINE_HEADER
+#define GRUB_CONSOLE_MACHINE_HEADER 1
+
+#ifndef ASM_FILE
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+#include <grub/term.h>
+#include <grub/i386/vga_common.h>
+
+/* These are global to share code between C and asm. */
+int grub_console_getkey (struct grub_term_input *term);
+grub_uint16_t grub_console_getxy (struct grub_term_output *term);
+void grub_console_gotoxy (struct grub_term_output *term,
+ grub_uint8_t x, grub_uint8_t y);
+void grub_console_cls (struct grub_term_output *term);
+void grub_console_setcursor (struct grub_term_output *term, int on);
+void grub_console_putchar (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c);
+
+/* Initialize the console system. */
+void grub_console_init (void);
+
+/* Finish the console system. */
+void grub_console_fini (void);
+
+#endif
+
+#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */
diff --git a/include/grub/i386/pc/int.h b/include/grub/i386/pc/int.h
new file mode 100644
index 0000000..de23775
--- /dev/null
+++ b/include/grub/i386/pc/int.h
@@ -0,0 +1,53 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_INTERRUPT_MACHINE_HEADER
+#define GRUB_INTERRUPT_MACHINE_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+struct grub_bios_int_registers
+{
+ grub_uint32_t eax;
+ grub_uint16_t es;
+ grub_uint16_t ds;
+ grub_uint16_t flags;
+ grub_uint16_t dummy;
+ grub_uint32_t ebx;
+ grub_uint32_t ecx;
+ grub_uint32_t edi;
+ grub_uint32_t esi;
+ grub_uint32_t edx;
+};
+
+#define GRUB_CPU_INT_FLAGS_CARRY 0x1
+#define GRUB_CPU_INT_FLAGS_PARITY 0x4
+#define GRUB_CPU_INT_FLAGS_ADJUST 0x10
+#define GRUB_CPU_INT_FLAGS_ZERO 0x40
+#define GRUB_CPU_INT_FLAGS_SIGN 0x80
+#define GRUB_CPU_INT_FLAGS_TRAP 0x100
+#define GRUB_CPU_INT_FLAGS_INTERRUPT 0x200
+#define GRUB_CPU_INT_FLAGS_DIRECTION 0x400
+#define GRUB_CPU_INT_FLAGS_OVERFLOW 0x800
+#define GRUB_CPU_INT_FLAGS_DEFAULT GRUB_CPU_INT_FLAGS_INTERRUPT
+
+void EXPORT_FUNC (grub_bios_interrupt) (grub_uint8_t intno,
+ struct grub_bios_int_registers *regs);
+
+#endif
diff --git a/include/grub/i386/pc/kernel.h b/include/grub/i386/pc/kernel.h
new file mode 100644
index 0000000..1de37a5
--- /dev/null
+++ b/include/grub/i386/pc/kernel.h
@@ -0,0 +1,49 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2007,2008 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 KERNEL_MACHINE_HEADER
+#define KERNEL_MACHINE_HEADER 1
+
+#include <grub/offsets.h>
+
+/* Enable LZMA compression */
+#define ENABLE_LZMA 1
+
+#ifndef ASM_FILE
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+/* The size of kernel image. */
+extern grub_int32_t grub_kernel_image_size;
+
+/* The total size of module images following the kernel. */
+extern grub_int32_t grub_total_module_size;
+
+/* The DOS partition number of the installed partition. */
+extern grub_int32_t grub_install_dos_part;
+
+/* The BSD partition number of the installed partition. */
+extern grub_int32_t grub_install_bsd_part;
+
+/* The boot BIOS drive number. */
+extern grub_uint8_t EXPORT_VAR(grub_boot_drive);
+
+#endif /* ! ASM_FILE */
+
+#endif /* ! KERNEL_MACHINE_HEADER */
diff --git a/include/grub/i386/pc/loader.h b/include/grub/i386/pc/loader.h
new file mode 100644
index 0000000..bfbcaac
--- /dev/null
+++ b/include/grub/i386/pc/loader.h
@@ -0,0 +1,27 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,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_LOADER_MACHINE_HEADER
+#define GRUB_LOADER_MACHINE_HEADER 1
+
+#include <grub/symbol.h>
+
+/* This is an asm part of the chainloader. */
+void EXPORT_FUNC(grub_chainloader_real_boot) (int drive, void *part_addr) __attribute__ ((noreturn));
+
+#endif /* ! GRUB_LOADER_MACHINE_HEADER */
diff --git a/include/grub/i386/pc/memory.h b/include/grub/i386/pc/memory.h
new file mode 100644
index 0000000..401c837
--- /dev/null
+++ b/include/grub/i386/pc/memory.h
@@ -0,0 +1,97 @@
+/* memory.h - describe the memory map */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,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_MEMORY_MACHINE_HEADER
+#define GRUB_MEMORY_MACHINE_HEADER 1
+
+#include <grub/symbol.h>
+#ifndef ASM_FILE
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/memory.h>
+#endif
+
+#include <grub/i386/memory.h>
+
+#include <grub/offsets.h>
+
+/* The scratch buffer used in real mode code. */
+#define GRUB_MEMORY_MACHINE_SCRATCH_ADDR 0x68000
+#define GRUB_MEMORY_MACHINE_SCRATCH_SEG (GRUB_MEMORY_MACHINE_SCRATCH_ADDR >> 4)
+#define GRUB_MEMORY_MACHINE_SCRATCH_SIZE 0x10000
+
+/* The real mode stack. */
+#define GRUB_MEMORY_MACHINE_REAL_STACK (0x2000 - 0x10)
+
+/* The size of the protect mode stack. */
+#define GRUB_MEMORY_MACHINE_PROT_STACK_SIZE 0x8000
+
+/* The protected mode stack. */
+#define GRUB_MEMORY_MACHINE_PROT_STACK \
+ (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + GRUB_MEMORY_MACHINE_SCRATCH_SIZE \
+ + GRUB_MEMORY_MACHINE_PROT_STACK_SIZE - 0x10)
+
+/* The memory area where GRUB uses its own purpose. This part is not added
+ into free memory for dynamic allocations. */
+#define GRUB_MEMORY_MACHINE_RESERVED_START \
+ GRUB_MEMORY_MACHINE_SCRATCH_ADDR
+#define GRUB_MEMORY_MACHINE_RESERVED_END \
+ (GRUB_MEMORY_MACHINE_PROT_STACK + 0x10)
+
+/* The area where GRUB is decompressed at early startup. */
+#define GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR 0x100000
+
+/* The address of a partition table passed to another boot loader. */
+#define GRUB_MEMORY_MACHINE_PART_TABLE_ADDR 0x7be
+
+/* The address where another boot loader is loaded. */
+#define GRUB_MEMORY_MACHINE_BOOT_LOADER_ADDR 0x7c00
+
+/* The code segment of the protected mode. */
+#define GRUB_MEMORY_MACHINE_PROT_MODE_CSEG 0x8
+
+/* The data segment of the protected mode. */
+#define GRUB_MEMORY_MACHINE_PROT_MODE_DSEG 0x10
+
+/* The code segment of the pseudo real mode. */
+#define GRUB_MEMORY_MACHINE_PSEUDO_REAL_CSEG 0x18
+
+/* The data segment of the pseudo real mode. */
+#define GRUB_MEMORY_MACHINE_PSEUDO_REAL_DSEG 0x20
+
+#define GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR 0x400
+
+#ifndef ASM_FILE
+
+/* See http://heim.ifi.uio.no/~stanisls/helppc/bios_data_area.html for a
+ description of the BIOS Data Area layout. */
+struct grub_machine_bios_data_area
+{
+ grub_uint8_t unused1[0x17];
+ grub_uint8_t keyboard_flag_lower; /* 0x17 */
+ grub_uint8_t unused2[0xf0 - 0x18];
+};
+
+grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
+ int type, int handle);
+grub_err_t grub_machine_mmap_unregister (int handle);
+
+#endif
+
+#endif /* ! GRUB_MEMORY_MACHINE_HEADER */
diff --git a/include/grub/i386/pc/pxe.h b/include/grub/i386/pc/pxe.h
new file mode 100644
index 0000000..62ece21
--- /dev/null
+++ b/include/grub/i386/pc/pxe.h
@@ -0,0 +1,328 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_CPU_PXE_H
+#define GRUB_CPU_PXE_H
+
+#include <grub/types.h>
+
+#define GRUB_PXENV_TFTP_OPEN 0x0020
+#define GRUB_PXENV_TFTP_CLOSE 0x0021
+#define GRUB_PXENV_TFTP_READ 0x0022
+#define GRUB_PXENV_TFTP_READ_FILE 0x0023
+#define GRUB_PXENV_TFTP_READ_FILE_PMODE 0x0024
+#define GRUB_PXENV_TFTP_GET_FSIZE 0x0025
+
+#define GRUB_PXENV_UDP_OPEN 0x0030
+#define GRUB_PXENV_UDP_CLOSE 0x0031
+#define GRUB_PXENV_UDP_READ 0x0032
+#define GRUB_PXENV_UDP_WRITE 0x0033
+
+#define GRUB_PXENV_START_UNDI 0x0000
+#define GRUB_PXENV_UNDI_STARTUP 0x0001
+#define GRUB_PXENV_UNDI_CLEANUP 0x0002
+#define GRUB_PXENV_UNDI_INITIALIZE 0x0003
+#define GRUB_PXENV_UNDI_RESET_NIC 0x0004
+#define GRUB_PXENV_UNDI_SHUTDOWN 0x0005
+#define GRUB_PXENV_UNDI_OPEN 0x0006
+#define GRUB_PXENV_UNDI_CLOSE 0x0007
+#define GRUB_PXENV_UNDI_TRANSMIT 0x0008
+#define GRUB_PXENV_UNDI_SET_MCAST_ADDR 0x0009
+#define GRUB_PXENV_UNDI_SET_STATION_ADDR 0x000A
+#define GRUB_PXENV_UNDI_SET_PACKET_FILTER 0x000B
+#define GRUB_PXENV_UNDI_GET_INFORMATION 0x000C
+#define GRUB_PXENV_UNDI_GET_STATISTICS 0x000D
+#define GRUB_PXENV_UNDI_CLEAR_STATISTICS 0x000E
+#define GRUB_PXENV_UNDI_INITIATE_DIAGS 0x000F
+#define GRUB_PXENV_UNDI_FORCE_INTERRUPT 0x0010
+#define GRUB_PXENV_UNDI_GET_MCAST_ADDR 0x0011
+#define GRUB_PXENV_UNDI_GET_NIC_TYPE 0x0012
+#define GRUB_PXENV_UNDI_GET_IFACE_INFO 0x0013
+#define GRUB_PXENV_UNDI_ISR 0x0014
+#define GRUB_PXENV_STOP_UNDI 0x0015
+#define GRUB_PXENV_UNDI_GET_STATE 0x0015
+
+#define GRUB_PXENV_UNLOAD_STACK 0x0070
+#define GRUB_PXENV_GET_CACHED_INFO 0x0071
+#define GRUB_PXENV_RESTART_DHCP 0x0072
+#define GRUB_PXENV_RESTART_TFTP 0x0073
+#define GRUB_PXENV_MODE_SWITCH 0x0074
+#define GRUB_PXENV_START_BASE 0x0075
+#define GRUB_PXENV_STOP_BASE 0x0076
+
+#define GRUB_PXENV_EXIT_SUCCESS 0x0000
+#define GRUB_PXENV_EXIT_FAILURE 0x0001
+
+#define GRUB_PXENV_STATUS_SUCCESS 0x00
+#define GRUB_PXENV_STATUS_FAILURE 0x01
+#define GRUB_PXENV_STATUS_BAD_FUNC 0x02
+#define GRUB_PXENV_STATUS_UNSUPPORTED 0x03
+#define GRUB_PXENV_STATUS_KEEP_UNDI 0x04
+#define GRUB_PXENV_STATUS_KEEP_ALL 0x05
+#define GRUB_PXENV_STATUS_OUT_OF_RESOURCES 0x06
+#define GRUB_PXENV_STATUS_ARP_TIMEOUT 0x11
+#define GRUB_PXENV_STATUS_UDP_CLOSED 0x18
+#define GRUB_PXENV_STATUS_UDP_OPEN 0x19
+#define GRUB_PXENV_STATUS_TFTP_CLOSED 0x1A
+#define GRUB_PXENV_STATUS_TFTP_OPEN 0x1B
+#define GRUB_PXENV_STATUS_MCOPY_PROBLEM 0x20
+#define GRUB_PXENV_STATUS_BIS_INTEGRITY_FAILURE 0x21
+#define GRUB_PXENV_STATUS_BIS_VALIDATE_FAILURE 0x22
+#define GRUB_PXENV_STATUS_BIS_INIT_FAILURE 0x23
+#define GRUB_PXENV_STATUS_BIS_SHUTDOWN_FAILURE 0x24
+#define GRUB_PXENV_STATUS_BIS_GBOA_FAILURE 0x25
+#define GRUB_PXENV_STATUS_BIS_FREE_FAILURE 0x26
+#define GRUB_PXENV_STATUS_BIS_GSI_FAILURE 0x27
+#define GRUB_PXENV_STATUS_BIS_BAD_CKSUM 0x28
+#define GRUB_PXENV_STATUS_TFTP_CANNOT_ARP_ADDRESS 0x30
+#define GRUB_PXENV_STATUS_TFTP_OPEN_TIMEOUT 0x32
+
+#define GRUB_PXENV_STATUS_TFTP_UNKNOWN_OPCODE 0x33
+#define GRUB_PXENV_STATUS_TFTP_READ_TIMEOUT 0x35
+#define GRUB_PXENV_STATUS_TFTP_ERROR_OPCODE 0x36
+#define GRUB_PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION 0x38
+#define GRUB_PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION 0x39
+#define GRUB_PXENV_STATUS_TFTP_TOO_MANY_PACKAGES 0x3A
+#define GRUB_PXENV_STATUS_TFTP_FILE_NOT_FOUND 0x3B
+#define GRUB_PXENV_STATUS_TFTP_ACCESS_VIOLATION 0x3C
+#define GRUB_PXENV_STATUS_TFTP_NO_MCAST_ADDRESS 0x3D
+#define GRUB_PXENV_STATUS_TFTP_NO_FILESIZE 0x3E
+#define GRUB_PXENV_STATUS_TFTP_INVALID_PACKET_SIZE 0x3F
+#define GRUB_PXENV_STATUS_DHCP_TIMEOUT 0x51
+#define GRUB_PXENV_STATUS_DHCP_NO_IP_ADDRESS 0x52
+#define GRUB_PXENV_STATUS_DHCP_NO_BOOTFILE_NAME 0x53
+#define GRUB_PXENV_STATUS_DHCP_BAD_IP_ADDRESS 0x54
+#define GRUB_PXENV_STATUS_UNDI_INVALID_FUNCTION 0x60
+#define GRUB_PXENV_STATUS_UNDI_MEDIATEST_FAILED 0x61
+#define GRUB_PXENV_STATUS_UNDI_CANNOT_INIT_NIC_FOR_MCAST 0x62
+#define GRUB_PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC 0x63
+#define GRUB_PXENV_STATUS_UNDI_CANNOT_INITIALIZE_PHY 0x64
+#define GRUB_PXENV_STATUS_UNDI_CANNOT_READ_CONFIG_DATA 0x65
+#define GRUB_PXENV_STATUS_UNDI_CANNOT_READ_INIT_DATA 0x66
+#define GRUB_PXENV_STATUS_UNDI_BAD_MAC_ADDRESS 0x67
+#define GRUB_PXENV_STATUS_UNDI_BAD_EEPROM_CHECKSUM 0x68
+#define GRUB_PXENV_STATUS_UNDI_ERROR_SETTING_ISR 0x69
+#define GRUB_PXENV_STATUS_UNDI_INVALID_STATE 0x6A
+#define GRUB_PXENV_STATUS_UNDI_TRANSMIT_ERROR 0x6B
+#define GRUB_PXENV_STATUS_UNDI_INVALID_PARAMETER 0x6C
+#define GRUB_PXENV_STATUS_BSTRAP_PROMPT_MENU 0x74
+#define GRUB_PXENV_STATUS_BSTRAP_MCAST_ADDR 0x76
+#define GRUB_PXENV_STATUS_BSTRAP_MISSING_LIST 0x77
+#define GRUB_PXENV_STATUS_BSTRAP_NO_RESPONSE 0x78
+#define GRUB_PXENV_STATUS_BSTRAP_FILE_TOO_BIG 0x79
+#define GRUB_PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE 0xA0
+#define GRUB_PXENV_STATUS_BINL_NO_PXE_SERVER 0xA1
+#define GRUB_PXENV_STATUS_NOT_AVAILABLE_IN_PMODE 0xA2
+#define GRUB_PXENV_STATUS_NOT_AVAILABLE_IN_RMODE 0xA3
+#define GRUB_PXENV_STATUS_BUSD_DEVICE_NOT_SUPPORTED 0xB0
+#define GRUB_PXENV_STATUS_LOADER_NO_FREE_BASE_MEMORY 0xC0
+#define GRUB_PXENV_STATUS_LOADER_NO_BC_ROMID 0xC1
+#define GRUB_PXENV_STATUS_LOADER_BAD_BC_ROMID 0xC2
+#define GRUB_PXENV_STATUS_LOADER_BAD_BC_RUNTIME_IMAGE 0xC3
+#define GRUB_PXENV_STATUS_LOADER_NO_UNDI_ROMID 0xC4
+#define GRUB_PXENV_STATUS_LOADER_BAD_UNDI_ROMID 0xC5
+#define GRUB_PXENV_STATUS_LOADER_BAD_UNDI_DRIVER_IMAGE 0xC6
+#define GRUB_PXENV_STATUS_LOADER_NO_PXE_STRUCT 0xC8
+#define GRUB_PXENV_STATUS_LOADER_NO_PXENV_STRUCT 0xC9
+#define GRUB_PXENV_STATUS_LOADER_UNDI_START 0xCA
+#define GRUB_PXENV_STATUS_LOADER_BC_START 0xCB
+
+#define GRUB_PXENV_PACKET_TYPE_DHCP_DISCOVER 1
+#define GRUB_PXENV_PACKET_TYPE_DHCP_ACK 2
+#define GRUB_PXENV_PACKET_TYPE_CACHED_REPLY 3
+
+#define GRUB_PXE_BOOTP_REQ 1
+#define GRUB_PXE_BOOTP_REP 2
+
+#define GRUB_PXE_BOOTP_BCAST 0x8000
+
+#if 1
+#define GRUB_PXE_BOOTP_DHCPVEND 1024 /* DHCP extended vendor field size. */
+#else
+#define GRUB_PXE_BOOTP_DHCPVEND 312 /* DHCP standard vendor field size. */
+#endif
+
+#define GRUB_PXE_MIN_BLKSIZE 512
+#define GRUB_PXE_MAX_BLKSIZE 1432
+
+#define GRUB_PXE_TFTP_PORT 69
+
+#define GRUB_PXE_VM_RFC1048 0x63825363L
+
+#define GRUB_PXE_ERR_LEN 0xFFFFFFFF
+
+#ifndef ASM_FILE
+
+#define GRUB_PXE_SIGNATURE "PXENV+"
+
+struct grub_pxenv
+{
+ grub_uint8_t signature[6]; /* 'PXENV+'. */
+ grub_uint16_t version; /* MSB = major, LSB = minor. */
+ grub_uint8_t length; /* structure length. */
+ grub_uint8_t checksum; /* checksum pad. */
+ grub_uint32_t rm_entry; /* SEG:OFF to PXE entry point. */
+ grub_uint32_t pm_offset; /* Protected mode entry. */
+ grub_uint16_t pm_selector; /* Protected mode selector. */
+ grub_uint16_t stack_seg; /* Stack segment address. */
+ grub_uint16_t stack_size; /* Stack segment size (bytes). */
+ grub_uint16_t bc_code_seg; /* BC Code segment address. */
+ grub_uint16_t bc_code_size; /* BC Code segment size (bytes). */
+ grub_uint16_t bc_data_seg; /* BC Data segment address. */
+ grub_uint16_t bc_data_size; /* BC Data segment size (bytes). */
+ grub_uint16_t undi_data_seg; /* UNDI Data segment address. */
+ grub_uint16_t undi_data_size; /* UNDI Data segment size (bytes). */
+ grub_uint16_t undi_code_seg; /* UNDI Code segment address. */
+ grub_uint16_t undi_code_size; /* UNDI Code segment size (bytes). */
+ grub_uint32_t pxe_ptr; /* SEG:OFF to !PXE struct. */
+} __attribute__ ((packed));
+
+struct grub_pxe_bangpxe
+{
+ grub_uint8_t signature[4];
+#define GRUB_PXE_BANGPXE_SIGNATURE "!PXE"
+ grub_uint8_t length;
+ grub_uint8_t chksum;
+ grub_uint8_t rev;
+ grub_uint8_t reserved;
+ grub_uint32_t undiromid;
+ grub_uint32_t baseromid;
+ grub_uint32_t rm_entry;
+} __attribute__ ((packed));
+
+struct grub_pxenv_get_cached_info
+{
+ grub_uint16_t status;
+ grub_uint16_t packet_type;
+ grub_uint16_t buffer_size;
+ grub_uint32_t buffer;
+ grub_uint16_t buffer_limit;
+} __attribute__ ((packed));
+
+#define GRUB_PXE_MAC_ADDR_LEN 16
+
+typedef grub_uint8_t grub_pxe_mac_addr_t[GRUB_PXE_MAC_ADDR_LEN];
+
+struct grub_pxenv_boot_player
+{
+ grub_uint8_t opcode;
+ grub_uint8_t hw_type; /* hardware type. */
+ grub_uint8_t hw_len; /* hardware addr len. */
+ grub_uint8_t gate_hops; /* zero it. */
+ grub_uint32_t ident; /* random number chosen by client. */
+ grub_uint16_t seconds; /* seconds since did initial bootstrap. */
+ grub_uint16_t flags;
+ grub_uint32_t client_ip;
+ grub_uint32_t your_ip;
+ grub_uint32_t server_ip;
+ grub_uint32_t gateway_ip;
+ grub_pxe_mac_addr_t mac_addr;
+ grub_uint8_t server_name[64];
+ grub_uint8_t boot_file[128];
+ union
+ {
+ grub_uint8_t d[GRUB_PXE_BOOTP_DHCPVEND]; /* raw array of vendor/dhcp options. */
+ struct
+ {
+ grub_uint32_t magic; /* DHCP magic cookie. */
+ grub_uint32_t flags; /* bootp flags/opcodes. */
+ grub_uint8_t padding[56];
+ } v;
+ } vendor;
+} __attribute__ ((packed));
+
+struct grub_pxenv_tftp_open
+{
+ grub_uint16_t status;
+ grub_uint32_t server_ip;
+ grub_uint32_t gateway_ip;
+ grub_uint8_t filename[128];
+ grub_uint16_t tftp_port;
+ grub_uint16_t packet_size;
+} __attribute__ ((packed));
+
+struct grub_pxenv_tftp_close
+{
+ grub_uint16_t status;
+} __attribute__ ((packed));
+
+struct grub_pxenv_tftp_read
+{
+ grub_uint16_t status;
+ grub_uint16_t packet_number;
+ grub_uint16_t buffer_size;
+ grub_uint32_t buffer;
+} __attribute__ ((packed));
+
+struct grub_pxenv_tftp_get_fsize
+{
+ grub_uint16_t status;
+ grub_uint32_t server_ip;
+ grub_uint32_t gateway_ip;
+ grub_uint8_t filename[128];
+ grub_uint32_t file_size;
+} __attribute__ ((packed));
+
+struct grub_pxenv_udp_open
+{
+ grub_uint16_t status;
+ grub_uint32_t src_ip;
+} __attribute__ ((packed));
+
+struct grub_pxenv_udp_close
+{
+ grub_uint16_t status;
+} __attribute__ ((packed));
+
+struct grub_pxenv_udp_write
+{
+ grub_uint16_t status;
+ grub_uint32_t ip;
+ grub_uint32_t gateway;
+ grub_uint16_t src_port;
+ grub_uint16_t dst_port;
+ grub_uint16_t buffer_size;
+ grub_uint32_t buffer;
+} __attribute__ ((packed));
+
+struct grub_pxenv_udp_read
+{
+ grub_uint16_t status;
+ grub_uint32_t src_ip;
+ grub_uint32_t dst_ip;
+ grub_uint16_t src_port;
+ grub_uint16_t dst_port;
+ grub_uint16_t buffer_size;
+ grub_uint32_t buffer;
+} __attribute__ ((packed));
+
+struct grub_pxenv_unload_stack
+{
+ grub_uint16_t status;
+ grub_uint8_t reserved[10];
+} __attribute__ ((packed));
+
+int EXPORT_FUNC(grub_pxe_call) (int func, void * data, grub_uint32_t pxe_rm_entry);
+
+extern struct grub_pxe_bangpxe *grub_pxe_pxenv;
+
+void grub_pxe_unload (void);
+
+#endif
+
+#endif /* GRUB_CPU_PXE_H */
diff --git a/include/grub/i386/pc/time.h b/include/grub/i386/pc/time.h
new file mode 100644
index 0000000..98399b6
--- /dev/null
+++ b/include/grub/i386/pc/time.h
@@ -0,0 +1,29 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,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 KERNEL_MACHINE_TIME_HEADER
+#define KERNEL_MACHINE_TIME_HEADER 1
+
+#include <grub/symbol.h>
+
+#define GRUB_TICKS_PER_SECOND 18
+
+/* Return the real time in ticks. */
+grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void);
+
+#endif /* ! KERNEL_MACHINE_TIME_HEADER */
diff --git a/include/grub/i386/pc/vbe.h b/include/grub/i386/pc/vbe.h
new file mode 100644
index 0000000..fba3ee6
--- /dev/null
+++ b/include/grub/i386/pc/vbe.h
@@ -0,0 +1,217 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,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_VBE_MACHINE_HEADER
+#define GRUB_VBE_MACHINE_HEADER 1
+
+/* Default video mode to be used. */
+#define GRUB_VBE_DEFAULT_VIDEO_MODE 0x101
+
+/* VBE status codes. */
+#define GRUB_VBE_STATUS_OK 0x004f
+
+#define GRUB_VBE_CAPABILITY_DACWIDTH (1 << 0)
+
+/* Bits from the GRUB_VBE "mode_attributes" field in the mode info struct. */
+#define GRUB_VBE_MODEATTR_SUPPORTED (1 << 0)
+#define GRUB_VBE_MODEATTR_RESERVED_1 (1 << 1)
+#define GRUB_VBE_MODEATTR_BIOS_TTY_OUTPUT_SUPPORT (1 << 2)
+#define GRUB_VBE_MODEATTR_COLOR (1 << 3)
+#define GRUB_VBE_MODEATTR_GRAPHICS (1 << 4)
+#define GRUB_VBE_MODEATTR_VGA_COMPATIBLE (1 << 5)
+#define GRUB_VBE_MODEATTR_VGA_WINDOWED_AVAIL (1 << 6)
+#define GRUB_VBE_MODEATTR_LFB_AVAIL (1 << 7)
+#define GRUB_VBE_MODEATTR_DOUBLE_SCAN_AVAIL (1 << 8)
+#define GRUB_VBE_MODEATTR_INTERLACED_AVAIL (1 << 9)
+#define GRUB_VBE_MODEATTR_TRIPLE_BUF_AVAIL (1 << 10)
+#define GRUB_VBE_MODEATTR_STEREO_AVAIL (1 << 11)
+#define GRUB_VBE_MODEATTR_DUAL_DISPLAY_START (1 << 12)
+
+/* Values for the GRUB_VBE memory_model field in the mode info struct. */
+#define GRUB_VBE_MEMORY_MODEL_TEXT 0x00
+#define GRUB_VBE_MEMORY_MODEL_CGA 0x01
+#define GRUB_VBE_MEMORY_MODEL_HERCULES 0x02
+#define GRUB_VBE_MEMORY_MODEL_PLANAR 0x03
+#define GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL 0x04
+#define GRUB_VBE_MEMORY_MODEL_NONCHAIN4_256 0x05
+#define GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR 0x06
+#define GRUB_VBE_MEMORY_MODEL_YUV 0x07
+
+/* Note:
+
+ Please refer to VESA BIOS Extension 3.0 Specification for more descriptive
+ meanings of following structures and how they should be used.
+
+ I have tried to maintain field name compatibility against specification
+ while following naming conventions used in GRUB. */
+
+typedef grub_uint32_t grub_vbe_farptr_t;
+typedef grub_uint32_t grub_vbe_physptr_t;
+typedef grub_uint32_t grub_vbe_status_t;
+
+struct grub_vbe_info_block
+{
+ grub_uint8_t signature[4];
+ grub_uint16_t version;
+
+ grub_vbe_farptr_t oem_string_ptr;
+ grub_uint32_t capabilities;
+ grub_vbe_farptr_t video_mode_ptr;
+ grub_uint16_t total_memory;
+
+ grub_uint16_t oem_software_rev;
+ grub_vbe_farptr_t oem_vendor_name_ptr;
+ grub_vbe_farptr_t oem_product_name_ptr;
+ grub_vbe_farptr_t oem_product_rev_ptr;
+
+ grub_uint8_t reserved[222];
+
+ grub_uint8_t oem_data[256];
+} __attribute__ ((packed));
+
+struct grub_vbe_mode_info_block
+{
+ /* Mandatory information for all VBE revisions. */
+ grub_uint16_t mode_attributes;
+ grub_uint8_t win_a_attributes;
+ grub_uint8_t win_b_attributes;
+ grub_uint16_t win_granularity;
+ grub_uint16_t win_size;
+ grub_uint16_t win_a_segment;
+ grub_uint16_t win_b_segment;
+ grub_vbe_farptr_t win_func_ptr;
+ grub_uint16_t bytes_per_scan_line;
+
+ /* Mandatory information for VBE 1.2 and above. */
+ grub_uint16_t x_resolution;
+ grub_uint16_t y_resolution;
+ grub_uint8_t x_char_size;
+ grub_uint8_t y_char_size;
+ grub_uint8_t number_of_planes;
+ grub_uint8_t bits_per_pixel;
+ grub_uint8_t number_of_banks;
+ grub_uint8_t memory_model;
+ grub_uint8_t bank_size;
+ grub_uint8_t number_of_image_pages;
+ grub_uint8_t reserved;
+
+ /* Direct Color fields (required for direct/6 and YUV/7 memory models). */
+ grub_uint8_t red_mask_size;
+ grub_uint8_t red_field_position;
+ grub_uint8_t green_mask_size;
+ grub_uint8_t green_field_position;
+ grub_uint8_t blue_mask_size;
+ grub_uint8_t blue_field_position;
+ grub_uint8_t rsvd_mask_size;
+ grub_uint8_t rsvd_field_position;
+ grub_uint8_t direct_color_mode_info;
+
+ /* Mandatory information for VBE 2.0 and above. */
+ grub_vbe_physptr_t phys_base_addr;
+ grub_uint32_t reserved2;
+ grub_uint16_t reserved3;
+
+ /* Mandatory information for VBE 3.0 and above. */
+ grub_uint16_t lin_bytes_per_scan_line;
+ grub_uint8_t bnk_number_of_image_pages;
+ grub_uint8_t lin_number_of_image_pages;
+ grub_uint8_t lin_red_mask_size;
+ grub_uint8_t lin_red_field_position;
+ grub_uint8_t lin_green_mask_size;
+ grub_uint8_t lin_green_field_position;
+ grub_uint8_t lin_blue_mask_size;
+ grub_uint8_t lin_blue_field_position;
+ grub_uint8_t lin_rsvd_mask_size;
+ grub_uint8_t lin_rsvd_field_position;
+ grub_uint32_t max_pixel_clock;
+
+ /* Reserved field to make structure to be 256 bytes long, VESA BIOS
+ Extension 3.0 Specification says to reserve 189 bytes here but
+ that doesn't make structure to be 256 bytes. So additional one is
+ added here. */
+ grub_uint8_t reserved4[189 + 1];
+} __attribute__ ((packed));
+
+struct grub_vbe_crtc_info_block
+{
+ grub_uint16_t horizontal_total;
+ grub_uint16_t horizontal_sync_start;
+ grub_uint16_t horizontal_sync_end;
+ grub_uint16_t vertical_total;
+ grub_uint16_t vertical_sync_start;
+ grub_uint16_t vertical_sync_end;
+ grub_uint8_t flags;
+ grub_uint32_t pixel_clock;
+ grub_uint16_t refresh_rate;
+ grub_uint8_t reserved[40];
+} __attribute__ ((packed));
+
+struct grub_vbe_palette_data
+{
+ grub_uint8_t blue;
+ grub_uint8_t green;
+ grub_uint8_t red;
+ grub_uint8_t alignment;
+} __attribute__ ((packed));
+
+/* Prototypes for helper functions. */
+/* Call VESA BIOS 0x4f00 to get VBE Controller Information, return status. */
+grub_vbe_status_t
+grub_vbe_bios_get_controller_info (struct grub_vbe_info_block *controller_info);
+/* Call VESA BIOS 0x4f01 to get VBE Mode Information, return status. */
+grub_vbe_status_t
+grub_vbe_bios_get_mode_info (grub_uint32_t mode,
+ struct grub_vbe_mode_info_block *mode_info);
+/* Call VESA BIOS 0x4f03 to return current VBE Mode, return status. */
+grub_vbe_status_t
+grub_vbe_bios_get_mode (grub_uint32_t *mode);
+/* Call VESA BIOS 0x4f05 to set memory window, return status. */
+grub_vbe_status_t
+grub_vbe_bios_set_memory_window (grub_uint32_t window, grub_uint32_t position);
+/* Call VESA BIOS 0x4f05 to return memory window, return status. */
+grub_vbe_status_t
+grub_vbe_bios_get_memory_window (grub_uint32_t window,
+ grub_uint32_t *position);
+/* Call VESA BIOS 0x4f06 to set scanline length (in bytes), return status. */
+grub_vbe_status_t
+grub_vbe_bios_set_scanline_length (grub_uint32_t length);
+/* Call VESA BIOS 0x4f06 to return scanline length (in bytes), return status. */
+grub_vbe_status_t
+grub_vbe_bios_get_scanline_length (grub_uint32_t *length);
+/* Call VESA BIOS 0x4f07 to get display start, return status. */
+grub_vbe_status_t
+grub_vbe_bios_get_display_start (grub_uint32_t *x,
+ grub_uint32_t *y);
+
+grub_vbe_status_t grub_vbe_bios_getset_dac_palette_width (int set, int *width);
+
+#define grub_vbe_bios_get_dac_palette_width(width) grub_vbe_bios_getset_dac_palette_width(0, (width))
+#define grub_vbe_bios_set_dac_palette_width(width) grub_vbe_bios_getset_dac_palette_width(1, (width))
+
+grub_err_t grub_vbe_probe (struct grub_vbe_info_block *info_block);
+grub_err_t grub_vbe_set_video_mode (grub_uint32_t mode,
+ struct grub_vbe_mode_info_block *mode_info);
+grub_err_t grub_vbe_get_video_mode (grub_uint32_t *mode);
+grub_err_t grub_vbe_get_video_mode_info (grub_uint32_t mode,
+ struct grub_vbe_mode_info_block *mode_info);
+grub_vbe_status_t
+grub_vbe_bios_get_pm_interface (grub_uint16_t *seg, grub_uint16_t *offset,
+ grub_uint16_t *length);
+
+
+#endif /* ! GRUB_VBE_MACHINE_HEADER */
diff --git a/include/grub/i386/pc/vesa_modes_table.h b/include/grub/i386/pc/vesa_modes_table.h
new file mode 100644
index 0000000..376ca37
--- /dev/null
+++ b/include/grub/i386/pc/vesa_modes_table.h
@@ -0,0 +1,19 @@
+#ifndef GRUB_VESA_MODE_TABLE_HEADER
+#define GRUB_VESA_MODE_TABLE_HEADER 1
+
+#include <grub/types.h>
+
+#define GRUB_VESA_MODE_TABLE_START 0x300
+#define GRUB_VESA_MODE_TABLE_END 0x373
+
+struct grub_vesa_mode_table_entry {
+ grub_uint16_t width;
+ grub_uint16_t height;
+ grub_uint8_t depth;
+};
+
+extern struct grub_vesa_mode_table_entry
+grub_vesa_mode_table[GRUB_VESA_MODE_TABLE_END
+ - GRUB_VESA_MODE_TABLE_START + 1];
+
+#endif
diff --git a/include/grub/i386/pc/vga.h b/include/grub/i386/pc/vga.h
new file mode 100644
index 0000000..ecc1690
--- /dev/null
+++ b/include/grub/i386/pc/vga.h
@@ -0,0 +1,28 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2007,2008 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_VGA_MACHINE_HEADER
+#define GRUB_VGA_MACHINE_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/machine/memory.h>
+
+/* The VGA (at the beginning of upper memory). */
+#define GRUB_MEMORY_MACHINE_VGA_ADDR GRUB_MEMORY_MACHINE_UPPER
+
+#endif /* ! GRUB_VGA_MACHINE_HEADER */
diff --git a/include/grub/i386/pci.h b/include/grub/i386/pci.h
new file mode 100644
index 0000000..795dec5
--- /dev/null
+++ b/include/grub/i386/pci.h
@@ -0,0 +1,89 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_CPU_PCI_H
+#define GRUB_CPU_PCI_H 1
+
+#include <grub/types.h>
+#include <grub/i386/io.h>
+
+#define GRUB_MACHINE_PCI_IO_BASE 0
+#define GRUB_PCI_ADDR_REG 0xcf8
+#define GRUB_PCI_DATA_REG 0xcfc
+#define GRUB_PCI_NUM_BUS 256
+#define GRUB_PCI_NUM_DEVICES 32
+
+static inline grub_uint32_t
+grub_pci_read (grub_pci_address_t addr)
+{
+ grub_outl (addr, GRUB_PCI_ADDR_REG);
+ return grub_inl (GRUB_PCI_DATA_REG);
+}
+
+static inline grub_uint16_t
+grub_pci_read_word (grub_pci_address_t addr)
+{
+ grub_outl (addr & ~3, GRUB_PCI_ADDR_REG);
+ return grub_inw (GRUB_PCI_DATA_REG + (addr & 3));
+}
+
+static inline grub_uint8_t
+grub_pci_read_byte (grub_pci_address_t addr)
+{
+ grub_outl (addr & ~3, GRUB_PCI_ADDR_REG);
+ return grub_inb (GRUB_PCI_DATA_REG + (addr & 3));
+}
+
+static inline void
+grub_pci_write (grub_pci_address_t addr, grub_uint32_t data)
+{
+ grub_outl (addr, GRUB_PCI_ADDR_REG);
+ grub_outl (data, GRUB_PCI_DATA_REG);
+}
+
+static inline void
+grub_pci_write_word (grub_pci_address_t addr, grub_uint16_t data)
+{
+ grub_outl (addr & ~3, GRUB_PCI_ADDR_REG);
+ grub_outw (data, GRUB_PCI_DATA_REG + (addr & 3));
+}
+
+static inline void
+grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
+{
+ grub_outl (addr & ~3, GRUB_PCI_ADDR_REG);
+ grub_outb (data, GRUB_PCI_DATA_REG + (addr & 3));
+}
+
+static inline volatile void *
+grub_pci_device_map_range (grub_pci_device_t dev __attribute__ ((unused)),
+ grub_addr_t base,
+ grub_size_t size __attribute__ ((unused)))
+{
+ return (volatile void *) base;
+}
+
+static inline void
+grub_pci_device_unmap_range (grub_pci_device_t dev __attribute__ ((unused)),
+ volatile void *mem __attribute__ ((unused)),
+ grub_size_t size __attribute__ ((unused)))
+{
+}
+
+
+#endif /* GRUB_CPU_PCI_H */
diff --git a/include/grub/i386/pit.h b/include/grub/i386/pit.h
new file mode 100644
index 0000000..ff9b9a6
--- /dev/null
+++ b/include/grub/i386/pit.h
@@ -0,0 +1,27 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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 KERNEL_CPU_PIT_HEADER
+#define KERNEL_CPU_PIT_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+
+void EXPORT_FUNC(grub_pit_wait) (grub_uint16_t tics);
+
+#endif /* ! KERNEL_CPU_PIT_HEADER */
diff --git a/include/grub/i386/qemu/boot.h b/include/grub/i386/qemu/boot.h
new file mode 100644
index 0000000..5f53eab
--- /dev/null
+++ b/include/grub/i386/qemu/boot.h
@@ -0,0 +1,25 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_BOOT_MACHINE_HEADER
+#define GRUB_BOOT_MACHINE_HEADER 1
+
+/* The size of boot.img. */
+#define GRUB_BOOT_MACHINE_SIZE (0x100000 - GRUB_BOOT_MACHINE_LINK_ADDR)
+
+#endif
diff --git a/include/grub/i386/qemu/console.h b/include/grub/i386/qemu/console.h
new file mode 100644
index 0000000..774399a
--- /dev/null
+++ b/include/grub/i386/qemu/console.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/console.h>
diff --git a/include/grub/i386/qemu/kernel.h b/include/grub/i386/qemu/kernel.h
new file mode 100644
index 0000000..df06e67
--- /dev/null
+++ b/include/grub/i386/qemu/kernel.h
@@ -0,0 +1,41 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,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_KERNEL_MACHINE_HEADER
+#define GRUB_KERNEL_MACHINE_HEADER 1
+
+#include <grub/offsets.h>
+
+#ifndef ASM_FILE
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+extern grub_addr_t grub_core_entry_addr;
+
+/* The size of kernel image. */
+extern grub_int32_t grub_kernel_image_size;
+
+/* The total size of module images following the kernel. */
+extern grub_int32_t grub_total_module_size;
+
+void grub_qemu_init_cirrus (void);
+
+#endif /* ! ASM_FILE */
+
+#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
diff --git a/include/grub/i386/qemu/memory.h b/include/grub/i386/qemu/memory.h
new file mode 100644
index 0000000..2003e49
--- /dev/null
+++ b/include/grub/i386/qemu/memory.h
@@ -0,0 +1,42 @@
+/* memory.h - describe the memory map */
+/*
+ * 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_MEMORY_MACHINE_HEADER
+#define _GRUB_MEMORY_MACHINE_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/i386/coreboot/memory.h>
+
+#ifndef ASM_FILE
+#include <grub/err.h>
+#include <grub/types.h>
+#endif
+
+#define GRUB_MEMORY_MACHINE_LOWER_USABLE 0x9fc00 /* 640 kiB - 1 kiB */
+
+#define GRUB_MEMORY_MACHINE_UPPER_START 0x100000 /* 1 MiB */
+#define GRUB_MEMORY_MACHINE_LOWER_SIZE GRUB_MEMORY_MACHINE_UPPER_START
+
+#ifndef ASM_FILE
+
+void grub_machine_mmap_init (void);
+
+#endif
+
+#endif /* ! _GRUB_MEMORY_MACHINE_HEADER */
diff --git a/include/grub/i386/qemu/serial.h b/include/grub/i386/qemu/serial.h
new file mode 100644
index 0000000..2d85634
--- /dev/null
+++ b/include/grub/i386/qemu/serial.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/serial.h>
diff --git a/include/grub/i386/qemu/time.h b/include/grub/i386/qemu/time.h
new file mode 100644
index 0000000..7177c74
--- /dev/null
+++ b/include/grub/i386/qemu/time.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/time.h>
diff --git a/include/grub/i386/relocator.h b/include/grub/i386/relocator.h
new file mode 100644
index 0000000..6ff5c66
--- /dev/null
+++ b/include/grub/i386/relocator.h
@@ -0,0 +1,74 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_RELOCATOR_CPU_HEADER
+#define GRUB_RELOCATOR_CPU_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/relocator.h>
+
+struct grub_relocator32_state
+{
+ grub_uint32_t esp;
+ grub_uint32_t ebp;
+ grub_uint32_t eax;
+ grub_uint32_t ebx;
+ grub_uint32_t ecx;
+ grub_uint32_t edx;
+ grub_uint32_t eip;
+ grub_uint32_t esi;
+ grub_uint32_t edi;
+};
+
+struct grub_relocator16_state
+{
+ grub_uint16_t cs;
+ grub_uint16_t ds;
+ grub_uint16_t es;
+ grub_uint16_t fs;
+ grub_uint16_t gs;
+ grub_uint16_t ss;
+ grub_uint16_t sp;
+ grub_uint16_t ip;
+ grub_uint32_t edx;
+};
+
+struct grub_relocator64_state
+{
+ grub_uint64_t rsp;
+ grub_uint64_t rax;
+ grub_uint64_t rbx;
+ grub_uint64_t rcx;
+ grub_uint64_t rdx;
+ grub_uint64_t rip;
+ grub_uint64_t rsi;
+ grub_addr_t cr3;
+};
+
+grub_err_t grub_relocator16_boot (struct grub_relocator *rel,
+ struct grub_relocator16_state state);
+
+grub_err_t grub_relocator32_boot (struct grub_relocator *rel,
+ struct grub_relocator32_state state);
+
+grub_err_t grub_relocator64_boot (struct grub_relocator *rel,
+ struct grub_relocator64_state state,
+ grub_addr_t min_addr, grub_addr_t max_addr);
+
+#endif /* ! GRUB_RELOCATOR_CPU_HEADER */
diff --git a/include/grub/i386/setjmp.h b/include/grub/i386/setjmp.h
new file mode 100644
index 0000000..6b6b6fd
--- /dev/null
+++ b/include/grub/i386/setjmp.h
@@ -0,0 +1,33 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2006,2007,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_SETJMP_CPU_HEADER
+#define GRUB_SETJMP_CPU_HEADER 1
+
+typedef unsigned long grub_jmp_buf[6];
+
+#ifdef __MINGW32__
+int grub_setjmp (grub_jmp_buf env) __attribute__ ((cdecl, regparm (3)));
+#else
+int grub_setjmp (grub_jmp_buf env) __attribute__ ((returns_twice, cdecl,
+ regparm (3)));
+#endif
+void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn, cdecl,
+ regparm (3)));
+
+#endif /* ! GRUB_SETJMP_CPU_HEADER */
diff --git a/include/grub/i386/time.h b/include/grub/i386/time.h
new file mode 100644
index 0000000..842882c
--- /dev/null
+++ b/include/grub/i386/time.h
@@ -0,0 +1,29 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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 KERNEL_CPU_TIME_HEADER
+#define KERNEL_CPU_TIME_HEADER 1
+
+static __inline void
+grub_cpu_idle (void)
+{
+ /* FIXME: this can't work until we handle interrupts. */
+/* __asm__ __volatile__ ("hlt"); */
+}
+
+#endif /* ! KERNEL_CPU_TIME_HEADER */
diff --git a/include/grub/i386/tsc.h b/include/grub/i386/tsc.h
new file mode 100644
index 0000000..dad9d06
--- /dev/null
+++ b/include/grub/i386/tsc.h
@@ -0,0 +1,141 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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 KERNEL_CPU_TSC_HEADER
+#define KERNEL_CPU_TSC_HEADER 1
+
+#include <grub/types.h>
+
+/* Read the TSC value, which increments with each CPU clock cycle. */
+static __inline grub_uint64_t
+grub_get_tsc (void)
+{
+ grub_uint32_t lo, hi;
+
+ /* The CPUID instruction is a 'serializing' instruction, and
+ avoids out-of-order execution of the RDTSC instruction. */
+#ifdef APPLE_CC
+ __asm__ __volatile__ ("xorl %%eax, %%eax\n\t"
+#ifdef __x86_64__
+ "push %%rbx\n"
+#else
+ "push %%ebx\n"
+#endif
+ "cpuid\n"
+#ifdef __x86_64__
+ "pop %%rbx\n"
+#else
+ "pop %%ebx\n"
+#endif
+ :::"%rax", "%rcx", "%rdx");
+#else
+ __asm__ __volatile__ ("xorl %%eax, %%eax\n\t"
+ "cpuid":::"%rax", "%rbx", "%rcx", "%rdx");
+#endif
+ /* Read TSC value. We cannot use "=A", since this would use
+ %rax on x86_64. */
+ __asm__ __volatile__ ("rdtsc":"=a" (lo), "=d" (hi));
+
+ return (((grub_uint64_t) hi) << 32) | lo;
+}
+
+#ifdef __x86_64__
+
+static __inline int
+grub_cpu_is_cpuid_supported (void)
+{
+ grub_uint64_t id_supported;
+
+ __asm__ ("pushfq\n\t"
+ "popq %%rax /* Get EFLAGS into EAX */\n\t"
+ "movq %%rax, %%rcx /* Save original flags in ECX */\n\t"
+ "xorq $0x200000, %%rax /* Flip ID bit in EFLAGS */\n\t"
+ "pushq %%rax /* Store modified EFLAGS on stack */\n\t"
+ "popfq /* Replace current EFLAGS */\n\t"
+ "pushfq /* Read back the EFLAGS */\n\t"
+ "popq %%rax /* Get EFLAGS into EAX */\n\t"
+ "xorq %%rcx, %%rax /* Check if flag could be modified */\n\t"
+ : "=a" (id_supported)
+ : /* No inputs. */
+ : /* Clobbered: */ "%rcx");
+
+ return id_supported != 0;
+}
+
+#else
+
+static __inline int
+grub_cpu_is_cpuid_supported (void)
+{
+ grub_uint32_t id_supported;
+
+ __asm__ ("pushfl\n\t"
+ "popl %%eax /* Get EFLAGS into EAX */\n\t"
+ "movl %%eax, %%ecx /* Save original flags in ECX */\n\t"
+ "xorl $0x200000, %%eax /* Flip ID bit in EFLAGS */\n\t"
+ "pushl %%eax /* Store modified EFLAGS on stack */\n\t"
+ "popfl /* Replace current EFLAGS */\n\t"
+ "pushfl /* Read back the EFLAGS */\n\t"
+ "popl %%eax /* Get EFLAGS into EAX */\n\t"
+ "xorl %%ecx, %%eax /* Check if flag could be modified */\n\t"
+ : "=a" (id_supported)
+ : /* No inputs. */
+ : /* Clobbered: */ "%rcx");
+
+ return id_supported != 0;
+}
+
+#endif
+
+static __inline int
+grub_cpu_is_tsc_supported (void)
+{
+ if (! grub_cpu_is_cpuid_supported ())
+ return 0;
+
+ grub_uint32_t features;
+#ifdef APPLE_CC
+ __asm__ ("movl $1, %%eax\n\t"
+#ifdef __x86_64__
+ "push %%rbx\n"
+#else
+ "push %%ebx\n"
+#endif
+ "cpuid\n"
+#ifdef __x86_64__
+ "pop %%rbx\n"
+#else
+ "pop %%ebx\n"
+#endif
+ : "=d" (features)
+ : /* No inputs. */
+ : /* Clobbered: */ "%rax", "%rcx");
+#else
+ __asm__ ("movl $1, %%eax\n\t"
+ "cpuid\n"
+ : "=d" (features)
+ : /* No inputs. */
+ : /* Clobbered: */ "%rax", "%rbx", "%rcx");
+#endif
+ return (features & (1 << 4)) != 0;
+}
+
+void grub_tsc_init (void);
+grub_uint64_t grub_tsc_get_time_ms (void);
+
+#endif /* ! KERNEL_CPU_TSC_HEADER */
diff --git a/include/grub/i386/types.h b/include/grub/i386/types.h
new file mode 100644
index 0000000..0ac6473
--- /dev/null
+++ b/include/grub/i386/types.h
@@ -0,0 +1,31 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2006,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_TYPES_CPU_HEADER
+#define GRUB_TYPES_CPU_HEADER 1
+
+/* The size of void *. */
+#define GRUB_TARGET_SIZEOF_VOID_P 4
+
+/* The size of long. */
+#define GRUB_TARGET_SIZEOF_LONG 4
+
+/* i386 is little-endian. */
+#undef GRUB_TARGET_WORDS_BIGENDIAN
+
+#endif /* ! GRUB_TYPES_CPU_HEADER */
diff --git a/include/grub/i386/vga_common.h b/include/grub/i386/vga_common.h
new file mode 100644
index 0000000..8727903
--- /dev/null
+++ b/include/grub/i386/vga_common.h
@@ -0,0 +1,32 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,2007,2008 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_VGA_COMMON_CPU_HEADER
+#define GRUB_VGA_COMMON_CPU_HEADER 1
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+#include <grub/term.h>
+
+extern grub_uint8_t grub_console_cur_color;
+
+grub_uint16_t grub_console_getwh (struct grub_term_output *term);
+void grub_console_setcolorstate (struct grub_term_output *term,
+ grub_term_color_state state);
+
+#endif /* ! GRUB_VGA_COMMON_CPU_HEADER */
diff --git a/include/grub/i386/xnu.h b/include/grub/i386/xnu.h
new file mode 100644
index 0000000..386c8b9
--- /dev/null
+++ b/include/grub/i386/xnu.h
@@ -0,0 +1,118 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_CPU_XNU_H
+#define GRUB_CPU_XNU_H 1
+
+#include <grub/err.h>
+#include <grub/efi/api.h>
+#include <grub/cpu/relocator.h>
+
+#define XNU_RELOCATOR(x) (grub_relocator32_ ## x)
+
+#define GRUB_XNU_PAGESIZE 4096
+typedef grub_uint32_t grub_xnu_ptr_t;
+
+struct grub_xnu_boot_params
+{
+ grub_uint16_t verminor;
+ grub_uint16_t vermajor;
+ /* Command line passed to xnu. */
+ grub_uint8_t cmdline[1024];
+
+ /* Later are the same as EFI's get_memory_map (). */
+ grub_xnu_ptr_t efi_mmap;
+ grub_uint32_t efi_mmap_size;
+ grub_uint32_t efi_mem_desc_size;
+ grub_uint32_t efi_mem_desc_version;
+
+ /* Later are video parameters. */
+ grub_xnu_ptr_t lfb_base;
+#define GRUB_XNU_VIDEO_SPLASH 1
+#define GRUB_XNU_VIDEO_TEXT_IN_VIDEO 2
+ grub_uint32_t lfb_mode;
+ grub_uint32_t lfb_line_len;
+ grub_uint32_t lfb_width;
+ grub_uint32_t lfb_height;
+ grub_uint32_t lfb_depth;
+
+ /* Pointer to device tree and its len. */
+ grub_xnu_ptr_t devtree;
+ grub_uint32_t devtreelen;
+
+ /* First used address by kernel or boot structures. */
+ grub_xnu_ptr_t heap_start;
+ /* Last used address by kernel or boot structures minus previous value. */
+ grub_uint32_t heap_size;
+
+ /* First memory page containing runtime code or data. */
+ grub_uint32_t efi_runtime_first_page;
+ /* First memory page containing runtime code or data minus previous value. */
+ grub_uint32_t efi_runtime_npages;
+ grub_uint32_t efi_system_table;
+ /* Size of grub_efi_uintn_t in bits. */
+ grub_uint8_t efi_uintnbits;
+} __attribute__ ((packed));
+#define GRUB_XNU_BOOTARGS_VERMINOR 5
+#define GRUB_XNU_BOOTARGS_VERMAJOR 1
+
+struct grub_xnu_devprop_header
+{
+ grub_uint32_t length;
+ /* Always set to 1. Version? */
+ grub_uint32_t alwaysone;
+ grub_uint32_t num_devices;
+};
+
+struct grub_xnu_devprop_device_header
+{
+ grub_uint32_t length;
+ grub_uint32_t num_values;
+};
+
+void grub_cpu_xnu_unload (void);
+
+struct grub_xnu_devprop_device_descriptor;
+
+struct grub_xnu_devprop_device_descriptor *
+grub_xnu_devprop_add_device (struct grub_efi_device_path *path, int length);
+grub_err_t
+grub_xnu_devprop_remove_device (struct grub_xnu_devprop_device_descriptor *dev);
+grub_err_t
+grub_xnu_devprop_remove_property (struct grub_xnu_devprop_device_descriptor *dev,
+ char *name);
+grub_err_t
+grub_xnu_devprop_add_property_utf8 (struct grub_xnu_devprop_device_descriptor *dev,
+ char *name, void *data, int datalen);
+grub_err_t
+grub_xnu_devprop_add_property_utf16 (struct grub_xnu_devprop_device_descriptor *dev,
+ grub_uint16_t *name, int namelen,
+ void *data, int datalen);
+grub_err_t
+grub_xnu_devprop_remove_property_utf8 (struct grub_xnu_devprop_device_descriptor *dev,
+ char *name);
+void grub_cpu_xnu_init (void);
+void grub_cpu_xnu_fini (void);
+
+extern grub_uint32_t grub_xnu_entry_point;
+extern grub_uint32_t grub_xnu_stack;
+extern grub_uint32_t grub_xnu_arg1;
+extern char grub_xnu_cmdline[1024];
+grub_err_t grub_xnu_boot (void);
+grub_err_t grub_cpu_xnu_fill_devicetree (void);
+#endif
diff --git a/include/grub/icon_manager.h b/include/grub/icon_manager.h
new file mode 100644
index 0000000..81c4884
--- /dev/null
+++ b/include/grub/icon_manager.h
@@ -0,0 +1,41 @@
+/* icon_manager.h - gfxmenu icon manager. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_ICON_MANAGER_HEADER
+#define GRUB_ICON_MANAGER_HEADER 1
+
+#include <grub/menu.h>
+#include <grub/bitmap.h>
+
+/* Forward declaration of opaque structure handle type. */
+typedef struct grub_gfxmenu_icon_manager *grub_gfxmenu_icon_manager_t;
+
+grub_gfxmenu_icon_manager_t grub_gfxmenu_icon_manager_new (void);
+void grub_gfxmenu_icon_manager_destroy (grub_gfxmenu_icon_manager_t mgr);
+void grub_gfxmenu_icon_manager_clear_cache (grub_gfxmenu_icon_manager_t mgr);
+void grub_gfxmenu_icon_manager_set_theme_path (grub_gfxmenu_icon_manager_t mgr,
+ const char *path);
+void grub_gfxmenu_icon_manager_set_icon_size (grub_gfxmenu_icon_manager_t mgr,
+ int width, int height);
+struct grub_video_bitmap *
+grub_gfxmenu_icon_manager_get_icon (grub_gfxmenu_icon_manager_t mgr,
+ grub_menu_entry_t entry);
+
+#endif /* GRUB_ICON_MANAGER_HEADER */
+
diff --git a/include/grub/ieee1275/console.h b/include/grub/ieee1275/console.h
new file mode 100644
index 0000000..e054f54
--- /dev/null
+++ b/include/grub/ieee1275/console.h
@@ -0,0 +1,31 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_CONSOLE_MACHINE_HEADER
+#define GRUB_CONSOLE_MACHINE_HEADER 1
+
+#include <grub/symbol.h>
+
+/* Initialize the console system. */
+void grub_console_init_early (void);
+void grub_console_init_lately (void);
+
+/* Finish the console system. */
+void grub_console_fini (void);
+
+#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
new file mode 100644
index 0000000..4c56cc2
--- /dev/null
+++ b/include/grub/ieee1275/ieee1275.h
@@ -0,0 +1,201 @@
+/* ieee1275.h - Access the Open Firmware client interface. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,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_IEEE1275_HEADER
+#define GRUB_IEEE1275_HEADER 1
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/machine/ieee1275.h>
+
+/* Maps a device alias to a pathname. */
+struct grub_ieee1275_devalias
+{
+ char *name;
+ char *path;
+ char *type;
+};
+
+struct grub_ieee1275_mem_region
+{
+ unsigned int start;
+ unsigned int size;
+};
+
+#define IEEE1275_MAX_PROP_LEN 8192
+#define IEEE1275_MAX_PATH_LEN 256
+
+#ifndef IEEE1275_CALL_ENTRY_FN
+#define IEEE1275_CALL_ENTRY_FN(args) (*grub_ieee1275_entry_fn) (args)
+#endif
+
+/* All backcalls to the firmware is done by calling an entry function
+ which was passed to us from the bootloader. When doing the backcall,
+ a structure is passed which specifies what the firmware should do.
+ NAME is the requested service. NR_INS and NR_OUTS is the number of
+ passed arguments and the expected number of return values, resp. */
+struct grub_ieee1275_common_hdr
+{
+ grub_ieee1275_cell_t name;
+ grub_ieee1275_cell_t nr_ins;
+ grub_ieee1275_cell_t nr_outs;
+};
+
+#define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \
+ (p)->name = (grub_ieee1275_cell_t) xname; \
+ (p)->nr_ins = (grub_ieee1275_cell_t) xins; \
+ (p)->nr_outs = (grub_ieee1275_cell_t) xouts
+
+typedef grub_uint32_t grub_ieee1275_ihandle_t;
+typedef grub_uint32_t grub_ieee1275_phandle_t;
+
+extern grub_ieee1275_phandle_t EXPORT_VAR(grub_ieee1275_chosen);
+extern grub_ieee1275_ihandle_t EXPORT_VAR(grub_ieee1275_mmu);
+extern int (* EXPORT_VAR(grub_ieee1275_entry_fn)) (void *);
+
+enum grub_ieee1275_flag
+{
+ /* Old World Macintosh firmware fails seek when "dev:0" is opened. */
+ GRUB_IEEE1275_FLAG_NO_PARTITION_0,
+
+ /* Apple firmware runs in translated mode and requires use of the "map"
+ method. Other firmware runs in untranslated mode and doesn't like "map"
+ calls. */
+ GRUB_IEEE1275_FLAG_REAL_MODE,
+
+ /* CHRP specifies partitions are numbered from 1 (partition 0 refers to the
+ whole disk). However, CodeGen firmware numbers partitions from 0. */
+ GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS,
+
+ /* CodeGen firmware does not correctly implement "output-device output" */
+ GRUB_IEEE1275_FLAG_BROKEN_OUTPUT,
+
+ /* OLPC / XO firmware hangs when accessing USB devices. */
+ GRUB_IEEE1275_FLAG_OFDISK_SDCARD_ONLY,
+
+ /* Open Hack'Ware stops when trying to set colors */
+ GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS,
+
+ /* Open Hack'Ware stops when grub_ieee1275_interpret is used. */
+ GRUB_IEEE1275_FLAG_CANNOT_INTERPRET,
+
+ /* Open Hack'Ware has no memory map, just claim what we need. */
+ GRUB_IEEE1275_FLAG_FORCE_CLAIM,
+
+ /* Open Hack'Ware don't support the ANSI sequence. */
+ GRUB_IEEE1275_FLAG_NO_ANSI,
+
+ /* OpenFirmware hangs on qemu if one requests any memory below 1.5 MiB. */
+ GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM,
+
+ /* OLPC / XO firmware has the cursor ON/OFF routines. */
+ GRUB_IEEE1275_FLAG_HAS_CURSORONOFF,
+
+ /* Some PowerMacs claim to use 2 address cells but in fact use only 1.
+ Other PowerMacs claim to use only 1 and really do so. Always assume
+ 1 address cell is used on PowerMacs.
+ */
+ GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS,
+};
+
+extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);
+extern void EXPORT_FUNC(grub_ieee1275_set_flag) (enum grub_ieee1275_flag flag);
+
+
+
+
+void EXPORT_FUNC(grub_ieee1275_init) (void);
+int EXPORT_FUNC(grub_ieee1275_finddevice) (char *name,
+ grub_ieee1275_phandle_t *phandlep);
+int EXPORT_FUNC(grub_ieee1275_get_property) (grub_ieee1275_phandle_t phandle,
+ const char *property, void *buf,
+ grub_size_t size,
+ grub_ssize_t *actual);
+int EXPORT_FUNC(grub_ieee1275_get_integer_property) (grub_ieee1275_phandle_t phandle,
+ const char *property, grub_uint32_t *buf,
+ grub_size_t size,
+ grub_ssize_t *actual);
+int EXPORT_FUNC(grub_ieee1275_next_property) (grub_ieee1275_phandle_t phandle,
+ char *prev_prop, char *prop);
+int EXPORT_FUNC(grub_ieee1275_get_property_length)
+ (grub_ieee1275_phandle_t phandle, const char *prop, grub_ssize_t *length);
+int EXPORT_FUNC(grub_ieee1275_instance_to_package)
+ (grub_ieee1275_ihandle_t ihandle, grub_ieee1275_phandle_t *phandlep);
+int EXPORT_FUNC(grub_ieee1275_package_to_path) (grub_ieee1275_phandle_t phandle,
+ char *path, grub_size_t len,
+ grub_ssize_t *actual);
+int EXPORT_FUNC(grub_ieee1275_instance_to_path)
+ (grub_ieee1275_ihandle_t ihandle, char *path, grub_size_t len,
+ grub_ssize_t *actual);
+int EXPORT_FUNC(grub_ieee1275_write) (grub_ieee1275_ihandle_t ihandle,
+ void *buffer, grub_size_t len,
+ grub_ssize_t *actualp);
+int EXPORT_FUNC(grub_ieee1275_read) (grub_ieee1275_ihandle_t ihandle,
+ void *buffer, grub_size_t len,
+ grub_ssize_t *actualp);
+int EXPORT_FUNC(grub_ieee1275_seek) (grub_ieee1275_ihandle_t ihandle,
+ grub_disk_addr_t pos,
+ grub_ssize_t *result);
+int EXPORT_FUNC(grub_ieee1275_peer) (grub_ieee1275_phandle_t node,
+ grub_ieee1275_phandle_t *result);
+int EXPORT_FUNC(grub_ieee1275_child) (grub_ieee1275_phandle_t node,
+ grub_ieee1275_phandle_t *result);
+int EXPORT_FUNC(grub_ieee1275_parent) (grub_ieee1275_phandle_t node,
+ grub_ieee1275_phandle_t *result);
+int EXPORT_FUNC(grub_ieee1275_interpret) (const char *command,
+ grub_ieee1275_cell_t *catch);
+int EXPORT_FUNC(grub_ieee1275_enter) (void);
+void EXPORT_FUNC(grub_ieee1275_exit) (void) __attribute__ ((noreturn));
+int EXPORT_FUNC(grub_ieee1275_open) (const char *node,
+ grub_ieee1275_ihandle_t *result);
+int EXPORT_FUNC(grub_ieee1275_close) (grub_ieee1275_ihandle_t ihandle);
+int EXPORT_FUNC(grub_ieee1275_claim) (grub_addr_t addr, grub_size_t size,
+ unsigned int align, grub_addr_t *result);
+int EXPORT_FUNC(grub_ieee1275_release) (grub_addr_t addr, grub_size_t size);
+int EXPORT_FUNC(grub_ieee1275_set_property) (grub_ieee1275_phandle_t phandle,
+ const char *propname, void *buf,
+ grub_size_t size,
+ grub_ssize_t *actual);
+int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle,
+ int index, int r, int g, int b);
+int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs);
+
+
+int EXPORT_FUNC(grub_devalias_iterate)
+ (int (*hook) (struct grub_ieee1275_devalias *alias));
+int EXPORT_FUNC(grub_children_iterate) (char *devpath,
+ int (*hook) (struct grub_ieee1275_devalias *alias));
+grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
+ (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
+int EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
+
+int
+EXPORT_FUNC(grub_ieee1275_map) (grub_addr_t phys, grub_addr_t virt,
+ grub_size_t size, grub_uint32_t mode);
+
+char *EXPORT_FUNC(grub_ieee1275_encode_devname) (const char *path);
+char *EXPORT_FUNC(grub_ieee1275_get_filename) (const char *path);
+
+int EXPORT_FUNC(grub_ieee1275_devices_iterate) (int (*hook)
+ (struct grub_ieee1275_devalias *
+ alias));
+
+char *EXPORT_FUNC(grub_ieee1275_canonicalise_devname) (const char *path);
+
+#endif /* ! GRUB_IEEE1275_HEADER */
diff --git a/include/grub/ieee1275/ofdisk.h b/include/grub/ieee1275/ofdisk.h
new file mode 100644
index 0000000..2f69e3f
--- /dev/null
+++ b/include/grub/ieee1275/ofdisk.h
@@ -0,0 +1,25 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,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_OFDISK_HEADER
+#define GRUB_OFDISK_HEADER 1
+
+extern void grub_ofdisk_init (void);
+extern void grub_ofdisk_fini (void);
+
+#endif /* ! GRUB_INIT_HEADER */
diff --git a/include/grub/kernel.h b/include/grub/kernel.h
new file mode 100644
index 0000000..2ecc73d
--- /dev/null
+++ b/include/grub/kernel.h
@@ -0,0 +1,96 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,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_KERNEL_HEADER
+#define GRUB_KERNEL_HEADER 1
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+
+enum
+{
+ OBJ_TYPE_ELF,
+ OBJ_TYPE_MEMDISK,
+ OBJ_TYPE_CONFIG
+};
+
+/* The module header. */
+struct grub_module_header
+{
+ /* The type of object. */
+ grub_uint8_t type;
+ /* The size of object (including this header). */
+ grub_uint32_t size;
+};
+
+/* "gmim" (GRUB Module Info Magic). */
+#define GRUB_MODULE_MAGIC 0x676d696d
+
+struct grub_module_info32
+{
+ /* Magic number so we know we have modules present. */
+ grub_uint32_t magic;
+ /* The offset of the modules. */
+ grub_uint32_t offset;
+ /* The size of all modules plus this header. */
+ grub_uint32_t size;
+};
+
+struct grub_module_info64
+{
+ /* Magic number so we know we have modules present. */
+ grub_uint32_t magic;
+ grub_uint32_t padding;
+ /* The offset of the modules. */
+ grub_uint64_t offset;
+ /* The size of all modules plus this header. */
+ grub_uint64_t size;
+};
+
+#if GRUB_TARGET_SIZEOF_VOID_P == 8
+#define grub_module_info grub_module_info64
+#else
+#define grub_module_info grub_module_info32
+#endif
+
+extern grub_addr_t grub_arch_modules_addr (void);
+
+extern void EXPORT_FUNC(grub_module_iterate) (int (*hook) (struct grub_module_header *));
+
+grub_addr_t grub_modules_get_end (void);
+
+/* The start point of the C code. */
+void grub_main (void);
+
+/* The machine-specific initialization. This must initialize memory. */
+void grub_machine_init (void);
+
+/* The machine-specific finalization. */
+void EXPORT_FUNC(grub_machine_fini) (void);
+
+/* The machine-specific prefix initialization. */
+void grub_machine_set_prefix (void);
+
+/* Register all the exported symbols. This is automatically generated. */
+void grub_register_exported_symbols (void);
+
+#if ! defined (ASM_FILE) && !defined (GRUB_MACHINE_EMU)
+extern char grub_prefix[];
+#endif
+
+#endif /* ! GRUB_KERNEL_HEADER */
diff --git a/include/grub/keyboard_layouts.h b/include/grub/keyboard_layouts.h
new file mode 100644
index 0000000..24d4880
--- /dev/null
+++ b/include/grub/keyboard_layouts.h
@@ -0,0 +1,142 @@
+/*
+ * 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_KEYBOARD_LAYOUTS_H
+#define GRUB_KEYBOARD_LAYOUTS_H 1
+
+#define GRUB_KEYBOARD_LAYOUTS_FILEMAGIC "GRUBLAYO"
+#define GRUB_KEYBOARD_LAYOUTS_FILEMAGIC_SIZE (sizeof(GRUB_KEYBOARD_LAYOUTS_FILEMAGIC) - 1)
+#define GRUB_KEYBOARD_LAYOUTS_VERSION 8
+
+#define GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE 128
+
+struct grub_keyboard_layout
+{
+ grub_uint32_t keyboard_map[GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE];
+ grub_uint32_t keyboard_map_shift[GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE];
+ grub_uint32_t keyboard_map_l3[GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE];
+ grub_uint32_t keyboard_map_shift_l3[GRUB_KEYBOARD_LAYOUTS_ARRAY_SIZE];
+};
+
+typedef enum grub_keyboard_key
+ {
+ GRUB_KEYBOARD_KEY_A = 0x04,
+ GRUB_KEYBOARD_KEY_B = 0x05,
+ GRUB_KEYBOARD_KEY_C = 0x06,
+ GRUB_KEYBOARD_KEY_D = 0x07,
+ GRUB_KEYBOARD_KEY_E = 0x08,
+ GRUB_KEYBOARD_KEY_F = 0x09,
+ GRUB_KEYBOARD_KEY_G = 0x0a,
+ GRUB_KEYBOARD_KEY_H = 0x0b,
+ GRUB_KEYBOARD_KEY_I = 0x0c,
+ GRUB_KEYBOARD_KEY_J = 0x0d,
+ GRUB_KEYBOARD_KEY_K = 0x0e,
+ GRUB_KEYBOARD_KEY_L = 0x0f,
+ GRUB_KEYBOARD_KEY_M = 0x10,
+ GRUB_KEYBOARD_KEY_N = 0x11,
+ GRUB_KEYBOARD_KEY_O = 0x12,
+ GRUB_KEYBOARD_KEY_P = 0x13,
+ GRUB_KEYBOARD_KEY_Q = 0x14,
+ GRUB_KEYBOARD_KEY_R = 0x15,
+ GRUB_KEYBOARD_KEY_S = 0x16,
+ GRUB_KEYBOARD_KEY_T = 0x17,
+ GRUB_KEYBOARD_KEY_U = 0x18,
+ GRUB_KEYBOARD_KEY_V = 0x19,
+ GRUB_KEYBOARD_KEY_W = 0x1a,
+ GRUB_KEYBOARD_KEY_X = 0x1b,
+ GRUB_KEYBOARD_KEY_Y = 0x1c,
+ GRUB_KEYBOARD_KEY_Z = 0x1d,
+ GRUB_KEYBOARD_KEY_1 = 0x1e,
+ GRUB_KEYBOARD_KEY_2 = 0x1f,
+ GRUB_KEYBOARD_KEY_3 = 0x20,
+ GRUB_KEYBOARD_KEY_4 = 0x21,
+ GRUB_KEYBOARD_KEY_5 = 0x22,
+ GRUB_KEYBOARD_KEY_6 = 0x23,
+ GRUB_KEYBOARD_KEY_7 = 0x24,
+ GRUB_KEYBOARD_KEY_8 = 0x25,
+ GRUB_KEYBOARD_KEY_9 = 0x26,
+ GRUB_KEYBOARD_KEY_0 = 0x27,
+ GRUB_KEYBOARD_KEY_ENTER = 0x28,
+ GRUB_KEYBOARD_KEY_ESCAPE = 0x29,
+ GRUB_KEYBOARD_KEY_BACKSPACE = 0x2a,
+ GRUB_KEYBOARD_KEY_TAB = 0x2b,
+ GRUB_KEYBOARD_KEY_SPACE = 0x2c,
+ GRUB_KEYBOARD_KEY_DASH = 0x2d,
+ GRUB_KEYBOARD_KEY_EQUAL = 0x2e,
+ GRUB_KEYBOARD_KEY_LBRACKET = 0x2f,
+ GRUB_KEYBOARD_KEY_RBRACKET = 0x30,
+ GRUB_KEYBOARD_KEY_BACKSLASH = 0x32,
+ GRUB_KEYBOARD_KEY_SEMICOLON = 0x33,
+ GRUB_KEYBOARD_KEY_DQUOTE = 0x34,
+ GRUB_KEYBOARD_KEY_RQUOTE = 0x35,
+ GRUB_KEYBOARD_KEY_COMMA = 0x36,
+ GRUB_KEYBOARD_KEY_DOT = 0x37,
+ GRUB_KEYBOARD_KEY_SLASH = 0x38,
+ GRUB_KEYBOARD_KEY_CAPS_LOCK = 0x39,
+ GRUB_KEYBOARD_KEY_F1 = 0x3a,
+ GRUB_KEYBOARD_KEY_F2 = 0x3b,
+ GRUB_KEYBOARD_KEY_F3 = 0x3c,
+ GRUB_KEYBOARD_KEY_F4 = 0x3d,
+ GRUB_KEYBOARD_KEY_F5 = 0x3e,
+ GRUB_KEYBOARD_KEY_F6 = 0x3f,
+ GRUB_KEYBOARD_KEY_F7 = 0x40,
+ GRUB_KEYBOARD_KEY_F8 = 0x41,
+ GRUB_KEYBOARD_KEY_F9 = 0x42,
+ GRUB_KEYBOARD_KEY_F10 = 0x43,
+ GRUB_KEYBOARD_KEY_F11 = 0x44,
+ GRUB_KEYBOARD_KEY_F12 = 0x45,
+ GRUB_KEYBOARD_KEY_SCROLL_LOCK = 0x47,
+ GRUB_KEYBOARD_KEY_INSERT = 0x49,
+ GRUB_KEYBOARD_KEY_HOME = 0x4a,
+ GRUB_KEYBOARD_KEY_PPAGE = 0x4b,
+ GRUB_KEYBOARD_KEY_DELETE = 0x4c,
+ GRUB_KEYBOARD_KEY_END = 0x4d,
+ GRUB_KEYBOARD_KEY_NPAGE = 0x4e,
+ GRUB_KEYBOARD_KEY_RIGHT = 0x4f,
+ GRUB_KEYBOARD_KEY_LEFT = 0x50,
+ GRUB_KEYBOARD_KEY_DOWN = 0x51,
+ GRUB_KEYBOARD_KEY_UP = 0x52,
+ GRUB_KEYBOARD_KEY_NUM_LOCK = 0x53,
+ GRUB_KEYBOARD_KEY_NUMSLASH = 0x54,
+ GRUB_KEYBOARD_KEY_NUMMUL = 0x55,
+ GRUB_KEYBOARD_KEY_NUMMINUS = 0x56,
+ GRUB_KEYBOARD_KEY_NUMPLUS = 0x57,
+ GRUB_KEYBOARD_KEY_NUMENTER = 0x58,
+ GRUB_KEYBOARD_KEY_NUM1 = 0x59,
+ GRUB_KEYBOARD_KEY_NUM2 = 0x5a,
+ GRUB_KEYBOARD_KEY_NUM3 = 0x5b,
+ GRUB_KEYBOARD_KEY_NUM4 = 0x5c,
+ GRUB_KEYBOARD_KEY_NUM5 = 0x5d,
+ GRUB_KEYBOARD_KEY_NUM6 = 0x5e,
+ GRUB_KEYBOARD_KEY_NUM7 = 0x5f,
+ GRUB_KEYBOARD_KEY_NUM8 = 0x60,
+ GRUB_KEYBOARD_KEY_NUM9 = 0x61,
+ GRUB_KEYBOARD_KEY_NUM0 = 0x62,
+ GRUB_KEYBOARD_KEY_NUMDOT = 0x63,
+ GRUB_KEYBOARD_KEY_102ND = 0x64,
+ GRUB_KEYBOARD_KEY_LEFT_CTRL = 0xe0,
+ GRUB_KEYBOARD_KEY_LEFT_SHIFT = 0xe1,
+ GRUB_KEYBOARD_KEY_LEFT_ALT = 0xe2,
+ GRUB_KEYBOARD_KEY_RIGHT_CTRL = 0xe4,
+ GRUB_KEYBOARD_KEY_RIGHT_SHIFT = 0xe5,
+ GRUB_KEYBOARD_KEY_RIGHT_ALT = 0xe6,
+ } grub_keyboard_key_t;
+
+unsigned EXPORT_FUNC(grub_term_map_key) (grub_keyboard_key_t code, int status);
+
+#endif /* GRUB_KEYBOARD_LAYOUTS */
diff --git a/include/grub/legacy_parse.h b/include/grub/legacy_parse.h
new file mode 100644
index 0000000..a5e67a0
--- /dev/null
+++ b/include/grub/legacy_parse.h
@@ -0,0 +1,27 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_LEGACY_PARSE_HEADER
+#define GRUB_LEGACY_PARSE_HEADER 1
+
+#include <grub/types.h>
+
+char *grub_legacy_parse (const char *buf, char **entryname, char **suffix);
+char *grub_legacy_escape (const char *in, grub_size_t len);
+
+#endif
diff --git a/include/grub/lib/LzFind.h b/include/grub/lib/LzFind.h
new file mode 100644
index 0000000..69447b6
--- /dev/null
+++ b/include/grub/lib/LzFind.h
@@ -0,0 +1,130 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (c) 1999-2008 Igor Pavlov
+ * Copyright (C) 2008 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/>.
+ */
+
+/*
+ * This code was taken from LZMA SDK 4.58 beta, and was slightly modified
+ * to adapt it to GRUB's requirement.
+ *
+ * See <http://www.7-zip.org>, for more information about LZMA.
+ */
+
+#ifndef __LZFIND_H
+#define __LZFIND_H
+
+#include <grub/lib/LzmaTypes.h>
+
+typedef UInt32 CLzRef;
+
+typedef struct _CMatchFinder
+{
+ Byte *buffer;
+ UInt32 pos;
+ UInt32 posLimit;
+ UInt32 streamPos;
+ UInt32 lenLimit;
+
+ UInt32 cyclicBufferPos;
+ UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
+
+ UInt32 matchMaxLen;
+ CLzRef *hash;
+ CLzRef *son;
+ UInt32 hashMask;
+ UInt32 cutValue;
+
+ Byte *bufferBase;
+ ISeqInStream *stream;
+ int streamEndWasReached;
+
+ UInt32 blockSize;
+ UInt32 keepSizeBefore;
+ UInt32 keepSizeAfter;
+
+ UInt32 numHashBytes;
+ int directInput;
+ int btMode;
+ /* int skipModeBits; */
+ int bigHash;
+ UInt32 historySize;
+ UInt32 fixedHashSize;
+ UInt32 hashSizeSum;
+ UInt32 numSons;
+ SRes result;
+ UInt32 crc[256];
+} CMatchFinder;
+
+#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
+#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)])
+
+#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
+
+int MatchFinder_NeedMove(CMatchFinder *p);
+Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
+void MatchFinder_MoveBlock(CMatchFinder *p);
+void MatchFinder_ReadIfRequired(CMatchFinder *p);
+
+void MatchFinder_Construct(CMatchFinder *p);
+
+/* Conditions:
+ historySize <= 3 GB
+ keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
+*/
+int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
+ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
+ ISzAlloc *alloc);
+void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
+void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
+void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
+
+UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
+ UInt32 *distances, UInt32 maxLen);
+
+/*
+Conditions:
+ Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
+ Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
+*/
+
+typedef void (*Mf_Init_Func)(void *object);
+typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index);
+typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
+typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
+typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
+typedef void (*Mf_Skip_Func)(void *object, UInt32);
+
+typedef struct _IMatchFinder
+{
+ Mf_Init_Func Init;
+ Mf_GetIndexByte_Func GetIndexByte;
+ Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
+ Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
+ Mf_GetMatches_Func GetMatches;
+ Mf_Skip_Func Skip;
+} IMatchFinder;
+
+void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
+
+void MatchFinder_Init(CMatchFinder *p);
+UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
+UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
+void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
+void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
+
+#endif
diff --git a/include/grub/lib/LzHash.h b/include/grub/lib/LzHash.h
new file mode 100644
index 0000000..c3d5586
--- /dev/null
+++ b/include/grub/lib/LzHash.h
@@ -0,0 +1,77 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (c) 1999-2008 Igor Pavlov
+ * Copyright (C) 2008 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/>.
+ */
+
+/*
+ * This code was taken from LZMA SDK 4.58 beta, and was slightly modified
+ * to adapt it to GRUB's requirement.
+ *
+ * See <http://www.7-zip.org>, for more information about LZMA.
+ */
+
+#ifndef __LZHASH_H
+#define __LZHASH_H
+
+#define kHash2Size (1 << 10)
+#define kHash3Size (1 << 16)
+#define kHash4Size (1 << 20)
+
+#define kFix3HashSize (kHash2Size)
+#define kFix4HashSize (kHash2Size + kHash3Size)
+#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
+
+#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8);
+
+#define HASH3_CALC { \
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
+
+#define HASH4_CALC { \
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
+ hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
+
+#define HASH5_CALC { \
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
+ hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \
+ hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \
+ hash4Value &= (kHash4Size - 1); }
+
+/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
+#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
+
+
+#define MT_HASH2_CALC \
+ hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);
+
+#define MT_HASH3_CALC { \
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
+
+#define MT_HASH4_CALC { \
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
+ hash2Value = temp & (kHash2Size - 1); \
+ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
+ hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
+
+#endif
diff --git a/include/grub/lib/LzmaDec.h b/include/grub/lib/LzmaDec.h
new file mode 100644
index 0000000..1e66b74
--- /dev/null
+++ b/include/grub/lib/LzmaDec.h
@@ -0,0 +1,246 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (c) 1999-2008 Igor Pavlov
+ * Copyright (C) 2008 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/>.
+ */
+
+/*
+ * This code was taken from LZMA SDK 4.58 beta, and was slightly modified
+ * to adapt it to GRUB's requirement.
+ *
+ * See <http://www.7-zip.org>, for more information about LZMA.
+ */
+
+#ifndef __LZMADEC_H
+#define __LZMADEC_H
+
+#include "Types.h"
+
+/* #define _LZMA_PROB32 */
+/* _LZMA_PROB32 can increase the speed on some CPUs,
+ but memory usage for CLzmaDec::probs will be doubled in that case */
+
+#ifdef _LZMA_PROB32
+#define CLzmaProb UInt32
+#else
+#define CLzmaProb UInt16
+#endif
+
+
+/* ---------- LZMA Properties ---------- */
+
+#define LZMA_PROPS_SIZE 5
+
+typedef struct _CLzmaProps
+{
+ unsigned lc, lp, pb;
+ UInt32 dicSize;
+} CLzmaProps;
+
+/* LzmaProps_Decode - decodes properties
+Returns:
+ SZ_OK
+ SZ_ERROR_UNSUPPORTED - Unsupported properties
+*/
+
+SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
+
+
+/* ---------- LZMA Decoder state ---------- */
+
+/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.
+ Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */
+
+#define LZMA_REQUIRED_INPUT_MAX 20
+
+typedef struct
+{
+ CLzmaProps prop;
+ CLzmaProb *probs;
+ Byte *dic;
+ const Byte *buf;
+ UInt32 range, code;
+ SizeT dicPos;
+ SizeT dicBufSize;
+ UInt32 processedPos;
+ UInt32 checkDicSize;
+ unsigned state;
+ UInt32 reps[4];
+ unsigned remainLen;
+ int needFlush;
+ int needInitState;
+ UInt32 numProbs;
+ unsigned tempBufSize;
+ Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
+} CLzmaDec;
+
+#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
+
+void LzmaDec_Init(CLzmaDec *p);
+
+/* There are two types of LZMA streams:
+ 0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
+ 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
+
+typedef enum
+{
+ LZMA_FINISH_ANY, /* finish at any point */
+ LZMA_FINISH_END /* block must be finished at the end */
+} ELzmaFinishMode;
+
+/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!
+
+ You must use LZMA_FINISH_END, when you know that current output buffer
+ covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.
+
+ If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,
+ and output value of destLen will be less than output buffer size limit.
+ You can check status result also.
+
+ You can use multiple checks to test data integrity after full decompression:
+ 1) Check Result and "status" variable.
+ 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
+ 3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
+ You must use correct finish mode in that case. */
+
+typedef enum
+{
+ LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */
+ LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
+ LZMA_STATUS_NOT_FINISHED, /* stream was not finished */
+ LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */
+ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */
+} ELzmaStatus;
+
+/* ELzmaStatus is used only as output value for function call */
+
+
+/* ---------- Interfaces ---------- */
+
+/* There are 3 levels of interfaces:
+ 1) Dictionary Interface
+ 2) Buffer Interface
+ 3) One Call Interface
+ You can select any of these interfaces, but don't mix functions from different
+ groups for same object. */
+
+
+/* There are two variants to allocate state for Dictionary Interface:
+ 1) LzmaDec_Allocate / LzmaDec_Free
+ 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
+ You can use variant 2, if you set dictionary buffer manually.
+ For Buffer Interface you must always use variant 1.
+
+LzmaDec_Allocate* can return:
+ SZ_OK
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_UNSUPPORTED - Unsupported properties
+*/
+
+SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
+void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
+
+SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);
+void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
+
+/* ---------- Dictionary Interface ---------- */
+
+/* You can use it, if you want to eliminate the overhead for data copying from
+ dictionary to some other external buffer.
+ You must work with CLzmaDec variables directly in this interface.
+
+ STEPS:
+ LzmaDec_Constr()
+ LzmaDec_Allocate()
+ for (each new stream)
+ {
+ LzmaDec_Init()
+ while (it needs more decompression)
+ {
+ LzmaDec_DecodeToDic()
+ use data from CLzmaDec::dic and update CLzmaDec::dicPos
+ }
+ }
+ LzmaDec_Free()
+*/
+
+/* LzmaDec_DecodeToDic
+
+ The decoding to internal dictionary buffer (CLzmaDec::dic).
+ You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
+
+finishMode:
+ It has meaning only if the decoding reaches output limit (dicLimit).
+ LZMA_FINISH_ANY - Decode just dicLimit bytes.
+ LZMA_FINISH_END - Stream must be finished after dicLimit.
+
+Returns:
+ SZ_OK
+ status:
+ LZMA_STATUS_FINISHED_WITH_MARK
+ LZMA_STATUS_NOT_FINISHED
+ LZMA_STATUS_NEEDS_MORE_INPUT
+ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
+ SZ_ERROR_DATA - Data error
+*/
+
+SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
+ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
+
+
+/* ---------- Buffer Interface ---------- */
+
+/* It's zlib-like interface.
+ See LzmaDec_DecodeToDic description for information about STEPS and return results,
+ but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need
+ to work with CLzmaDec variables manually.
+
+finishMode:
+ It has meaning only if the decoding reaches output limit (*destLen).
+ LZMA_FINISH_ANY - Decode just destLen bytes.
+ LZMA_FINISH_END - Stream must be finished after (*destLen).
+*/
+
+SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
+ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
+
+
+/* ---------- One Call Interface ---------- */
+
+/* LzmaDecode
+
+finishMode:
+ It has meaning only if the decoding reaches output limit (*destLen).
+ LZMA_FINISH_ANY - Decode just destLen bytes.
+ LZMA_FINISH_END - Stream must be finished after (*destLen).
+
+Returns:
+ SZ_OK
+ status:
+ LZMA_STATUS_FINISHED_WITH_MARK
+ LZMA_STATUS_NOT_FINISHED
+ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
+ SZ_ERROR_DATA - Data error
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_UNSUPPORTED - Unsupported properties
+ SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
+*/
+
+SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+ const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
+ ELzmaStatus *status, ISzAlloc *alloc);
+
+#endif
diff --git a/include/grub/lib/LzmaEnc.h b/include/grub/lib/LzmaEnc.h
new file mode 100644
index 0000000..fc156a4
--- /dev/null
+++ b/include/grub/lib/LzmaEnc.h
@@ -0,0 +1,95 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (c) 1999-2008 Igor Pavlov
+ * Copyright (C) 2008 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/>.
+ */
+
+/*
+ * This code was taken from LZMA SDK 4.58 beta, and was slightly modified
+ * to adapt it to GRUB's requirement.
+ *
+ * See <http://www.7-zip.org>, for more information about LZMA.
+ */
+
+#ifndef __LZMAENC_H
+#define __LZMAENC_H
+
+#include "LzmaTypes.h"
+
+#define LZMA_PROPS_SIZE 5
+
+typedef struct _CLzmaEncProps
+{
+ int level; /* 0 <= level <= 9 */
+ UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
+ (1 << 12) <= dictSize <= (1 << 30) for 64-bit version
+ default = (1 << 24) */
+ int lc; /* 0 <= lc <= 8, default = 3 */
+ int lp; /* 0 <= lp <= 4, default = 0 */
+ int pb; /* 0 <= pb <= 4, default = 2 */
+ int algo; /* 0 - fast, 1 - normal, default = 1 */
+ int fb; /* 5 <= fb <= 273, default = 32 */
+ int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
+ int numHashBytes; /* 2, 3 or 4, default = 4 */
+ UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
+ unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
+ int numThreads; /* 1 or 2, default = 2 */
+} CLzmaEncProps;
+
+void LzmaEncProps_Init(CLzmaEncProps *p);
+void LzmaEncProps_Normalize(CLzmaEncProps *p);
+UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
+
+
+/* ---------- CLzmaEncHandle Interface ---------- */
+
+/* LzmaEnc_* functions can return the following exit codes:
+Returns:
+ SZ_OK - OK
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_PARAM - Incorrect parameter in props
+ SZ_ERROR_WRITE - Write callback error.
+ SZ_ERROR_PROGRESS - some break from progress callback
+ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
+*/
+
+typedef void * CLzmaEncHandle;
+
+CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
+void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
+SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
+SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
+SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
+ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
+SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+ int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
+
+/* ---------- One Call Interface ---------- */
+
+/* LzmaEncode
+Return code:
+ SZ_OK - OK
+ SZ_ERROR_MEM - Memory allocation error
+ SZ_ERROR_PARAM - Incorrect parameter
+ SZ_ERROR_OUTPUT_EOF - output buffer overflow
+ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
+*/
+
+SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+ const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
+ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
+
+#endif
diff --git a/include/grub/lib/LzmaTypes.h b/include/grub/lib/LzmaTypes.h
new file mode 100644
index 0000000..1e783a2
--- /dev/null
+++ b/include/grub/lib/LzmaTypes.h
@@ -0,0 +1,151 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (c) 1999-2008 Igor Pavlov
+ * Copyright (C) 2008 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/>.
+ */
+
+/*
+ * This code was taken from LZMA SDK 4.58 beta, and was slightly modified
+ * to adapt it to GRUB's requirement.
+ *
+ * See <http://www.7-zip.org>, for more information about LZMA.
+ */
+
+#ifndef __7Z_TYPES_H
+#define __7Z_TYPES_H
+
+#define SZ_OK 0
+
+#define SZ_ERROR_DATA 1
+#define SZ_ERROR_MEM 2
+#define SZ_ERROR_CRC 3
+#define SZ_ERROR_UNSUPPORTED 4
+#define SZ_ERROR_PARAM 5
+#define SZ_ERROR_INPUT_EOF 6
+#define SZ_ERROR_OUTPUT_EOF 7
+#define SZ_ERROR_READ 8
+#define SZ_ERROR_WRITE 9
+#define SZ_ERROR_PROGRESS 10
+#define SZ_ERROR_FAIL 11
+#define SZ_ERROR_THREAD 12
+
+#define SZ_ERROR_ARCHIVE 16
+#define SZ_ERROR_NO_ARCHIVE 17
+
+typedef int SRes;
+
+#ifndef RINOK
+#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
+#endif
+
+typedef unsigned char Byte;
+typedef short Int16;
+typedef unsigned short UInt16;
+
+#ifdef _LZMA_UINT32_IS_ULONG
+typedef long Int32;
+typedef unsigned long UInt32;
+#else
+typedef int Int32;
+typedef unsigned int UInt32;
+#endif
+
+/* #define _SZ_NO_INT_64 */
+/* define it if your compiler doesn't support 64-bit integers */
+
+#ifdef _SZ_NO_INT_64
+
+typedef long Int64;
+typedef unsigned long UInt64;
+
+#else
+
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+typedef __int64 Int64;
+typedef unsigned __int64 UInt64;
+#else
+typedef long long int Int64;
+typedef unsigned long long int UInt64;
+#endif
+
+#endif
+
+#ifdef _LZMA_NO_SYSTEM_SIZE_T
+typedef UInt32 SizeT;
+#else
+#include <stddef.h>
+typedef size_t SizeT;
+#endif
+
+typedef int Bool;
+#define True 1
+#define False 0
+
+
+#ifdef _MSC_VER
+
+#if _MSC_VER >= 1300
+#define MY_NO_INLINE __declspec(noinline)
+#else
+#define MY_NO_INLINE
+#endif
+
+#define MY_CDECL __cdecl
+#define MY_STD_CALL __stdcall
+#define MY_FAST_CALL MY_NO_INLINE __fastcall
+
+#else
+
+#define MY_CDECL
+#define MY_STD_CALL
+#define MY_FAST_CALL
+
+#endif
+
+
+/* The following interfaces use first parameter as pointer to structure */
+
+typedef struct
+{
+ SRes (*Read)(void *p, void *buf, size_t *size);
+ /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
+ (output(*size) < input(*size)) is allowed */
+} ISeqInStream;
+
+typedef struct
+{
+ size_t (*Write)(void *p, const void *buf, size_t size);
+ /* Returns: result - the number of actually written bytes.
+ (result < size) means error */
+} ISeqOutStream;
+
+typedef struct
+{
+ SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
+ /* Returns: result. (result != SZ_OK) means break.
+ Value (UInt64)(Int64)-1 for size means unknown value. */
+} ICompressProgress;
+
+typedef struct
+{
+ void *(*Alloc)(void *p, size_t size);
+ void (*Free)(void *p, void *address); /* address can be 0 */
+} ISzAlloc;
+
+#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
+#define IAlloc_Free(p, a) (p)->Free((p), a)
+
+#endif
diff --git a/include/grub/lib/arg.h b/include/grub/lib/arg.h
new file mode 100644
index 0000000..b61f6f3
--- /dev/null
+++ b/include/grub/lib/arg.h
@@ -0,0 +1,79 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2005,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_ARG_HEADER
+#define GRUB_ARG_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/err.h>
+#include <grub/types.h>
+
+enum grub_arg_type
+ {
+ ARG_TYPE_NONE,
+ ARG_TYPE_STRING,
+ ARG_TYPE_INT,
+ ARG_TYPE_DEVICE,
+ ARG_TYPE_FILE,
+ ARG_TYPE_DIR,
+ ARG_TYPE_PATHNAME
+ };
+
+typedef enum grub_arg_type grub_arg_type_t;
+
+/* Flags for the option field op grub_arg_option. */
+#define GRUB_ARG_OPTION_OPTIONAL (1 << 1)
+/* Flags for an option that can appear multiple times. */
+#define GRUB_ARG_OPTION_REPEATABLE (1 << 2)
+
+enum grub_key_type
+ {
+ GRUB_KEY_ARG = -1,
+ GRUB_KEY_END = -2
+ };
+typedef enum grub_key_type grub_arg_key_type_t;
+
+struct grub_arg_option
+{
+ const char *longarg;
+ int shortarg;
+ int flags;
+ char *doc;
+ char *arg;
+ grub_arg_type_t type;
+};
+
+struct grub_arg_list
+{
+ int set;
+ union {
+ char *arg;
+ char **args;
+ };
+};
+
+struct grub_extcmd;
+
+int grub_arg_parse (struct grub_extcmd *cmd, int argc, char **argv,
+ struct grub_arg_list *usr, char ***args, int *argnum);
+
+void EXPORT_FUNC(grub_arg_show_help) (struct grub_extcmd *cmd);
+struct grub_arg_list* grub_arg_list_alloc (struct grub_extcmd *cmd,
+ int argc, char *argv[]);
+
+#endif /* ! GRUB_ARG_HEADER */
diff --git a/include/grub/lib/cmdline.h b/include/grub/lib/cmdline.h
new file mode 100644
index 0000000..1fe8d01
--- /dev/null
+++ b/include/grub/lib/cmdline.h
@@ -0,0 +1,31 @@
+/* cmdline.h - linux command line handling */
+/*
+ * 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_CMDLINE_HEADER
+#define GRUB_CMDLINE_HEADER 1
+
+#include <grub/types.h>
+
+#define LINUX_IMAGE "BOOT_IMAGE="
+
+unsigned int grub_loader_cmdline_size (int argc, char *argv[]);
+int grub_create_loader_cmdline (int argc, char *argv[], char *buf,
+ grub_size_t size);
+
+#endif /* ! GRUB_CMDLINE_HEADER */
diff --git a/include/grub/lib/crc.h b/include/grub/lib/crc.h
new file mode 100644
index 0000000..c5098a8
--- /dev/null
+++ b/include/grub/lib/crc.h
@@ -0,0 +1,25 @@
+/* crc.h - prototypes for crc */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_CRC_H
+#define GRUB_CRC_H 1
+
+grub_uint32_t grub_getcrc32c (grub_uint32_t crc, const void *buf, int size);
+
+#endif /* ! GRUB_CRC_H */
diff --git a/include/grub/lib/envblk.h b/include/grub/lib/envblk.h
new file mode 100644
index 0000000..368ba53
--- /dev/null
+++ b/include/grub/lib/envblk.h
@@ -0,0 +1,55 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_ENVBLK_HEADER
+#define GRUB_ENVBLK_HEADER 1
+
+#define GRUB_ENVBLK_SIGNATURE "# GRUB Environment Block\n"
+#define GRUB_ENVBLK_DEFCFG "grubenv"
+
+#ifndef ASM_FILE
+
+struct grub_envblk
+{
+ char *buf;
+ grub_size_t size;
+};
+typedef struct grub_envblk *grub_envblk_t;
+
+grub_envblk_t grub_envblk_open (char *buf, grub_size_t size);
+int grub_envblk_set (grub_envblk_t envblk, const char *name, const char *value);
+void grub_envblk_delete (grub_envblk_t envblk, const char *name);
+void grub_envblk_iterate (grub_envblk_t envblk,
+ int hook (const char *name, const char *value));
+void grub_envblk_close (grub_envblk_t envblk);
+
+static inline char *
+grub_envblk_buffer (const grub_envblk_t envblk)
+{
+ return envblk->buf;
+}
+
+static inline grub_size_t
+grub_envblk_size (const grub_envblk_t envblk)
+{
+ return envblk->size;
+}
+
+#endif /* ! ASM_FILE */
+
+#endif /* ! GRUB_ENVBLK_HEADER */
diff --git a/include/grub/lib/hexdump.h b/include/grub/lib/hexdump.h
new file mode 100644
index 0000000..23c6fa6
--- /dev/null
+++ b/include/grub/lib/hexdump.h
@@ -0,0 +1,25 @@
+/* hexdump.h - prototypes for dump */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_HEXDUMP_H
+#define GRUB_HEXDUMP_H 1
+
+void hexdump (unsigned long bse,char* buf,int len);
+
+#endif /* ! GRUB_HEXDUMP_H */
diff --git a/include/grub/libgcc.h b/include/grub/libgcc.h
new file mode 100644
index 0000000..8c4c19d
--- /dev/null
+++ b/include/grub/libgcc.h
@@ -0,0 +1,85 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,2007,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/>.
+ */
+
+/* We need to include config-util.h.in for HAVE_*. */
+#include <config-util.h>
+
+/* On x86 these functions aren't really needed. Save some space. */
+#if !defined (__i386__) && !defined (__x86_64__)
+# ifdef HAVE___ASHLDI3
+void EXPORT_FUNC (__ashldi3) (void);
+# endif
+# ifdef HAVE___ASHRDI3
+void EXPORT_FUNC (__ashrdi3) (void);
+# endif
+# ifdef HAVE___LSHRDI3
+void EXPORT_FUNC (__lshrdi3) (void);
+# endif
+# ifdef HAVE___UCMPDI2
+void EXPORT_FUNC (__ucmpdi2) (void);
+# endif
+# ifdef HAVE___BSWAPSI2
+void EXPORT_FUNC (__bswapsi2) (void);
+# endif
+# ifdef HAVE___BSWAPDI2
+void EXPORT_FUNC (__bswapdi2) (void);
+# endif
+#endif
+
+#ifdef HAVE___TRAMPOLINE_SETUP
+void EXPORT_FUNC (__trampoline_setup) (void);
+#endif
+
+#ifdef HAVE__RESTGPR_14_X
+void EXPORT_FUNC (_restgpr_14_x) (void);
+void EXPORT_FUNC (_restgpr_15_x) (void);
+void EXPORT_FUNC (_restgpr_16_x) (void);
+void EXPORT_FUNC (_restgpr_17_x) (void);
+void EXPORT_FUNC (_restgpr_18_x) (void);
+void EXPORT_FUNC (_restgpr_19_x) (void);
+void EXPORT_FUNC (_restgpr_20_x) (void);
+void EXPORT_FUNC (_restgpr_21_x) (void);
+void EXPORT_FUNC (_restgpr_22_x) (void);
+void EXPORT_FUNC (_restgpr_23_x) (void);
+void EXPORT_FUNC (_restgpr_24_x) (void);
+void EXPORT_FUNC (_restgpr_25_x) (void);
+void EXPORT_FUNC (_restgpr_26_x) (void);
+void EXPORT_FUNC (_restgpr_27_x) (void);
+void EXPORT_FUNC (_restgpr_28_x) (void);
+void EXPORT_FUNC (_restgpr_29_x) (void);
+void EXPORT_FUNC (_restgpr_30_x) (void);
+void EXPORT_FUNC (_restgpr_31_x) (void);
+void EXPORT_FUNC (_savegpr_14) (void);
+void EXPORT_FUNC (_savegpr_15) (void);
+void EXPORT_FUNC (_savegpr_16) (void);
+void EXPORT_FUNC (_savegpr_17) (void);
+void EXPORT_FUNC (_savegpr_18) (void);
+void EXPORT_FUNC (_savegpr_19) (void);
+void EXPORT_FUNC (_savegpr_20) (void);
+void EXPORT_FUNC (_savegpr_21) (void);
+void EXPORT_FUNC (_savegpr_22) (void);
+void EXPORT_FUNC (_savegpr_23) (void);
+void EXPORT_FUNC (_savegpr_24) (void);
+void EXPORT_FUNC (_savegpr_25) (void);
+void EXPORT_FUNC (_savegpr_26) (void);
+void EXPORT_FUNC (_savegpr_27) (void);
+void EXPORT_FUNC (_savegpr_28) (void);
+void EXPORT_FUNC (_savegpr_29) (void);
+void EXPORT_FUNC (_savegpr_30) (void);
+void EXPORT_FUNC (_savegpr_31) (void);
+#endif
diff --git a/include/grub/libpciaccess.h b/include/grub/libpciaccess.h
new file mode 100644
index 0000000..4d2b3bd
--- /dev/null
+++ b/include/grub/libpciaccess.h
@@ -0,0 +1,26 @@
+/*
+ * 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/>.
+ */
+
+void EXPORT_FUNC (pci_slot_match_iterator_create) (void);
+void EXPORT_FUNC (pci_system_cleanup) (void);
+void EXPORT_FUNC (pci_device_unmap_range) (void);
+void EXPORT_FUNC (pci_iterator_destroy) (void);
+void EXPORT_FUNC (pci_device_map_range) (void);
+void EXPORT_FUNC (pci_device_cfg_read_u32) (void);
+void EXPORT_FUNC (pci_device_next) (void);
+void EXPORT_FUNC (pci_system_init) (void);
diff --git a/include/grub/libusb.h b/include/grub/libusb.h
new file mode 100644
index 0000000..26548bc
--- /dev/null
+++ b/include/grub/libusb.h
@@ -0,0 +1,29 @@
+/*
+ * 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/>.
+ */
+
+void EXPORT_FUNC (usb_bulk_write) (void);
+void EXPORT_FUNC (usb_find_busses) (void);
+void EXPORT_FUNC (usb_init) (void);
+void EXPORT_FUNC (usb_find_devices) (void);
+void EXPORT_FUNC (usb_open) (void);
+void EXPORT_FUNC (usb_get_busses) (void);
+void EXPORT_FUNC (usb_control_msg) (void);
+void EXPORT_FUNC (usb_release_interface) (void);
+void EXPORT_FUNC (usb_close) (void);
+void EXPORT_FUNC (usb_bulk_read) (void);
+void EXPORT_FUNC (usb_claim_interface) (void);
diff --git a/include/grub/list.h b/include/grub/list.h
new file mode 100644
index 0000000..7535301
--- /dev/null
+++ b/include/grub/list.h
@@ -0,0 +1,117 @@
+/* list.h - header for grub list */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_LIST_HEADER
+#define GRUB_LIST_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/misc.h>
+
+struct grub_list
+{
+ struct grub_list *next;
+};
+typedef struct grub_list *grub_list_t;
+
+void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item);
+void EXPORT_FUNC(grub_list_remove) (grub_list_t *head, grub_list_t item);
+
+#define FOR_LIST_ELEMENTS(var, list) for ((var) = (list); (var); (var) = (var)->next)
+
+static inline void *
+grub_bad_type_cast_real (int line, const char *file)
+ ATTRIBUTE_ERROR ("bad type cast between incompatible grub types");
+
+static inline void *
+grub_bad_type_cast_real (int line, const char *file)
+{
+ grub_fatal ("error:%s:%u: bad type cast between incompatible grub types",
+ file, line);
+ return 0;
+}
+
+#define grub_bad_type_cast() grub_bad_type_cast_real(__LINE__, GRUB_FILE)
+
+#define GRUB_FIELD_MATCH(ptr, type, field) \
+ ((char *) &(ptr)->field == (char *) &((type) (ptr))->field)
+
+#define GRUB_AS_LIST(ptr) \
+ (GRUB_FIELD_MATCH (ptr, grub_list_t, next) ? \
+ (grub_list_t) ptr : grub_bad_type_cast ())
+
+#define GRUB_AS_LIST_P(pptr) \
+ (GRUB_FIELD_MATCH (*pptr, grub_list_t, next) ? \
+ (grub_list_t *) (void *) pptr : grub_bad_type_cast ())
+
+struct grub_named_list
+{
+ struct grub_named_list *next;
+ char *name;
+};
+typedef struct grub_named_list *grub_named_list_t;
+
+void * EXPORT_FUNC(grub_named_list_find) (grub_named_list_t head,
+ const char *name);
+
+#define GRUB_AS_NAMED_LIST(ptr) \
+ ((GRUB_FIELD_MATCH (ptr, grub_named_list_t, next) && \
+ GRUB_FIELD_MATCH (ptr, grub_named_list_t, name))? \
+ (grub_named_list_t) ptr : grub_bad_type_cast ())
+
+#define GRUB_AS_NAMED_LIST_P(pptr) \
+ ((GRUB_FIELD_MATCH (*pptr, grub_named_list_t, next) && \
+ GRUB_FIELD_MATCH (*pptr, grub_named_list_t, name))? \
+ (grub_named_list_t *) (void *) pptr : grub_bad_type_cast ())
+
+#define GRUB_PRIO_LIST_PRIO_MASK 0xff
+#define GRUB_PRIO_LIST_FLAG_ACTIVE 0x100
+
+struct grub_prio_list
+{
+ struct grub_prio_list *next;
+ char *name;
+ int prio;
+};
+typedef struct grub_prio_list *grub_prio_list_t;
+
+void EXPORT_FUNC(grub_prio_list_insert) (grub_prio_list_t *head,
+ grub_prio_list_t item);
+
+static inline void
+grub_prio_list_remove (grub_prio_list_t *head, grub_prio_list_t item)
+{
+ if ((item->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) && (item->next))
+ item->next->prio |= GRUB_PRIO_LIST_FLAG_ACTIVE;
+ grub_list_remove (GRUB_AS_LIST_P (head), GRUB_AS_LIST (item));
+}
+
+#define GRUB_AS_PRIO_LIST(ptr) \
+ ((GRUB_FIELD_MATCH (ptr, grub_prio_list_t, next) && \
+ GRUB_FIELD_MATCH (ptr, grub_prio_list_t, name) && \
+ GRUB_FIELD_MATCH (ptr, grub_prio_list_t, prio))? \
+ (grub_prio_list_t) ptr : grub_bad_type_cast ())
+
+#define GRUB_AS_PRIO_LIST_P(pptr) \
+ ((GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, next) && \
+ GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, name) && \
+ GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, prio))? \
+ (grub_prio_list_t *) (void *) pptr : grub_bad_type_cast ())
+
+#endif /* ! GRUB_LIST_HEADER */
diff --git a/include/grub/loader.h b/include/grub/loader.h
new file mode 100644
index 0000000..c71e8dd
--- /dev/null
+++ b/include/grub/loader.h
@@ -0,0 +1,66 @@
+/* loader.h - OS loaders */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2006,2007,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_LOADER_HEADER
+#define GRUB_LOADER_HEADER 1
+
+#include <grub/file.h>
+#include <grub/symbol.h>
+#include <grub/err.h>
+#include <grub/types.h>
+
+/* Check if a loader is loaded. */
+int EXPORT_FUNC (grub_loader_is_loaded) (void);
+
+/* Set loader functions. NORETURN must be set to true, if BOOT won't return
+ to the original state. */
+void EXPORT_FUNC (grub_loader_set) (grub_err_t (*boot) (void),
+ grub_err_t (*unload) (void),
+ int noreturn);
+
+/* Unset current loader, if any. */
+void EXPORT_FUNC (grub_loader_unset) (void);
+
+/* Call the boot hook in current loader. This may or may not return,
+ depending on the setting by grub_loader_set. */
+grub_err_t grub_loader_boot (void);
+
+/* The space between numbers is intentional for the simplicity of adding new
+ values even if external modules use them. */
+typedef enum {
+ /* A preboot hook which can use everything and turns nothing off. */
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_NORMAL = 400,
+ /* A preboot hook which can't use disks and may stop disks. */
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK = 300,
+ /* A preboot hook which can't use disks or console and may stop console. */
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_CONSOLE = 200,
+ /* A preboot hook which can't use disks or console, can't modify memory map
+ and may stop memory services or finalize memory map. */
+ GRUB_LOADER_PREBOOT_HOOK_PRIO_MEMORY = 100,
+} grub_loader_preboot_hook_prio_t;
+
+/* Register a preboot hook. */
+void *EXPORT_FUNC(grub_loader_register_preboot_hook) (grub_err_t (*preboot_func) (int noret),
+ grub_err_t (*preboot_rest_func) (void),
+ grub_loader_preboot_hook_prio_t prio);
+
+/* Unregister given preboot hook. */
+void grub_loader_unregister_preboot_hook (void *hnd);
+
+#endif /* ! GRUB_LOADER_HEADER */
diff --git a/include/grub/lvm.h b/include/grub/lvm.h
new file mode 100644
index 0000000..b962dfd
--- /dev/null
+++ b/include/grub/lvm.h
@@ -0,0 +1,137 @@
+/* lvm.h - On disk structures for LVM. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,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_LVM_H
+#define GRUB_LVM_H 1
+
+#include <grub/types.h>
+
+/* Length of ID string, excluding terminating zero. */
+#define GRUB_LVM_ID_STRLEN 38
+
+struct grub_lvm_vg {
+ char id[GRUB_LVM_ID_STRLEN+1];
+ char *name;
+ int extent_size;
+ struct grub_lvm_pv *pvs;
+ struct grub_lvm_lv *lvs;
+ struct grub_lvm_vg *next;
+};
+
+struct grub_lvm_pv {
+ char id[GRUB_LVM_ID_STRLEN+1];
+ char *name;
+ grub_disk_t disk;
+ int start; /* Sector number where the data area starts. */
+ struct grub_lvm_pv *next;
+};
+
+struct grub_lvm_lv {
+ char *name;
+ unsigned int number;
+ unsigned int segment_count;
+ grub_uint64_t size;
+
+ int visible;
+
+ struct grub_lvm_segment *segments; /* Pointer to segment_count segments. */
+ struct grub_lvm_vg *vg;
+ struct grub_lvm_lv *next;
+};
+
+struct grub_lvm_segment {
+ unsigned int start_extent;
+ unsigned int extent_count;
+ enum { GRUB_LVM_STRIPED, GRUB_LVM_MIRROR } type;
+
+ unsigned int node_count;
+ struct grub_lvm_node *nodes;
+
+ unsigned int stripe_size;
+};
+
+struct grub_lvm_node {
+ grub_disk_addr_t start;
+ char *name;
+ struct grub_lvm_pv *pv;
+ struct grub_lvm_lv *lv;
+};
+
+#define GRUB_LVM_LABEL_SIZE GRUB_DISK_SECTOR_SIZE
+#define GRUB_LVM_LABEL_SCAN_SECTORS 4L
+
+#define GRUB_LVM_LABEL_ID "LABELONE"
+#define GRUB_LVM_LVM2_LABEL "LVM2 001"
+
+#define GRUB_LVM_ID_LEN 32
+
+/* On disk - 32 bytes */
+struct grub_lvm_label_header {
+ grub_int8_t id[8]; /* LABELONE */
+ grub_uint64_t sector_xl; /* Sector number of this label */
+ grub_uint32_t crc_xl; /* From next field to end of sector */
+ grub_uint32_t offset_xl; /* Offset from start of struct to contents */
+ grub_int8_t type[8]; /* LVM2 001 */
+} __attribute__ ((packed));
+
+/* On disk */
+struct grub_lvm_disk_locn {
+ grub_uint64_t offset; /* Offset in bytes to start sector */
+ grub_uint64_t size; /* Bytes */
+} __attribute__ ((packed));
+
+/* Fields with the suffix _xl should be xlate'd wherever they appear */
+/* On disk */
+struct grub_lvm_pv_header {
+ grub_int8_t pv_uuid[GRUB_LVM_ID_LEN];
+
+ /* This size can be overridden if PV belongs to a VG */
+ grub_uint64_t device_size_xl; /* Bytes */
+
+ /* NULL-terminated list of data areas followed by */
+ /* NULL-terminated list of metadata area headers */
+ struct grub_lvm_disk_locn disk_areas_xl[0]; /* Two lists */
+} __attribute__ ((packed));
+
+#define GRUB_LVM_FMTT_MAGIC "\040\114\126\115\062\040\170\133\065\101\045\162\060\116\052\076"
+#define GRUB_LVM_FMTT_VERSION 1
+#define GRUB_LVM_MDA_HEADER_SIZE 512
+
+/* On disk */
+struct grub_lvm_raw_locn {
+ grub_uint64_t offset; /* Offset in bytes to start sector */
+ grub_uint64_t size; /* Bytes */
+ grub_uint32_t checksum;
+ grub_uint32_t filler;
+} __attribute__ ((packed));
+
+/* On disk */
+/* Structure size limited to one sector */
+struct grub_lvm_mda_header {
+ grub_uint32_t checksum_xl; /* Checksum of rest of mda_header */
+ grub_int8_t magic[16]; /* To aid scans for metadata */
+ grub_uint32_t version;
+ grub_uint64_t start; /* Absolute start byte of mda_header */
+ grub_uint64_t size; /* Size of metadata area */
+
+ struct grub_lvm_raw_locn raw_locns[0]; /* NULL-terminated list */
+} __attribute__ ((packed));
+
+
+#endif /* ! GRUB_LVM_H */
diff --git a/include/grub/macho.h b/include/grub/macho.h
new file mode 100644
index 0000000..8214583
--- /dev/null
+++ b/include/grub/macho.h
@@ -0,0 +1,124 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_MACHO_H
+#define GRUB_MACHO_H 1
+#include <grub/types.h>
+
+/* Multi-architecture header. Always in big-endian. */
+struct grub_macho_fat_header
+{
+ grub_uint32_t magic;
+ grub_uint32_t nfat_arch;
+} __attribute__ ((packed));
+#define GRUB_MACHO_FAT_MAGIC 0xcafebabe
+
+typedef grub_uint32_t grub_macho_cpu_type_t;
+typedef grub_uint32_t grub_macho_cpu_subtype_t;
+
+/* Architecture descriptor. Always in big-endian. */
+struct grub_macho_fat_arch
+{
+ grub_macho_cpu_type_t cputype;
+ grub_macho_cpu_subtype_t cpusubtype;
+ grub_uint32_t offset;
+ grub_uint32_t size;
+ grub_uint32_t align;
+} __attribute__ ((packed));
+
+/* File header for 32-bit. Always in native-endian. */
+struct grub_macho_header32
+{
+#define GRUB_MACHO_MAGIC32 0xfeedface
+ grub_uint32_t magic;
+ grub_macho_cpu_type_t cputype;
+ grub_macho_cpu_subtype_t cpusubtype;
+ grub_uint32_t filetype;
+ grub_uint32_t ncmds;
+ grub_uint32_t sizeofcmds;
+ grub_uint32_t flags;
+} __attribute__ ((packed));
+
+/* File header for 64-bit. Always in native-endian. */
+struct grub_macho_header64
+{
+#define GRUB_MACHO_MAGIC64 0xfeedfacf
+ grub_uint32_t magic;
+ grub_macho_cpu_type_t cputype;
+ grub_macho_cpu_subtype_t cpusubtype;
+ grub_uint32_t filetype;
+ grub_uint32_t ncmds;
+ grub_uint32_t sizeofcmds;
+ grub_uint32_t flags;
+ grub_uint32_t reserved;
+} __attribute__ ((packed));
+
+/* Convenience union. What do we need to load to identify the file type. */
+union grub_macho_filestart
+{
+ struct grub_macho_fat_header fat;
+ struct grub_macho_header32 thin32;
+ struct grub_macho_header64 thin64;
+} __attribute__ ((packed));
+
+/* Common header of Mach-O commands. */
+struct grub_macho_cmd
+{
+ grub_uint32_t cmd;
+ grub_uint32_t cmdsize;
+} __attribute__ ((packed));
+
+typedef grub_uint32_t grub_macho_vmprot_t;
+
+/* 32-bit segment command. */
+struct grub_macho_segment32
+{
+#define GRUB_MACHO_CMD_SEGMENT32 1
+ grub_uint32_t cmd;
+ grub_uint32_t cmdsize;
+ grub_uint8_t segname[16];
+ grub_uint32_t vmaddr;
+ grub_uint32_t vmsize;
+ grub_uint32_t fileoff;
+ grub_uint32_t filesize;
+ grub_macho_vmprot_t maxprot;
+ grub_macho_vmprot_t initprot;
+ grub_uint32_t nsects;
+ grub_uint32_t flags;
+} __attribute__ ((packed));
+
+/* 64-bit segment command. */
+struct grub_macho_segment64
+{
+#define GRUB_MACHO_CMD_SEGMENT64 0x19
+ grub_uint32_t cmd;
+ grub_uint32_t cmdsize;
+ grub_uint8_t segname[16];
+ grub_uint64_t vmaddr;
+ grub_uint64_t vmsize;
+ grub_uint64_t fileoff;
+ grub_uint64_t filesize;
+ grub_macho_vmprot_t maxprot;
+ grub_macho_vmprot_t initprot;
+ grub_uint32_t nsects;
+ grub_uint32_t flags;
+} __attribute__ ((packed));
+
+#define GRUB_MACHO_CMD_THREAD 5
+
+#endif
diff --git a/include/grub/machoload.h b/include/grub/machoload.h
new file mode 100644
index 0000000..8410162
--- /dev/null
+++ b/include/grub/machoload.h
@@ -0,0 +1,73 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_MACHOLOAD_HEADER
+#define GRUB_MACHOLOAD_HEADER 1
+
+#include <grub/err.h>
+#include <grub/elf.h>
+#include <grub/file.h>
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+struct grub_macho_file
+{
+ grub_file_t file;
+ grub_ssize_t offset32;
+ grub_ssize_t end32;
+ int ncmds32;
+ grub_size_t cmdsize32;
+ grub_uint8_t *cmds32;
+ grub_ssize_t offset64;
+ grub_ssize_t end64;
+ int ncmds64;
+ grub_size_t cmdsize64;
+ grub_uint8_t *cmds64;
+};
+typedef struct grub_macho_file *grub_macho_t;
+
+grub_macho_t grub_macho_open (const char *);
+grub_macho_t grub_macho_file (grub_file_t);
+grub_err_t grub_macho_close (grub_macho_t);
+
+int grub_macho_contains_macho32 (grub_macho_t);
+grub_err_t grub_macho_size32 (grub_macho_t macho, grub_uint32_t *segments_start,
+ grub_uint32_t *segments_end, int flags);
+grub_uint32_t grub_macho_get_entry_point32 (grub_macho_t macho);
+
+int grub_macho_contains_macho64 (grub_macho_t);
+grub_err_t grub_macho_size64 (grub_macho_t macho, grub_uint64_t *segments_start,
+ grub_uint64_t *segments_end, int flags);
+grub_uint64_t grub_macho_get_entry_point64 (grub_macho_t macho);
+
+/* Ignore BSS segments when loading. */
+#define GRUB_MACHO_NOBSS 0x1
+grub_err_t grub_macho_load32 (grub_macho_t macho, char *offset, int flags);
+grub_err_t grub_macho_load64 (grub_macho_t macho, char *offset, int flags);
+
+/* Like filesize and file_read but take only 32-bit part
+ for current architecture. */
+grub_size_t grub_macho_filesize32 (grub_macho_t macho);
+grub_err_t grub_macho_readfile32 (grub_macho_t macho, void *dest);
+grub_size_t grub_macho_filesize64 (grub_macho_t macho);
+grub_err_t grub_macho_readfile64 (grub_macho_t macho, void *dest);
+
+void grub_macho_parse32 (grub_macho_t macho);
+void grub_macho_parse64 (grub_macho_t macho);
+
+#endif /* ! GRUB_MACHOLOAD_HEADER */
diff --git a/include/grub/memory.h b/include/grub/memory.h
new file mode 100644
index 0000000..d983865
--- /dev/null
+++ b/include/grub/memory.h
@@ -0,0 +1,73 @@
+/* memory.h - describe the memory map */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2007,2008 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_MEMORY_HEADER
+#define GRUB_MEMORY_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+
+typedef enum grub_memory_type
+ {
+ GRUB_MEMORY_AVAILABLE = 1,
+ GRUB_MEMORY_RESERVED = 2,
+ GRUB_MEMORY_ACPI = 3,
+ GRUB_MEMORY_NVS = 4,
+ GRUB_MEMORY_BADRAM = 5,
+ GRUB_MEMORY_CODE = 20,
+ /* This one is special: it's used internally but is never reported
+ by firmware. */
+ GRUB_MEMORY_HOLE = 21
+ } grub_memory_type_t;
+
+typedef int NESTED_FUNC_ATTR (*grub_memory_hook_t) (grub_uint64_t,
+ grub_uint64_t,
+ grub_memory_type_t);
+
+grub_err_t grub_mmap_iterate (grub_memory_hook_t hook);
+
+#if !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_EFI)
+grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate) (grub_memory_hook_t hook);
+#else
+grub_err_t grub_machine_mmap_iterate (grub_memory_hook_t hook);
+#endif
+
+int grub_mmap_register (grub_uint64_t start, grub_uint64_t size, int type);
+grub_err_t grub_mmap_unregister (int handle);
+
+void *grub_mmap_malign_and_register (grub_uint64_t align, grub_uint64_t size,
+ int *handle, int type, int flags);
+
+void grub_mmap_free_and_unregister (int handle);
+
+#ifndef GRUB_MMAP_REGISTER_BY_FIRMWARE
+
+struct grub_mmap_region
+{
+ struct grub_mmap_region *next;
+ grub_uint64_t start;
+ grub_uint64_t end;
+ grub_memory_type_t type;
+ int handle;
+};
+
+extern struct grub_mmap_region *grub_mmap_overlays;
+#endif
+
+#endif /* ! GRUB_MEMORY_HEADER */
diff --git a/include/grub/menu.h b/include/grub/menu.h
new file mode 100644
index 0000000..1f23a23
--- /dev/null
+++ b/include/grub/menu.h
@@ -0,0 +1,103 @@
+/* menu.h - Menu model function prototypes and data structures. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_MENU_HEADER
+#define GRUB_MENU_HEADER 1
+
+struct grub_menu_entry_class
+{
+ char *name;
+ struct grub_menu_entry_class *next;
+};
+
+/* The menu entry. */
+struct grub_menu_entry
+{
+ /* The title name. */
+ const char *title;
+
+ /* If set means not everybody is allowed to boot this entry. */
+ int restricted;
+
+ /* Allowed users. */
+ const char *users;
+
+ /* The classes associated with the menu entry:
+ used to choose an icon or other style attributes.
+ This is a dummy head node for the linked list, so for an entry E,
+ E.classes->next is the first class if it is not NULL. */
+ struct grub_menu_entry_class *classes;
+
+ /* The sourcecode of the menu entry, used by the editor. */
+ const char *sourcecode;
+
+ /* Parameters to be passed to menu definition. */
+ int argc;
+ char **args;
+
+ int hotkey;
+
+ int submenu;
+
+ /* The next element. */
+ struct grub_menu_entry *next;
+};
+typedef struct grub_menu_entry *grub_menu_entry_t;
+
+/* The menu. */
+struct grub_menu
+{
+ /* The size of a menu. */
+ int size;
+
+ /* The list of menu entries. */
+ grub_menu_entry_t entry_list;
+};
+typedef struct grub_menu *grub_menu_t;
+
+/* Callback structure menu viewers can use to provide user feedback when
+ default entries are executed, possibly including fallback entries. */
+typedef struct grub_menu_execute_callback
+{
+ /* Called immediately before ENTRY is booted. */
+ void (*notify_booting) (grub_menu_entry_t entry, void *userdata);
+
+ /* Called when executing one entry has failed, and another entry, ENTRY, will
+ be executed as a fallback. The implementation of this function should
+ delay for a period of at least 2 seconds before returning in order to
+ allow the user time to read the information before it can be lost by
+ executing ENTRY. */
+ void (*notify_fallback) (grub_menu_entry_t entry, void *userdata);
+
+ /* Called when an entry has failed to execute and there is no remaining
+ fallback entry to attempt. */
+ void (*notify_failure) (void *userdata);
+}
+*grub_menu_execute_callback_t;
+
+grub_menu_entry_t grub_menu_get_entry (grub_menu_t menu, int no);
+int grub_menu_get_timeout (void);
+void grub_menu_set_timeout (int timeout);
+void grub_menu_entry_run (grub_menu_entry_t entry);
+int grub_menu_get_default_entry_index (grub_menu_t menu);
+
+void grub_menu_init (void);
+void grub_menu_fini (void);
+
+#endif /* GRUB_MENU_HEADER */
diff --git a/include/grub/menu_viewer.h b/include/grub/menu_viewer.h
new file mode 100644
index 0000000..c6513c4
--- /dev/null
+++ b/include/grub/menu_viewer.h
@@ -0,0 +1,48 @@
+/* menu_viewer.h - Interface to menu viewer implementations. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_MENU_VIEWER_HEADER
+#define GRUB_MENU_VIEWER_HEADER 1
+
+#include <grub/err.h>
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/menu.h>
+#include <grub/term.h>
+
+struct grub_menu_viewer
+{
+ struct grub_menu_viewer *next;
+ void *data;
+ void (*set_chosen_entry) (int entry, void *data);
+ void (*print_timeout) (int timeout, void *data);
+ void (*clear_timeout) (void *data);
+ void (*fini) (void *fini);
+};
+
+void grub_menu_register_viewer (struct grub_menu_viewer *viewer);
+
+grub_err_t
+grub_menu_try_text (struct grub_term_output *term,
+ int entry, grub_menu_t menu, int nested);
+
+extern grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu,
+ int nested);
+
+#endif /* GRUB_MENU_VIEWER_HEADER */
diff --git a/include/grub/mips/at_keyboard.h b/include/grub/mips/at_keyboard.h
new file mode 100644
index 0000000..0c30753
--- /dev/null
+++ b/include/grub/mips/at_keyboard.h
@@ -0,0 +1 @@
+#include <grub/machine/at_keyboard.h>
diff --git a/include/grub/mips/cache.h b/include/grub/mips/cache.h
new file mode 100644
index 0000000..c347057
--- /dev/null
+++ b/include/grub/mips/cache.h
@@ -0,0 +1,27 @@
+/* cache.h - Flush the processor's cache. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2004,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_CPU_CACHE_H
+#define GRUB_CPU_CACHE_H 1
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+void EXPORT_FUNC(grub_cpu_flush_cache) (void *start, grub_size_t size, int type);
+#endif
diff --git a/include/grub/mips/cmos.h b/include/grub/mips/cmos.h
new file mode 100644
index 0000000..79a7a4c
--- /dev/null
+++ b/include/grub/mips/cmos.h
@@ -0,0 +1 @@
+#include <grub/machine/cmos.h>
diff --git a/include/grub/mips/io.h b/include/grub/mips/io.h
new file mode 100644
index 0000000..dee76bd
--- /dev/null
+++ b/include/grub/mips/io.h
@@ -0,0 +1,62 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_IO_H
+#define GRUB_IO_H 1
+
+#include <grub/types.h>
+
+typedef grub_addr_t grub_port_t;
+
+static __inline unsigned char
+grub_inb (grub_port_t port)
+{
+ return *(volatile grub_uint8_t *) port;
+}
+
+static __inline unsigned short int
+grub_inw (grub_port_t port)
+{
+ return *(volatile grub_uint16_t *) port;
+}
+
+static __inline unsigned int
+grub_inl (grub_port_t port)
+{
+ return *(volatile grub_uint32_t *) port;
+}
+
+static __inline void
+grub_outb (unsigned char value, grub_port_t port)
+{
+ *(volatile grub_uint8_t *) port = value;
+}
+
+static __inline void
+grub_outw (unsigned short int value, grub_port_t port)
+{
+ *(volatile grub_uint16_t *) port = value;
+}
+
+static __inline void
+grub_outl (unsigned int value, grub_port_t port)
+{
+ *(volatile grub_uint32_t *) port = value;
+}
+
+#endif /* _SYS_IO_H */
diff --git a/include/grub/mips/loongson.h b/include/grub/mips/loongson.h
new file mode 100644
index 0000000..6cb1178
--- /dev/null
+++ b/include/grub/mips/loongson.h
@@ -0,0 +1,90 @@
+/*
+ * 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_LOONGSON_CPU_HEADER
+#define GRUB_LOONGSON_CPU_HEADER 1
+
+#ifdef ASM_FILE
+#define GRUB_CPU_REGISTER_WRAP(x) x
+#else
+#define GRUB_CPU_REGISTER_WRAP(x) #x
+#endif
+
+#define GRUB_CPU_LOONGSON_FLASH_START 0xbfc00000
+#define GRUB_CPU_LOONGSON_FLASH_TLB_REFILL 0xbfc00200
+#define GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR 0xbfc00300
+#define GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION 0xbfc00380
+
+#define GRUB_CPU_LOONGSON_DDR2_BASE 0xaffffe00
+#define GRUB_CPU_LOONGSON_DDR2_REG1_HI_8BANKS 0x00000001
+#define GRUB_CPU_LOONGSON_DDR2_REG_SIZE 0x8
+#define GRUB_CPU_LOONGSON_DDR2_REG_STEP 0x10
+
+#define GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG GRUB_CPU_REGISTER_WRAP($16)
+#define GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG_ILINESIZE 0x10
+#define GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG_DLINESIZE 0x8
+#define GRUB_CPU_LOONGSON_COP0_CACHE_DSIZE_SHIFT 6
+#define GRUB_CPU_LOONGSON_COP0_CACHE_ISIZE_SHIFT 9
+#define GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_MASK 0x7
+#define GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_OFFSET 12
+
+#define GRUB_CPU_LOONGSON_COP0_I_INDEX_INVALIDATE 0
+#define GRUB_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE 9
+#define GRUB_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE 11
+
+#define GRUB_CPU_LOONGSON_COP0_I_INDEX_BIT_OFFSET 5
+#define GRUB_CPU_LOONGSON_COP0_D_INDEX_BIT_OFFSET 5
+#define GRUB_CPU_LOONGSON_COP0_S_INDEX_BIT_OFFSET 5
+
+#define GRUB_CPU_LOONGSON_CACHE_ACCELERATED 7
+#define GRUB_CPU_LOONGSON_CACHE_UNCACHED 2
+#define GRUB_CPU_LOONGSON_CACHE_CACHED 3
+#define GRUB_CPU_LOONGSON_CACHE_TYPE_MASK 7
+#define GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_SMALL 4
+#define GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG 5
+#define GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_SMALL 16
+#define GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_BIG 32
+
+#define GRUB_CPU_LOONGSON_I_CACHE_LOG_WAYS 2
+#define GRUB_CPU_LOONGSON_D_CACHE_LOG_WAYS 2
+#define GRUB_CPU_LOONGSON_S_CACHE_LOG_WAYS 2
+
+/* FIXME: determine dynamically. */
+#define GRUB_CPU_LOONGSON_SECONDARY_CACHE_LOG_SIZE 19
+
+#define GRUB_CPU_LOONGSON_COP0_BADVADDR GRUB_CPU_REGISTER_WRAP($8)
+#define GRUB_CPU_LOONGSON_COP0_TIMER_COUNT GRUB_CPU_REGISTER_WRAP($9)
+#define GRUB_CPU_LOONGSON_COP0_CAUSE GRUB_CPU_REGISTER_WRAP($13)
+#define GRUB_CPU_LOONGSON_COP0_EPC GRUB_CPU_REGISTER_WRAP($14)
+#define GRUB_CPU_LOONGSON_COP0_CACHE_TAGLO GRUB_CPU_REGISTER_WRAP($28)
+#define GRUB_CPU_LOONGSON_COP0_CACHE_TAGHI GRUB_CPU_REGISTER_WRAP($29)
+
+#define GRUB_CPU_LOONGSON_LIOCFG 0xbfe00108
+#define GRUB_CPU_LOONGSON_ROM_DELAY_OFFSET 2
+#define GRUB_CPU_LOONGSON_ROM_DELAY_MASK 0x1f
+#define GRUB_CPU_LOONGSON_CORECFG 0xbfe00180
+#define GRUB_CPU_LOONGSON_CORECFG_DISABLE_DDR2_SPACE 0x100
+#define GRUB_CPU_LOONGSON_CORECFG_BUFFER_CPU 0x200
+
+#define GRUB_CPU_LOONGSON_PCI_HIT1_SEL_LO 0xbfe00150
+#define GRUB_CPU_LOONGSON_PCI_HIT1_SEL_HI 0xbfe00154
+
+#define GRUB_CPU_LOONGSON_GPIOCFG 0xbfe00120
+#define GRUB_CPU_LOONGSON_SHUTDOWN_GPIO 1
+
+#endif
diff --git a/include/grub/mips/memory.h b/include/grub/mips/memory.h
new file mode 100644
index 0000000..e51bcc1
--- /dev/null
+++ b/include/grub/mips/memory.h
@@ -0,0 +1 @@
+#include <grub/machine/memory.h>
diff --git a/include/grub/mips/multiboot.h b/include/grub/mips/multiboot.h
new file mode 100644
index 0000000..4aebf29
--- /dev/null
+++ b/include/grub/mips/multiboot.h
@@ -0,0 +1,31 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,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_MULTIBOOT_CPU_HEADER
+#define GRUB_MULTIBOOT_CPU_HEADER 1
+
+#define MULTIBOOT_INITIAL_STATE { .gpr[4] = MULTIBOOT_BOOTLOADER_MAGIC, \
+ .jumpreg = 1 }
+#define MULTIBOOT_ENTRY_REGISTER gpr[1]
+#define MULTIBOOT_MBI_REGISTER gpr[5]
+#define MULTIBOOT_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_MIPS32
+
+#define MULTIBOOT_ELF32_MACHINE EM_MIPS
+#define MULTIBOOT_ELF64_MACHINE EM_MIPS
+
+#endif /* ! GRUB_MULTIBOOT_CPU_HEADER */
diff --git a/include/grub/mips/pci.h b/include/grub/mips/pci.h
new file mode 100644
index 0000000..8b49d84
--- /dev/null
+++ b/include/grub/mips/pci.h
@@ -0,0 +1 @@
+#include <grub/machine/pci.h>
diff --git a/include/grub/mips/qemu-mips/kernel.h b/include/grub/mips/qemu-mips/kernel.h
new file mode 100644
index 0000000..230455d
--- /dev/null
+++ b/include/grub/mips/qemu-mips/kernel.h
@@ -0,0 +1,32 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,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_KERNEL_MACHINE_HEADER
+#define GRUB_KERNEL_MACHINE_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/cpu/kernel.h>
+
+#ifndef ASM_FILE
+
+void EXPORT_FUNC (grub_reboot) (void);
+void EXPORT_FUNC (grub_halt) (void);
+
+#endif
+
+#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
diff --git a/include/grub/mips/qemu-mips/loader.h b/include/grub/mips/qemu-mips/loader.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/include/grub/mips/qemu-mips/loader.h
diff --git a/include/grub/mips/qemu-mips/memory.h b/include/grub/mips/qemu-mips/memory.h
new file mode 100644
index 0000000..99d9ef2
--- /dev/null
+++ b/include/grub/mips/qemu-mips/memory.h
@@ -0,0 +1,52 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_MEMORY_MACHINE_HEADER
+#define GRUB_MEMORY_MACHINE_HEADER 1
+
+#ifndef ASM_FILE
+#include <grub/symbol.h>
+#include <grub/err.h>
+#include <grub/types.h>
+#endif
+
+#define GRUB_MACHINE_MEMORY_STACK_HIGH 0x80f00000
+#define GRUB_MACHINE_MEMORY_USABLE 0x81000000
+
+#ifndef ASM_FILE
+grub_err_t EXPORT_FUNC (grub_machine_mmap_iterate)
+(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
+grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
+ (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
+
+static inline grub_err_t
+grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)),
+ grub_uint64_t size __attribute__ ((unused)),
+ int type __attribute__ ((unused)),
+ int handle __attribute__ ((unused)))
+{
+ return GRUB_ERR_NONE;
+}
+static inline grub_err_t
+grub_machine_mmap_unregister (int handle __attribute__ ((unused)))
+{
+ return GRUB_ERR_NONE;
+}
+#endif
+
+#endif
diff --git a/include/grub/mips/qemu-mips/serial.h b/include/grub/mips/qemu-mips/serial.h
new file mode 100644
index 0000000..1f8ce08
--- /dev/null
+++ b/include/grub/mips/qemu-mips/serial.h
@@ -0,0 +1,24 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_MACHINE_SERIAL_HEADER
+#define GRUB_MACHINE_SERIAL_HEADER 1
+
+#define GRUB_MACHINE_SERIAL_PORTS { 0x140003f8 }
+
+#endif
diff --git a/include/grub/mips/qemu-mips/time.h b/include/grub/mips/qemu-mips/time.h
new file mode 100644
index 0000000..a73f64d
--- /dev/null
+++ b/include/grub/mips/qemu-mips/time.h
@@ -0,0 +1,34 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,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 KERNEL_MACHINE_TIME_HEADER
+#define KERNEL_MACHINE_TIME_HEADER 1
+
+#include <grub/symbol.h>
+
+#define GRUB_TICKS_PER_SECOND 1000
+
+/* Return the real time in ticks. */
+grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void);
+
+static inline void
+grub_cpu_idle(void)
+{
+}
+
+#endif /* ! KERNEL_MACHINE_TIME_HEADER */
diff --git a/include/grub/mips/relocator.h b/include/grub/mips/relocator.h
new file mode 100644
index 0000000..67b0a4c
--- /dev/null
+++ b/include/grub/mips/relocator.h
@@ -0,0 +1,38 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_RELOCATOR_CPU_HEADER
+#define GRUB_RELOCATOR_CPU_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/relocator.h>
+
+struct grub_relocator32_state
+{
+ /* gpr[0] is ignored since it's hardwired to 0. */
+ grub_uint32_t gpr[32];
+ /* Register holding target $pc. */
+ int jumpreg;
+};
+
+grub_err_t
+grub_relocator32_boot (struct grub_relocator *rel,
+ struct grub_relocator32_state state);
+
+#endif /* ! GRUB_RELOCATOR_CPU_HEADER */
diff --git a/include/grub/mips/setjmp.h b/include/grub/mips/setjmp.h
new file mode 100644
index 0000000..5e59855
--- /dev/null
+++ b/include/grub/mips/setjmp.h
@@ -0,0 +1,27 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2006,2007,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_SETJMP_CPU_HEADER
+#define GRUB_SETJMP_CPU_HEADER 1
+
+typedef unsigned long grub_jmp_buf[11];
+
+int grub_setjmp (grub_jmp_buf env) __attribute__ ((returns_twice));
+void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn));
+
+#endif /* ! GRUB_SETJMP_CPU_HEADER */
diff --git a/include/grub/mips/time.h b/include/grub/mips/time.h
new file mode 100644
index 0000000..b143a48
--- /dev/null
+++ b/include/grub/mips/time.h
@@ -0,0 +1,6 @@
+#ifdef GRUB_MACHINE_EMU
+static inline void
+grub_cpu_idle(void)
+{
+}
+#endif
diff --git a/include/grub/mips/types.h b/include/grub/mips/types.h
new file mode 100644
index 0000000..fe09afa
--- /dev/null
+++ b/include/grub/mips/types.h
@@ -0,0 +1,38 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2006,2007,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_TYPES_CPU_HEADER
+#define GRUB_TYPES_CPU_HEADER 1
+
+/* The size of void *. */
+#define GRUB_TARGET_SIZEOF_VOID_P 4
+
+/* The size of long. */
+#define GRUB_TARGET_SIZEOF_LONG 4
+
+#ifdef GRUB_CPU_MIPSEL
+/* mipsEL is little-endian. */
+#undef GRUB_TARGET_WORDS_BIGENDIAN
+#elif defined (GRUB_CPU_MIPS)
+/* mips is big-endian. */
+#define GRUB_TARGET_WORDS_BIGENDIAN
+#elif !defined (GRUB_SYMBOL_GENERATOR)
+#error Neither GRUB_CPU_MIPS nor GRUB_CPU_MIPSEL is defined
+#endif
+
+#endif /* ! GRUB_TYPES_CPU_HEADER */
diff --git a/include/grub/mips/yeeloong/at_keyboard.h b/include/grub/mips/yeeloong/at_keyboard.h
new file mode 100644
index 0000000..f279ac8
--- /dev/null
+++ b/include/grub/mips/yeeloong/at_keyboard.h
@@ -0,0 +1,25 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_MACHINE_AT_KEYBOARD_HEADER
+#define GRUB_MACHINE_AT_KEYBOARD_HEADER 1
+
+#define KEYBOARD_REG_DATA 0xbfd00060
+#define KEYBOARD_REG_STATUS 0xbfd00064
+
+#endif
diff --git a/include/grub/mips/yeeloong/cmos.h b/include/grub/mips/yeeloong/cmos.h
new file mode 100644
index 0000000..f2a32d7
--- /dev/null
+++ b/include/grub/mips/yeeloong/cmos.h
@@ -0,0 +1,28 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_CPU_CMOS_H
+#define GRUB_CPU_CMOS_H 1
+
+#include <grub/types.h>
+#include <grub/cpu/io.h>
+
+#define GRUB_CMOS_ADDR_REG 0xbfd00070
+#define GRUB_CMOS_DATA_REG 0xbfd00071
+
+#endif /* GRUB_CPU_CMOS_H */
diff --git a/include/grub/mips/yeeloong/ec.h b/include/grub/mips/yeeloong/ec.h
new file mode 100644
index 0000000..62d1d33
--- /dev/null
+++ b/include/grub/mips/yeeloong/ec.h
@@ -0,0 +1,41 @@
+/*
+ * 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_EC_MACHINE_HEADER
+#define GRUB_EC_MACHINE_HEADER 1
+
+#define GRUB_MACHINE_EC_MAGIC_PORT1 0x381
+#define GRUB_MACHINE_EC_MAGIC_PORT2 0x382
+#define GRUB_MACHINE_EC_DATA_PORT 0x383
+
+#define GRUB_MACHINE_EC_MAGIC_VAL1 0xf4
+#define GRUB_MACHINE_EC_MAGIC_VAL2 0xec
+
+#define GRUB_MACHINE_EC_COMMAND_REBOOT 1
+
+static inline void
+grub_write_ec (grub_uint8_t value)
+{
+ grub_outb (GRUB_MACHINE_EC_MAGIC_VAL1,
+ GRUB_MACHINE_PCI_IO_BASE + GRUB_MACHINE_EC_MAGIC_PORT1);
+ grub_outb (GRUB_MACHINE_EC_MAGIC_VAL2,
+ GRUB_MACHINE_PCI_IO_BASE + GRUB_MACHINE_EC_MAGIC_PORT2);
+ grub_outb (value, GRUB_MACHINE_PCI_IO_BASE + GRUB_MACHINE_EC_DATA_PORT);
+}
+
+#endif
diff --git a/include/grub/mips/yeeloong/kernel.h b/include/grub/mips/yeeloong/kernel.h
new file mode 100644
index 0000000..15cf9f9
--- /dev/null
+++ b/include/grub/mips/yeeloong/kernel.h
@@ -0,0 +1,31 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,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_KERNEL_MACHINE_HEADER
+#define GRUB_KERNEL_MACHINE_HEADER 1
+
+#include <grub/symbol.h>
+
+#ifndef ASM_FILE
+
+void EXPORT_FUNC (grub_reboot) (void) __attribute__ ((noreturn));
+void EXPORT_FUNC (grub_halt) (void) __attribute__ ((noreturn));
+
+#endif
+
+#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
diff --git a/include/grub/mips/yeeloong/memory.h b/include/grub/mips/yeeloong/memory.h
new file mode 100644
index 0000000..9d53b5e
--- /dev/null
+++ b/include/grub/mips/yeeloong/memory.h
@@ -0,0 +1,81 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_MEMORY_MACHINE_HEADER
+#define GRUB_MEMORY_MACHINE_HEADER 1
+
+#ifndef ASM_FILE
+#include <grub/symbol.h>
+#include <grub/err.h>
+#include <grub/types.h>
+#endif
+
+#define GRUB_MACHINE_MEMORY_STACK_HIGH 0x801ffff0
+#define GRUB_ARCH_LOWMEMVSTART 0x80000000
+#define GRUB_ARCH_LOWMEMPSTART 0x00000000
+#define GRUB_ARCH_LOWMEMMAXSIZE 0x10000000
+#define GRUB_ARCH_HIGHMEMPSTART 0x10000000
+
+#ifndef ASM_FILE
+
+typedef grub_addr_t grub_phys_addr_t;
+
+static inline grub_phys_addr_t
+grub_vtop (void *a)
+{
+ return ((grub_phys_addr_t) a) & 0x1fffffff;
+}
+
+static inline void *
+grub_map_memory (grub_phys_addr_t a, grub_size_t size __attribute__ ((unused)))
+{
+ return (void *) (a | 0x80000000);
+}
+
+static inline void
+grub_unmap_memory (void *a __attribute__ ((unused)),
+ grub_size_t size __attribute__ ((unused)))
+{
+}
+
+grub_err_t EXPORT_FUNC (grub_machine_mmap_iterate)
+(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
+
+static inline grub_err_t
+grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)),
+ grub_uint64_t size __attribute__ ((unused)),
+ int type __attribute__ ((unused)),
+ int handle __attribute__ ((unused)))
+{
+ return GRUB_ERR_NONE;
+}
+static inline grub_err_t
+grub_machine_mmap_unregister (int handle __attribute__ ((unused)))
+{
+ return GRUB_ERR_NONE;
+}
+
+grub_uint64_t grub_mmap_get_lower (void);
+grub_uint64_t grub_mmap_get_upper (void);
+
+extern grub_uint32_t EXPORT_VAR (grub_arch_memsize);
+extern grub_uint32_t EXPORT_VAR (grub_arch_highmemsize);
+
+#endif
+
+#endif
diff --git a/include/grub/mips/yeeloong/pci.h b/include/grub/mips/yeeloong/pci.h
new file mode 100644
index 0000000..199bac0
--- /dev/null
+++ b/include/grub/mips/yeeloong/pci.h
@@ -0,0 +1,121 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_MACHINE_PCI_H
+#define GRUB_MACHINE_PCI_H 1
+
+#ifndef ASM_FILE
+#include <grub/types.h>
+#include <grub/cpu/io.h>
+#endif
+
+#define GRUB_YEELOONG_OHCI_PCIID 0x00351033
+#define GRUB_YEELOONG_EHCI_PCIID 0x00e01033
+#define GRUB_YEELOONG_OHCI_GHOST_FUNCTION 4
+#define GRUB_YEELOONG_EHCI_GHOST_FUNCTION 5
+
+#define GRUB_PCI_NUM_BUS 1
+#define GRUB_PCI_NUM_DEVICES 16
+
+#define GRUB_MACHINE_PCI_IO_BASE 0xbfd00000
+#define GRUB_MACHINE_PCI_CONFSPACE 0xbfe80000
+#define GRUB_MACHINE_PCI_CONTROLLER_HEADER 0xbfe00000
+
+#define GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR 0xbfe00118
+
+#ifndef ASM_FILE
+#define GRUB_MACHINE_PCI_CONF_CTRL_REG (*(volatile grub_uint32_t *) \
+ GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR)
+#define GRUB_MACHINE_PCI_IO_CTRL_REG (*(volatile grub_uint32_t *) 0xbfe00110)
+#endif
+#define GRUB_MACHINE_PCI_WIN_MASK_SIZE 6
+#define GRUB_MACHINE_PCI_WIN_MASK ((1 << GRUB_MACHINE_PCI_WIN_MASK_SIZE) - 1)
+
+/* We have 3 PCI windows. */
+#define GRUB_MACHINE_PCI_NUM_WIN 3
+/* Each window is 64MiB. */
+#define GRUB_MACHINE_PCI_WIN_SHIFT 26
+#define GRUB_MACHINE_PCI_WIN_OFFSET_MASK ((1 << GRUB_MACHINE_PCI_WIN_SHIFT) - 1)
+
+#define GRUB_MACHINE_PCI_WIN_SIZE 0x04000000
+/* Graphical acceleration takes 1 MiB away. */
+#define GRUB_MACHINE_PCI_WIN1_SIZE 0x03f00000
+
+#define GRUB_MACHINE_PCI_WIN1_ADDR 0xb0000000
+#define GRUB_MACHINE_PCI_WIN2_ADDR 0xb4000000
+#define GRUB_MACHINE_PCI_WIN3_ADDR 0xb8000000
+
+#ifndef ASM_FILE
+static inline grub_uint32_t
+grub_pci_read (grub_pci_address_t addr)
+{
+ GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
+ return *(volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONFSPACE
+ | (addr & 0x03ff));
+}
+
+static inline grub_uint16_t
+grub_pci_read_word (grub_pci_address_t addr)
+{
+ GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
+ return *(volatile grub_uint16_t *) (GRUB_MACHINE_PCI_CONFSPACE
+ | (addr & 0x03ff));
+}
+
+static inline grub_uint8_t
+grub_pci_read_byte (grub_pci_address_t addr)
+{
+ GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
+ return *(volatile grub_uint8_t *) (GRUB_MACHINE_PCI_CONFSPACE
+ | (addr & 0x03ff));
+}
+
+static inline void
+grub_pci_write (grub_pci_address_t addr, grub_uint32_t data)
+{
+ GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
+ *(volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONFSPACE
+ | (addr & 0x03ff)) = data;
+}
+
+static inline void
+grub_pci_write_word (grub_pci_address_t addr, grub_uint16_t data)
+{
+ GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
+ *(volatile grub_uint16_t *) (GRUB_MACHINE_PCI_CONFSPACE
+ | (addr & 0x03ff)) = data;
+}
+
+static inline void
+grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
+{
+ GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
+ *(volatile grub_uint8_t *) (GRUB_MACHINE_PCI_CONFSPACE
+ | (addr & 0x03ff)) = data;
+}
+
+volatile void *
+EXPORT_FUNC (grub_pci_device_map_range) (grub_pci_device_t dev,
+ grub_addr_t base, grub_size_t size);
+void
+EXPORT_FUNC (grub_pci_device_unmap_range) (grub_pci_device_t dev,
+ volatile void *mem,
+ grub_size_t size);
+#endif
+
+#endif /* GRUB_MACHINE_PCI_H */
diff --git a/include/grub/mips/yeeloong/serial.h b/include/grub/mips/yeeloong/serial.h
new file mode 100644
index 0000000..ebe3638
--- /dev/null
+++ b/include/grub/mips/yeeloong/serial.h
@@ -0,0 +1,30 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_MACHINE_SERIAL_HEADER
+#define GRUB_MACHINE_SERIAL_HEADER 1
+
+#define GRUB_MACHINE_SERIAL_DIVISOR_115200 2
+#define GRUB_MACHINE_SERIAL_PORT 0xbff003f8
+
+#ifndef ASM_FILE
+#define GRUB_MACHINE_SERIAL_PORTS { GRUB_MACHINE_SERIAL_PORT }
+#else
+#endif
+
+#endif
diff --git a/include/grub/mips/yeeloong/time.h b/include/grub/mips/yeeloong/time.h
new file mode 100644
index 0000000..7f468bf
--- /dev/null
+++ b/include/grub/mips/yeeloong/time.h
@@ -0,0 +1,37 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,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 KERNEL_MACHINE_TIME_HEADER
+#define KERNEL_MACHINE_TIME_HEADER 1
+
+#include <grub/symbol.h>
+
+#define GRUB_TICKS_PER_SECOND (grub_arch_cpuclock / 2)
+
+/* Return the real time in ticks. */
+grub_uint64_t EXPORT_FUNC (grub_get_rtc) (void);
+
+extern grub_uint32_t EXPORT_VAR (grub_arch_busclock);
+extern grub_uint32_t EXPORT_VAR (grub_arch_cpuclock);
+
+static inline void
+grub_cpu_idle(void)
+{
+}
+
+#endif /* ! KERNEL_MACHINE_TIME_HEADER */
diff --git a/include/grub/misc.h b/include/grub/misc.h
new file mode 100644
index 0000000..80588be
--- /dev/null
+++ b/include/grub/misc.h
@@ -0,0 +1,368 @@
+/* misc.h - prototypes for misc functions */
+/*
+ * 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_MISC_HEADER
+#define GRUB_MISC_HEADER 1
+
+#include <stdarg.h>
+#include <grub/types.h>
+#include <grub/symbol.h>
+#include <grub/err.h>
+
+/* GCC version checking borrowed from glibc. */
+#if defined(__GNUC__) && defined(__GNUC_MINOR__)
+# define GNUC_PREREQ(maj,min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+# define GNUC_PREREQ(maj,min) 0
+#endif
+
+/* Does this compiler support compile-time error attributes? */
+#if GNUC_PREREQ(4,3)
+# define ATTRIBUTE_ERROR(msg) \
+ __attribute__ ((__error__ (msg)))
+#else
+# define ATTRIBUTE_ERROR(msg)
+#endif
+
+#define ALIGN_UP(addr, align) \
+ ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1))
+#define ALIGN_DOWN(addr, align) \
+ ((addr) & ~((typeof (addr)) align - 1))
+#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
+#define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
+
+#define grub_dprintf(condition, fmt, args...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, fmt, ## args)
+/* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
+#define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n))
+
+void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n);
+char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src);
+char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, int c);
+char *EXPORT_FUNC(grub_stpcpy) (char *dest, const char *src);
+
+static inline char *
+grub_strcat (char *dest, const char *src)
+{
+ char *p = dest;
+
+ while (*p)
+ p++;
+
+ while ((*p = *src) != '\0')
+ {
+ p++;
+ src++;
+ }
+
+ return dest;
+}
+
+static inline char *
+grub_strncat (char *dest, const char *src, int c)
+{
+ char *p = dest;
+
+ while (*p)
+ p++;
+
+ while ((*p = *src) != '\0' && c--)
+ {
+ p++;
+ src++;
+ }
+
+ *p = '\0';
+
+ return dest;
+}
+
+/* Prototypes for aliases. */
+#ifndef GRUB_UTIL
+int EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n);
+void *EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n);
+void *EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n);
+void *EXPORT_FUNC(memset) (void *s, int c, grub_size_t n);
+#endif
+
+int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n);
+int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2);
+int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n);
+
+char *EXPORT_FUNC(grub_strchr) (const char *s, int c);
+char *EXPORT_FUNC(grub_strrchr) (const char *s, int c);
+int EXPORT_FUNC(grub_strword) (const char *s, const char *w);
+char *EXPORT_FUNC(grub_strstr) (const char *haystack, const char *needle);
+int EXPORT_FUNC(grub_isspace) (int c);
+int EXPORT_FUNC(grub_isprint) (int c);
+
+static inline int
+grub_iscntrl (int c)
+{
+ return (c >= 0x00 && c <= 0x1F) || c == 0x7F;
+}
+
+static inline int
+grub_isalpha (int c)
+{
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
+}
+
+static inline int
+grub_isgraph (int c)
+{
+ return (c >= '!' && c <= '~');
+}
+
+static inline int
+grub_isdigit (int c)
+{
+ return (c >= '0' && c <= '9');
+}
+
+static inline int
+grub_isalnum (int c)
+{
+ return grub_isalpha (c) || grub_isdigit (c);
+}
+
+static inline int
+grub_tolower (int c)
+{
+ if (c >= 'A' && c <= 'Z')
+ return c - 'A' + 'a';
+
+ return c;
+}
+
+static inline int
+grub_toupper (int c)
+{
+ if (c >= 'a' && c <= 'z')
+ return c - 'a' + 'A';
+
+ return c;
+}
+
+static inline int
+grub_strcasecmp (const char *s1, const char *s2)
+{
+ while (*s1 && *s2)
+ {
+ if (grub_tolower (*s1) != grub_tolower (*s2))
+ break;
+
+ s1++;
+ s2++;
+ }
+
+ return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
+}
+
+static inline int
+grub_strncasecmp (const char *s1, const char *s2, grub_size_t n)
+{
+ if (n == 0)
+ return 0;
+
+ while (*s1 && *s2 && --n)
+ {
+ if (grub_tolower (*s1) != grub_tolower (*s2))
+ break;
+
+ s1++;
+ s2++;
+ }
+
+ return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
+}
+
+/* Replace all `ch' characters of `input' with `with' and copy the
+ result into `output'; return EOS address of `output'. */
+static inline char *
+grub_strchrsub (char *output, const char *input, char ch, const char *with)
+{
+ grub_size_t grub_strlen (const char *s);
+ while (*input)
+ {
+ if (*input == ch)
+ {
+ grub_strcpy (output, with);
+ output += grub_strlen (with);
+ input++;
+ continue;
+ }
+ *output++ = *input++;
+ }
+ *output = '\0';
+ return output;
+}
+
+unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, char **end, int base);
+unsigned long long EXPORT_FUNC(grub_strtoull) (const char *str, char **end, int base);
+
+static inline long
+grub_strtol (const char *str, char **end, int base)
+{
+ int negative = 0;
+ unsigned long magnitude;
+
+ while (*str && grub_isspace (*str))
+ str++;
+
+ if (*str == '-')
+ {
+ negative = 1;
+ str++;
+ }
+
+ magnitude = grub_strtoull (str, end, base);
+ if (negative)
+ {
+ if (magnitude > (unsigned long) GRUB_LONG_MAX + 1)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, "negative overflow");
+ return GRUB_LONG_MIN;
+ }
+ return -((long) magnitude);
+ }
+ else
+ {
+ if (magnitude > GRUB_LONG_MAX)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, "positive overflow");
+ return GRUB_LONG_MAX;
+ }
+ return (long) magnitude;
+ }
+}
+
+char *EXPORT_FUNC(grub_strdup) (const char *s) __attribute__ ((warn_unused_result));
+char *EXPORT_FUNC(grub_strndup) (const char *s, grub_size_t n) __attribute__ ((warn_unused_result));
+void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n);
+grub_size_t EXPORT_FUNC(grub_strlen) (const char *s) __attribute__ ((warn_unused_result));
+int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
+int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
+
+extern void (*EXPORT_VAR (grub_xputs)) (const char *str);
+
+static inline int
+grub_puts (const char *s)
+{
+ const char nl[2] = "\n";
+ grub_xputs (s);
+ grub_xputs (nl);
+
+ return 1; /* Cannot fail. */
+}
+
+int EXPORT_FUNC(grub_puts_) (const char *s);
+void EXPORT_FUNC(grub_real_dprintf) (const char *file,
+ const int line,
+ const char *condition,
+ const char *fmt, ...) __attribute__ ((format (printf, 4, 5)));
+int EXPORT_FUNC(grub_vprintf) (const char *fmt, va_list args);
+int EXPORT_FUNC(grub_snprintf) (char *str, grub_size_t n, const char *fmt, ...)
+ __attribute__ ((format (printf, 3, 4)));
+int EXPORT_FUNC(grub_vsnprintf) (char *str, grub_size_t n, const char *fmt,
+ va_list args);
+char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2))) __attribute__ ((warn_unused_result));
+char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args) __attribute__ ((warn_unused_result));
+void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn));
+void EXPORT_FUNC(grub_abort) (void) __attribute__ ((noreturn));
+grub_uint64_t EXPORT_FUNC(grub_divmod64_full) (grub_uint64_t n,
+ grub_uint64_t d,
+ grub_uint64_t *r);
+static inline grub_uint64_t grub_divmod64 (grub_uint64_t n,
+ grub_uint32_t d,
+ grub_uint32_t *r)
+{
+ grub_uint64_t ret, rr;
+
+ ret = grub_divmod64_full (n, d, &rr);
+ if (r)
+ *r = rr;
+ return ret;
+}
+
+#if NEED_ENABLE_EXECUTE_STACK && !defined(GRUB_UTIL)
+void EXPORT_FUNC(__enable_execute_stack) (void *addr);
+#endif
+
+#if NEED_REGISTER_FRAME_INFO && !defined(GRUB_UTIL)
+void EXPORT_FUNC (__register_frame_info) (void);
+void EXPORT_FUNC (__deregister_frame_info) (void);
+#endif
+
+/* Inline functions. */
+
+static inline unsigned int
+grub_abs (int x)
+{
+ if (x < 0)
+ return (unsigned int) (-x);
+ else
+ return (unsigned int) x;
+}
+
+static inline long
+grub_min (long x, long y)
+{
+ if (x < y)
+ return x;
+ else
+ return y;
+}
+
+static inline long
+grub_max (long x, long y)
+{
+ if (x > y)
+ return x;
+ else
+ return y;
+}
+
+/* Rounded-up division */
+static inline unsigned int
+grub_div_roundup (unsigned int x, unsigned int y)
+{
+ return (x + y - 1) / y;
+}
+
+/* Reboot the machine. */
+void EXPORT_FUNC (grub_reboot) (void) __attribute__ ((noreturn));
+
+#ifdef GRUB_MACHINE_PCBIOS
+/* Halt the system, using APM if possible. If NO_APM is true, don't
+ * use APM even if it is available. */
+void grub_halt (int no_apm) __attribute__ ((noreturn));
+#else
+void grub_halt (void) __attribute__ ((noreturn));
+#endif
+
+#ifdef GRUB_MACHINE_EMU
+/* Flag to control module autoloading in normal mode. */
+extern int EXPORT_VAR(grub_no_autoload);
+#else
+#define grub_no_autoload 0
+#endif
+
+#endif /* ! GRUB_MISC_HEADER */
diff --git a/include/grub/mm.h b/include/grub/mm.h
new file mode 100644
index 0000000..0470069
--- /dev/null
+++ b/include/grub/mm.h
@@ -0,0 +1,75 @@
+/* mm.h - prototypes and declarations for memory manager */
+/*
+ * 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_MM_H
+#define GRUB_MM_H 1
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+#include <config.h>
+
+#ifndef NULL
+# define NULL ((void *) 0)
+#endif
+
+void grub_mm_init_region (void *addr, grub_size_t size);
+void *EXPORT_FUNC(grub_malloc) (grub_size_t size);
+void *EXPORT_FUNC(grub_zalloc) (grub_size_t size);
+void EXPORT_FUNC(grub_free) (void *ptr);
+void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size);
+void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
+
+void grub_mm_check_real (char *file, int line);
+#define grub_mm_check() grub_mm_check_real (GRUB_FILE, __LINE__);
+
+/* For debugging. */
+#if defined(MM_DEBUG) && !defined(GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
+/* Set this variable to 1 when you want to trace all memory function calls. */
+extern int EXPORT_VAR(grub_mm_debug);
+
+void grub_mm_dump_free (void);
+void grub_mm_dump (unsigned lineno);
+
+#define grub_malloc(size) \
+ grub_debug_malloc (GRUB_FILE, __LINE__, size)
+
+#define grub_zalloc(size) \
+ grub_debug_zalloc (GRUB_FILE, __LINE__, size)
+
+#define grub_realloc(ptr,size) \
+ grub_debug_realloc (GRUB_FILE, __LINE__, ptr, size)
+
+#define grub_memalign(align,size) \
+ grub_debug_memalign (GRUB_FILE, __LINE__, align, size)
+
+#define grub_free(ptr) \
+ grub_debug_free (GRUB_FILE, __LINE__, ptr)
+
+void *EXPORT_FUNC(grub_debug_malloc) (const char *file, int line,
+ grub_size_t size);
+void *EXPORT_FUNC(grub_debug_zalloc) (const char *file, int line,
+ grub_size_t size);
+void EXPORT_FUNC(grub_debug_free) (const char *file, int line, void *ptr);
+void *EXPORT_FUNC(grub_debug_realloc) (const char *file, int line, void *ptr,
+ grub_size_t size);
+void *EXPORT_FUNC(grub_debug_memalign) (const char *file, int line,
+ grub_size_t align, grub_size_t size);
+#endif /* MM_DEBUG && ! GRUB_UTIL */
+
+#endif /* ! GRUB_MM_H */
diff --git a/include/grub/mm_private.h b/include/grub/mm_private.h
new file mode 100644
index 0000000..c2c4cb1
--- /dev/null
+++ b/include/grub/mm_private.h
@@ -0,0 +1,64 @@
+/*
+ * 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_MM_PRIVATE_H
+#define GRUB_MM_PRIVATE_H 1
+
+#include <grub/mm.h>
+
+/* Magic words. */
+#define GRUB_MM_FREE_MAGIC 0x2d3c2808
+#define GRUB_MM_ALLOC_MAGIC 0x6db08fa4
+
+typedef struct grub_mm_header
+{
+ struct grub_mm_header *next;
+ grub_size_t size;
+ grub_size_t magic;
+#if GRUB_CPU_SIZEOF_VOID_P == 4
+ char padding[4];
+#elif GRUB_CPU_SIZEOF_VOID_P == 8
+ char padding[8];
+#else
+# error "unknown word size"
+#endif
+}
+*grub_mm_header_t;
+
+#if GRUB_CPU_SIZEOF_VOID_P == 4
+# define GRUB_MM_ALIGN_LOG2 4
+#elif GRUB_CPU_SIZEOF_VOID_P == 8
+# define GRUB_MM_ALIGN_LOG2 5
+#endif
+
+#define GRUB_MM_ALIGN (1 << GRUB_MM_ALIGN_LOG2)
+
+typedef struct grub_mm_region
+{
+ struct grub_mm_header *first;
+ struct grub_mm_region *next;
+ grub_size_t pre_size;
+ grub_size_t size;
+}
+*grub_mm_region_t;
+
+#ifndef GRUB_MACHINE_EMU
+extern grub_mm_region_t EXPORT_VAR (grub_mm_base);
+#endif
+
+#endif
diff --git a/include/grub/msdos_partition.h b/include/grub/msdos_partition.h
new file mode 100644
index 0000000..a6e3fda
--- /dev/null
+++ b/include/grub/msdos_partition.h
@@ -0,0 +1,124 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2004,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_PC_PARTITION_HEADER
+#define GRUB_PC_PARTITION_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/disk.h>
+#include <grub/partition.h>
+
+/* The signature. */
+#define GRUB_PC_PARTITION_SIGNATURE 0xaa55
+
+/* This is not a flag actually, but used as if it were a flag. */
+#define GRUB_PC_PARTITION_TYPE_HIDDEN_FLAG 0x10
+
+/* DOS partition types. */
+#define GRUB_PC_PARTITION_TYPE_NONE 0
+#define GRUB_PC_PARTITION_TYPE_FAT12 1
+#define GRUB_PC_PARTITION_TYPE_FAT16_LT32M 4
+#define GRUB_PC_PARTITION_TYPE_EXTENDED 5
+#define GRUB_PC_PARTITION_TYPE_FAT16_GT32M 6
+#define GRUB_PC_PARTITION_TYPE_NTFS 7
+#define GRUB_PC_PARTITION_TYPE_FAT32 0xb
+#define GRUB_PC_PARTITION_TYPE_FAT32_LBA 0xc
+#define GRUB_PC_PARTITION_TYPE_FAT16_LBA 0xe
+#define GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED 0xf
+#define GRUB_PC_PARTITION_TYPE_EZD 0x55
+#define GRUB_PC_PARTITION_TYPE_MINIX 0x80
+#define GRUB_PC_PARTITION_TYPE_LINUX_MINIX 0x81
+#define GRUB_PC_PARTITION_TYPE_EXT2FS 0x83
+#define GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED 0x85
+#define GRUB_PC_PARTITION_TYPE_VSTAFS 0x9e
+#define GRUB_PC_PARTITION_TYPE_FREEBSD 0xa5
+#define GRUB_PC_PARTITION_TYPE_OPENBSD 0xa6
+#define GRUB_PC_PARTITION_TYPE_NETBSD 0xa9
+#define GRUB_PC_PARTITION_TYPE_HFS 0xaf
+#define GRUB_PC_PARTITION_TYPE_GPT_DISK 0xee
+#define GRUB_PC_PARTITION_TYPE_LINUX_RAID 0xfd
+
+/* The partition entry. */
+struct grub_msdos_partition_entry
+{
+ /* If active, 0x80, otherwise, 0x00. */
+ grub_uint8_t flag;
+
+ /* The head of the start. */
+ grub_uint8_t start_head;
+
+ /* (S | ((C >> 2) & 0xC0)) where S is the sector of the start and C
+ is the cylinder of the start. Note that S is counted from one. */
+ grub_uint8_t start_sector;
+
+ /* (C & 0xFF) where C is the cylinder of the start. */
+ grub_uint8_t start_cylinder;
+
+ /* The partition type. */
+ grub_uint8_t type;
+
+ /* The end versions of start_head, start_sector and start_cylinder,
+ respectively. */
+ grub_uint8_t end_head;
+ grub_uint8_t end_sector;
+ grub_uint8_t end_cylinder;
+
+ /* The start sector. Note that this is counted from zero. */
+ grub_uint32_t start;
+
+ /* The length in sector units. */
+ grub_uint32_t length;
+} __attribute__ ((packed));
+
+/* The structure of MBR. */
+struct grub_msdos_partition_mbr
+{
+ /* The code area (actually, including BPB). */
+ grub_uint8_t code[446];
+
+ /* Four partition entries. */
+ struct grub_msdos_partition_entry entries[4];
+
+ /* The signature 0xaa55. */
+ grub_uint16_t signature;
+} __attribute__ ((packed));
+
+
+
+static inline int
+grub_msdos_partition_is_empty (int type)
+{
+ return (type == GRUB_PC_PARTITION_TYPE_NONE);
+}
+
+static inline int
+grub_msdos_partition_is_extended (int type)
+{
+ return (type == GRUB_PC_PARTITION_TYPE_EXTENDED
+ || type == GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED
+ || type == GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED);
+}
+
+grub_err_t
+grub_partition_msdos_iterate (grub_disk_t disk,
+ int (*hook) (grub_disk_t disk,
+ const grub_partition_t partition));
+
+#endif /* ! GRUB_PC_PARTITION_HEADER */
diff --git a/include/grub/multiboot.h b/include/grub/multiboot.h
new file mode 100644
index 0000000..9a0b573
--- /dev/null
+++ b/include/grub/multiboot.h
@@ -0,0 +1,92 @@
+/* multiboot.h - multiboot header file with grub definitions. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2007,2008,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_MULTIBOOT_HEADER
+#define GRUB_MULTIBOOT_HEADER 1
+
+#include <grub/file.h>
+
+#ifdef GRUB_USE_MULTIBOOT2
+#include <multiboot2.h>
+/* Same thing as far as our loader is concerned. */
+#define MULTIBOOT_BOOTLOADER_MAGIC MULTIBOOT2_BOOTLOADER_MAGIC
+#define MULTIBOOT_HEADER_MAGIC MULTIBOOT2_HEADER_MAGIC
+#else
+#include <multiboot.h>
+#endif
+
+#include <grub/types.h>
+#include <grub/err.h>
+
+extern struct grub_relocator *grub_multiboot_relocator;
+
+void grub_multiboot (int argc, char *argv[]);
+void grub_module (int argc, char *argv[]);
+
+void grub_multiboot_set_accepts_video (int val);
+grub_err_t grub_multiboot_make_mbi (grub_uint32_t *target);
+void grub_multiboot_free_mbi (void);
+grub_err_t grub_multiboot_init_mbi (int argc, char *argv[]);
+grub_err_t grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
+ int argc, char *argv[]);
+void grub_multiboot_set_bootdev (void);
+void
+grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize,
+ unsigned shndx, void *data);
+
+grub_uint32_t grub_get_multiboot_mmap_count (void);
+grub_err_t grub_multiboot_set_video_mode (void);
+
+/* FIXME: support coreboot as well. */
+#if defined (GRUB_MACHINE_PCBIOS)
+#define GRUB_MACHINE_HAS_VBE 1
+#else
+#define GRUB_MACHINE_HAS_VBE 0
+#endif
+
+#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU)
+#define GRUB_MACHINE_HAS_VGA_TEXT 1
+#else
+#define GRUB_MACHINE_HAS_VGA_TEXT 0
+#endif
+
+#if defined (GRUB_MACHINE_EFI) || defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT)
+#define GRUB_MACHINE_HAS_ACPI 1
+#else
+#define GRUB_MACHINE_HAS_ACPI 0
+#endif
+
+#define GRUB_MULTIBOOT_CONSOLE_EGA_TEXT 1
+#define GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER 2
+
+grub_err_t
+grub_multiboot_set_console (int console_type, int accepted_consoles,
+ int width, int height, int depth,
+ int console_required);
+grub_err_t
+grub_multiboot_load (grub_file_t file);
+/* Load ELF32 or ELF64. */
+grub_err_t
+grub_multiboot_load_elf (grub_file_t file, void *buffer);
+extern grub_size_t grub_multiboot_pure_size;
+extern grub_size_t grub_multiboot_alloc_mbi;
+extern grub_uint32_t grub_multiboot_payload_eip;
+
+
+#endif /* ! GRUB_MULTIBOOT_HEADER */
diff --git a/include/grub/multiboot_loader.h b/include/grub/multiboot_loader.h
new file mode 100644
index 0000000..bf1c130
--- /dev/null
+++ b/include/grub/multiboot_loader.h
@@ -0,0 +1,28 @@
+/* multiboot_loader.h - multiboot loader header file. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,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_MULTIBOOT_LOADER_HEADER
+#define GRUB_MULTIBOOT_LOADER_HEADER 1
+
+/* Provided by the core ("rescue mode"). */
+void grub_rescue_cmd_multiboot_loader (int argc, char *argv[]);
+void grub_rescue_cmd_module_loader (int argc, char *argv[]);
+
+#endif /* ! GRUB_MULTIBOOT_LOADER_HEADER */
diff --git a/include/grub/net.h b/include/grub/net.h
new file mode 100644
index 0000000..c6d71d5
--- /dev/null
+++ b/include/grub/net.h
@@ -0,0 +1,72 @@
+/*
+ * 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_NET_HEADER
+#define GRUB_NET_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/err.h>
+#include <grub/types.h>
+
+struct grub_net;
+
+struct grub_net_dev
+{
+ /* The device name. */
+ const char *name;
+
+ /* FIXME: Just a template. */
+ int (*probe) (struct grub_net *net, const void *addr);
+ void (*reset) (struct grub_net *net);
+ int (*poll) (struct grub_net *net);
+ void (*transmit) (struct grub_net *net, const void *destip,
+ unsigned srcsock, unsigned destsock, const void *packet);
+ void (*disable) (struct grub_net *net);
+
+ /* The next net device. */
+ struct grub_net_dev *next;
+};
+typedef struct grub_net_dev *grub_net_dev_t;
+
+struct grub_fs;
+
+struct grub_net
+{
+ /* The net name. */
+ const char *name;
+
+ /* The underlying disk device. */
+ grub_net_dev_t dev;
+
+ /* The binding filesystem. */
+ struct grub_fs *fs;
+
+ /* FIXME: More data would be required, such as an IP address, a mask,
+ a gateway, etc. */
+
+ /* Device-specific data. */
+ void *data;
+};
+typedef struct grub_net *grub_net_t;
+
+/* FIXME: How to abstract networks? More consideration is necessary. */
+
+/* Note: Networks are very different from disks, because networks must
+ be initialized before used, and the status is persistent. */
+
+#endif /* ! GRUB_NET_HEADER */
diff --git a/include/grub/normal.h b/include/grub/normal.h
new file mode 100644
index 0000000..08c14d2
--- /dev/null
+++ b/include/grub/normal.h
@@ -0,0 +1,138 @@
+/* normal.h - prototypes for the normal mode */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,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_NORMAL_HEADER
+#define GRUB_NORMAL_HEADER 1
+
+#include <grub/term.h>
+#include <grub/symbol.h>
+#include <grub/err.h>
+#include <grub/env.h>
+#include <grub/menu.h>
+#include <grub/command.h>
+#include <grub/file.h>
+
+/* The maximum size of a command-line. */
+#define GRUB_MAX_CMDLINE 1600
+
+/* The standard left and right margin for some messages. */
+#define STANDARD_MARGIN 6
+
+/* The type of a completion item. */
+enum grub_completion_type
+ {
+ GRUB_COMPLETION_TYPE_COMMAND,
+ GRUB_COMPLETION_TYPE_DEVICE,
+ GRUB_COMPLETION_TYPE_PARTITION,
+ GRUB_COMPLETION_TYPE_FILE,
+ GRUB_COMPLETION_TYPE_ARGUMENT
+ };
+typedef enum grub_completion_type grub_completion_type_t;
+
+extern struct grub_menu_viewer grub_normal_text_menu_viewer;
+extern int grub_normal_exit_level;
+
+/* Defined in `main.c'. */
+void grub_enter_normal_mode (const char *config);
+void grub_normal_execute (const char *config, int nested, int batch);
+void grub_menu_init_page (int nested, int edit, int *num_entries,
+ struct grub_term_output *term);
+void grub_normal_init_page (struct grub_term_output *term);
+char *grub_file_getline (grub_file_t file);
+void grub_cmdline_run (int nested);
+
+/* Defined in `cmdline.c'. */
+char *grub_cmdline_get (const char *prompt);
+grub_err_t grub_set_history (int newsize);
+
+/* Defined in `completion.c'. */
+char *grub_normal_do_completion (char *buf, int *restore,
+ void (*hook) (const char *item, grub_completion_type_t type, int count));
+
+/* Defined in `misc.c'. */
+grub_err_t grub_normal_print_device_info (const char *name);
+
+/* Defined in `color.c'. */
+char *grub_env_write_color_normal (struct grub_env_var *var, const char *val);
+char *grub_env_write_color_highlight (struct grub_env_var *var, const char *val);
+int grub_parse_color_name_pair (grub_uint8_t *ret, const char *name);
+
+/* Defined in `menu_text.c'. */
+void grub_wait_after_message (void);
+void
+grub_print_ucs4 (const grub_uint32_t * str,
+ const grub_uint32_t * last_position,
+ int margin_left, int margin_right,
+ struct grub_term_output *term);
+int
+grub_ucs4_count_lines (const grub_uint32_t * str,
+ const grub_uint32_t * last_position,
+ int margin_left, int margin_right,
+ struct grub_term_output *term);
+grub_ssize_t grub_getstringwidth (grub_uint32_t * str,
+ const grub_uint32_t * last_position,
+ struct grub_term_output *term);
+void grub_print_message_indented (const char *msg, int margin_left,
+ int margin_right,
+ struct grub_term_output *term);
+void
+grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested);
+grub_err_t
+grub_show_menu (grub_menu_t menu, int nested, int autobooted);
+
+/* Defined in `handler.c'. */
+void read_handler_list (void);
+void free_handler_list (void);
+
+/* Defined in `dyncmd.c'. */
+void read_command_list (const char *prefix);
+
+/* Defined in `autofs.c'. */
+void read_fs_list (const char *prefix);
+
+void grub_context_init (void);
+void grub_context_fini (void);
+
+void read_crypto_list (const char *prefix);
+
+void read_terminal_list (const char *prefix);
+
+void grub_set_more (int onoff);
+
+void grub_normal_reset_more (void);
+
+void grub_xputs_normal (const char *str);
+
+extern int grub_extractor_level;
+
+grub_err_t
+grub_normal_add_menu_entry (int argc, const char **args, char **classes,
+ const char *users, const char *hotkey,
+ const char *prefix, const char *sourcecode,
+ int submenu);
+
+grub_err_t
+grub_normal_set_password (const char *user, const char *password);
+
+void grub_normal_free_menu (grub_menu_t menu);
+
+void grub_normal_auth_init (void);
+void grub_normal_auth_fini (void);
+
+#endif /* ! GRUB_NORMAL_HEADER */
diff --git a/include/grub/ns8250.h b/include/grub/ns8250.h
new file mode 100644
index 0000000..7947ba9
--- /dev/null
+++ b/include/grub/ns8250.h
@@ -0,0 +1,80 @@
+/* serial.h - serial device interface */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2000,2001,2002,2005,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_NS8250_HEADER
+#define GRUB_NS8250_HEADER 1
+
+/* Macros. */
+
+/* The offsets of UART registers. */
+#define UART_TX 0
+#define UART_RX 0
+#define UART_DLL 0
+#define UART_IER 1
+#define UART_DLH 1
+#define UART_IIR 2
+#define UART_FCR 2
+#define UART_LCR 3
+#define UART_MCR 4
+#define UART_LSR 5
+#define UART_MSR 6
+#define UART_SR 7
+
+/* For LSR bits. */
+#define UART_DATA_READY 0x01
+#define UART_EMPTY_TRANSMITTER 0x20
+
+/* The type of parity. */
+#define UART_NO_PARITY 0x00
+#define UART_ODD_PARITY 0x08
+#define UART_EVEN_PARITY 0x18
+
+/* The type of word length. */
+#define UART_5BITS_WORD 0x00
+#define UART_6BITS_WORD 0x01
+#define UART_7BITS_WORD 0x02
+#define UART_8BITS_WORD 0x03
+
+/* The type of the length of stop bit. */
+#define UART_1_STOP_BIT 0x00
+#define UART_2_STOP_BITS 0x04
+
+/* the switch of DLAB. */
+#define UART_DLAB 0x80
+
+/* Enable the FIFO. */
+#define UART_ENABLE_FIFO_TRIGGER14 0xC7
+
+/* Enable the FIFO. */
+#define UART_ENABLE_FIFO_TRIGGER1 0x07
+
+/* Turn on DTR, RTS, and OUT2. */
+#define UART_ENABLE_DTRRTS 0x03
+
+/* Turn on DTR, RTS, and OUT2. */
+#define UART_ENABLE_OUT2 0x08
+
+#ifndef ASM_FILE
+#include <grub/cpu/io.h>
+
+grub_port_t
+grub_ns8250_hw_get_port (const unsigned int unit);
+#endif
+
+#endif /* ! GRUB_SERIAL_MACHINE_HEADER */
diff --git a/include/grub/ntfs.h b/include/grub/ntfs.h
new file mode 100644
index 0000000..31b9939
--- /dev/null
+++ b/include/grub/ntfs.h
@@ -0,0 +1,183 @@
+/* ntfs.h - header for the NTFS filesystem */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007,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_NTFS_H
+#define GRUB_NTFS_H 1
+
+#define FILE_MFT 0
+#define FILE_MFTMIRR 1
+#define FILE_LOGFILE 2
+#define FILE_VOLUME 3
+#define FILE_ATTRDEF 4
+#define FILE_ROOT 5
+#define FILE_BITMAP 6
+#define FILE_BOOT 7
+#define FILE_BADCLUS 8
+#define FILE_QUOTA 9
+#define FILE_UPCASE 10
+
+#define AT_STANDARD_INFORMATION 0x10
+#define AT_ATTRIBUTE_LIST 0x20
+#define AT_FILENAME 0x30
+#define AT_OBJECT_ID 0x40
+#define AT_SECURITY_DESCRIPTOR 0x50
+#define AT_VOLUME_NAME 0x60
+#define AT_VOLUME_INFORMATION 0x70
+#define AT_DATA 0x80
+#define AT_INDEX_ROOT 0x90
+#define AT_INDEX_ALLOCATION 0xA0
+#define AT_BITMAP 0xB0
+#define AT_SYMLINK 0xC0
+#define AT_EA_INFORMATION 0xD0
+#define AT_EA 0xE0
+
+#define ATTR_READ_ONLY 0x1
+#define ATTR_HIDDEN 0x2
+#define ATTR_SYSTEM 0x4
+#define ATTR_ARCHIVE 0x20
+#define ATTR_DEVICE 0x40
+#define ATTR_NORMAL 0x80
+#define ATTR_TEMPORARY 0x100
+#define ATTR_SPARSE 0x200
+#define ATTR_REPARSE 0x400
+#define ATTR_COMPRESSED 0x800
+#define ATTR_OFFLINE 0x1000
+#define ATTR_NOT_INDEXED 0x2000
+#define ATTR_ENCRYPTED 0x4000
+#define ATTR_DIRECTORY 0x10000000
+#define ATTR_INDEX_VIEW 0x20000000
+
+#define FLAG_COMPRESSED 1
+#define FLAG_ENCRYPTED 0x4000
+#define FLAG_SPARSE 0x8000
+
+#define BLK_SHR GRUB_DISK_SECTOR_BITS
+
+#define MAX_MFT (1024 >> BLK_SHR)
+#define MAX_IDX (16384 >> BLK_SHR)
+
+#define COM_LEN 4096
+#define COM_LOG_LEN 12
+#define COM_SEC (COM_LEN >> BLK_SHR)
+
+#define AF_ALST 1
+#define AF_MMFT 2
+#define AF_GPOS 4
+
+#define RF_COMP 1
+#define RF_CBLK 2
+#define RF_BLNK 4
+
+#define valueat(buf,ofs,type) *((type*)(((char*)buf)+ofs))
+
+#define u16at(buf,ofs) grub_le_to_cpu16(valueat(buf,ofs,grub_uint16_t))
+#define u32at(buf,ofs) grub_le_to_cpu32(valueat(buf,ofs,grub_uint32_t))
+#define u64at(buf,ofs) grub_le_to_cpu64(valueat(buf,ofs,grub_uint64_t))
+
+#define v16at(buf,ofs) valueat(buf,ofs,grub_uint16_t)
+#define v32at(buf,ofs) valueat(buf,ofs,grub_uint32_t)
+#define v64at(buf,ofs) valueat(buf,ofs,grub_uint64_t)
+
+struct grub_ntfs_bpb
+{
+ grub_uint8_t jmp_boot[3];
+ grub_uint8_t oem_name[8];
+ grub_uint16_t bytes_per_sector;
+ grub_uint8_t sectors_per_cluster;
+ grub_uint8_t reserved_1[7];
+ grub_uint8_t media;
+ grub_uint16_t reserved_2;
+ grub_uint16_t sectors_per_track;
+ grub_uint16_t num_heads;
+ grub_uint32_t num_hidden_sectors;
+ grub_uint32_t reserved_3[2];
+ grub_uint64_t num_total_sectors;
+ grub_uint64_t mft_lcn;
+ grub_uint64_t mft_mirr_lcn;
+ grub_int8_t clusters_per_mft;
+ grub_int8_t reserved_4[3];
+ grub_int8_t clusters_per_index;
+ grub_int8_t reserved_5[3];
+ grub_uint64_t num_serial;
+ grub_uint32_t checksum;
+} __attribute__ ((packed));
+
+#define grub_ntfs_file grub_fshelp_node
+
+struct grub_ntfs_attr
+{
+ int flags;
+ char *emft_buf, *edat_buf;
+ char *attr_cur, *attr_nxt, *attr_end;
+ grub_uint32_t save_pos;
+ char *sbuf;
+ struct grub_ntfs_file *mft;
+};
+
+struct grub_fshelp_node
+{
+ struct grub_ntfs_data *data;
+ char *buf;
+ grub_uint64_t size;
+ grub_uint32_t ino;
+ int inode_read;
+ struct grub_ntfs_attr attr;
+};
+
+struct grub_ntfs_data
+{
+ struct grub_ntfs_file cmft;
+ struct grub_ntfs_file mmft;
+ grub_disk_t disk;
+ grub_uint32_t mft_size;
+ grub_uint32_t idx_size;
+ grub_uint32_t spc;
+ grub_uint32_t blocksize;
+ grub_uint32_t mft_start;
+ grub_uint64_t uuid;
+};
+
+struct grub_ntfs_comp
+{
+ grub_disk_t disk;
+ int comp_head, comp_tail;
+ grub_uint32_t comp_table[16][2];
+ grub_uint32_t cbuf_ofs, cbuf_vcn, spc;
+ char *cbuf;
+};
+
+struct grub_ntfs_rlst
+{
+ int flags;
+ grub_disk_addr_t target_vcn, curr_vcn, next_vcn, curr_lcn;
+ char *cur_run;
+ struct grub_ntfs_attr *attr;
+ struct grub_ntfs_comp comp;
+};
+
+typedef grub_err_t (*ntfscomp_func_t) (struct grub_ntfs_attr * at, char *dest,
+ grub_uint32_t ofs, grub_uint32_t len,
+ struct grub_ntfs_rlst * ctx,
+ grub_uint32_t vcn);
+
+extern ntfscomp_func_t EXPORT_VAR (grub_ntfscomp_func);
+
+grub_err_t EXPORT_FUNC(grub_ntfs_read_run_list) (struct grub_ntfs_rlst *ctx);
+
+#endif /* ! GRUB_NTFS_H */
diff --git a/include/grub/offsets.h b/include/grub/offsets.h
new file mode 100644
index 0000000..31deb50
--- /dev/null
+++ b/include/grub/offsets.h
@@ -0,0 +1,182 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2007,2008 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 OFFSETS_HEADER
+#define OFFSETS_HEADER 1
+
+/* The offset of GRUB_TOTAL_MODULE_SIZE. */
+#define GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE 0x8
+
+/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
+#define GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE 0xc
+
+/* The offset of GRUB_COMPRESSED_SIZE. */
+#define GRUB_KERNEL_I386_PC_COMPRESSED_SIZE 0x10
+
+/* The offset of GRUB_INSTALL_DOS_PART. */
+#define GRUB_KERNEL_I386_PC_INSTALL_DOS_PART 0x14
+
+/* The offset of GRUB_INSTALL_BSD_PART. */
+#define GRUB_KERNEL_I386_PC_INSTALL_BSD_PART 0x18
+
+/* Offset of reed_solomon_redundancy. */
+#define GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY 0x1c
+
+/* The size of the first region which won't be compressed. */
+#define GRUB_KERNEL_I386_PC_RAW_SIZE 0xcd0
+
+#define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x730
+
+/* The offset of GRUB_PREFIX. */
+#define GRUB_KERNEL_I386_PC_PREFIX GRUB_KERNEL_I386_PC_RAW_SIZE
+
+/* End of the data section. */
+#define GRUB_KERNEL_I386_PC_PREFIX_END (GRUB_KERNEL_I386_PC_PREFIX + 0x40)
+
+/* The segment where the kernel is loaded. */
+#define GRUB_BOOT_I386_PC_KERNEL_SEG 0x800
+
+#define GRUB_KERNEL_I386_PC_LINK_ADDR 0x8200
+
+/* The upper memory area (starting at 640 kiB). */
+#define GRUB_MEMORY_I386_PC_UPPER 0xa0000
+#define GRUB_MEMORY_I386_QEMU_UPPER GRUB_MEMORY_I386_PC_UPPER
+
+/* The offset of GRUB_CORE_ENTRY_ADDR. */
+#define GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR 0x4
+
+/* The offset of GRUB_CORE_ENTRY_ADDR. */
+#define GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR 0x8
+
+/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
+#define GRUB_KERNEL_I386_QEMU_KERNEL_IMAGE_SIZE 0xc
+
+/* The offset of GRUB_PREFIX. */
+#define GRUB_KERNEL_I386_QEMU_PREFIX 0x10
+
+/* End of the data section. */
+#define GRUB_KERNEL_I386_QEMU_PREFIX_END 0x50
+
+#define GRUB_KERNEL_I386_QEMU_LINK_ADDR 0x8200
+
+/* The offset of GRUB_TOTAL_MODULE_SIZE. */
+#define GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE 0x8
+
+/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
+#define GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE 0xc
+
+/* The offset of GRUB_COMPRESSED_SIZE. */
+#define GRUB_KERNEL_SPARC64_IEEE1275_COMPRESSED_SIZE 0x10
+
+/* The offset of GRUB_PREFIX. */
+#define GRUB_KERNEL_SPARC64_IEEE1275_PREFIX 0x14
+
+/* End of the data section. */
+#define GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END 0x114
+
+#define GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE 12
+
+#define GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS 0x4400
+#define GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE 0
+#define GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR 0x4400
+
+#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX 0x4
+#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX_END 0x44
+#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
+#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR 0x200000
+
+#define GRUB_KERNEL_MIPS_YEELOONG_LINK_ADDR 0x80200000
+
+#define GRUB_KERNEL_MIPS_YEELOONG_LINK_ALIGN 32
+
+#define GRUB_KERNEL_MIPS_YEELOONG_COMPRESSED_SIZE 0x8
+#define GRUB_KERNEL_MIPS_YEELOONG_UNCOMPRESSED_SIZE 0xc
+
+#define GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE 0x08
+#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX 0x0c
+#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX_END 0x54
+
+/* The offset of GRUB_PREFIX. */
+#define GRUB_KERNEL_I386_EFI_PREFIX 0x8
+
+/* End of the data section. */
+#define GRUB_KERNEL_I386_EFI_PREFIX_END 0x50
+
+/* The offset of GRUB_PREFIX. */
+#define GRUB_KERNEL_X86_64_EFI_PREFIX 0x8
+
+/* End of the data section. */
+#define GRUB_KERNEL_X86_64_EFI_PREFIX_END 0x50
+
+#define GRUB_KERNEL_I386_COREBOOT_PREFIX 0x2
+#define GRUB_KERNEL_I386_COREBOOT_PREFIX_END 0x42
+#define GRUB_KERNEL_I386_COREBOOT_LINK_ADDR 0x8200
+
+#define GRUB_KERNEL_I386_MULTIBOOT_PREFIX GRUB_KERNEL_I386_COREBOOT_PREFIX
+#define GRUB_KERNEL_I386_MULTIBOOT_PREFIX_END GRUB_KERNEL_I386_COREBOOT_PREFIX_END
+
+#define GRUB_KERNEL_I386_IEEE1275_PREFIX 0x2
+#define GRUB_KERNEL_I386_IEEE1275_PREFIX_END 0x42
+#define GRUB_KERNEL_I386_IEEE1275_LINK_ADDR 0x10000
+
+#define GRUB_KERNEL_I386_IEEE1275_MOD_ALIGN 0x1000
+#define GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN 0x1
+#define GRUB_KERNEL_I386_MULTIBOOT_MOD_ALIGN GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN
+
+/* Non-zero value is only needed for PowerMacs. */
+#define GRUB_KERNEL_I386_IEEE1275_MOD_GAP 0x0
+#define GRUB_KERNEL_I386_COREBOOT_MOD_GAP 0x0
+
+#define GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN 0x1000
+
+#define GRUB_KERNEL_MIPS_YEELOONG_MOD_ALIGN 0x1
+
+/* Minimal gap between _end and the start of the modules. It's a hack
+ for PowerMac to prevent "CLAIM failed" error. The real fix is to
+ rewrite grub-mkimage to generate valid ELF files. */
+#define GRUB_KERNEL_POWERPC_IEEE1275_MOD_GAP 0x8000
+
+#ifdef GRUB_MACHINE
+#define GRUB_OFFSETS_CONCAT_(a,b,c) a ## b ## c
+#define GRUB_OFFSETS_CONCAT(a,b,c) GRUB_OFFSETS_CONCAT_(a,b,c)
+#define GRUB_KERNEL_MACHINE_MOD_ALIGN GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _MOD_ALIGN)
+#define GRUB_KERNEL_MACHINE_MOD_GAP GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _MOD_GAP)
+#define GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _TOTAL_MODULE_SIZE)
+#define GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _KERNEL_IMAGE_SIZE)
+#define GRUB_KERNEL_MACHINE_COMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _COMPRESSED_SIZE)
+#define GRUB_KERNEL_MACHINE_UNCOMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _UNCOMPRESSED_SIZE)
+
+#define GRUB_KERNEL_MACHINE_PREFIX GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _PREFIX)
+#define GRUB_KERNEL_MACHINE_PREFIX_END GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _PREFIX_END)
+#define GRUB_BOOT_MACHINE_KERNEL_SEG GRUB_OFFSETS_CONCAT (GRUB_BOOT_, GRUB_MACHINE, _KERNEL_SEG)
+#define GRUB_MEMORY_MACHINE_UPPER GRUB_OFFSETS_CONCAT (GRUB_MEMORY_, GRUB_MACHINE, _UPPER)
+#define GRUB_KERNEL_MACHINE_RAW_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _RAW_SIZE)
+#define GRUB_KERNEL_MACHINE_INSTALL_BSD_PART GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _INSTALL_BSD_PART)
+#define GRUB_KERNEL_MACHINE_INSTALL_DOS_PART GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _INSTALL_DOS_PART)
+#endif
+
+#ifndef ASM_FILE
+struct grub_pc_bios_boot_blocklist
+{
+ grub_uint64_t start;
+ grub_uint16_t len;
+ grub_uint16_t segment;
+} __attribute__ ((packed));
+#endif
+
+#endif
diff --git a/include/grub/parser.h b/include/grub/parser.h
new file mode 100644
index 0000000..de4da05
--- /dev/null
+++ b/include/grub/parser.h
@@ -0,0 +1,91 @@
+/* parser.h - prototypes for the command line parser. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,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_PARSER_HEADER
+#define GRUB_PARSER_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/reader.h>
+
+/* All the states for the command line. */
+typedef enum
+ {
+ GRUB_PARSER_STATE_TEXT = 1,
+ GRUB_PARSER_STATE_ESC,
+ GRUB_PARSER_STATE_QUOTE,
+ GRUB_PARSER_STATE_DQUOTE,
+ GRUB_PARSER_STATE_VAR,
+ GRUB_PARSER_STATE_VARNAME,
+ GRUB_PARSER_STATE_VARNAME2,
+ GRUB_PARSER_STATE_QVAR,
+ GRUB_PARSER_STATE_QVARNAME,
+ GRUB_PARSER_STATE_QVARNAME2
+ } grub_parser_state_t;
+
+/* A single state transition. */
+struct grub_parser_state_transition
+{
+ /* The state that is looked up. */
+ grub_parser_state_t from_state;
+
+ /* The next state, determined by FROM_STATE and INPUT. */
+ grub_parser_state_t to_state;
+
+ /* The input that will determine the next state from FROM_STATE. */
+ char input;
+
+ /* If set to 1, the input is valid and should be used. */
+ int keep_value;
+};
+
+/* Determines the state following STATE, determined by C. */
+grub_parser_state_t
+EXPORT_FUNC (grub_parser_cmdline_state) (grub_parser_state_t state,
+ char c, char *result);
+
+grub_err_t
+EXPORT_FUNC (grub_parser_split_cmdline) (const char *cmdline,
+ grub_reader_getline_t getline,
+ int *argc, char ***argv);
+
+struct grub_parser
+{
+ /* The next parser. */
+ struct grub_parser *next;
+
+ /* The parser name. */
+ const char *name;
+
+ /* Initialize the parser. */
+ grub_err_t (*init) (void);
+
+ /* Clean up the parser. */
+ grub_err_t (*fini) (void);
+
+ grub_err_t (*parse_line) (char *line, grub_reader_getline_t getline);
+};
+typedef struct grub_parser *grub_parser_t;
+
+grub_err_t grub_parser_execute (char *source);
+
+grub_err_t
+grub_rescue_parse_line (char *line, grub_reader_getline_t getline);
+
+#endif /* ! GRUB_PARSER_HEADER */
diff --git a/include/grub/partition.h b/include/grub/partition.h
new file mode 100644
index 0000000..e7e00ef
--- /dev/null
+++ b/include/grub/partition.h
@@ -0,0 +1,134 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2004,2006,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_PART_HEADER
+#define GRUB_PART_HEADER 1
+
+#include <grub/dl.h>
+#include <grub/list.h>
+
+struct grub_disk;
+
+typedef struct grub_partition *grub_partition_t;
+
+#ifdef GRUB_UTIL
+typedef enum
+{
+ GRUB_EMBED_PCBIOS
+} grub_embed_type_t;
+#endif
+
+/* Partition map type. */
+struct grub_partition_map
+{
+ /* The next partition map type. */
+ struct grub_partition_map *next;
+
+ /* The name of the partition map type. */
+ const char *name;
+
+ /* Call HOOK with each partition, until HOOK returns non-zero. */
+ grub_err_t (*iterate) (struct grub_disk *disk,
+ int (*hook) (struct grub_disk *disk,
+ const grub_partition_t partition));
+#ifdef GRUB_UTIL
+ /* Determine sectors available for embedding. */
+ grub_err_t (*embed) (struct grub_disk *disk, unsigned int *nsectors,
+ grub_embed_type_t embed_type,
+ grub_disk_addr_t **sectors);
+#endif
+};
+typedef struct grub_partition_map *grub_partition_map_t;
+
+/* Partition description. */
+struct grub_partition
+{
+ /* The partition number. */
+ int number;
+
+ /* The start sector (relative to parent). */
+ grub_disk_addr_t start;
+
+ /* The length in sector units. */
+ grub_uint64_t len;
+
+ /* The offset of the partition table. */
+ grub_disk_addr_t offset;
+
+ /* The index of this partition in the partition table. */
+ int index;
+
+ /* Parent partition (physically contains this partition). */
+ struct grub_partition *parent;
+
+ /* The type partition map. */
+ grub_partition_map_t partmap;
+
+ /* The type of partition whne it's on MSDOS.
+ Used for embedding detection. */
+ grub_uint8_t msdostype;
+};
+
+grub_partition_t EXPORT_FUNC(grub_partition_probe) (struct grub_disk *disk,
+ const char *str);
+int EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk,
+ int (*hook) (struct grub_disk *disk,
+ const grub_partition_t partition));
+char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
+
+
+extern grub_partition_map_t EXPORT_VAR(grub_partition_map_list);
+
+#ifndef GRUB_LST_GENERATOR
+static inline void
+grub_partition_map_register (grub_partition_map_t partmap)
+{
+ grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list),
+ GRUB_AS_LIST (partmap));
+}
+#endif
+
+static inline void
+grub_partition_map_unregister (grub_partition_map_t partmap)
+{
+ grub_list_remove (GRUB_AS_LIST_P (&grub_partition_map_list),
+ GRUB_AS_LIST (partmap));
+}
+
+#define FOR_PARTITION_MAPS(var) FOR_LIST_ELEMENTS((var), (grub_partition_map_list))
+
+
+static inline grub_disk_addr_t
+grub_partition_get_start (const grub_partition_t p)
+{
+ grub_partition_t part;
+ grub_uint64_t part_start = 0;
+
+ for (part = p; part; part = part->parent)
+ part_start += part->start;
+
+ return part_start;
+}
+
+static inline grub_uint64_t
+grub_partition_get_len (const grub_partition_t p)
+{
+ return p->len;
+}
+
+#endif /* ! GRUB_PART_HEADER */
diff --git a/include/grub/parttool.h b/include/grub/parttool.h
new file mode 100644
index 0000000..8291e11
--- /dev/null
+++ b/include/grub/parttool.h
@@ -0,0 +1,58 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_PARTTOOL_HEADER
+#define GRUB_PARTTOOL_HEADER 1
+
+struct grub_parttool_argdesc
+{
+ char *name;
+ char *desc;
+ enum {GRUB_PARTTOOL_ARG_END, GRUB_PARTTOOL_ARG_BOOL, GRUB_PARTTOOL_ARG_VAL}
+ type;
+};
+
+struct grub_parttool_args
+{
+ int set;
+ union
+ {
+ int bool;
+ char *str;
+ };
+};
+
+typedef grub_err_t (*grub_parttool_function_t) (const grub_device_t dev,
+ const struct grub_parttool_args *args);
+
+struct grub_parttool
+{
+ struct grub_parttool *next;
+ char *name;
+ int handle;
+ int nargs;
+ struct grub_parttool_argdesc *args;
+ grub_parttool_function_t func;
+};
+
+int grub_parttool_register(const char *part_name,
+ const grub_parttool_function_t func,
+ const struct grub_parttool_argdesc *args);
+void grub_parttool_unregister (int handle);
+
+#endif /* ! GRUB_PARTTOOL_HEADER*/
diff --git a/include/grub/pci.h b/include/grub/pci.h
new file mode 100644
index 0000000..f34e3d9
--- /dev/null
+++ b/include/grub/pci.h
@@ -0,0 +1,137 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_PCI_H
+#define GRUB_PCI_H 1
+
+#ifndef ASM_FILE
+#include <grub/types.h>
+#include <grub/symbol.h>
+#endif
+
+#define GRUB_PCI_ADDR_SPACE_MASK 0x01
+#define GRUB_PCI_ADDR_SPACE_MEMORY 0x00
+#define GRUB_PCI_ADDR_SPACE_IO 0x01
+
+#define GRUB_PCI_ADDR_MEM_TYPE_MASK 0x06
+#define GRUB_PCI_ADDR_MEM_TYPE_32 0x00 /* 32 bit address */
+#define GRUB_PCI_ADDR_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */
+#define GRUB_PCI_ADDR_MEM_TYPE_64 0x04 /* 64 bit address */
+#define GRUB_PCI_ADDR_MEM_PREFETCH 0x08 /* prefetchable */
+
+#define GRUB_PCI_ADDR_MEM_MASK ~0xf
+#define GRUB_PCI_ADDR_IO_MASK ~0x03
+
+#define GRUB_PCI_REG_PCI_ID 0x00
+#define GRUB_PCI_REG_VENDOR 0x00
+#define GRUB_PCI_REG_DEVICE 0x02
+#define GRUB_PCI_REG_COMMAND 0x04
+#define GRUB_PCI_REG_STATUS 0x06
+#define GRUB_PCI_REG_REVISION 0x08
+#define GRUB_PCI_REG_CLASS 0x08
+#define GRUB_PCI_REG_CACHELINE 0x0c
+#define GRUB_PCI_REG_LAT_TIMER 0x0d
+#define GRUB_PCI_REG_HEADER_TYPE 0x0e
+#define GRUB_PCI_REG_BIST 0x0f
+#define GRUB_PCI_REG_ADDRESSES 0x10
+
+/* Beware that 64-bit address takes 2 registers. */
+#define GRUB_PCI_REG_ADDRESS_REG0 0x10
+#define GRUB_PCI_REG_ADDRESS_REG1 0x14
+#define GRUB_PCI_REG_ADDRESS_REG2 0x18
+#define GRUB_PCI_REG_ADDRESS_REG3 0x1c
+#define GRUB_PCI_REG_ADDRESS_REG4 0x20
+#define GRUB_PCI_REG_ADDRESS_REG5 0x24
+
+#define GRUB_PCI_REG_CIS_POINTER 0x28
+#define GRUB_PCI_REG_SUBVENDOR 0x2c
+#define GRUB_PCI_REG_SUBSYSTEM 0x2e
+#define GRUB_PCI_REG_ROM_ADDRESS 0x30
+#define GRUB_PCI_REG_CAP_POINTER 0x34
+#define GRUB_PCI_REG_IRQ_LINE 0x3c
+#define GRUB_PCI_REG_IRQ_PIN 0x3d
+#define GRUB_PCI_REG_MIN_GNT 0x3e
+#define GRUB_PCI_REG_MAX_LAT 0x3f
+
+#define GRUB_PCI_COMMAND_IO_ENABLED 0x0001
+#define GRUB_PCI_COMMAND_MEM_ENABLED 0x0002
+#define GRUB_PCI_COMMAND_BUS_MASTER 0x0004
+#define GRUB_PCI_COMMAND_PARITY_ERROR 0x0040
+#define GRUB_PCI_COMMAND_SERR_ENABLE 0x0100
+
+#define GRUB_PCI_STATUS_CAPABILITIES 0x0010
+#define GRUB_PCI_STATUS_66MHZ_CAPABLE 0x0020
+#define GRUB_PCI_STATUS_FAST_B2B_CAPABLE 0x0080
+
+#define GRUB_PCI_STATUS_DEVSEL_TIMING_SHIFT 9
+#define GRUB_PCI_STATUS_DEVSEL_TIMING_MASK 0x0600
+#define GRUB_PCI_CLASS_SUBCLASS_VGA 0x0300
+
+#ifndef ASM_FILE
+typedef grub_uint32_t grub_pci_id_t;
+
+#ifdef GRUB_MACHINE_EMU
+#include <grub/pciutils.h>
+#else
+typedef grub_uint32_t grub_pci_address_t;
+struct grub_pci_device
+{
+ int bus;
+ int device;
+ int function;
+};
+typedef struct grub_pci_device grub_pci_device_t;
+static inline int
+grub_pci_get_bus (grub_pci_device_t dev)
+{
+ return dev.bus;
+}
+
+static inline int
+grub_pci_get_device (grub_pci_device_t dev)
+{
+ return dev.device;
+}
+
+static inline int
+grub_pci_get_function (grub_pci_device_t dev)
+{
+ return dev.function;
+}
+#include <grub/cpu/pci.h>
+#endif
+
+typedef int NESTED_FUNC_ATTR (*grub_pci_iteratefunc_t)
+ (grub_pci_device_t dev, grub_pci_id_t pciid);
+
+grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (grub_pci_device_t dev,
+ int reg);
+
+void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook);
+
+struct grub_pci_dma_chunk;
+
+struct grub_pci_dma_chunk *EXPORT_FUNC(grub_memalign_dma32) (grub_size_t align,
+ grub_size_t size);
+void EXPORT_FUNC(grub_dma_free) (struct grub_pci_dma_chunk *ch);
+volatile void *EXPORT_FUNC(grub_dma_get_virt) (struct grub_pci_dma_chunk *ch);
+grub_uint32_t EXPORT_FUNC(grub_dma_get_phys) (struct grub_pci_dma_chunk *ch);
+
+#endif
+
+#endif /* GRUB_PCI_H */
diff --git a/include/grub/pciutils.h b/include/grub/pciutils.h
new file mode 100644
index 0000000..36d47e5
--- /dev/null
+++ b/include/grub/pciutils.h
@@ -0,0 +1,103 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_PCIUTILS_H
+#define GRUB_PCIUTILS_H 1
+
+#include <pciaccess.h>
+
+typedef struct pci_device *grub_pci_device_t;
+
+static inline int
+grub_pci_get_bus (grub_pci_device_t dev)
+{
+ return dev->bus;
+}
+
+static inline int
+grub_pci_get_device (grub_pci_device_t dev)
+{
+ return dev->dev;
+}
+
+static inline int
+grub_pci_get_function (grub_pci_device_t dev)
+{
+ return dev->func;
+}
+
+struct grub_pci_address
+{
+ grub_pci_device_t dev;
+ int pos;
+};
+
+typedef struct grub_pci_address grub_pci_address_t;
+
+static inline grub_uint32_t
+grub_pci_read (grub_pci_address_t addr)
+{
+ grub_uint32_t ret;
+ pci_device_cfg_read_u32 (addr.dev, &ret, addr.pos);
+ return ret;
+}
+
+static inline grub_uint16_t
+grub_pci_read_word (grub_pci_address_t addr)
+{
+ grub_uint16_t ret;
+ pci_device_cfg_read_u16 (addr.dev, &ret, addr.pos);
+ return ret;
+}
+
+static inline grub_uint8_t
+grub_pci_read_byte (grub_pci_address_t addr)
+{
+ grub_uint8_t ret;
+ pci_device_cfg_read_u8 (addr.dev, &ret, addr.pos);
+ return ret;
+}
+
+static inline void
+grub_pci_write (grub_pci_address_t addr, grub_uint32_t data)
+{
+ pci_device_cfg_write_u32 (addr.dev, data, addr.pos);
+}
+
+static inline void
+grub_pci_write_word (grub_pci_address_t addr, grub_uint16_t data)
+{
+ pci_device_cfg_write_u16 (addr.dev, data, addr.pos);
+}
+
+static inline void
+grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
+{
+ pci_device_cfg_write_u8 (addr.dev, data, addr.pos);
+}
+
+void *
+grub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base,
+ grub_size_t size);
+
+void
+grub_pci_device_unmap_range (grub_pci_device_t dev, void *mem,
+ grub_size_t size);
+
+
+#endif /* GRUB_PCIUTILS_H */
diff --git a/include/grub/powerpc/ieee1275/biosdisk.h b/include/grub/powerpc/ieee1275/biosdisk.h
new file mode 100644
index 0000000..30584d6
--- /dev/null
+++ b/include/grub/powerpc/ieee1275/biosdisk.h
@@ -0,0 +1,46 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,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_BIOSDISK_MACHINE_HEADER
+#define GRUB_BIOSDISK_MACHINE_HEADER 1
+
+#define GRUB_BIOSDISK_FLAG_LBA 1
+
+struct grub_biosdisk_data
+{
+ int drive;
+ unsigned long cylinders;
+ unsigned long heads;
+ unsigned long sectors;
+ unsigned long flags;
+};
+
+int grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap);
+int grub_biosdisk_rw_standard (int ah, int drive, int coff, int hoff,
+ int soff, int nsec, int segment);
+int grub_biosdisk_check_int13_extensions (int drive);
+int grub_biosdisk_get_diskinfo_int13_extensions (int drive, void *drp);
+int grub_biosdisk_get_diskinfo_standard (int drive,
+ unsigned long *cylinders,
+ unsigned long *heads,
+ unsigned long *sectors);
+int grub_biosdisk_get_num_floppies (void);
+
+void grub_biosdisk_init (void);
+
+#endif /* ! GRUB_BIOSDISK_MACHINE_HEADER */
diff --git a/include/grub/powerpc/ieee1275/ieee1275.h b/include/grub/powerpc/ieee1275/ieee1275.h
new file mode 100644
index 0000000..3c7683f
--- /dev/null
+++ b/include/grub/powerpc/ieee1275/ieee1275.h
@@ -0,0 +1,28 @@
+/* ieee1275.h - Access the Open Firmware client interface. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,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_IEEE1275_MACHINE_HEADER
+#define GRUB_IEEE1275_MACHINE_HEADER 1
+
+#include <grub/types.h>
+
+#define GRUB_IEEE1275_CELL_SIZEOF 4
+typedef grub_uint32_t grub_ieee1275_cell_t;
+
+#endif /* ! GRUB_IEEE1275_MACHINE_HEADER */
diff --git a/include/grub/powerpc/ieee1275/time.h b/include/grub/powerpc/ieee1275/time.h
new file mode 100644
index 0000000..3f8ad26
--- /dev/null
+++ b/include/grub/powerpc/ieee1275/time.h
@@ -0,0 +1,29 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,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 KERNEL_MACHINE_TIME_HEADER
+#define KERNEL_MACHINE_TIME_HEADER 1
+
+#include <grub/symbol.h>
+
+#define GRUB_TICKS_PER_SECOND 1000
+
+/* Return the real time in ticks. */
+grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void);
+
+#endif /* ! KERNEL_MACHINE_TIME_HEADER */
diff --git a/include/grub/powerpc/ieee1275/util/biosdisk.h b/include/grub/powerpc/ieee1275/util/biosdisk.h
new file mode 100644
index 0000000..f4262a0
--- /dev/null
+++ b/include/grub/powerpc/ieee1275/util/biosdisk.h
@@ -0,0 +1,27 @@
+/* biosdisk.h - emulate biosdisk */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,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_BIOSDISK_MACHINE_UTIL_HEADER
+#define GRUB_BIOSDISK_MACHINE_UTIL_HEADER 1
+
+void grub_util_biosdisk_init (const char *dev_map);
+void grub_util_biosdisk_fini (void);
+char *grub_util_biosdisk_get_grub_dev (const char *os_dev);
+
+#endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */
diff --git a/include/grub/powerpc/kernel.h b/include/grub/powerpc/kernel.h
new file mode 100644
index 0000000..3fc0b9e
--- /dev/null
+++ b/include/grub/powerpc/kernel.h
@@ -0,0 +1,22 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008 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_KERNEL_CPU_HEADER
+#define GRUB_KERNEL_CPU_HEADER 1
+
+#endif
diff --git a/include/grub/powerpc/memory.h b/include/grub/powerpc/memory.h
new file mode 100644
index 0000000..b748f33
--- /dev/null
+++ b/include/grub/powerpc/memory.h
@@ -0,0 +1,47 @@
+/* memory.h - describe the memory map */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,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_MEMORY_CPU_HEADER
+#define GRUB_MEMORY_CPU_HEADER 1
+
+#ifndef ASM_FILE
+
+typedef grub_addr_t grub_phys_addr_t;
+
+static inline grub_phys_addr_t
+grub_vtop (void *a)
+{
+ return (grub_phys_addr_t) a;
+}
+
+static inline void *
+grub_map_memory (grub_phys_addr_t a, grub_size_t size __attribute__ ((unused)))
+{
+ return (void *) a;
+}
+
+static inline void
+grub_unmap_memory (void *a __attribute__ ((unused)),
+ grub_size_t size __attribute__ ((unused)))
+{
+}
+
+#endif
+
+#endif /* ! GRUB_MEMORY_CPU_HEADER */
diff --git a/include/grub/powerpc/relocator.h b/include/grub/powerpc/relocator.h
new file mode 100644
index 0000000..c2780bb
--- /dev/null
+++ b/include/grub/powerpc/relocator.h
@@ -0,0 +1,37 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_RELOCATOR_CPU_HEADER
+#define GRUB_RELOCATOR_CPU_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/relocator.h>
+
+#define GRUB_PPC_JUMP_REGISTER 31
+
+struct grub_relocator32_state
+{
+ grub_uint32_t gpr[32];
+};
+
+grub_err_t
+grub_relocator32_boot (struct grub_relocator *rel,
+ struct grub_relocator32_state state);
+
+#endif /* ! GRUB_RELOCATOR_CPU_HEADER */
diff --git a/include/grub/powerpc/setjmp.h b/include/grub/powerpc/setjmp.h
new file mode 100644
index 0000000..fa16f73
--- /dev/null
+++ b/include/grub/powerpc/setjmp.h
@@ -0,0 +1,27 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2006,2007,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_SETJMP_CPU_HEADER
+#define GRUB_SETJMP_CPU_HEADER 1
+
+typedef unsigned long grub_jmp_buf[20];
+
+int grub_setjmp (grub_jmp_buf env) __attribute__ ((returns_twice));
+void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn));
+
+#endif /* ! GRUB_SETJMP_CPU_HEADER */
diff --git a/include/grub/powerpc/time.h b/include/grub/powerpc/time.h
new file mode 100644
index 0000000..5db7ff4
--- /dev/null
+++ b/include/grub/powerpc/time.h
@@ -0,0 +1,28 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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 KERNEL_CPU_TIME_HEADER
+#define KERNEL_CPU_TIME_HEADER 1
+
+static __inline void
+grub_cpu_idle (void)
+{
+ /* FIXME: not implemented */
+}
+
+#endif /* ! KERNEL_CPU_TIME_HEADER */
diff --git a/include/grub/powerpc/types.h b/include/grub/powerpc/types.h
new file mode 100644
index 0000000..a098ae6
--- /dev/null
+++ b/include/grub/powerpc/types.h
@@ -0,0 +1,32 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2006,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_TYPES_CPU_HEADER
+#define GRUB_TYPES_CPU_HEADER 1
+
+/* The size of void *. */
+#define GRUB_TARGET_SIZEOF_VOID_P 4
+
+/* The size of long. */
+#define GRUB_TARGET_SIZEOF_LONG 4
+
+/* powerpc is big-endian. */
+#define GRUB_TARGET_WORDS_BIGENDIAN 1
+
+
+#endif /* ! GRUB_TYPES_CPU_HEADER */
diff --git a/include/grub/raid.h b/include/grub/raid.h
new file mode 100644
index 0000000..d585363
--- /dev/null
+++ b/include/grub/raid.h
@@ -0,0 +1,96 @@
+/* raid.h - On disk structures for RAID. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,2007,2008,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_RAID_H
+#define GRUB_RAID_H 1
+
+#include <grub/types.h>
+
+#define GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC 0
+#define GRUB_RAID_LAYOUT_RIGHT_ASYMMETRIC 1
+#define GRUB_RAID_LAYOUT_LEFT_SYMMETRIC 2
+#define GRUB_RAID_LAYOUT_RIGHT_SYMMETRIC 3
+
+#define GRUB_RAID_LAYOUT_RIGHT_MASK 1
+#define GRUB_RAID_LAYOUT_SYMMETRIC_MASK 2
+
+struct grub_raid_member
+{
+ grub_disk_t device; /* Array of total_devs devices. */
+ grub_disk_addr_t start_sector;
+ /* Start of each device, in 512 byte sectors. */
+};
+
+struct grub_raid_array
+{
+ int number; /* The device number, taken from md_minor so we
+ are consistent with the device name in
+ Linux. */
+ int level; /* RAID levels, only 0, 1 or 5 at the moment. */
+ int layout; /* Layout for RAID 5/6. */
+ unsigned int total_devs; /* Total number of devices in the array. */
+ grub_size_t chunk_size; /* The size of a chunk, in 512 byte sectors. */
+ grub_uint64_t disk_size; /* Size of an individual disk, in 512 byte
+ sectors. */
+ unsigned int index; /* Index of current device. */
+ int uuid_len; /* The length of uuid. */
+ char *uuid; /* The UUID of the device. */
+
+ /* The following field is setup by the caller. */
+ char *name; /* That will be "md<number>". */
+ unsigned int nr_devs; /* The number of devices we've found so far. */
+ unsigned int allocated_devs;
+ struct grub_raid_member *members;
+ struct grub_raid_array *next;
+
+#ifdef GRUB_UTIL
+ struct grub_raid *driver;
+#endif
+};
+
+struct grub_raid
+{
+ const char *name;
+
+ grub_err_t (*detect) (grub_disk_t disk, struct grub_raid_array *array,
+ grub_disk_addr_t *start_sector);
+
+ struct grub_raid *next;
+};
+typedef struct grub_raid *grub_raid_t;
+
+void grub_raid_register (grub_raid_t raid);
+void grub_raid_unregister (grub_raid_t raid);
+
+void grub_raid_block_xor (char *buf1, const char *buf2, int size);
+
+typedef grub_err_t (*grub_raid5_recover_func_t) (struct grub_raid_array *array,
+ int disknr, char *buf,
+ grub_disk_addr_t sector,
+ int size);
+
+typedef grub_err_t (*grub_raid6_recover_func_t) (struct grub_raid_array *array,
+ int disknr, int p, char *buf,
+ grub_disk_addr_t sector,
+ int size);
+
+extern grub_raid5_recover_func_t grub_raid5_recover_func;
+extern grub_raid6_recover_func_t grub_raid6_recover_func;
+
+#endif /* ! GRUB_RAID_H */
diff --git a/include/grub/reader.h b/include/grub/reader.h
new file mode 100644
index 0000000..fd72a32
--- /dev/null
+++ b/include/grub/reader.h
@@ -0,0 +1,29 @@
+/* reader.h - prototypes for command line reader. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_READER_HEADER
+#define GRUB_READER_HEADER 1
+
+#include <grub/err.h>
+
+typedef grub_err_t (*grub_reader_getline_t) (char **, int);
+
+void grub_rescue_run (void);
+
+#endif /* ! GRUB_READER_HEADER */
diff --git a/include/grub/reed_solomon.h b/include/grub/reed_solomon.h
new file mode 100644
index 0000000..596dff2
--- /dev/null
+++ b/include/grub/reed_solomon.h
@@ -0,0 +1,30 @@
+/*
+ * 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_REED_SOLOMON_HEADER
+#define GRUB_REED_SOLOMON_HEADER 1
+
+void
+grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size,
+ grub_size_t redundancy);
+
+void
+grub_reed_solomon_recover (void *buffer, grub_size_t data_size,
+ grub_size_t redundancy);
+
+#endif
diff --git a/include/grub/relocator.h b/include/grub/relocator.h
new file mode 100644
index 0000000..653a00e
--- /dev/null
+++ b/include/grub/relocator.h
@@ -0,0 +1,58 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_RELOCATOR_HEADER
+#define GRUB_RELOCATOR_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/memory.h>
+#include <grub/cpu/memory.h>
+
+struct grub_relocator;
+struct grub_relocator_chunk;
+typedef const struct grub_relocator_chunk *grub_relocator_chunk_t;
+
+struct grub_relocator *grub_relocator_new (void);
+
+grub_err_t
+grub_relocator_alloc_chunk_addr (struct grub_relocator *rel,
+ grub_relocator_chunk_t *out,
+ grub_phys_addr_t target, grub_size_t size);
+
+void *
+get_virtual_current_address (grub_relocator_chunk_t in);
+grub_phys_addr_t
+get_physical_target_address (grub_relocator_chunk_t in);
+
+grub_err_t
+grub_relocator_alloc_chunk_align (struct grub_relocator *rel,
+ grub_relocator_chunk_t *out,
+ grub_phys_addr_t min_addr,
+ grub_phys_addr_t max_addr,
+ grub_size_t size, grub_size_t align,
+ int preference);
+
+#define GRUB_RELOCATOR_PREFERENCE_NONE 0
+#define GRUB_RELOCATOR_PREFERENCE_LOW 1
+#define GRUB_RELOCATOR_PREFERENCE_HIGH 2
+
+void
+grub_relocator_unload (struct grub_relocator *rel);
+
+#endif
diff --git a/include/grub/relocator_private.h b/include/grub/relocator_private.h
new file mode 100644
index 0000000..1c563cb
--- /dev/null
+++ b/include/grub/relocator_private.h
@@ -0,0 +1,113 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_RELOCATOR_PRIVATE_HEADER
+#define GRUB_RELOCATOR_PRIVATE_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/mm_private.h>
+
+extern grub_size_t grub_relocator_align;
+extern grub_size_t grub_relocator_forward_size;
+extern grub_size_t grub_relocator_backward_size;
+extern grub_size_t grub_relocator_jumper_size;
+
+void
+grub_cpu_relocator_init (void);
+grub_err_t
+grub_relocator_prepare_relocs (struct grub_relocator *rel,
+ grub_addr_t addr,
+ void **relstart, grub_size_t *relsize);
+void grub_cpu_relocator_forward (void *rels, void *src, void *tgt,
+ grub_size_t size);
+void grub_cpu_relocator_backward (void *rels, void *src, void *tgt,
+ grub_size_t size);
+void grub_cpu_relocator_jumper (void *rels, grub_addr_t addr);
+
+/* Remark: GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG = 1 or 2
+ aren't supported. */
+#ifdef GRUB_MACHINE_IEEE1275
+#define GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS 1
+#define GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG 0
+#elif defined (GRUB_MACHINE_EFI)
+#define GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS 1
+#define GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG 12
+#else
+#define GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS 0
+#endif
+
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS && GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG != 0
+#define GRUB_RELOCATOR_HAVE_LEFTOVERS 1
+#else
+#define GRUB_RELOCATOR_HAVE_LEFTOVERS 0
+#endif
+
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+#define GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT (1 << GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG)
+#endif
+
+struct grub_relocator_mmap_event
+{
+ enum {
+ IN_REG_START = 0,
+ IN_REG_END = 1,
+ REG_BEG_START = 2,
+ REG_BEG_END = REG_BEG_START | 1,
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ REG_FIRMWARE_START = 4,
+ REG_FIRMWARE_END = REG_FIRMWARE_START | 1,
+ /* To track the regions already in heap. */
+ FIRMWARE_BLOCK_START = 6,
+ FIRMWARE_BLOCK_END = FIRMWARE_BLOCK_START | 1,
+#endif
+#if GRUB_RELOCATOR_HAVE_LEFTOVERS
+ REG_LEFTOVER_START = 8,
+ REG_LEFTOVER_END = REG_LEFTOVER_START | 1,
+#endif
+ COLLISION_START = 10,
+ COLLISION_END = COLLISION_START | 1
+ } type;
+ grub_phys_addr_t pos;
+ union
+ {
+ struct
+ {
+ grub_mm_region_t reg;
+ grub_mm_header_t hancestor;
+ grub_mm_region_t *regancestor;
+ grub_mm_header_t head;
+ };
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+ struct grub_relocator_fw_leftover *leftover;
+#endif
+ };
+};
+
+/* Return 0 on failure, 1 on success. The failure here
+ can be very time-expensive, so please make sure fill events is accurate. */
+#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
+int grub_relocator_firmware_alloc_region (grub_phys_addr_t start,
+ grub_size_t size);
+unsigned grub_relocator_firmware_fill_events (struct grub_relocator_mmap_event *events);
+unsigned grub_relocator_firmware_get_max_events (void);
+void grub_relocator_firmware_free_region (grub_phys_addr_t start,
+ grub_size_t size);
+#endif
+
+#endif
diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h
new file mode 100644
index 0000000..6d31fca
--- /dev/null
+++ b/include/grub/script_sh.h
@@ -0,0 +1,405 @@
+/* normal_parser.h */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,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_NORMAL_PARSER_HEADER
+#define GRUB_NORMAL_PARSER_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/parser.h>
+#include <grub/command.h>
+
+struct grub_script_mem;
+
+/* The generic header for each scripting command or structure. */
+struct grub_script_cmd
+{
+ /* This function is called to execute the command. */
+ grub_err_t (*exec) (struct grub_script_cmd *cmd);
+
+ /* The next command. This can be used by the parent to form a chain
+ of commands. */
+ struct grub_script_cmd *next;
+};
+
+struct grub_script
+{
+ unsigned refcnt;
+ struct grub_script_mem *mem;
+ struct grub_script_cmd *cmd;
+
+ /* grub_scripts from block arguments. */
+ struct grub_script *next_siblings;
+ struct grub_script *children;
+};
+
+typedef enum
+{
+ GRUB_SCRIPT_ARG_TYPE_VAR,
+ GRUB_SCRIPT_ARG_TYPE_TEXT,
+ GRUB_SCRIPT_ARG_TYPE_DQVAR,
+ GRUB_SCRIPT_ARG_TYPE_DQSTR,
+ GRUB_SCRIPT_ARG_TYPE_SQSTR,
+ GRUB_SCRIPT_ARG_TYPE_BLOCK
+} grub_script_arg_type_t;
+
+/* A part of an argument. */
+struct grub_script_arg
+{
+ grub_script_arg_type_t type;
+
+ char *str;
+
+ /* Parsed block argument. */
+ struct grub_script *script;
+
+ /* Next argument part. */
+ struct grub_script_arg *next;
+};
+
+/* An argument vector. */
+struct grub_script_argv
+{
+ unsigned argc;
+ char **args;
+ struct grub_script *script;
+};
+
+/* Pluggable wildcard translator. */
+struct grub_script_wildcard_translator
+{
+ char *(*escape) (const char *str);
+ char *(*unescape) (const char *str);
+ grub_err_t (*expand) (const char *str, char ***expansions);
+};
+extern struct grub_script_wildcard_translator *grub_wildcard_translator;
+extern struct grub_script_wildcard_translator grub_filename_translator;
+
+/* A complete argument. It consists of a list of one or more `struct
+ grub_script_arg's. */
+struct grub_script_arglist
+{
+ struct grub_script_arglist *next;
+ struct grub_script_arg *arg;
+ /* Only stored in the first link. */
+ int argcount;
+};
+
+/* A single command line. */
+struct grub_script_cmdline
+{
+ struct grub_script_cmd cmd;
+
+ /* The arguments for this command. */
+ struct grub_script_arglist *arglist;
+};
+
+/* An if statement. */
+struct grub_script_cmdif
+{
+ struct grub_script_cmd cmd;
+
+ /* The command used to check if the 'if' is true or false. */
+ struct grub_script_cmd *exec_to_evaluate;
+
+ /* The code executed in case the result of 'if' was true. */
+ struct grub_script_cmd *exec_on_true;
+
+ /* The code executed in case the result of 'if' was false. */
+ struct grub_script_cmd *exec_on_false;
+};
+
+/* A for statement. */
+struct grub_script_cmdfor
+{
+ struct grub_script_cmd cmd;
+
+ /* The name used as looping variable. */
+ struct grub_script_arg *name;
+
+ /* The words loop iterates over. */
+ struct grub_script_arglist *words;
+
+ /* The command list executed in each loop. */
+ struct grub_script_cmd *list;
+};
+
+/* A while/until command. */
+struct grub_script_cmdwhile
+{
+ struct grub_script_cmd cmd;
+
+ /* The command list used as condition. */
+ struct grub_script_cmd *cond;
+
+ /* The command list executed in each loop. */
+ struct grub_script_cmd *list;
+
+ /* The flag to indicate this as "until" loop. */
+ int until;
+};
+
+/* State of the lexer as passed to the lexer. */
+struct grub_lexer_param
+{
+ /* Function used by the lexer to get a new line when more input is
+ expected, but not available. */
+ grub_reader_getline_t getline;
+
+ /* A reference counter. If this is >0 it means that the parser
+ expects more tokens and `getline' should be called to fetch more.
+ Otherwise the lexer can stop processing if the current buffer is
+ depleted. */
+ int refs;
+
+ /* While walking through the databuffer, `record' the characters to
+ this other buffer. It can be used to edit the menu entry at a
+ later moment. */
+
+ /* If true, recording is enabled. */
+ int record;
+
+ /* Points to the recording. */
+ char *recording;
+
+ /* index in the RECORDING. */
+ int recordpos;
+
+ /* Size of RECORDING. */
+ int recordlen;
+
+ /* End of file reached. */
+ int eof;
+
+ /* Merge multiple word tokens. */
+ int merge_start;
+ int merge_end;
+
+ /* Part of a multi-part token. */
+ char *text;
+ unsigned used;
+ unsigned size;
+
+ /* Type of text. */
+ grub_script_arg_type_t type;
+
+ /* Flag to indicate resplit in progres. */
+ unsigned resplit;
+
+ /* Text that is unput. */
+ char *prefix;
+
+ /* Flex scanner. */
+ void *yyscanner;
+
+ /* Flex scanner buffer. */
+ void *buffer;
+};
+
+#define GRUB_LEXER_INITIAL_TEXT_SIZE 32
+#define GRUB_LEXER_INITIAL_RECORD_SIZE 256
+
+/* State of the parser as passes to the parser. */
+struct grub_parser_param
+{
+ /* Keep track of the memory allocated for this specific
+ function. */
+ struct grub_script_mem *func_mem;
+
+ /* When set to 0, no errors have occurred during parsing. */
+ int err;
+
+ /* The memory that was used while parsing and scanning. */
+ struct grub_script_mem *memused;
+
+ /* The block argument scripts. */
+ struct grub_script *scripts;
+
+ /* The result of the parser. */
+ struct grub_script_cmd *parsed;
+
+ struct grub_lexer_param *lexerstate;
+};
+
+void grub_script_init (void);
+void grub_script_fini (void);
+
+void grub_script_mem_free (struct grub_script_mem *mem);
+
+void grub_script_argv_free (struct grub_script_argv *argv);
+int grub_script_argv_make (struct grub_script_argv *argv, int argc, char **args);
+int grub_script_argv_next (struct grub_script_argv *argv);
+int grub_script_argv_append (struct grub_script_argv *argv, const char *s);
+int grub_script_argv_split_append (struct grub_script_argv *argv, char *s);
+
+struct grub_script_arglist *
+grub_script_create_arglist (struct grub_parser_param *state);
+
+struct grub_script_arglist *
+grub_script_add_arglist (struct grub_parser_param *state,
+ struct grub_script_arglist *list,
+ struct grub_script_arg *arg);
+struct grub_script_cmd *
+grub_script_create_cmdline (struct grub_parser_param *state,
+ struct grub_script_arglist *arglist);
+
+struct grub_script_cmd *
+grub_script_create_cmdif (struct grub_parser_param *state,
+ struct grub_script_cmd *exec_to_evaluate,
+ struct grub_script_cmd *exec_on_true,
+ struct grub_script_cmd *exec_on_false);
+
+struct grub_script_cmd *
+grub_script_create_cmdfor (struct grub_parser_param *state,
+ struct grub_script_arg *name,
+ struct grub_script_arglist *words,
+ struct grub_script_cmd *list);
+
+struct grub_script_cmd *
+grub_script_create_cmdwhile (struct grub_parser_param *state,
+ struct grub_script_cmd *cond,
+ struct grub_script_cmd *list,
+ int is_an_until_loop);
+
+struct grub_script_cmd *
+grub_script_append_cmd (struct grub_parser_param *state,
+ struct grub_script_cmd *list,
+ struct grub_script_cmd *last);
+struct grub_script_arg *
+grub_script_arg_add (struct grub_parser_param *state,
+ struct grub_script_arg *arg,
+ grub_script_arg_type_t type, char *str);
+
+struct grub_script *grub_script_parse (char *script,
+ grub_reader_getline_t getline);
+void grub_script_free (struct grub_script *script);
+struct grub_script *grub_script_create (struct grub_script_cmd *cmd,
+ struct grub_script_mem *mem);
+
+struct grub_lexer_param *grub_script_lexer_init (struct grub_parser_param *parser,
+ char *script,
+ grub_reader_getline_t getline);
+void grub_script_lexer_fini (struct grub_lexer_param *);
+void grub_script_lexer_ref (struct grub_lexer_param *);
+void grub_script_lexer_deref (struct grub_lexer_param *);
+unsigned grub_script_lexer_record_start (struct grub_parser_param *);
+char *grub_script_lexer_record_stop (struct grub_parser_param *, unsigned);
+int grub_script_lexer_yywrap (struct grub_parser_param *, const char *input);
+void grub_script_lexer_record (struct grub_parser_param *, char *);
+
+/* Functions to track allocated memory. */
+struct grub_script_mem *grub_script_mem_record (struct grub_parser_param *state);
+struct grub_script_mem *grub_script_mem_record_stop (struct grub_parser_param *state,
+ struct grub_script_mem *restore);
+void *grub_script_malloc (struct grub_parser_param *state, grub_size_t size);
+
+/* Functions used by bison. */
+union YYSTYPE;
+int grub_script_yylex (union YYSTYPE *, struct grub_parser_param *);
+int grub_script_yyparse (struct grub_parser_param *);
+void grub_script_yyerror (struct grub_parser_param *, char const *);
+
+/* Commands to execute, don't use these directly. */
+grub_err_t grub_script_execute_cmdline (struct grub_script_cmd *cmd);
+grub_err_t grub_script_execute_cmdlist (struct grub_script_cmd *cmd);
+grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd);
+grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd);
+grub_err_t grub_script_execute_cmdwhile (struct grub_script_cmd *cmd);
+
+/* Execute any GRUB pre-parsed command or script. */
+grub_err_t grub_script_execute (struct grub_script *script);
+grub_err_t grub_script_execute_sourcecode (const char *source, int argc, char **args);
+
+/* Break command for loops. */
+grub_err_t grub_script_break (grub_command_t cmd, int argc, char *argv[]);
+
+/* SHIFT command for GRUB script. */
+grub_err_t grub_script_shift (grub_command_t cmd, int argc, char *argv[]);
+
+/* SETPARAMS command for GRUB script functions. */
+grub_err_t grub_script_setparams (grub_command_t cmd, int argc, char *argv[]);
+
+/* RETURN command for functions. */
+grub_err_t grub_script_return (grub_command_t cmd, int argc, char *argv[]);
+
+/* This variable points to the parsed command. This is used to
+ communicate with the bison code. */
+extern struct grub_script_cmd *grub_script_parsed;
+
+
+
+/* The function description. */
+struct grub_script_function
+{
+ /* The name. */
+ char *name;
+
+ /* The script function. */
+ struct grub_script *func;
+
+ /* The flags. */
+ unsigned flags;
+
+ /* The next element. */
+ struct grub_script_function *next;
+
+ int references;
+};
+typedef struct grub_script_function *grub_script_function_t;
+
+extern grub_script_function_t grub_script_function_list;
+
+#define FOR_SCRIPT_FUNCTIONS(var) for((var) = grub_script_function_list; \
+ (var); (var) = (var)->next)
+
+grub_script_function_t grub_script_function_create (struct grub_script_arg *functionname,
+ struct grub_script *cmd);
+void grub_script_function_remove (const char *name);
+grub_script_function_t grub_script_function_find (char *functionname);
+
+grub_err_t grub_script_function_call (grub_script_function_t func,
+ int argc, char **args);
+
+char **
+grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *count);
+
+grub_err_t
+grub_normal_parse_line (char *line, grub_reader_getline_t getline);
+
+static inline struct grub_script *
+grub_script_ref (struct grub_script *script)
+{
+ if (script)
+ script->refcnt++;
+ return script;
+}
+
+static inline void
+grub_script_unref (struct grub_script *script)
+{
+ if (! script)
+ return;
+
+ if (script->refcnt == 0)
+ grub_script_free (script);
+ else
+ script->refcnt--;
+}
+
+#endif /* ! GRUB_NORMAL_PARSER_HEADER */
diff --git a/include/grub/scsi.h b/include/grub/scsi.h
new file mode 100644
index 0000000..b30d317
--- /dev/null
+++ b/include/grub/scsi.h
@@ -0,0 +1,106 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_SCSI_H
+#define GRUB_SCSI_H 1
+
+typedef struct grub_scsi_dev *grub_scsi_dev_t;
+
+void grub_scsi_dev_register (grub_scsi_dev_t dev);
+void grub_scsi_dev_unregister (grub_scsi_dev_t dev);
+
+struct grub_scsi;
+
+enum
+ {
+ GRUB_SCSI_SUBSYSTEM_USBMS,
+ GRUB_SCSI_SUBSYSTEM_ATAPI
+ };
+
+#define GRUB_SCSI_ID_SUBSYSTEM_SHIFT 24
+#define GRUB_SCSI_ID_BUS_SHIFT 8
+#define GRUB_SCSI_ID_LUN_SHIFT 0
+
+static inline grub_uint32_t
+grub_make_scsi_id (int subsystem, int bus, int lun)
+{
+ return (subsystem << GRUB_SCSI_ID_SUBSYSTEM_SHIFT)
+ | (bus << GRUB_SCSI_ID_BUS_SHIFT) | (lun << GRUB_SCSI_ID_LUN_SHIFT);
+}
+
+struct grub_scsi_dev
+{
+ /* The device name. */
+ const char *name;
+
+ grub_uint8_t id;
+
+ /* Call HOOK with each device name, until HOOK returns non-zero. */
+ int (*iterate) (int (*hook) (int bus, int luns));
+
+ /* Open the device named NAME, and set up SCSI. */
+ grub_err_t (*open) (int bus, struct grub_scsi *scsi);
+
+ /* Close the scsi device SCSI. */
+ void (*close) (struct grub_scsi *scsi);
+
+ /* Read SIZE bytes from the device SCSI into BUF after sending the
+ command CMD of size CMDSIZE. */
+ grub_err_t (*read) (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
+ grub_size_t size, char *buf);
+
+ /* Write SIZE bytes from BUF to the device SCSI after sending the
+ command CMD of size CMDSIZE. */
+ grub_err_t (*write) (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
+ grub_size_t size, char *buf);
+
+ /* The next scsi device. */
+ struct grub_scsi_dev *next;
+};
+
+struct grub_scsi
+{
+ /* The underlying scsi device. */
+ grub_scsi_dev_t dev;
+
+ /* Type of SCSI device. XXX: Make enum. */
+ grub_uint8_t devtype;
+
+ int bus;
+
+ /* Number of LUNs. */
+ int luns;
+
+ /* LUN for this `struct grub_scsi'. */
+ int lun;
+
+ /* Set to 0 when not removable, 1 when removable. */
+ int removable;
+
+ /* Size of the device in blocks. */
+ int size;
+
+ /* Size of one block. */
+ int blocksize;
+
+ /* Device-specific data. */
+ void *data;
+};
+typedef struct grub_scsi *grub_scsi_t;
+
+#endif /* GRUB_SCSI_H */
diff --git a/include/grub/scsicmd.h b/include/grub/scsicmd.h
new file mode 100644
index 0000000..9cc5afe
--- /dev/null
+++ b/include/grub/scsicmd.h
@@ -0,0 +1,166 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_SCSICMD_H
+#define GRUB_SCSICMD_H 1
+
+#include <grub/types.h>
+
+#define GRUB_SCSI_DEVTYPE_MASK 31
+#define GRUB_SCSI_REMOVABLE_BIT 7
+#define GRUB_SCSI_LUN_SHIFT 5
+
+struct grub_scsi_test_unit_ready
+{
+ grub_uint8_t opcode;
+ grub_uint8_t lun; /* 7-5 LUN, 4-0 reserved */
+ grub_uint8_t reserved1;
+ grub_uint8_t reserved2;
+ grub_uint8_t reserved3;
+ grub_uint8_t control;
+ grub_uint8_t pad[6]; /* To be ATAPI compatible */
+} __attribute__((packed));
+
+struct grub_scsi_inquiry
+{
+ grub_uint8_t opcode;
+ grub_uint8_t lun; /* 7-5 LUN, 4-1 reserved, 0 EVPD */
+ grub_uint8_t page; /* page code if EVPD=1 */
+ grub_uint8_t reserved;
+ grub_uint8_t alloc_length;
+ grub_uint8_t control;
+ grub_uint8_t pad[6]; /* To be ATAPI compatible */
+} __attribute__((packed));
+
+struct grub_scsi_inquiry_data
+{
+ grub_uint8_t devtype;
+ grub_uint8_t rmb;
+ grub_uint16_t reserved;
+ grub_uint8_t length;
+ grub_uint8_t reserved2[3];
+ char vendor[8];
+ char prodid[16];
+ char prodrev[4];
+} __attribute__((packed));
+
+struct grub_scsi_request_sense
+{
+ grub_uint8_t opcode;
+ grub_uint8_t lun; /* 7-5 LUN, 4-0 reserved */
+ grub_uint8_t reserved1;
+ grub_uint8_t reserved2;
+ grub_uint8_t alloc_length;
+ grub_uint8_t control;
+ grub_uint8_t pad[6]; /* To be ATAPI compatible */
+} __attribute__((packed));
+
+struct grub_scsi_request_sense_data
+{
+ grub_uint8_t error_code; /* 7 Valid, 6-0 Err. code */
+ grub_uint8_t segment_number;
+ grub_uint8_t sense_key; /*7 FileMark, 6 EndOfMedia, 5 ILI, 4-0 sense key */
+ grub_uint32_t information;
+ grub_uint8_t additional_sense_length;
+ grub_uint32_t cmd_specific_info;
+ grub_uint8_t additional_sense_code;
+ grub_uint8_t additional_sense_code_qualifier;
+ grub_uint8_t field_replaceable_unit_code;
+ grub_uint8_t sense_key_specific[3];
+ /* there can be additional sense field */
+} __attribute__((packed));
+
+struct grub_scsi_read_capacity
+{
+ grub_uint8_t opcode;
+ grub_uint8_t lun; /* 7-5 LUN, 4-1 reserved, 0 reserved */
+ grub_uint32_t logical_block_addr; /* only if PMI=1 */
+ grub_uint8_t reserved1;
+ grub_uint8_t reserved2;
+ grub_uint8_t PMI;
+ grub_uint8_t control;
+ grub_uint16_t pad; /* To be ATAPI compatible */
+} __attribute__((packed));
+
+struct grub_scsi_read_capacity_data
+{
+ grub_uint32_t size;
+ grub_uint32_t blocksize;
+} __attribute__((packed));
+
+struct grub_scsi_read10
+{
+ grub_uint8_t opcode;
+ grub_uint8_t lun;
+ grub_uint32_t lba;
+ grub_uint8_t reserved;
+ grub_uint16_t size;
+ grub_uint8_t reserved2;
+ grub_uint16_t pad;
+} __attribute__((packed));
+
+struct grub_scsi_read12
+{
+ grub_uint8_t opcode;
+ grub_uint8_t lun;
+ grub_uint32_t lba;
+ grub_uint32_t size;
+ grub_uint8_t reserved;
+ grub_uint8_t control;
+} __attribute__((packed));
+
+struct grub_scsi_write10
+{
+ grub_uint8_t opcode;
+ grub_uint8_t lun;
+ grub_uint32_t lba;
+ grub_uint8_t reserved;
+ grub_uint16_t size;
+ grub_uint8_t reserved2;
+ grub_uint16_t pad;
+} __attribute__((packed));
+
+struct grub_scsi_write12
+{
+ grub_uint8_t opcode;
+ grub_uint8_t lun;
+ grub_uint32_t lba;
+ grub_uint32_t size;
+ grub_uint8_t reserved;
+ grub_uint8_t control;
+} __attribute__((packed));
+
+typedef enum
+ {
+ grub_scsi_cmd_test_unit_ready = 0x00,
+ grub_scsi_cmd_request_sense = 0x03,
+ grub_scsi_cmd_inquiry = 0x12,
+ grub_scsi_cmd_read_capacity = 0x25,
+ grub_scsi_cmd_read10 = 0x28,
+ grub_scsi_cmd_write10 = 0x2a,
+ grub_scsi_cmd_read12 = 0xa8,
+ grub_scsi_cmd_write12 = 0xaa,
+ } grub_scsi_cmd_t;
+
+typedef enum
+ {
+ grub_scsi_devtype_direct = 0x00,
+ grub_scsi_devtype_cdrom = 0x05
+ } grub_scsi_devtype_t;
+
+#endif /* GRUB_SCSICMD_H */
diff --git a/include/grub/sdl.h b/include/grub/sdl.h
new file mode 100644
index 0000000..e4efdc9
--- /dev/null
+++ b/include/grub/sdl.h
@@ -0,0 +1,24 @@
+/*
+ * 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/>.
+ */
+
+void EXPORT_FUNC (SDL_Quit) (void);
+void EXPORT_FUNC (SDL_SetColors) (void);
+void EXPORT_FUNC (SDL_Init) (void);
+void EXPORT_FUNC (SDL_GetError) (void);
+void EXPORT_FUNC (SDL_Flip) (void);
+void EXPORT_FUNC (SDL_SetVideoMode) (void);
diff --git a/include/grub/search.h b/include/grub/search.h
new file mode 100644
index 0000000..d80347d
--- /dev/null
+++ b/include/grub/search.h
@@ -0,0 +1,29 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_SEARCH_HEADER
+#define GRUB_SEARCH_HEADER 1
+
+void grub_search_fs_file (const char *key, const char *var, int no_floppy,
+ char **hints, unsigned nhints);
+void grub_search_fs_uuid (const char *key, const char *var, int no_floppy,
+ char **hints, unsigned nhints);
+void grub_search_label (const char *key, const char *var, int no_floppy,
+ char **hints, unsigned nhints);
+
+#endif
diff --git a/include/grub/serial.h b/include/grub/serial.h
new file mode 100644
index 0000000..9540bee
--- /dev/null
+++ b/include/grub/serial.h
@@ -0,0 +1,123 @@
+/* serial.h - serial device interface */
+/*
+ * 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_SERIAL_HEADER
+#define GRUB_SERIAL_HEADER 1
+
+#include <grub/types.h>
+#include <grub/cpu/io.h>
+#include <grub/usb.h>
+#include <grub/list.h>
+#include <grub/term.h>
+
+struct grub_serial_port;
+struct grub_serial_config;
+
+struct grub_serial_driver
+{
+ grub_err_t (*configure) (struct grub_serial_port *port,
+ struct grub_serial_config *config);
+ int (*fetch) (struct grub_serial_port *port);
+ void (*put) (struct grub_serial_port *port, const int c);
+ void (*fini) (struct grub_serial_port *port);
+};
+
+/* The type of parity. */
+typedef enum
+ {
+ GRUB_SERIAL_PARITY_NONE,
+ GRUB_SERIAL_PARITY_ODD,
+ GRUB_SERIAL_PARITY_EVEN,
+ } grub_serial_parity_t;
+
+typedef enum
+ {
+ GRUB_SERIAL_STOP_BITS_1,
+ GRUB_SERIAL_STOP_BITS_2,
+ } grub_serial_stop_bits_t;
+
+struct grub_serial_config
+{
+ unsigned speed;
+ int word_len;
+ grub_serial_parity_t parity;
+ grub_serial_stop_bits_t stop_bits;
+};
+
+struct grub_serial_port
+{
+ struct grub_serial_port *next;
+ char *name;
+ struct grub_serial_driver *driver;
+ struct grub_serial_config config;
+ int configured;
+ /* This should be void *data but since serial is useful as an early console
+ when malloc isn't available it's a union.
+ */
+ union
+ {
+ struct
+ {
+ grub_port_t port;
+ int broken;
+ };
+ struct
+ {
+ grub_usb_device_t usbdev;
+ int configno;
+ int interfno;
+ char buf[64];
+ int bufstart, bufend;
+ struct grub_usb_desc_endp *in_endp;
+ struct grub_usb_desc_endp *out_endp;
+ };
+ };
+ grub_term_output_t term_out;
+ grub_term_input_t term_in;
+};
+
+grub_err_t EXPORT_FUNC(grub_serial_register) (struct grub_serial_port *port);
+
+void EXPORT_FUNC(grub_serial_unregister) (struct grub_serial_port *port);
+
+ /* Set default settings. */
+static inline grub_err_t
+grub_serial_config_defaults (struct grub_serial_port *port)
+{
+ struct grub_serial_config config =
+ {
+#ifdef GRUB_MACHINE_MIPS_YEELOONG
+ .speed = 115200,
+#else
+ .speed = 9600,
+#endif
+ .word_len = 8,
+ .parity = GRUB_SERIAL_PARITY_NONE,
+ .stop_bits = GRUB_SERIAL_STOP_BITS_1
+ };
+
+ return port->driver->configure (port, &config);
+}
+
+void grub_ns8250_init (void);
+char *grub_serial_ns8250_add_port (grub_port_t port);
+extern struct grub_serial_driver grub_ns8250_driver;
+void EXPORT_FUNC(grub_serial_unregister_driver) (struct grub_serial_driver *driver);
+
+#endif
diff --git a/include/grub/setjmp.h b/include/grub/setjmp.h
new file mode 100644
index 0000000..70147a7
--- /dev/null
+++ b/include/grub/setjmp.h
@@ -0,0 +1,33 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2006,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_SETJMP_HEADER
+#define GRUB_SETJMP_HEADER 1
+
+#if defined(GRUB_UTIL) && !defined(GRUBOF)
+#include <setjmp.h>
+typedef jmp_buf grub_jmp_buf;
+#define grub_setjmp setjmp
+#define grub_longjmp longjmp
+#else
+/* This must define grub_jmp_buf, and declare grub_setjmp and
+ grub_longjmp. */
+# include <grub/cpu/setjmp.h>
+#endif
+
+#endif /* ! GRUB_SETJMP_HEADER */
diff --git a/include/grub/smbus.h b/include/grub/smbus.h
new file mode 100644
index 0000000..0b8e671
--- /dev/null
+++ b/include/grub/smbus.h
@@ -0,0 +1,70 @@
+/*
+ * 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_SMBUS_HEADER
+#define GRUB_SMBUS_HEADER 1
+
+#define GRUB_SMB_RAM_START_ADDR 0x50
+#define GRUB_SMB_RAM_NUM_MAX 0x08
+
+#define GRUB_SMBUS_SPD_MEMORY_TYPE_ADDR 2
+#define GRUB_SMBUS_SPD_MEMORY_TYPE_DDR2 8
+#define GRUB_SMBUS_SPD_MEMORY_NUM_BANKS_ADDR 17
+#define GRUB_SMBUS_SPD_MEMORY_NUM_ROWS_ADDR 3
+#define GRUB_SMBUS_SPD_MEMORY_NUM_COLUMNS_ADDR 4
+#define GRUB_SMBUS_SPD_MEMORY_NUM_OF_RANKS_ADDR 5
+#define GRUB_SMBUS_SPD_MEMORY_NUM_OF_RANKS_MASK 0x7
+#define GRUB_SMBUS_SPD_MEMORY_CAS_LATENCY_ADDR 18
+#define GRUB_SMBUS_SPD_MEMORY_CAS_LATENCY_MIN_VALUE 5
+#define GRUB_SMBUS_SPD_MEMORY_TRAS_ADDR 30
+#define GRUB_SMBUS_SPD_MEMORY_TRTP_ADDR 38
+
+#ifndef ASM_FILE
+
+struct grub_smbus_spd
+{
+ grub_uint8_t written_size;
+ grub_uint8_t log_total_flash_size;
+ grub_uint8_t memory_type;
+ union
+ {
+ grub_uint8_t unknown[253];
+ struct {
+ grub_uint8_t num_rows;
+ grub_uint8_t num_columns;
+ grub_uint8_t num_of_ranks;
+ grub_uint8_t unused1[12];
+ grub_uint8_t num_of_banks;
+ grub_uint8_t unused2[2];
+ grub_uint8_t cas_latency;
+ grub_uint8_t unused3[9];
+ grub_uint8_t rank_capacity;
+ grub_uint8_t unused4[1];
+ grub_uint8_t tras;
+ grub_uint8_t unused5[7];
+ grub_uint8_t trtp;
+ grub_uint8_t unused6[31];
+ grub_uint8_t part_number[18];
+ grub_uint8_t unused7[165];
+ } ddr2;
+ };
+};
+
+#endif
+
+#endif
diff --git a/include/grub/sparc64/ieee1275/boot.h b/include/grub/sparc64/ieee1275/boot.h
new file mode 100644
index 0000000..112d19b
--- /dev/null
+++ b/include/grub/sparc64/ieee1275/boot.h
@@ -0,0 +1,64 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_BOOT_MACHINE_HEADER
+#define GRUB_BOOT_MACHINE_HEADER 1
+
+#define CIF_REG %l0
+#define CHOSEN_NODE_REG %l4
+#define STDOUT_NODE_REG %l5
+#define BOOTDEV_REG %l6
+#define PIC_REG %l7
+
+#define SCRATCH_PAD_BOOT 0x5000
+#define SCRATCH_PAD_DISKBOOT 0x4000
+
+#define GET_ABS(symbol, reg) \
+ add PIC_REG, (symbol - pic_base), reg
+#define LDUW_ABS(symbol, offset, reg) \
+ lduw [PIC_REG + (symbol - pic_base) + (offset)], reg
+#define LDX_ABS(symbol, offset, reg) \
+ ldx [PIC_REG + (symbol - pic_base) + (offset)], reg
+
+#define GRUB_BOOT_AOUT_HEADER_SIZE 32
+
+#define GRUB_BOOT_MACHINE_SIGNATURE 0xbb44aa55
+
+#define GRUB_BOOT_MACHINE_VER_MAJ 0x08
+
+#define GRUB_BOOT_MACHINE_BOOT_DEVPATH 0x0a
+
+#define GRUB_BOOT_MACHINE_BOOT_DEVPATH_END 0x80
+
+#define GRUB_BOOT_MACHINE_KERNEL_BYTE 0x80
+
+#define GRUB_BOOT_MACHINE_CODE_END \
+ (0x1fc - GRUB_BOOT_AOUT_HEADER_SIZE)
+
+#define GRUB_BOOT_MACHINE_KERNEL_ADDR 0x4200
+
+#ifndef ASM_FILE
+/* This is the blocklist used in the diskboot image. */
+struct grub_boot_blocklist
+{
+ grub_uint64_t start;
+ grub_uint32_t len;
+} __attribute__ ((packed));
+#endif
+
+#endif /* ! BOOT_MACHINE_HEADER */
diff --git a/include/grub/sparc64/ieee1275/ieee1275.h b/include/grub/sparc64/ieee1275/ieee1275.h
new file mode 100644
index 0000000..32c77f8
--- /dev/null
+++ b/include/grub/sparc64/ieee1275/ieee1275.h
@@ -0,0 +1,48 @@
+/* ieee1275.h - Access the Open Firmware client interface. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007,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_IEEE1275_MACHINE_HEADER
+#define GRUB_IEEE1275_MACHINE_HEADER 1
+
+#include <grub/types.h>
+
+#define GRUB_IEEE1275_CELL_SIZEOF 8
+typedef grub_uint64_t grub_ieee1275_cell_t;
+
+/* Encoding of 'mode' argument to grub_ieee1275_map_physical() */
+#define IEEE1275_MAP_WRITE 0x0001 /* Writable */
+#define IEEE1275_MAP_READ 0x0002 /* Readable */
+#define IEEE1275_MAP_EXEC 0x0004 /* Executable */
+#define IEEE1275_MAP_LOCKED 0x0010 /* Locked in TLB */
+#define IEEE1275_MAP_CACHED 0x0020 /* Cacheable */
+#define IEEE1275_MAP_SE 0x0040 /* Side-effects */
+#define IEEE1275_MAP_GLOBAL 0x0080 /* Global */
+#define IEEE1275_MAP_IE 0x0100 /* Invert Endianness */
+#define IEEE1275_MAP_DEFAULT (IEEE1275_MAP_WRITE | IEEE1275_MAP_READ | \
+ IEEE1275_MAP_EXEC | IEEE1275_MAP_CACHED)
+
+extern int EXPORT_FUNC(grub_ieee1275_claim_vaddr) (grub_addr_t vaddr,
+ grub_size_t size);
+extern int EXPORT_FUNC(grub_ieee1275_alloc_physmem) (grub_addr_t *paddr,
+ grub_size_t size,
+ grub_uint32_t align);
+
+extern grub_addr_t EXPORT_VAR (grub_ieee1275_original_stack);
+
+#endif /* ! GRUB_IEEE1275_MACHINE_HEADER */
diff --git a/include/grub/sparc64/ieee1275/kernel.h b/include/grub/sparc64/ieee1275/kernel.h
new file mode 100644
index 0000000..5aa50b8
--- /dev/null
+++ b/include/grub/sparc64/ieee1275/kernel.h
@@ -0,0 +1,37 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2007,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_KERNEL_MACHINE_HEADER
+#define GRUB_KERNEL_MACHINE_HEADER 1
+
+#define GRUB_KERNEL_MACHINE_STACK_SIZE 0x40000
+
+#ifndef ASM_FILE
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+
+/* The size of kernel image. */
+extern grub_int32_t grub_kernel_image_size;
+
+/* The total size of module images following the kernel. */
+extern grub_int32_t grub_total_module_size;
+
+#endif /* ! ASM_FILE */
+
+#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
diff --git a/include/grub/sparc64/ieee1275/time.h b/include/grub/sparc64/ieee1275/time.h
new file mode 100644
index 0000000..3f8ad26
--- /dev/null
+++ b/include/grub/sparc64/ieee1275/time.h
@@ -0,0 +1,29 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,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 KERNEL_MACHINE_TIME_HEADER
+#define KERNEL_MACHINE_TIME_HEADER 1
+
+#include <grub/symbol.h>
+
+#define GRUB_TICKS_PER_SECOND 1000
+
+/* Return the real time in ticks. */
+grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void);
+
+#endif /* ! KERNEL_MACHINE_TIME_HEADER */
diff --git a/include/grub/sparc64/setjmp.h b/include/grub/sparc64/setjmp.h
new file mode 100644
index 0000000..6096bae
--- /dev/null
+++ b/include/grub/sparc64/setjmp.h
@@ -0,0 +1,29 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2006,2007,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_SETJMP_CPU_HEADER
+#define GRUB_SETJMP_CPU_HEADER 1
+
+#include <grub/types.h>
+
+typedef grub_uint64_t grub_jmp_buf[3];
+
+int grub_setjmp (grub_jmp_buf env) __attribute__ ((returns_twice));
+void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn));
+
+#endif /* ! GRUB_SETJMP_CPU_HEADER */
diff --git a/include/grub/sparc64/time.h b/include/grub/sparc64/time.h
new file mode 100644
index 0000000..5db7ff4
--- /dev/null
+++ b/include/grub/sparc64/time.h
@@ -0,0 +1,28 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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 KERNEL_CPU_TIME_HEADER
+#define KERNEL_CPU_TIME_HEADER 1
+
+static __inline void
+grub_cpu_idle (void)
+{
+ /* FIXME: not implemented */
+}
+
+#endif /* ! KERNEL_CPU_TIME_HEADER */
diff --git a/include/grub/sparc64/types.h b/include/grub/sparc64/types.h
new file mode 100644
index 0000000..b9b0cf9
--- /dev/null
+++ b/include/grub/sparc64/types.h
@@ -0,0 +1,32 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2004,2006,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_TYPES_CPU_HEADER
+#define GRUB_TYPES_CPU_HEADER 1
+
+/* The size of void *. */
+#define GRUB_TARGET_SIZEOF_VOID_P 8
+
+/* The size of long. */
+#define GRUB_TARGET_SIZEOF_LONG 8
+
+/* sparc64 is big-endian. */
+#define GRUB_TARGET_WORDS_BIGENDIAN 1
+
+
+#endif /* ! GRUB_TYPES_CPU_HEADER */
diff --git a/include/grub/symbol.h b/include/grub/symbol.h
new file mode 100644
index 0000000..c6adb7e
--- /dev/null
+++ b/include/grub/symbol.h
@@ -0,0 +1,52 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,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_SYMBOL_HEADER
+#define GRUB_SYMBOL_HEADER 1
+
+#include <config.h>
+
+/* Apple assembler requires local labels to start with a capital L */
+#define LOCAL(sym) L_ ## sym
+
+/* Add an underscore to a C symbol in assembler code if needed. */
+#if HAVE_ASM_USCORE
+# define EXT_C(sym) _ ## sym
+#else
+# define EXT_C(sym) sym
+#endif
+
+#if defined (APPLE_CC)
+#define FUNCTION(x) .globl EXT_C(x) ; EXT_C(x):
+#define VARIABLE(x) .globl EXT_C(x) ; EXT_C(x):
+#elif ! defined (__CYGWIN__) && ! defined (__MINGW32__)
+#define FUNCTION(x) .globl EXT_C(x) ; .type EXT_C(x), "function" ; EXT_C(x):
+#define VARIABLE(x) .globl EXT_C(x) ; .type EXT_C(x), "object" ; EXT_C(x):
+#else
+/* .type not supported for non-ELF targets. XXX: Check this in configure? */
+#define FUNCTION(x) .globl EXT_C(x) ; .def EXT_C(x); .scl 2; .type 32; .endef; EXT_C(x):
+#define VARIABLE(x) .globl EXT_C(x) ; .def EXT_C(x); .scl 2; .type 0; .endef; EXT_C(x):
+#endif
+
+/* Mark an exported symbol. */
+#ifndef GRUB_SYMBOL_GENERATOR
+# define EXPORT_FUNC(x) x
+# define EXPORT_VAR(x) x
+#endif /* ! GRUB_SYMBOL_GENERATOR */
+
+#endif /* ! GRUB_SYMBOL_HEADER */
diff --git a/include/grub/term.h b/include/grub/term.h
new file mode 100644
index 0000000..726c84d
--- /dev/null
+++ b/include/grub/term.h
@@ -0,0 +1,471 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,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_TERM_HEADER
+#define GRUB_TERM_HEADER 1
+
+#define GRUB_TERM_NO_KEY 0
+
+/* Internal codes used by GRUB to represent terminal input. */
+/* Only for keys otherwise not having shifted modification. */
+#define GRUB_TERM_SHIFT 0x01000000
+#define GRUB_TERM_CTRL 0x02000000
+#define GRUB_TERM_ALT 0x04000000
+
+/* Keys without associated character. */
+#define GRUB_TERM_EXTENDED 0x00800000
+#define GRUB_TERM_KEY_MASK 0x00ffffff
+
+#define GRUB_TERM_KEY_LEFT (GRUB_TERM_EXTENDED | 0x4b)
+#define GRUB_TERM_KEY_RIGHT (GRUB_TERM_EXTENDED | 0x4d)
+#define GRUB_TERM_KEY_UP (GRUB_TERM_EXTENDED | 0x48)
+#define GRUB_TERM_KEY_DOWN (GRUB_TERM_EXTENDED | 0x50)
+#define GRUB_TERM_KEY_HOME (GRUB_TERM_EXTENDED | 0x47)
+#define GRUB_TERM_KEY_END (GRUB_TERM_EXTENDED | 0x4f)
+#define GRUB_TERM_KEY_DC (GRUB_TERM_EXTENDED | 0x53)
+#define GRUB_TERM_KEY_PPAGE (GRUB_TERM_EXTENDED | 0x49)
+#define GRUB_TERM_KEY_NPAGE (GRUB_TERM_EXTENDED | 0x51)
+#define GRUB_TERM_KEY_F1 (GRUB_TERM_EXTENDED | 0x3b)
+#define GRUB_TERM_KEY_F2 (GRUB_TERM_EXTENDED | 0x3c)
+#define GRUB_TERM_KEY_F3 (GRUB_TERM_EXTENDED | 0x3d)
+#define GRUB_TERM_KEY_F4 (GRUB_TERM_EXTENDED | 0x3e)
+#define GRUB_TERM_KEY_F5 (GRUB_TERM_EXTENDED | 0x3f)
+#define GRUB_TERM_KEY_F6 (GRUB_TERM_EXTENDED | 0x40)
+#define GRUB_TERM_KEY_F7 (GRUB_TERM_EXTENDED | 0x41)
+#define GRUB_TERM_KEY_F8 (GRUB_TERM_EXTENDED | 0x42)
+#define GRUB_TERM_KEY_F9 (GRUB_TERM_EXTENDED | 0x43)
+#define GRUB_TERM_KEY_F10 (GRUB_TERM_EXTENDED | 0x44)
+#define GRUB_TERM_KEY_F11 (GRUB_TERM_EXTENDED | 0x57)
+#define GRUB_TERM_KEY_F12 (GRUB_TERM_EXTENDED | 0x58)
+#define GRUB_TERM_KEY_INSERT (GRUB_TERM_EXTENDED | 0x52)
+#define GRUB_TERM_KEY_CENTER (GRUB_TERM_EXTENDED | 0x4c)
+
+#define GRUB_TERM_ESC '\e'
+#define GRUB_TERM_TAB '\t'
+#define GRUB_TERM_BACKSPACE '\b'
+
+#ifndef ASM_FILE
+
+#include <grub/err.h>
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/unicode.h>
+#include <grub/list.h>
+
+/* These are used to represent the various color states we use. */
+typedef enum
+ {
+ /* The color used to display all text that does not use the
+ user defined colors below. */
+ GRUB_TERM_COLOR_STANDARD,
+ /* The user defined colors for normal text. */
+ GRUB_TERM_COLOR_NORMAL,
+ /* The user defined colors for highlighted text. */
+ GRUB_TERM_COLOR_HIGHLIGHT
+ }
+grub_term_color_state;
+
+/* Flags for representing the capabilities of a terminal. */
+/* Some notes about the flags:
+ - These flags are used by higher-level functions but not terminals
+ themselves.
+ - If a terminal is dumb, you may assume that only putchar, getkey and
+ checkkey are called.
+ - Some fancy features (setcolorstate, setcolor and setcursor) can be set
+ to NULL. */
+
+/* Set when input characters shouldn't be echoed back. */
+#define GRUB_TERM_NO_ECHO (1 << 0)
+/* Set when the editing feature should be disabled. */
+#define GRUB_TERM_NO_EDIT (1 << 1)
+/* Set when the terminal cannot do fancy things. */
+#define GRUB_TERM_DUMB (1 << 2)
+/* Which encoding does terminal expect stream to be. */
+#define GRUB_TERM_CODE_TYPE_SHIFT 3
+#define GRUB_TERM_CODE_TYPE_MASK (7 << GRUB_TERM_CODE_TYPE_SHIFT)
+/* Only ASCII characters accepted. */
+#define GRUB_TERM_CODE_TYPE_ASCII (0 << GRUB_TERM_CODE_TYPE_SHIFT)
+/* Expects CP-437 characters (ASCII + pseudographics). */
+#define GRUB_TERM_CODE_TYPE_CP437 (1 << GRUB_TERM_CODE_TYPE_SHIFT)
+/* UTF-8 stream in logical order. Usually used for terminals
+ which just forward the stream to another computer. */
+#define GRUB_TERM_CODE_TYPE_UTF8_LOGICAL (2 << GRUB_TERM_CODE_TYPE_SHIFT)
+/* UTF-8 in visual order. Like UTF-8 logical but for buggy endpoints. */
+#define GRUB_TERM_CODE_TYPE_UTF8_VISUAL (3 << GRUB_TERM_CODE_TYPE_SHIFT)
+/* Glyph description in visual order. */
+#define GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS (4 << GRUB_TERM_CODE_TYPE_SHIFT)
+
+
+/* Bitmasks for modifier keys returned by grub_getkeystatus. */
+#define GRUB_TERM_STATUS_RSHIFT (1 << 0)
+#define GRUB_TERM_STATUS_LSHIFT (1 << 1)
+#define GRUB_TERM_STATUS_RCTRL (1 << 2)
+#define GRUB_TERM_STATUS_RALT (1 << 3)
+#define GRUB_TERM_STATUS_SCROLL (1 << 4)
+#define GRUB_TERM_STATUS_NUM (1 << 5)
+#define GRUB_TERM_STATUS_CAPS (1 << 6)
+#define GRUB_TERM_STATUS_LCTRL (1 << 8)
+#define GRUB_TERM_STATUS_LALT (1 << 9)
+
+/* Menu-related geometrical constants. */
+
+/* The number of lines of "GRUB version..." at the top. */
+#define GRUB_TERM_INFO_HEIGHT 1
+
+/* The number of columns/lines between messages/borders/etc. */
+#define GRUB_TERM_MARGIN 1
+
+/* The number of columns of scroll information. */
+#define GRUB_TERM_SCROLL_WIDTH 1
+
+/* The Y position of the top border. */
+#define GRUB_TERM_TOP_BORDER_Y (GRUB_TERM_MARGIN + GRUB_TERM_INFO_HEIGHT \
+ + GRUB_TERM_MARGIN)
+
+/* The X position of the left border. */
+#define GRUB_TERM_LEFT_BORDER_X GRUB_TERM_MARGIN
+
+/* The Y position of the first entry. */
+#define GRUB_TERM_FIRST_ENTRY_Y (GRUB_TERM_TOP_BORDER_Y + 1)
+
+struct grub_term_input
+{
+ /* The next terminal. */
+ struct grub_term_input *next;
+
+ /* The terminal name. */
+ const char *name;
+
+ /* Initialize the terminal. */
+ grub_err_t (*init) (struct grub_term_input *term);
+
+ /* Clean up the terminal. */
+ grub_err_t (*fini) (struct grub_term_input *term);
+
+ /* Get a character if any input character is available. Otherwise return -1 */
+ int (*getkey) (struct grub_term_input *term);
+
+ /* Get keyboard modifier status. */
+ int (*getkeystatus) (struct grub_term_input *term);
+
+ void *data;
+};
+typedef struct grub_term_input *grub_term_input_t;
+
+struct grub_term_output
+{
+ /* The next terminal. */
+ struct grub_term_output *next;
+
+ /* The terminal name. */
+ const char *name;
+
+ /* Initialize the terminal. */
+ grub_err_t (*init) (struct grub_term_output *term);
+
+ /* Clean up the terminal. */
+ grub_err_t (*fini) (struct grub_term_output *term);
+
+ /* Put a character. C is encoded in Unicode. */
+ void (*putchar) (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c);
+
+ /* Get the number of columns occupied by a given character C. C is
+ encoded in Unicode. */
+ grub_ssize_t (*getcharwidth) (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c);
+
+ /* Get the screen size. The return value is ((Width << 8) | Height). */
+ grub_uint16_t (*getwh) (struct grub_term_output *term);
+
+ /* Get the cursor position. The return value is ((X << 8) | Y). */
+ grub_uint16_t (*getxy) (struct grub_term_output *term);
+
+ /* Go to the position (X, Y). */
+ void (*gotoxy) (struct grub_term_output *term,
+ grub_uint8_t x, grub_uint8_t y);
+
+ /* Clear the screen. */
+ void (*cls) (struct grub_term_output *term);
+
+ /* Set the current color to be used */
+ void (*setcolorstate) (struct grub_term_output *term,
+ grub_term_color_state state);
+
+ /* Turn on/off the cursor. */
+ void (*setcursor) (struct grub_term_output *term, int on);
+
+ /* Update the screen. */
+ void (*refresh) (struct grub_term_output *term);
+
+ /* The feature flags defined above. */
+ grub_uint32_t flags;
+
+ /* Current color state. */
+ grub_uint8_t normal_color;
+ grub_uint8_t highlight_color;
+
+ void *data;
+};
+typedef struct grub_term_output *grub_term_output_t;
+
+#define GRUB_TERM_DEFAULT_NORMAL_COLOR 0x07
+#define GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR 0x70
+#define GRUB_TERM_DEFAULT_STANDARD_COLOR 0x07
+
+extern struct grub_term_output *EXPORT_VAR(grub_term_outputs_disabled);
+extern struct grub_term_input *EXPORT_VAR(grub_term_inputs_disabled);
+extern struct grub_term_output *EXPORT_VAR(grub_term_outputs);
+extern struct grub_term_input *EXPORT_VAR(grub_term_inputs);
+
+static inline void
+grub_term_register_input (const char *name __attribute__ ((unused)),
+ grub_term_input_t term)
+{
+ if (grub_term_inputs)
+ grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
+ GRUB_AS_LIST (term));
+ else
+ {
+ /* If this is the first terminal, enable automatically. */
+ if (! term->init || term->init (term) == GRUB_ERR_NONE)
+ grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
+ }
+}
+
+static inline void
+grub_term_register_input_active (const char *name __attribute__ ((unused)),
+ grub_term_input_t term)
+{
+ if (! term->init || term->init (term) == GRUB_ERR_NONE)
+ grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
+}
+
+static inline void
+grub_term_register_output (const char *name __attribute__ ((unused)),
+ grub_term_output_t term)
+{
+ if (grub_term_outputs)
+ grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
+ GRUB_AS_LIST (term));
+ else
+ {
+ /* If this is the first terminal, enable automatically. */
+ if (! term->init || term->init (term) == GRUB_ERR_NONE)
+ grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
+ GRUB_AS_LIST (term));
+ }
+}
+
+static inline void
+grub_term_register_output_active (const char *name __attribute__ ((unused)),
+ grub_term_output_t term)
+{
+ if (! term->init || term->init (term) == GRUB_ERR_NONE)
+ grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
+ GRUB_AS_LIST (term));
+}
+
+static inline void
+grub_term_unregister_input (grub_term_input_t term)
+{
+ grub_list_remove (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
+ grub_list_remove (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
+ GRUB_AS_LIST (term));
+}
+
+static inline void
+grub_term_unregister_output (grub_term_output_t term)
+{
+ grub_list_remove (GRUB_AS_LIST_P (&grub_term_outputs), GRUB_AS_LIST (term));
+ grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)),
+ GRUB_AS_LIST (term));
+}
+
+#define FOR_ACTIVE_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs))
+#define FOR_DISABLED_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs_disabled))
+#define FOR_ACTIVE_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs))
+#define FOR_DISABLED_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs_disabled))
+
+void grub_putcode (grub_uint32_t code, struct grub_term_output *term);
+int EXPORT_FUNC(grub_getkey) (void);
+int EXPORT_FUNC(grub_checkkey) (void);
+void grub_cls (void);
+void EXPORT_FUNC(grub_refresh) (void);
+void grub_puts_terminal (const char *str, struct grub_term_output *term);
+grub_uint16_t *grub_term_save_pos (void);
+void grub_term_restore_pos (grub_uint16_t *pos);
+
+static inline unsigned grub_term_width (struct grub_term_output *term)
+{
+ return ((term->getwh(term)&0xFF00)>>8);
+}
+
+static inline unsigned grub_term_height (struct grub_term_output *term)
+{
+ return (term->getwh(term)&0xFF);
+}
+
+/* The width of the border. */
+static inline unsigned
+grub_term_border_width (struct grub_term_output *term)
+{
+ return grub_term_width (term) - GRUB_TERM_MARGIN * 3 - GRUB_TERM_SCROLL_WIDTH;
+}
+
+/* The max column number of an entry. The last "-1" is for a
+ continuation marker. */
+static inline int
+grub_term_entry_width (struct grub_term_output *term)
+{
+ return grub_term_border_width (term) - 2 - GRUB_TERM_MARGIN * 2 - 1;
+}
+
+static inline grub_uint16_t
+grub_term_getxy (struct grub_term_output *term)
+{
+ return term->getxy (term);
+}
+
+static inline void
+grub_term_refresh (struct grub_term_output *term)
+{
+ if (term->refresh)
+ term->refresh (term);
+}
+
+static inline void
+grub_term_gotoxy (struct grub_term_output *term, grub_uint8_t x, grub_uint8_t y)
+{
+ term->gotoxy (term, x, y);
+}
+
+static inline void
+grub_term_setcolorstate (struct grub_term_output *term,
+ grub_term_color_state state)
+{
+ if (term->setcolorstate)
+ term->setcolorstate (term, state);
+}
+
+static inline void
+grub_setcolorstate (grub_term_color_state state)
+{
+ struct grub_term_output *term;
+
+ FOR_ACTIVE_TERM_OUTPUTS(term)
+ grub_term_setcolorstate (term, state);
+}
+
+/* Set the normal color and the highlight color. The format of each
+ color is VGA's. */
+static inline void
+grub_term_setcolor (struct grub_term_output *term,
+ grub_uint8_t normal_color, grub_uint8_t highlight_color)
+{
+ term->normal_color = normal_color;
+ term->highlight_color = highlight_color;
+}
+
+/* Turn on/off the cursor. */
+static inline void
+grub_term_setcursor (struct grub_term_output *term, int on)
+{
+ if (term->setcursor)
+ term->setcursor (term, on);
+}
+
+static inline void
+grub_term_cls (struct grub_term_output *term)
+{
+ if (term->cls)
+ (term->cls) (term);
+ else
+ {
+ grub_putcode ('\n', term);
+ grub_term_refresh (term);
+ }
+}
+
+#ifdef HAVE_UNIFONT_WIDTHSPEC
+
+grub_ssize_t
+grub_unicode_estimate_width (const struct grub_unicode_glyph *c);
+
+#else
+
+static inline grub_ssize_t
+grub_unicode_estimate_width (const struct grub_unicode_glyph *c __attribute__ ((unused)))
+{
+ if (grub_unicode_get_comb_type (c->base))
+ return 0;
+ return 1;
+}
+
+#endif
+
+static inline grub_ssize_t
+grub_term_getcharwidth (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c)
+{
+ if (term->getcharwidth)
+ return term->getcharwidth (term, c);
+ else if (((term->flags & GRUB_TERM_CODE_TYPE_MASK)
+ == GRUB_TERM_CODE_TYPE_UTF8_LOGICAL)
+ || ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
+ == GRUB_TERM_CODE_TYPE_UTF8_VISUAL)
+ || ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
+ == GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS))
+ return grub_unicode_estimate_width (c);
+ else
+ return 1;
+}
+
+static inline void
+grub_term_getcolor (struct grub_term_output *term,
+ grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
+{
+ *normal_color = term->normal_color;
+ *highlight_color = term->highlight_color;
+}
+
+struct grub_term_autoload
+{
+ struct grub_term_autoload *next;
+ char *name;
+ char *modname;
+};
+
+extern struct grub_term_autoload *grub_term_input_autoload;
+extern struct grub_term_autoload *grub_term_output_autoload;
+
+static inline void
+grub_print_spaces (struct grub_term_output *term, int number_spaces)
+{
+ while (--number_spaces >= 0)
+ grub_putcode (' ', term);
+}
+
+extern void (*EXPORT_VAR (grub_term_poll_usb)) (void);
+
+#define GRUB_TERM_REPEAT_PRE_INTERVAL 400
+#define GRUB_TERM_REPEAT_INTERVAL 50
+
+#endif /* ! ASM_FILE */
+
+#endif /* ! GRUB_TERM_HEADER */
diff --git a/include/grub/terminfo.h b/include/grub/terminfo.h
new file mode 100644
index 0000000..5a552b3
--- /dev/null
+++ b/include/grub/terminfo.h
@@ -0,0 +1,81 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,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_TERMINFO_HEADER
+#define GRUB_TERMINFO_HEADER 1
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/term.h>
+
+char *EXPORT_FUNC(grub_terminfo_get_current) (struct grub_term_output *term);
+grub_err_t EXPORT_FUNC(grub_terminfo_set_current) (struct grub_term_output *term,
+ const char *);
+
+#define GRUB_TERMINFO_READKEY_MAX_LEN 4
+struct grub_terminfo_input_state
+{
+ int input_buf[GRUB_TERMINFO_READKEY_MAX_LEN];
+ int npending;
+ int (*readkey) (struct grub_term_input *term);
+};
+
+struct grub_terminfo_output_state
+{
+ struct grub_term_output *next;
+
+ char *name;
+
+ char *gotoxy;
+ char *cls;
+ char *reverse_video_on;
+ char *reverse_video_off;
+ char *cursor_on;
+ char *cursor_off;
+ char *setcolor;
+
+ unsigned int width, height;
+
+ unsigned int xpos, ypos;
+
+ void (*put) (struct grub_term_output *term, const int c);
+};
+
+grub_err_t EXPORT_FUNC(grub_terminfo_output_init) (struct grub_term_output *term);
+void EXPORT_FUNC(grub_terminfo_gotoxy) (grub_term_output_t term,
+ grub_uint8_t x, grub_uint8_t y);
+void EXPORT_FUNC(grub_terminfo_cls) (grub_term_output_t term);
+grub_uint16_t EXPORT_FUNC (grub_terminfo_getxy) (struct grub_term_output *term);
+void EXPORT_FUNC (grub_terminfo_setcursor) (struct grub_term_output *term,
+ const int on);
+void EXPORT_FUNC (grub_terminfo_setcolorstate) (struct grub_term_output *term,
+ const grub_term_color_state state);
+
+
+grub_err_t EXPORT_FUNC (grub_terminfo_input_init) (struct grub_term_input *term);
+int EXPORT_FUNC (grub_terminfo_getkey) (struct grub_term_input *term);
+void EXPORT_FUNC (grub_terminfo_putchar) (struct grub_term_output *term,
+ const struct grub_unicode_glyph *c);
+grub_uint16_t EXPORT_FUNC (grub_terminfo_getwh) (struct grub_term_output *term);
+
+
+grub_err_t EXPORT_FUNC (grub_terminfo_output_register) (struct grub_term_output *term,
+ const char *type);
+grub_err_t EXPORT_FUNC (grub_terminfo_output_unregister) (struct grub_term_output *term);
+
+#endif /* ! GRUB_TERMINFO_HEADER */
diff --git a/include/grub/test.h b/include/grub/test.h
new file mode 100644
index 0000000..336d3b6
--- /dev/null
+++ b/include/grub/test.h
@@ -0,0 +1,85 @@
+/*
+ * 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_TEST_HEADER
+#define GRUB_TEST_HEADER
+
+#include <grub/dl.h>
+#include <grub/list.h>
+#include <grub/misc.h>
+#include <grub/types.h>
+#include <grub/symbol.h>
+
+struct grub_test
+{
+ /* The next test. */
+ struct grub_test *next;
+
+ /* The test name. */
+ char *name;
+
+ /* The test main function. */
+ void (*main) (void);
+};
+typedef struct grub_test *grub_test_t;
+
+extern grub_test_t grub_test_list;
+
+void grub_test_register (const char *name, void (*test) (void));
+void grub_test_unregister (const char *name);
+
+/* Execute a test and print results. */
+int grub_test_run (grub_test_t test);
+
+/* Test `cond' for nonzero; log failure otherwise. */
+void grub_test_nonzero (int cond, const char *file,
+ const char *func, grub_uint32_t line,
+ const char *fmt, ...)
+ __attribute__ ((format (printf, 5, 6)));
+
+/* Macro to fill in location details and an optional error message. */
+#define grub_test_assert(cond, ...) \
+ grub_test_nonzero(cond, GRUB_FILE, __FUNCTION__, __LINE__, \
+ ## __VA_ARGS__, \
+ "assert failed: %s", #cond)
+
+/* Macro to define a unit test. */
+#define GRUB_UNIT_TEST(name, funp) \
+ void grub_unit_test_init (void) \
+ { \
+ grub_test_register (name, funp); \
+ } \
+ \
+ void grub_unit_test_fini (void) \
+ { \
+ grub_test_unregister (name); \
+ }
+
+/* Macro to define a functional test. */
+#define GRUB_FUNCTIONAL_TEST(name, funp) \
+ GRUB_MOD_INIT(name) \
+ { \
+ grub_test_register (#name, funp); \
+ } \
+ \
+ GRUB_MOD_FINI(name) \
+ { \
+ grub_test_unregister (#name); \
+ }
+
+#endif /* ! GRUB_TEST_HEADER */
diff --git a/include/grub/time.h b/include/grub/time.h
new file mode 100644
index 0000000..ae2617e
--- /dev/null
+++ b/include/grub/time.h
@@ -0,0 +1,47 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2007, 2008 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 KERNEL_TIME_HEADER
+#define KERNEL_TIME_HEADER 1
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+#include <grub/cpu/time.h>
+
+#if defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL)
+#define GRUB_TICKS_PER_SECOND 100000
+/* Return the real time in ticks. */
+grub_uint32_t EXPORT_FUNC (grub_get_rtc) (void);
+#else
+#include <grub/machine/time.h>
+#endif
+
+void EXPORT_FUNC(grub_millisleep) (grub_uint32_t ms);
+grub_uint64_t EXPORT_FUNC(grub_get_time_ms) (void);
+
+grub_uint64_t grub_rtc_get_time_ms (void);
+
+static __inline void
+grub_sleep (grub_uint32_t s)
+{
+ grub_millisleep (1000 * s);
+}
+
+void grub_install_get_time_ms (grub_uint64_t (*get_time_ms_func) (void));
+
+#endif /* ! KERNEL_TIME_HEADER */
diff --git a/include/grub/tparm.h b/include/grub/tparm.h
new file mode 100644
index 0000000..642a22f
--- /dev/null
+++ b/include/grub/tparm.h
@@ -0,0 +1,26 @@
+/* tparm.h - parameter formatting of terminfo */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,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_TPARM_HEADER
+#define GRUB_TPARM_HEADER 1
+
+/* Function prototypes. */
+char *grub_terminfo_tparm (const char *string, ...);
+
+#endif /* ! GRUB_TPARM_HEADER */
diff --git a/include/grub/trig.h b/include/grub/trig.h
new file mode 100644
index 0000000..2512a5f
--- /dev/null
+++ b/include/grub/trig.h
@@ -0,0 +1,44 @@
+/* trig.h - Trigonometric function support. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_TRIG_HEADER
+#define GRUB_TRIG_HEADER 1
+
+#define GRUB_TRIG_ANGLE_MAX 256
+#define GRUB_TRIG_ANGLE_MASK 255
+#define GRUB_TRIG_FRACTION_SCALE 16384
+
+extern short grub_trig_sintab[];
+extern short grub_trig_costab[];
+
+static __inline int
+grub_sin (int x)
+{
+ x &= GRUB_TRIG_ANGLE_MASK;
+ return grub_trig_sintab[x];
+}
+
+static __inline int
+grub_cos (int x)
+{
+ x &= GRUB_TRIG_ANGLE_MASK;
+ return grub_trig_costab[x];
+}
+
+#endif /* ! GRUB_TRIG_HEADER */
diff --git a/include/grub/types.h b/include/grub/types.h
new file mode 100644
index 0000000..8632eac
--- /dev/null
+++ b/include/grub/types.h
@@ -0,0 +1,218 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2005,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_TYPES_HEADER
+#define GRUB_TYPES_HEADER 1
+
+#include <config.h>
+#include <grub/cpu/types.h>
+
+#ifdef GRUB_UTIL
+# define GRUB_CPU_SIZEOF_VOID_P SIZEOF_VOID_P
+# define GRUB_CPU_SIZEOF_LONG SIZEOF_LONG
+# ifdef WORDS_BIGENDIAN
+# define GRUB_CPU_WORDS_BIGENDIAN 1
+# else
+# undef GRUB_CPU_WORDS_BIGENDIAN
+# endif
+#else /* ! GRUB_UTIL */
+# define GRUB_CPU_SIZEOF_VOID_P GRUB_TARGET_SIZEOF_VOID_P
+# define GRUB_CPU_SIZEOF_LONG GRUB_TARGET_SIZEOF_LONG
+# ifdef GRUB_TARGET_WORDS_BIGENDIAN
+# define GRUB_CPU_WORDS_BIGENDIAN 1
+# else
+# undef GRUB_CPU_WORDS_BIGENDIAN
+# endif
+#endif /* ! GRUB_UTIL */
+
+#if GRUB_CPU_SIZEOF_VOID_P != GRUB_CPU_SIZEOF_LONG
+# error "This architecture is not supported because sizeof(void *) != sizeof(long)"
+#endif
+
+#if GRUB_CPU_SIZEOF_VOID_P != 4 && GRUB_CPU_SIZEOF_VOID_P != 8
+# error "This architecture is not supported because sizeof(void *) != 4 and sizeof(void *) != 8"
+#endif
+
+#ifndef GRUB_TARGET_WORDSIZE
+# if GRUB_TARGET_SIZEOF_VOID_P == 4
+# define GRUB_TARGET_WORDSIZE 32
+# elif GRUB_TARGET_SIZEOF_VOID_P == 8
+# define GRUB_TARGET_WORDSIZE 64
+# endif
+#endif
+
+/* Define various wide integers. */
+typedef signed char grub_int8_t;
+typedef short grub_int16_t;
+typedef int grub_int32_t;
+#if GRUB_CPU_SIZEOF_LONG == 8
+typedef long grub_int64_t;
+#else
+typedef long long grub_int64_t;
+#endif
+
+typedef unsigned char grub_uint8_t;
+typedef unsigned short grub_uint16_t;
+typedef unsigned grub_uint32_t;
+# define PRIxGRUB_UINT32_T "x"
+# define PRIuGRUB_UINT32_T "u"
+#if GRUB_CPU_SIZEOF_LONG == 8
+typedef unsigned long grub_uint64_t;
+# define PRIxGRUB_UINT64_T "lx"
+# define PRIuGRUB_UINT64_T "lu"
+#else
+typedef unsigned long long grub_uint64_t;
+# define PRIxGRUB_UINT64_T "llx"
+# define PRIuGRUB_UINT64_T "llu"
+#endif
+
+/* Misc types. */
+#if GRUB_TARGET_SIZEOF_VOID_P == 8
+typedef grub_uint64_t grub_target_addr_t;
+typedef grub_uint64_t grub_target_size_t;
+typedef grub_int64_t grub_target_ssize_t;
+#else
+typedef grub_uint32_t grub_target_addr_t;
+typedef grub_uint32_t grub_target_size_t;
+typedef grub_int32_t grub_target_ssize_t;
+#endif
+
+#if GRUB_CPU_SIZEOF_VOID_P == 8
+typedef grub_uint64_t grub_addr_t;
+typedef grub_uint64_t grub_size_t;
+typedef grub_int64_t grub_ssize_t;
+
+# if GRUB_CPU_SIZEOF_LONG == 8
+# define PRIxGRUB_SIZE "lx"
+# define PRIuGRUB_SIZE "lu"
+# else
+# define PRIxGRUB_SIZE "llx"
+# define PRIuGRUB_SIZE "llu"
+# endif
+#else
+typedef grub_uint32_t grub_addr_t;
+typedef grub_uint32_t grub_size_t;
+typedef grub_int32_t grub_ssize_t;
+
+# define PRIxGRUB_SIZE "x"
+# define PRIuGRUB_SIZE "u"
+#endif
+
+#if GRUB_CPU_SIZEOF_LONG == 8
+# define GRUB_ULONG_MAX 18446744073709551615UL
+# define GRUB_LONG_MAX 9223372036854775807L
+# define GRUB_LONG_MIN (-9223372036854775807L - 1)
+#else
+# define GRUB_ULONG_MAX 4294967295UL
+# define GRUB_LONG_MAX 2147483647L
+# define GRUB_LONG_MIN (-2147483647L - 1)
+#endif
+
+#if GRUB_CPU_SIZEOF_VOID_P == 4
+#define UINT_TO_PTR(x) ((void*)(grub_uint32_t)(x))
+#define PTR_TO_UINT64(x) ((grub_uint64_t)(grub_uint32_t)(x))
+#define PTR_TO_UINT32(x) ((grub_uint32_t)(x))
+#else
+#define UINT_TO_PTR(x) ((void*)(grub_uint64_t)(x))
+#define PTR_TO_UINT64(x) ((grub_uint64_t)(x))
+#define PTR_TO_UINT32(x) ((grub_uint32_t)(grub_uint64_t)(x))
+#endif
+
+/* The type for representing a file offset. */
+typedef grub_uint64_t grub_off_t;
+
+/* The type for representing a disk block address. */
+typedef grub_uint64_t grub_disk_addr_t;
+
+/* Byte-orders. */
+#define grub_swap_bytes16(x) \
+({ \
+ grub_uint16_t _x = (x); \
+ (grub_uint16_t) ((_x << 8) | (_x >> 8)); \
+})
+
+#define grub_swap_bytes16_compile_time(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
+#define grub_swap_bytes32_compile_time(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000UL) >> 24))
+
+#if defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)
+static inline grub_uint32_t grub_swap_bytes32(grub_uint32_t x)
+{
+ return __builtin_bswap32(x);
+}
+
+static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t x)
+{
+ return __builtin_bswap64(x);
+}
+#else /* not gcc 4.3 or newer */
+#define grub_swap_bytes32(x) \
+({ \
+ grub_uint32_t _x = (x); \
+ (grub_uint32_t) ((_x << 24) \
+ | ((_x & (grub_uint32_t) 0xFF00UL) << 8) \
+ | ((_x & (grub_uint32_t) 0xFF0000UL) >> 8) \
+ | (_x >> 24)); \
+})
+
+#define grub_swap_bytes64(x) \
+({ \
+ grub_uint64_t _x = (x); \
+ (grub_uint64_t) ((_x << 56) \
+ | ((_x & (grub_uint64_t) 0xFF00ULL) << 40) \
+ | ((_x & (grub_uint64_t) 0xFF0000ULL) << 24) \
+ | ((_x & (grub_uint64_t) 0xFF000000ULL) << 8) \
+ | ((_x & (grub_uint64_t) 0xFF00000000ULL) >> 8) \
+ | ((_x & (grub_uint64_t) 0xFF0000000000ULL) >> 24) \
+ | ((_x & (grub_uint64_t) 0xFF000000000000ULL) >> 40) \
+ | (_x >> 56)); \
+})
+#endif /* not gcc 4.3 or newer */
+
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+# define grub_cpu_to_le16(x) grub_swap_bytes16(x)
+# define grub_cpu_to_le32(x) grub_swap_bytes32(x)
+# define grub_cpu_to_le64(x) grub_swap_bytes64(x)
+# define grub_le_to_cpu16(x) grub_swap_bytes16(x)
+# define grub_le_to_cpu32(x) grub_swap_bytes32(x)
+# define grub_le_to_cpu64(x) grub_swap_bytes64(x)
+# define grub_cpu_to_be16(x) ((grub_uint16_t) (x))
+# define grub_cpu_to_be32(x) ((grub_uint32_t) (x))
+# define grub_cpu_to_be64(x) ((grub_uint64_t) (x))
+# define grub_be_to_cpu16(x) ((grub_uint16_t) (x))
+# define grub_be_to_cpu32(x) ((grub_uint32_t) (x))
+# define grub_be_to_cpu64(x) ((grub_uint64_t) (x))
+# define grub_cpu_to_le32_compile_time(x) grub_swap_bytes32_compile_time(x)
+# define grub_cpu_to_le16_compile_time(x) grub_swap_bytes16_compile_time(x)
+#else /* ! WORDS_BIGENDIAN */
+# define grub_cpu_to_le16(x) ((grub_uint16_t) (x))
+# define grub_cpu_to_le32(x) ((grub_uint32_t) (x))
+# define grub_cpu_to_le64(x) ((grub_uint64_t) (x))
+# define grub_le_to_cpu16(x) ((grub_uint16_t) (x))
+# define grub_le_to_cpu32(x) ((grub_uint32_t) (x))
+# define grub_le_to_cpu64(x) ((grub_uint64_t) (x))
+# define grub_cpu_to_be16(x) grub_swap_bytes16(x)
+# define grub_cpu_to_be32(x) grub_swap_bytes32(x)
+# define grub_cpu_to_be64(x) grub_swap_bytes64(x)
+# define grub_be_to_cpu16(x) grub_swap_bytes16(x)
+# define grub_be_to_cpu32(x) grub_swap_bytes32(x)
+# define grub_be_to_cpu64(x) grub_swap_bytes64(x)
+# define grub_cpu_to_le16_compile_time(x) ((grub_uint16_t) (x))
+# define grub_cpu_to_le32_compile_time(x) ((grub_uint32_t) (x))
+#endif /* ! WORDS_BIGENDIAN */
+
+#endif /* ! GRUB_TYPES_HEADER */
diff --git a/include/grub/unicode.h b/include/grub/unicode.h
new file mode 100644
index 0000000..6476925
--- /dev/null
+++ b/include/grub/unicode.h
@@ -0,0 +1,272 @@
+/*
+ * 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_BIDI_HEADER
+#define GRUB_BIDI_HEADER 1
+
+#include <grub/types.h>
+#include <grub/mm.h>
+#include <grub/misc.h>
+
+struct grub_unicode_bidi_pair
+{
+ grub_uint32_t key;
+ grub_uint32_t replace;
+};
+
+struct grub_unicode_compact_range
+{
+ grub_uint32_t start:21;
+ grub_uint32_t end:21;
+ grub_uint8_t bidi_type:5;
+ grub_uint8_t comb_type;
+ grub_uint8_t bidi_mirror:1;
+ grub_uint8_t join_type:3;
+} __attribute__ ((packed));
+
+/* Old-style Arabic shaping. Used for "visual UTF-8" and
+ in grub-mkfont to find variant glyphs in absence of GPOS tables. */
+struct grub_unicode_arabic_shape
+{
+ grub_uint32_t code;
+ grub_uint32_t isolated;
+ grub_uint32_t right_linked;
+ grub_uint32_t both_linked;
+ grub_uint32_t left_linked;
+};
+
+extern struct grub_unicode_arabic_shape grub_unicode_arabic_shapes[];
+
+enum grub_bidi_type
+ {
+ GRUB_BIDI_TYPE_L = 0,
+ GRUB_BIDI_TYPE_LRE,
+ GRUB_BIDI_TYPE_LRO,
+ GRUB_BIDI_TYPE_R,
+ GRUB_BIDI_TYPE_AL,
+ GRUB_BIDI_TYPE_RLE,
+ GRUB_BIDI_TYPE_RLO,
+ GRUB_BIDI_TYPE_PDF,
+ GRUB_BIDI_TYPE_EN,
+ GRUB_BIDI_TYPE_ES,
+ GRUB_BIDI_TYPE_ET,
+ GRUB_BIDI_TYPE_AN,
+ GRUB_BIDI_TYPE_CS,
+ GRUB_BIDI_TYPE_NSM,
+ GRUB_BIDI_TYPE_BN,
+ GRUB_BIDI_TYPE_B,
+ GRUB_BIDI_TYPE_S,
+ GRUB_BIDI_TYPE_WS,
+ GRUB_BIDI_TYPE_ON
+ };
+
+enum grub_join_type
+ {
+ GRUB_JOIN_TYPE_NONJOINING = 0,
+ GRUB_JOIN_TYPE_LEFT = 1,
+ GRUB_JOIN_TYPE_RIGHT = 2,
+ GRUB_JOIN_TYPE_DUAL = 3,
+ GRUB_JOIN_TYPE_CAUSING = 4,
+ GRUB_JOIN_TYPE_TRANSPARENT = 5
+ };
+
+enum grub_comb_type
+ {
+ GRUB_UNICODE_COMB_NONE = 0,
+ GRUB_UNICODE_COMB_OVERLAY = 1,
+ GRUB_UNICODE_COMB_HEBREW_SHEVA = 10,
+ GRUB_UNICODE_COMB_HEBREW_HATAF_SEGOL = 11,
+ GRUB_UNICODE_COMB_HEBREW_HATAF_PATAH = 12,
+ GRUB_UNICODE_COMB_HEBREW_HATAF_QAMATS = 13,
+ GRUB_UNICODE_COMB_HEBREW_HIRIQ = 14,
+ GRUB_UNICODE_COMB_HEBREW_TSERE = 15,
+ GRUB_UNICODE_COMB_HEBREW_SEGOL = 16,
+ GRUB_UNICODE_COMB_HEBREW_PATAH = 17,
+ GRUB_UNICODE_COMB_HEBREW_QAMATS = 18,
+ GRUB_UNICODE_COMB_HEBREW_HOLAM = 19,
+ GRUB_UNICODE_COMB_HEBREW_QUBUTS = 20,
+ GRUB_UNICODE_COMB_HEBREW_DAGESH = 21,
+ GRUB_UNICODE_COMB_HEBREW_METEG = 22,
+ GRUB_UNICODE_COMB_HEBREW_RAFE = 23,
+ GRUB_UNICODE_COMB_HEBREW_SHIN_DOT = 24,
+ GRUB_UNICODE_COMB_HEBREW_SIN_DOT = 25,
+ GRUB_UNICODE_COMB_HEBREW_VARIKA = 26,
+ GRUB_UNICODE_COMB_ARABIC_FATHATAN = 27,
+ GRUB_UNICODE_COMB_ARABIC_DAMMATAN = 28,
+ GRUB_UNICODE_COMB_ARABIC_KASRATAN = 29,
+ GRUB_UNICODE_COMB_ARABIC_FATHAH = 30,
+ GRUB_UNICODE_COMB_ARABIC_DAMMAH = 31,
+ GRUB_UNICODE_COMB_ARABIC_KASRA = 32,
+ GRUB_UNICODE_COMB_ARABIC_SHADDA = 33,
+ GRUB_UNICODE_COMB_ARABIC_SUKUN = 34,
+ GRUB_UNICODE_COMB_ARABIC_SUPERSCRIPT_ALIF = 35,
+ GRUB_UNICODE_COMB_SYRIAC_SUPERSCRIPT_ALAPH = 36,
+ GRUB_UNICODE_STACK_ATTACHED_BELOW = 202,
+ GRUB_UNICODE_STACK_ATTACHED_ABOVE = 214,
+ GRUB_UNICODE_COMB_ATTACHED_ABOVE_RIGHT = 216,
+ GRUB_UNICODE_STACK_BELOW = 220,
+ GRUB_UNICODE_COMB_BELOW_RIGHT = 222,
+ GRUB_UNICODE_COMB_ABOVE_LEFT = 228,
+ GRUB_UNICODE_STACK_ABOVE = 230,
+ GRUB_UNICODE_COMB_ABOVE_RIGHT = 232,
+ GRUB_UNICODE_COMB_YPOGEGRAMMENI = 240,
+ /* If combining nature is indicated only by class and
+ not "combining type". */
+ GRUB_UNICODE_COMB_ME = 253,
+ GRUB_UNICODE_COMB_MC = 254,
+ GRUB_UNICODE_COMB_MN = 255,
+ };
+
+/* This structure describes a glyph as opposed to character. */
+struct grub_unicode_glyph
+{
+ grub_uint32_t base;
+ grub_uint16_t variant:9;
+ grub_uint8_t attributes:5;
+ grub_size_t ncomb;
+ struct grub_unicode_combining {
+ grub_uint32_t code;
+ enum grub_comb_type type;
+ } *combining;
+ /* Hint by unicode subsystem how wide this character usually is.
+ Real width is determined by font. Set only in UTF-8 stream. */
+ int estimated_width;
+};
+
+#define GRUB_UNICODE_GLYPH_ATTRIBUTE_MIRROR 0x1
+#define GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT 1
+#define GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED 0x2
+#define GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED \
+ (GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED \
+ << GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT)
+/* Set iff the corresponding joining flags come from ZWJ or ZWNJ. */
+#define GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT 0x8
+#define GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED_EXPLICIT \
+ (GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT \
+ << GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT)
+#define GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN \
+ (GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED \
+ | GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED \
+ | GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT \
+ | GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED_EXPLICIT)
+
+enum
+ {
+ GRUB_UNICODE_COMBINING_GRAPHEME_JOINER = 0x034f,
+ GRUB_UNICODE_HEBREW_WAW = 0x05d5,
+ GRUB_UNICODE_ARABIC_START = 0x0600,
+ GRUB_UNICODE_ARABIC_END = 0x0700,
+ GRUB_UNICODE_THAANA_ABAFILI = 0x07a6,
+ GRUB_UNICODE_THAANA_AABAAFILI = 0x07a7,
+ GRUB_UNICODE_THAANA_IBIFILI = 0x07a8,
+ GRUB_UNICODE_THAANA_EEBEEFILI = 0x07a9,
+ GRUB_UNICODE_THAANA_UBUFILI = 0x07aa,
+ GRUB_UNICODE_THAANA_OOBOOFILI = 0x07ab,
+ GRUB_UNICODE_THAANA_EBEFILI = 0x07ac,
+ GRUB_UNICODE_THAANA_EYBEYFILI = 0x07ad,
+ GRUB_UNICODE_THAANA_OBOFILI = 0x07ae,
+ GRUB_UNICODE_THAANA_OABOAFILI = 0x07af,
+ GRUB_UNICODE_THAANA_SUKUN = 0x07b0,
+ GRUB_UNICODE_ZWNJ = 0x200c,
+ GRUB_UNICODE_ZWJ = 0x200d,
+ GRUB_UNICODE_LEFTARROW = 0x2190,
+ GRUB_UNICODE_UPARROW = 0x2191,
+ GRUB_UNICODE_RIGHTARROW = 0x2192,
+ GRUB_UNICODE_DOWNARROW = 0x2193,
+ GRUB_UNICODE_LIGHT_HLINE = 0x2500,
+ GRUB_UNICODE_HLINE = 0x2501,
+ GRUB_UNICODE_LIGHT_VLINE = 0x2502,
+ GRUB_UNICODE_VLINE = 0x2503,
+ GRUB_UNICODE_LIGHT_CORNER_UL = 0x250c,
+ GRUB_UNICODE_CORNER_UL = 0x250f,
+ GRUB_UNICODE_LIGHT_CORNER_UR = 0x2510,
+ GRUB_UNICODE_CORNER_UR = 0x2513,
+ GRUB_UNICODE_LIGHT_CORNER_LL = 0x2514,
+ GRUB_UNICODE_CORNER_LL = 0x2517,
+ GRUB_UNICODE_LIGHT_CORNER_LR = 0x2518,
+ GRUB_UNICODE_CORNER_LR = 0x251b,
+ GRUB_UNICODE_BLACK_UP_TRIANGLE = 0x25b2,
+ GRUB_UNICODE_BLACK_RIGHT_TRIANGLE = 0x25ba,
+ GRUB_UNICODE_BLACK_DOWN_TRIANGLE = 0x25bc,
+ GRUB_UNICODE_BLACK_LEFT_TRIANGLE = 0x25c4,
+ GRUB_UNICODE_VARIATION_SELECTOR_1 = 0xfe00,
+ GRUB_UNICODE_VARIATION_SELECTOR_16 = 0xfe0f,
+ GRUB_UNICODE_VARIATION_SELECTOR_17 = 0xe0100,
+ GRUB_UNICODE_VARIATION_SELECTOR_256 = 0xe01ef
+ };
+
+extern struct grub_unicode_compact_range grub_unicode_compact[];
+extern struct grub_unicode_bidi_pair grub_unicode_bidi_pairs[];
+
+#define GRUB_UNICODE_MAX_CACHED_CHAR 0x20000
+/* Unicode mandates an arbitrary limit. */
+#define GRUB_BIDI_MAX_EXPLICIT_LEVEL 61
+
+grub_ssize_t
+grub_bidi_logical_to_visual (const grub_uint32_t *logical,
+ grub_size_t logical_len,
+ struct grub_unicode_glyph **visual_out,
+ grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
+ grub_size_t max_width,
+ grub_size_t start_width);
+
+enum grub_comb_type
+grub_unicode_get_comb_type (grub_uint32_t c);
+grub_size_t
+grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen,
+ struct grub_unicode_glyph *out);
+
+static inline struct grub_unicode_glyph *
+grub_unicode_glyph_dup (const struct grub_unicode_glyph *in)
+{
+ struct grub_unicode_glyph *out = grub_malloc (sizeof (*out));
+ if (!out)
+ return NULL;
+ grub_memcpy (out, in, sizeof (*in));
+ if (in->combining)
+ {
+ out->combining = grub_malloc (in->ncomb * sizeof (*in));
+ if (!out->combining)
+ {
+ grub_free (out);
+ return NULL;
+ }
+ grub_memcpy (out->combining, in->combining, in->ncomb * sizeof (*in));
+ }
+ return out;
+}
+
+static inline struct grub_unicode_glyph *
+grub_unicode_glyph_from_code (grub_uint32_t code)
+{
+ struct grub_unicode_glyph *ret;
+ ret = grub_zalloc (sizeof (*ret));
+ if (!ret)
+ return NULL;
+
+ ret->base = code;
+
+ return ret;
+}
+
+grub_uint32_t
+grub_unicode_mirror_code (grub_uint32_t in);
+grub_uint32_t
+grub_unicode_shape_code (grub_uint32_t in, grub_uint8_t attr);
+
+#endif
diff --git a/include/grub/usb.h b/include/grub/usb.h
new file mode 100644
index 0000000..6f838e4
--- /dev/null
+++ b/include/grub/usb.h
@@ -0,0 +1,288 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_USB_H
+#define GRUB_USB_H 1
+
+#include <grub/err.h>
+#include <grub/usbdesc.h>
+#include <grub/usbtrans.h>
+
+typedef struct grub_usb_device *grub_usb_device_t;
+typedef struct grub_usb_controller *grub_usb_controller_t;
+typedef struct grub_usb_controller_dev *grub_usb_controller_dev_t;
+
+typedef enum
+ {
+ GRUB_USB_ERR_NONE,
+ GRUB_USB_ERR_WAIT,
+ GRUB_USB_ERR_INTERNAL,
+ GRUB_USB_ERR_STALL,
+ GRUB_USB_ERR_DATA,
+ GRUB_USB_ERR_NAK,
+ GRUB_USB_ERR_BABBLE,
+ GRUB_USB_ERR_TIMEOUT,
+ GRUB_USB_ERR_BITSTUFF,
+ GRUB_USB_ERR_UNRECOVERABLE
+ } grub_usb_err_t;
+
+typedef enum
+ {
+ GRUB_USB_SPEED_NONE,
+ GRUB_USB_SPEED_LOW,
+ GRUB_USB_SPEED_FULL,
+ GRUB_USB_SPEED_HIGH
+ } grub_usb_speed_t;
+
+/* Call HOOK with each device, until HOOK returns non-zero. */
+int grub_usb_iterate (int (*hook) (grub_usb_device_t dev));
+
+grub_usb_err_t grub_usb_device_initialize (grub_usb_device_t dev);
+
+grub_usb_err_t grub_usb_get_descriptor (grub_usb_device_t dev,
+ grub_uint8_t type, grub_uint8_t index,
+ grub_size_t size, char *data);
+
+struct grub_usb_desc_endp *
+grub_usb_get_endpdescriptor (grub_usb_device_t usbdev, int addr);
+
+grub_usb_err_t grub_usb_clear_halt (grub_usb_device_t dev, int endpoint);
+
+
+grub_usb_err_t grub_usb_set_configuration (grub_usb_device_t dev,
+ int configuration);
+
+void grub_usb_controller_dev_register (grub_usb_controller_dev_t usb);
+
+void grub_usb_controller_dev_unregister (grub_usb_controller_dev_t usb);
+
+int grub_usb_controller_iterate (int (*hook) (grub_usb_controller_t dev));
+
+
+grub_usb_err_t grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype,
+ grub_uint8_t request, grub_uint16_t value,
+ grub_uint16_t index, grub_size_t size,
+ char *data);
+
+grub_usb_err_t
+grub_usb_bulk_read (grub_usb_device_t dev,
+ int endpoint, grub_size_t size, char *data);
+grub_usb_err_t
+grub_usb_bulk_write (grub_usb_device_t dev,
+ int endpoint, grub_size_t size, char *data);
+
+grub_usb_err_t
+grub_usb_root_hub (grub_usb_controller_t controller);
+
+
+
+/* XXX: All handled by libusb for now. */
+struct grub_usb_controller_dev
+{
+ /* The device name. */
+ const char *name;
+
+ int (*iterate) (int (*hook) (grub_usb_controller_t dev));
+
+ grub_usb_err_t (*setup_transfer) (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer);
+
+ grub_usb_err_t (*check_transfer) (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer,
+ grub_size_t *actual);
+
+ grub_usb_err_t (*cancel_transfer) (grub_usb_controller_t dev,
+ grub_usb_transfer_t transfer);
+
+ int (*hubports) (grub_usb_controller_t dev);
+
+ grub_err_t (*portstatus) (grub_usb_controller_t dev, unsigned int port,
+ unsigned int enable);
+
+ grub_usb_speed_t (*detect_dev) (grub_usb_controller_t dev, int port, int *changed);
+
+ /* Per controller flag - port reset pending, don't do another reset */
+ grub_uint64_t pending_reset;
+
+ /* The next host controller. */
+ struct grub_usb_controller_dev *next;
+};
+
+struct grub_usb_controller
+{
+ /* The underlying USB Host Controller device. */
+ grub_usb_controller_dev_t dev;
+
+ /* Data used by the USB Host Controller Driver. */
+ void *data;
+};
+
+
+struct grub_usb_interface
+{
+ struct grub_usb_desc_if *descif;
+
+ struct grub_usb_desc_endp *descendp;
+
+ /* A driver is handling this interface. Do we need to support multiple drivers
+ for single interface?
+ */
+ int attached;
+
+ void (*detach_hook) (struct grub_usb_device *dev, int config, int interface);
+
+ void *detach_data;
+};
+
+struct grub_usb_configuration
+{
+ /* Configuration descriptors . */
+ struct grub_usb_desc_config *descconf;
+
+ /* Interfaces associated to this configuration. */
+ struct grub_usb_interface interf[32];
+};
+
+struct grub_usb_device
+{
+ /* The device descriptor of this device. */
+ struct grub_usb_desc_device descdev;
+
+ /* The controller the device is connected to. */
+ struct grub_usb_controller controller;
+
+ /* Device configurations (after opening the device). */
+ struct grub_usb_configuration config[8];
+
+ /* Device address. */
+ int addr;
+
+ /* Device speed. */
+ grub_usb_speed_t speed;
+
+ /* All descriptors are read if this is set to 1. */
+ int initialized;
+
+ /* Data toggle values (used for bulk transfers only). */
+ int toggle[256];
+
+ /* Used by libusb wrapper. Schedulded for removal. */
+ void *data;
+
+ /* Hub information. */
+
+ /* Array of children for a hub. */
+ grub_usb_device_t *children;
+
+ /* Number of hub ports. */
+ unsigned nports;
+
+ grub_usb_transfer_t hub_transfer;
+
+ grub_uint32_t statuschange;
+
+ struct grub_usb_desc_endp *hub_endpoint;
+};
+
+
+
+typedef enum grub_usb_ep_type
+ {
+ GRUB_USB_EP_CONTROL,
+ GRUB_USB_EP_ISOCHRONOUS,
+ GRUB_USB_EP_BULK,
+ GRUB_USB_EP_INTERRUPT
+ } grub_usb_ep_type_t;
+
+static inline enum grub_usb_ep_type
+grub_usb_get_ep_type (struct grub_usb_desc_endp *ep)
+{
+ return ep->attrib & 3;
+}
+
+typedef enum
+ {
+ GRUB_USB_CLASS_NOTHERE,
+ GRUB_USB_CLASS_AUDIO,
+ GRUB_USB_CLASS_COMMUNICATION,
+ GRUB_USB_CLASS_HID,
+ GRUB_USB_CLASS_XXX,
+ GRUB_USB_CLASS_PHYSICAL,
+ GRUB_USB_CLASS_IMAGE,
+ GRUB_USB_CLASS_PRINTER,
+ GRUB_USB_CLASS_MASS_STORAGE,
+ GRUB_USB_CLASS_HUB,
+ GRUB_USB_CLASS_DATA_INTERFACE,
+ GRUB_USB_CLASS_SMART_CARD,
+ GRUB_USB_CLASS_CONTENT_SECURITY,
+ GRUB_USB_CLASS_VIDEO
+ } grub_usb_classes_t;
+
+typedef enum
+ {
+ GRUB_USBMS_SUBCLASS_BULK = 0x06,
+ /* Experimental support for non-pure SCSI devices */
+ GRUB_USBMS_SUBCLASS_RBC = 0x01,
+ GRUB_USBMS_SUBCLASS_MMC2 = 0x02,
+ GRUB_USBMS_SUBCLASS_UFI = 0x04,
+ GRUB_USBMS_SUBCLASS_SFF8070 = 0x05
+ } grub_usbms_subclass_t;
+
+typedef enum
+ {
+ GRUB_USBMS_PROTOCOL_BULK = 0x50
+ } grub_usbms_protocol_t;
+
+static inline struct grub_usb_desc_if *
+grub_usb_get_config_interface (struct grub_usb_desc_config *config)
+{
+ struct grub_usb_desc_if *interf;
+
+ interf = (struct grub_usb_desc_if *) (sizeof (*config) + (char *) config);
+ return interf;
+}
+
+typedef int (*grub_usb_attach_hook_class) (grub_usb_device_t usbdev,
+ int configno, int interfno);
+
+struct grub_usb_attach_desc
+{
+ struct grub_usb_attach_desc *next;
+ int class;
+ grub_usb_attach_hook_class hook;
+};
+
+void grub_usb_register_attach_hook_class (struct grub_usb_attach_desc *desc);
+void grub_usb_unregister_attach_hook_class (struct grub_usb_attach_desc *desc);
+
+void grub_usb_poll_devices (void);
+
+void grub_usb_device_attach (grub_usb_device_t dev);
+grub_usb_err_t
+grub_usb_bulk_read_extended (grub_usb_device_t dev,
+ int endpoint, grub_size_t size, char *data,
+ int timeout, grub_size_t *actual);
+grub_usb_transfer_t
+grub_usb_bulk_read_background (grub_usb_device_t dev,
+ int endpoint, grub_size_t size, void *data);
+grub_usb_err_t
+grub_usb_check_transfer (grub_usb_transfer_t trans, grub_size_t *actual);
+void
+grub_usb_cancel_transfer (grub_usb_transfer_t trans);
+
+#endif /* GRUB_USB_H */
diff --git a/include/grub/usbdesc.h b/include/grub/usbdesc.h
new file mode 100644
index 0000000..84b723a
--- /dev/null
+++ b/include/grub/usbdesc.h
@@ -0,0 +1,125 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_USBDESC_H
+#define GRUB_USBDESC_H 1
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+
+typedef enum {
+ GRUB_USB_DESCRIPTOR_DEVICE = 1,
+ GRUB_USB_DESCRIPTOR_CONFIG,
+ GRUB_USB_DESCRIPTOR_STRING,
+ GRUB_USB_DESCRIPTOR_INTERFACE,
+ GRUB_USB_DESCRIPTOR_ENDPOINT,
+ GRUB_USB_DESCRIPTOR_HUB = 0x29
+} grub_usb_descriptor_t;
+
+struct grub_usb_desc
+{
+ grub_uint8_t length;
+ grub_uint8_t type;
+} __attribute__ ((packed));
+
+struct grub_usb_desc_device
+{
+ grub_uint8_t length;
+ grub_uint8_t type;
+ grub_uint16_t usbrel;
+ grub_uint8_t class;
+ grub_uint8_t subclass;
+ grub_uint8_t protocol;
+ grub_uint8_t maxsize0;
+ grub_uint16_t vendorid;
+ grub_uint16_t prodid;
+ grub_uint16_t devrel;
+ grub_uint8_t strvendor;
+ grub_uint8_t strprod;
+ grub_uint8_t strserial;
+ grub_uint8_t configcnt;
+} __attribute__ ((packed));
+
+struct grub_usb_desc_config
+{
+ grub_uint8_t length;
+ grub_uint8_t type;
+ grub_uint16_t totallen;
+ grub_uint8_t numif;
+ grub_uint8_t config;
+ grub_uint8_t strconfig;
+ grub_uint8_t attrib;
+ grub_uint8_t maxpower;
+} __attribute__ ((packed));
+
+#if 0
+struct grub_usb_desc_if_association
+{
+ grub_uint8_t length;
+ grub_uint8_t type;
+ grub_uint8_t firstif;
+ grub_uint8_t ifcnt;
+ grub_uint8_t class;
+ grub_uint8_t subclass;
+ grub_uint8_t protocol;
+ grub_uint8_t function;
+} __attribute__ ((packed));
+#endif
+
+struct grub_usb_desc_if
+{
+ grub_uint8_t length;
+ grub_uint8_t type;
+ grub_uint8_t ifnum;
+ grub_uint8_t altsetting;
+ grub_uint8_t endpointcnt;
+ grub_uint8_t class;
+ grub_uint8_t subclass;
+ grub_uint8_t protocol;
+ grub_uint8_t strif;
+} __attribute__ ((packed));
+
+struct grub_usb_desc_endp
+{
+ grub_uint8_t length;
+ grub_uint8_t type;
+ grub_uint8_t endp_addr;
+ grub_uint8_t attrib;
+ grub_uint16_t maxpacket;
+ grub_uint8_t interval;
+} __attribute__ ((packed));
+
+struct grub_usb_desc_str
+{
+ grub_uint8_t length;
+ grub_uint8_t type;
+ grub_uint16_t str[0];
+} __attribute__ ((packed));
+
+struct grub_usb_usb_hubdesc
+{
+ grub_uint8_t length;
+ grub_uint8_t type;
+ grub_uint8_t portcnt;
+ grub_uint16_t characteristics;
+ grub_uint8_t pwdgood;
+ grub_uint8_t current;
+ /* Removable and power control bits follow. */
+} __attribute__ ((packed));
+
+#endif /* GRUB_USBDESC_H */
diff --git a/include/grub/usbserial.h b/include/grub/usbserial.h
new file mode 100644
index 0000000..7420125
--- /dev/null
+++ b/include/grub/usbserial.h
@@ -0,0 +1,34 @@
+/* serial.h - serial device interface */
+/*
+ * 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_USBSERIAL_HEADER
+#define GRUB_USBSERIAL_HEADER 1
+
+void grub_usbserial_fini (struct grub_serial_port *port);
+
+void grub_usbserial_detach (grub_usb_device_t usbdev, int configno,
+ int interfno);
+
+int
+grub_usbserial_attach (grub_usb_device_t usbdev, int configno, int interfno,
+ struct grub_serial_driver *driver);
+int
+grub_usbserial_fetch (struct grub_serial_port *port, grub_size_t header_size);
+
+#endif
diff --git a/include/grub/usbtrans.h b/include/grub/usbtrans.h
new file mode 100644
index 0000000..5ee276d
--- /dev/null
+++ b/include/grub/usbtrans.h
@@ -0,0 +1,153 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_USBTRANS_H
+#define GRUB_USBTRANS_H 1
+
+typedef enum
+ {
+ GRUB_USB_TRANSFER_TYPE_IN,
+ GRUB_USB_TRANSFER_TYPE_OUT,
+ GRUB_USB_TRANSFER_TYPE_SETUP
+ } grub_transfer_type_t;
+
+typedef enum
+ {
+ GRUB_USB_TRANSACTION_TYPE_CONTROL,
+ GRUB_USB_TRANSACTION_TYPE_BULK
+ } grub_transaction_type_t;
+
+struct grub_usb_transaction
+{
+ int size;
+ int toggle;
+ grub_transfer_type_t pid;
+ grub_uint32_t data;
+ grub_size_t preceding;
+};
+typedef struct grub_usb_transaction *grub_usb_transaction_t;
+
+struct grub_usb_transfer
+{
+ int devaddr;
+
+ int endpoint;
+
+ int size;
+
+ int transcnt;
+
+ int max;
+
+ grub_transaction_type_t type;
+
+ grub_transfer_type_t dir;
+
+ struct grub_usb_device *dev;
+
+ struct grub_usb_transaction *transactions;
+
+ int last_trans;
+ /* Index of last processed transaction in OHCI/UHCI driver. */
+
+ void *controller_data;
+
+ /* Used when finishing transfer to copy data back. */
+ struct grub_pci_dma_chunk *data_chunk;
+ void *data;
+};
+typedef struct grub_usb_transfer *grub_usb_transfer_t;
+
+
+
+enum
+ {
+ GRUB_USB_REQTYPE_TARGET_DEV = (0 << 0),
+ GRUB_USB_REQTYPE_TARGET_INTERF = (1 << 0),
+ GRUB_USB_REQTYPE_TARGET_ENDP = (2 << 0),
+ GRUB_USB_REQTYPE_TARGET_OTHER = (3 << 0),
+ GRUB_USB_REQTYPE_STANDARD = (0 << 5),
+ GRUB_USB_REQTYPE_CLASS = (1 << 5),
+ GRUB_USB_REQTYPE_VENDOR = (2 << 5),
+ GRUB_USB_REQTYPE_OUT = (0 << 7),
+ GRUB_USB_REQTYPE_IN = (1 << 7),
+ GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT = GRUB_USB_REQTYPE_TARGET_INTERF
+ | GRUB_USB_REQTYPE_CLASS | GRUB_USB_REQTYPE_OUT,
+ GRUB_USB_REQTYPE_VENDOR_OUT = GRUB_USB_REQTYPE_VENDOR | GRUB_USB_REQTYPE_OUT,
+ GRUB_USB_REQTYPE_CLASS_INTERFACE_IN = GRUB_USB_REQTYPE_TARGET_INTERF
+ | GRUB_USB_REQTYPE_CLASS | GRUB_USB_REQTYPE_IN,
+ GRUB_USB_REQTYPE_VENDOR_IN = GRUB_USB_REQTYPE_VENDOR | GRUB_USB_REQTYPE_IN
+ };
+
+enum
+ {
+ GRUB_USB_REQ_GET_STATUS = 0x00,
+ GRUB_USB_REQ_CLEAR_FEATURE = 0x01,
+ GRUB_USB_REQ_SET_FEATURE = 0x03,
+ GRUB_USB_REQ_SET_ADDRESS = 0x05,
+ GRUB_USB_REQ_GET_DESCRIPTOR = 0x06,
+ GRUB_USB_REQ_SET_DESCRIPTOR = 0x07,
+ GRUB_USB_REQ_GET_CONFIGURATION = 0x08,
+ GRUB_USB_REQ_SET_CONFIGURATION = 0x09,
+ GRUB_USB_REQ_GET_INTERFACE = 0x0A,
+ GRUB_USB_REQ_SET_INTERFACE = 0x0B,
+ GRUB_USB_REQ_SYNC_FRAME = 0x0C
+ };
+
+#define GRUB_USB_FEATURE_ENDP_HALT 0x00
+#define GRUB_USB_FEATURE_DEV_REMOTE_WU 0x01
+#define GRUB_USB_FEATURE_TEST_MODE 0x02
+
+enum
+ {
+ GRUB_USB_HUB_FEATURE_PORT_RESET = 0x04,
+ GRUB_USB_HUB_FEATURE_PORT_POWER = 0x08,
+ GRUB_USB_HUB_FEATURE_C_PORT_CONNECTED = 0x10,
+ GRUB_USB_HUB_FEATURE_C_PORT_ENABLED = 0x11,
+ GRUB_USB_HUB_FEATURE_C_PORT_SUSPEND = 0x12,
+ GRUB_USB_HUB_FEATURE_C_PORT_OVERCURRENT = 0x13,
+ GRUB_USB_HUB_FEATURE_C_PORT_RESET = 0x14
+ };
+
+enum
+ {
+ GRUB_USB_HUB_STATUS_PORT_CONNECTED = (1 << 0),
+ GRUB_USB_HUB_STATUS_PORT_ENABLED = (1 << 1),
+ GRUB_USB_HUB_STATUS_PORT_SUSPEND = (1 << 2),
+ GRUB_USB_HUB_STATUS_PORT_OVERCURRENT = (1 << 3),
+ GRUB_USB_HUB_STATUS_PORT_POWERED = (1 << 8),
+ GRUB_USB_HUB_STATUS_PORT_LOWSPEED = (1 << 9),
+ GRUB_USB_HUB_STATUS_PORT_HIGHSPEED = (1 << 10),
+ GRUB_USB_HUB_STATUS_C_PORT_CONNECTED = (1 << 16),
+ GRUB_USB_HUB_STATUS_C_PORT_ENABLED = (1 << 17),
+ GRUB_USB_HUB_STATUS_C_PORT_SUSPEND = (1 << 18),
+ GRUB_USB_HUB_STATUS_C_PORT_OVERCURRENT = (1 << 19),
+ GRUB_USB_HUB_STATUS_C_PORT_RESET = (1 << 20)
+ };
+
+struct grub_usb_packet_setup
+{
+ grub_uint8_t reqtype;
+ grub_uint8_t request;
+ grub_uint16_t value;
+ grub_uint16_t index;
+ grub_uint16_t length;
+} __attribute__((packed));
+
+
+#endif /* GRUB_USBTRANS_H */
diff --git a/include/grub/util/deviceiter.h b/include/grub/util/deviceiter.h
new file mode 100644
index 0000000..a8af03c
--- /dev/null
+++ b/include/grub/util/deviceiter.h
@@ -0,0 +1,11 @@
+#ifndef GRUB_DEVICEITER_MACHINE_UTIL_HEADER
+#define GRUB_DEVICEITER_MACHINE_UTIL_HEADER 1
+
+#include <config.h>
+
+void grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
+ int floppy_disks);
+void grub_util_emit_devicemap_entry (FILE *fp, char *name, int is_floppy,
+ int *num_fd, int *num_hd);
+
+#endif /* ! GRUB_DEVICEITER_MACHINE_UTIL_HEADER */
diff --git a/include/grub/util/libnvpair.h b/include/grub/util/libnvpair.h
new file mode 100644
index 0000000..26f7e9d
--- /dev/null
+++ b/include/grub/util/libnvpair.h
@@ -0,0 +1,39 @@
+/*
+ * 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 *);
+void nvlist_print (FILE *, nvlist_t *);
+
+#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/lvm.h b/include/grub/util/lvm.h
new file mode 100644
index 0000000..7a4c76c
--- /dev/null
+++ b/include/grub/util/lvm.h
@@ -0,0 +1,27 @@
+/* lvm.h - LVM support for GRUB utils. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,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_LVM_UTIL_HEADER
+#define GRUB_LVM_UTIL_HEADER 1
+
+#ifdef __linux__
+int grub_util_lvm_isvolume (char *name);
+#endif
+
+#endif /* ! GRUB_RAID_UTIL_HEADER */
diff --git a/include/grub/util/misc.h b/include/grub/util/misc.h
new file mode 100644
index 0000000..48dfbb8
--- /dev/null
+++ b/include/grub/util/misc.h
@@ -0,0 +1,63 @@
+/*
+ * 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_fp_size (FILE *fp);
+size_t grub_util_get_image_size (const char *path);
+void grub_util_read_at (void *img, size_t len, off_t offset, FILE *fp);
+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);
+void grub_util_write_image_at (const void *img, size_t size, off_t offset,
+ FILE *out);
+
+#ifdef __MINGW32__
+
+#define fseeko fseeko64
+#define ftello ftello64
+
+void sync (void);
+int fsync (int fno);
+void sleep(int s);
+
+grub_int64_t grub_util_get_disk_size (char *name);
+
+#endif
+
+
+char *make_system_path_relative_to_its_root (const char *path);
+
+char *canonicalize_file_name (const char *path);
+
+void grub_util_init_nls (void);
+
+#endif /* ! GRUB_UTIL_MISC_HEADER */
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/raid.h b/include/grub/util/raid.h
new file mode 100644
index 0000000..4da5eaa
--- /dev/null
+++ b/include/grub/util/raid.h
@@ -0,0 +1,27 @@
+/* raid.h - RAID support for GRUB utils. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,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_RAID_UTIL_HEADER
+#define GRUB_RAID_UTIL_HEADER 1
+
+#ifdef __linux__
+char** grub_util_raid_getmembers (const char *name);
+#endif
+
+#endif /* ! GRUB_RAID_UTIL_HEADER */
diff --git a/include/grub/util/resolve.h b/include/grub/util/resolve.h
new file mode 100644
index 0000000..f42df32
--- /dev/null
+++ b/include/grub/util/resolve.h
@@ -0,0 +1,35 @@
+/*
+ * 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[]);
+
+#endif /* ! GRUB_UTIL_RESOLVE_HEADER */
diff --git a/include/grub/vga.h b/include/grub/vga.h
new file mode 100644
index 0000000..7f112d8
--- /dev/null
+++ b/include/grub/vga.h
@@ -0,0 +1,371 @@
+/*
+ * 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_VGA_HEADER
+#define GRUB_VGA_HEADER 1
+
+#include <grub/pci.h>
+
+enum
+ {
+ GRUB_VGA_IO_ARX = 0x3c0,
+ GRUB_VGA_IO_ARX_READ = 0x3c1,
+ GRUB_VGA_IO_MISC_WRITE = 0x3c2,
+ GRUB_VGA_IO_SR_INDEX = 0x3c4,
+ GRUB_VGA_IO_SR_DATA = 0x3c5,
+ GRUB_VGA_IO_PIXEL_MASK = 0x3c6,
+ GRUB_VGA_IO_PALLETTE_READ_INDEX = 0x3c7,
+ GRUB_VGA_IO_PALLETTE_WRITE_INDEX = 0x3c8,
+ GRUB_VGA_IO_PALLETTE_DATA = 0x3c9,
+ GRUB_VGA_IO_GR_INDEX = 0x3ce,
+ GRUB_VGA_IO_GR_DATA = 0x3cf,
+ GRUB_VGA_IO_CR_INDEX = 0x3d4,
+ GRUB_VGA_IO_CR_DATA = 0x3d5,
+ GRUB_VGA_IO_INPUT_STATUS1_REGISTER = 0x3da
+ };
+
+#define GRUB_VGA_IO_INPUT_STATUS1_VERTR_BIT 0x08
+
+enum
+ {
+ GRUB_VGA_CR_HTOTAL = 0x00,
+ GRUB_VGA_CR_HORIZ_END = 0x01,
+ GRUB_VGA_CR_HBLANK_START = 0x02,
+ GRUB_VGA_CR_HBLANK_END = 0x03,
+ GRUB_VGA_CR_HORIZ_SYNC_PULSE_START = 0x04,
+ GRUB_VGA_CR_HORIZ_SYNC_PULSE_END = 0x05,
+ GRUB_VGA_CR_VERT_TOTAL = 0x06,
+ GRUB_VGA_CR_OVERFLOW = 0x07,
+ GRUB_VGA_CR_BYTE_PANNING = 0x08,
+ GRUB_VGA_CR_CELL_HEIGHT = 0x09,
+ GRUB_VGA_CR_CURSOR_START = 0x0a,
+ GRUB_VGA_CR_CURSOR_END = 0x0b,
+ GRUB_VGA_CR_START_ADDR_HIGH_REGISTER = 0x0c,
+ GRUB_VGA_CR_START_ADDR_LOW_REGISTER = 0x0d,
+ GRUB_VGA_CR_CURSOR_ADDR_HIGH = 0x0e,
+ GRUB_VGA_CR_CURSOR_ADDR_LOW = 0x0f,
+ GRUB_VGA_CR_VSYNC_START = 0x10,
+ GRUB_VGA_CR_VSYNC_END = 0x11,
+ GRUB_VGA_CR_VDISPLAY_END = 0x12,
+ GRUB_VGA_CR_PITCH = 0x13,
+ GRUB_VGA_CR_UNDERLINE_LOCATION = 0x14,
+ GRUB_VGA_CR_VERTICAL_BLANK_START = 0x15,
+ GRUB_VGA_CR_VERTICAL_BLANK_END = 0x16,
+ GRUB_VGA_CR_MODE = 0x17,
+ GRUB_VGA_CR_LINE_COMPARE = 0x18,
+ };
+
+enum
+ {
+ GRUB_VGA_CR_BYTE_PANNING_NORMAL = 0
+ };
+
+enum
+ {
+ GRUB_VGA_CR_UNDERLINE_LOCATION_DWORD_MODE = 0x40
+ };
+
+enum
+ {
+ GRUB_VGA_IO_MISC_COLOR = 0x01,
+ GRUB_VGA_IO_MISC_ENABLE_VRAM_ACCESS = 0x02,
+ GRUB_VGA_IO_MISC_EXTERNAL_CLOCK_0 = 0x08,
+ GRUB_VGA_IO_MISC_28MHZ = 0x04,
+ GRUB_VGA_IO_MISC_UPPER_64K = 0x20,
+ GRUB_VGA_IO_MISC_NEGATIVE_HORIZ_POLARITY = 0x40,
+ GRUB_VGA_IO_MISC_NEGATIVE_VERT_POLARITY = 0x80,
+ };
+
+enum
+ {
+ GRUB_VGA_ARX_MODE = 0x10,
+ GRUB_VGA_ARX_OVERSCAN = 0x11,
+ GRUB_VGA_ARX_COLOR_PLANE_ENABLE = 0x12,
+ GRUB_VGA_ARX_HORIZONTAL_PANNING = 0x13,
+ GRUB_VGA_ARX_COLOR_SELECT = 0x14
+ };
+
+enum
+ {
+ GRUB_VGA_ARX_MODE_TEXT = 0x00,
+ GRUB_VGA_ARX_MODE_GRAPHICS = 0x01,
+ GRUB_VGA_ARX_MODE_ENABLE_256COLOR = 0x40
+ };
+
+#define GRUB_VGA_CR_WIDTH_DIVISOR 8
+
+#define GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END1_SHIFT 7
+#define GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END1_MASK 0x02
+#define GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END2_SHIFT 3
+#define GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END2_MASK 0x40
+
+#define GRUB_VGA_CR_OVERFLOW_VERT_TOTAL1_SHIFT 8
+#define GRUB_VGA_CR_OVERFLOW_VERT_TOTAL1_MASK 0x01
+#define GRUB_VGA_CR_OVERFLOW_VERT_TOTAL2_SHIFT 4
+#define GRUB_VGA_CR_OVERFLOW_VERT_TOTAL2_MASK 0x20
+
+#define GRUB_VGA_CR_OVERFLOW_VSYNC_START1_SHIFT 6
+#define GRUB_VGA_CR_OVERFLOW_VSYNC_START1_MASK 0x04
+#define GRUB_VGA_CR_OVERFLOW_VSYNC_START2_SHIFT 2
+#define GRUB_VGA_CR_OVERFLOW_VSYNC_START2_MASK 0x80
+
+#define GRUB_VGA_CR_OVERFLOW_HEIGHT1_SHIFT 7
+#define GRUB_VGA_CR_OVERFLOW_HEIGHT1_MASK 0x02
+#define GRUB_VGA_CR_OVERFLOW_HEIGHT2_SHIFT 3
+#define GRUB_VGA_CR_OVERFLOW_HEIGHT2_MASK 0xc0
+#define GRUB_VGA_CR_OVERFLOW_LINE_COMPARE_SHIFT 4
+#define GRUB_VGA_CR_OVERFLOW_LINE_COMPARE_MASK 0x10
+
+#define GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_MASK 0x40
+#define GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_SHIFT 3
+#define GRUB_VGA_CR_CELL_HEIGHT_VERTICAL_BLANK_MASK 0x20
+#define GRUB_VGA_CR_CELL_HEIGHT_VERTICAL_BLANK_SHIFT 4
+#define GRUB_VGA_CR_CELL_HEIGHT_DOUBLE_SCAN 0x80
+enum
+ {
+ GRUB_VGA_CR_CURSOR_START_DISABLE = (1 << 5)
+ };
+
+#define GRUB_VGA_CR_PITCH_DIVISOR 8
+
+enum
+ {
+ GRUB_VGA_CR_MODE_NO_CGA = 0x01,
+ GRUB_VGA_CR_MODE_NO_HERCULES = 0x02,
+ GRUB_VGA_CR_MODE_ADDRESS_WRAP = 0x20,
+ GRUB_VGA_CR_MODE_BYTE_MODE = 0x40,
+ GRUB_VGA_CR_MODE_TIMING_ENABLE = 0x80
+ };
+
+enum
+ {
+ GRUB_VGA_SR_RESET = 0,
+ GRUB_VGA_SR_CLOCKING_MODE = 1,
+ GRUB_VGA_SR_MAP_MASK_REGISTER = 2,
+ GRUB_VGA_SR_CHAR_MAP_SELECT = 3,
+ GRUB_VGA_SR_MEMORY_MODE = 4,
+ };
+
+enum
+ {
+ GRUB_VGA_SR_RESET_ASYNC = 1,
+ GRUB_VGA_SR_RESET_SYNC = 2
+ };
+
+enum
+ {
+ GRUB_VGA_SR_CLOCKING_MODE_8_DOT_CLOCK = 1
+ };
+
+enum
+ {
+ GRUB_VGA_SR_MEMORY_MODE_NORMAL = 0,
+ GRUB_VGA_SR_MEMORY_MODE_EXTERNAL_VIDEO_MEMORY = 2,
+ GRUB_VGA_SR_MEMORY_MODE_SEQUENTIAL_ADDRESSING = 4,
+ GRUB_VGA_SR_MEMORY_MODE_CHAIN4 = 8,
+ };
+
+enum
+ {
+ GRUB_VGA_GR_SET_RESET_PLANE = 0,
+ GRUB_VGA_GR_SET_RESET_PLANE_ENABLE = 1,
+ GRUB_VGA_GR_COLOR_COMPARE = 2,
+ GRUB_VGA_GR_DATA_ROTATE = 3,
+ GRUB_VGA_GR_READ_MAP_REGISTER = 4,
+ GRUB_VGA_GR_MODE = 5,
+ GRUB_VGA_GR_GR6 = 6,
+ GRUB_VGA_GR_COLOR_COMPARE_DISABLE = 7,
+ GRUB_VGA_GR_BITMASK = 8,
+ GRUB_VGA_GR_MAX
+ };
+
+#define GRUB_VGA_ALL_PLANES 0xf
+#define GRUB_VGA_NO_PLANES 0x0
+
+enum
+ {
+ GRUB_VGA_GR_DATA_ROTATE_NOP = 0
+ };
+
+enum
+ {
+ GRUB_VGA_TEXT_TEXT_PLANE = 0,
+ GRUB_VGA_TEXT_ATTR_PLANE = 1,
+ GRUB_VGA_TEXT_FONT_PLANE = 2
+ };
+
+enum
+ {
+ GRUB_VGA_GR_GR6_GRAPHICS_MODE = 1,
+ GRUB_VGA_GR_GR6_MMAP_A0 = (1 << 2),
+ GRUB_VGA_GR_GR6_MMAP_CGA = (3 << 2)
+ };
+
+enum
+ {
+ GRUB_VGA_GR_MODE_READ_MODE1 = 0x08,
+ GRUB_VGA_GR_MODE_ODD_EVEN = 0x10,
+ GRUB_VGA_GR_MODE_ODD_EVEN_SHIFT = 0x20,
+ GRUB_VGA_GR_MODE_256_COLOR = 0x40
+ };
+
+static inline void
+grub_vga_gr_write (grub_uint8_t val, grub_uint8_t addr)
+{
+ grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_GR_INDEX);
+ grub_outb (val, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_GR_DATA);
+}
+
+static inline grub_uint8_t
+grub_vga_gr_read (grub_uint8_t addr)
+{
+ grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_GR_INDEX);
+ return grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_GR_DATA);
+}
+
+static inline void
+grub_vga_cr_write (grub_uint8_t val, grub_uint8_t addr)
+{
+ grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_CR_INDEX);
+ grub_outb (val, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_CR_DATA);
+}
+
+static inline grub_uint8_t
+grub_vga_cr_read (grub_uint8_t addr)
+{
+ grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_CR_INDEX);
+ return grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_CR_DATA);
+}
+
+static inline void
+grub_vga_sr_write (grub_uint8_t val, grub_uint8_t addr)
+{
+ grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_SR_INDEX);
+ grub_outb (val, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_SR_DATA);
+}
+
+static inline grub_uint8_t
+grub_vga_sr_read (grub_uint8_t addr)
+{
+ grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_SR_INDEX);
+ return grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_SR_DATA);
+}
+
+static inline void
+grub_vga_palette_read (grub_uint8_t addr, grub_uint8_t *r, grub_uint8_t *g,
+ grub_uint8_t *b)
+{
+ grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_READ_INDEX);
+ *r = grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_DATA);
+ *g = grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_DATA);
+ *b = grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_DATA);
+}
+
+static inline void
+grub_vga_palette_write (grub_uint8_t addr, grub_uint8_t r, grub_uint8_t g,
+ grub_uint8_t b)
+{
+ grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_WRITE_INDEX);
+ grub_outb (r, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_DATA);
+ grub_outb (g, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_DATA);
+ grub_outb (b, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_DATA);
+}
+
+static inline void
+grub_vga_write_arx (grub_uint8_t val, grub_uint8_t addr)
+{
+ grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_INPUT_STATUS1_REGISTER);
+ grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_ARX);
+ grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_ARX_READ);
+ grub_outb (val, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_ARX);
+}
+
+struct grub_video_hw_config
+{
+ unsigned vertical_total;
+ unsigned vertical_blank_start;
+ unsigned vertical_blank_end;
+ unsigned vertical_sync_start;
+ unsigned vertical_sync_end;
+ unsigned line_compare;
+ unsigned vdisplay_end;
+ unsigned pitch;
+ unsigned horizontal_total;
+ unsigned horizontal_blank_start;
+ unsigned horizontal_blank_end;
+ unsigned horizontal_sync_pulse_start;
+ unsigned horizontal_sync_pulse_end;
+ unsigned horizontal_end;
+};
+
+static inline void
+grub_vga_set_geometry (struct grub_video_hw_config *config,
+ void (*cr_write) (grub_uint8_t val, grub_uint8_t addr))
+{
+ unsigned vertical_total = config->vertical_total - 2;
+ unsigned vertical_blank_start = config->vertical_blank_start - 1;
+ unsigned vdisplay_end = config->vdisplay_end - 1;
+ grub_uint8_t overflow, cell_height_reg;
+
+ /* Disable CR0-7 write protection. */
+ cr_write (0, GRUB_VGA_CR_VSYNC_END);
+
+ overflow = ((vertical_total >> GRUB_VGA_CR_OVERFLOW_VERT_TOTAL1_SHIFT)
+ & GRUB_VGA_CR_OVERFLOW_VERT_TOTAL1_MASK)
+ | ((vertical_total >> GRUB_VGA_CR_OVERFLOW_VERT_TOTAL2_SHIFT)
+ & GRUB_VGA_CR_OVERFLOW_VERT_TOTAL2_MASK)
+ | ((config->vertical_sync_start >> GRUB_VGA_CR_OVERFLOW_VSYNC_START2_SHIFT)
+ & GRUB_VGA_CR_OVERFLOW_VSYNC_START2_MASK)
+ | ((config->vertical_sync_start >> GRUB_VGA_CR_OVERFLOW_VSYNC_START1_SHIFT)
+ & GRUB_VGA_CR_OVERFLOW_VSYNC_START1_MASK)
+ | ((vdisplay_end >> GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END1_SHIFT)
+ & GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END1_MASK)
+ | ((vdisplay_end >> GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END2_SHIFT)
+ & GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END2_MASK)
+ | ((config->vertical_sync_start >> GRUB_VGA_CR_OVERFLOW_VSYNC_START1_SHIFT)
+ & GRUB_VGA_CR_OVERFLOW_VSYNC_START1_MASK)
+ | ((config->line_compare >> GRUB_VGA_CR_OVERFLOW_LINE_COMPARE_SHIFT)
+ & GRUB_VGA_CR_OVERFLOW_LINE_COMPARE_MASK);
+
+ cell_height_reg = ((vertical_blank_start
+ >> GRUB_VGA_CR_CELL_HEIGHT_VERTICAL_BLANK_SHIFT)
+ & GRUB_VGA_CR_CELL_HEIGHT_VERTICAL_BLANK_MASK)
+ | ((config->line_compare >> GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_SHIFT)
+ & GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_MASK);
+
+ cr_write (config->horizontal_total - 1, GRUB_VGA_CR_HTOTAL);
+ cr_write (config->horizontal_end - 1, GRUB_VGA_CR_HORIZ_END);
+ cr_write (config->horizontal_blank_start - 1, GRUB_VGA_CR_HBLANK_START);
+ cr_write (config->horizontal_blank_end, GRUB_VGA_CR_HBLANK_END);
+ cr_write (config->horizontal_sync_pulse_start,
+ GRUB_VGA_CR_HORIZ_SYNC_PULSE_START);
+ cr_write (config->horizontal_sync_pulse_end,
+ GRUB_VGA_CR_HORIZ_SYNC_PULSE_END);
+ cr_write (vertical_total & 0xff, GRUB_VGA_CR_VERT_TOTAL);
+ cr_write (overflow, GRUB_VGA_CR_OVERFLOW);
+ cr_write (cell_height_reg, GRUB_VGA_CR_CELL_HEIGHT);
+ cr_write (config->vertical_sync_start & 0xff, GRUB_VGA_CR_VSYNC_START);
+ cr_write (config->vertical_sync_end & 0x0f, GRUB_VGA_CR_VSYNC_END);
+ cr_write (vdisplay_end & 0xff, GRUB_VGA_CR_VDISPLAY_END);
+ cr_write (config->pitch & 0xff, GRUB_VGA_CR_PITCH);
+ cr_write (vertical_blank_start & 0xff, GRUB_VGA_CR_VERTICAL_BLANK_START);
+ cr_write (config->vertical_blank_end & 0xff, GRUB_VGA_CR_VERTICAL_BLANK_END);
+ cr_write (config->line_compare & 0xff, GRUB_VGA_CR_LINE_COMPARE);
+}
+
+#endif
diff --git a/include/grub/video.h b/include/grub/video.h
new file mode 100644
index 0000000..5350d87
--- /dev/null
+++ b/include/grub/video.h
@@ -0,0 +1,431 @@
+/*
+ * 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_VIDEO_HEADER
+#define GRUB_VIDEO_HEADER 1
+
+#include <grub/err.h>
+#include <grub/types.h>
+#include <grub/list.h>
+
+/* Video color in hardware dependent format. Users should not assume any
+ specific coding format. */
+typedef grub_uint32_t grub_video_color_t;
+
+/* This structure is driver specific and should not be accessed directly by
+ outside code. */
+struct grub_video_render_target;
+
+/* Forward declarations for used data structures. */
+struct grub_video_bitmap;
+
+/* Defines used to describe video mode or rendering target. */
+/* If following is set render target contains currenly displayed image
+ after swapping buffers (otherwise it contains previously displayed image).
+ */
+typedef enum grub_video_mode_type
+ {
+ GRUB_VIDEO_MODE_TYPE_RGB = 0x00000001,
+ GRUB_VIDEO_MODE_TYPE_INDEX_COLOR = 0x00000002,
+ GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP = 0x00000004,
+ GRUB_VIDEO_MODE_TYPE_YUV = 0x00000008,
+
+ /* Defines used to mask flags. */
+ GRUB_VIDEO_MODE_TYPE_COLOR_MASK = 0x0000000F,
+
+ GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED = 0x00000010,
+ GRUB_VIDEO_MODE_TYPE_ALPHA = 0x00000020,
+ GRUB_VIDEO_MODE_TYPE_PURE_TEXT = 0x00000040,
+ GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP = 0x00000080,
+ GRUB_VIDEO_MODE_TYPE_OPERATIONAL_MASK = 0x000000F0,
+
+ /* Defines used to specify requested bit depth. */
+ GRUB_VIDEO_MODE_TYPE_DEPTH_MASK = 0x0000FF00,
+#define GRUB_VIDEO_MODE_TYPE_DEPTH_POS 8
+
+ GRUB_VIDEO_MODE_TYPE_UNKNOWN = 0x00010000,
+ GRUB_VIDEO_MODE_TYPE_HERCULES = 0x00020000,
+ GRUB_VIDEO_MODE_TYPE_PLANAR = 0x00040000,
+ GRUB_VIDEO_MODE_TYPE_NONCHAIN4 = 0x00080000,
+ GRUB_VIDEO_MODE_TYPE_CGA = 0x00100000,
+ GRUB_VIDEO_MODE_TYPE_INFO_MASK = 0x00FF0000,
+ } grub_video_mode_type_t;
+
+/* The basic render target representing the whole display. This always
+ renders to the back buffer when double-buffering is in use. */
+#define GRUB_VIDEO_RENDER_TARGET_DISPLAY \
+ ((struct grub_video_render_target *) 0)
+
+/* Defined blitting formats. */
+enum grub_video_blit_format
+ {
+ /* Generic RGBA, use fields & masks. */
+ GRUB_VIDEO_BLIT_FORMAT_RGBA,
+
+ /* Optimized RGBA's. */
+ GRUB_VIDEO_BLIT_FORMAT_RGBA_8888,
+ GRUB_VIDEO_BLIT_FORMAT_BGRA_8888,
+
+ /* Generic RGB, use fields & masks. */
+ GRUB_VIDEO_BLIT_FORMAT_RGB,
+
+ /* Optimized RGB's. */
+ GRUB_VIDEO_BLIT_FORMAT_RGB_888,
+ GRUB_VIDEO_BLIT_FORMAT_BGR_888,
+ GRUB_VIDEO_BLIT_FORMAT_RGB_565,
+ GRUB_VIDEO_BLIT_FORMAT_BGR_565,
+
+ /* When needed, decode color or just use value as is. */
+ GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR,
+
+ /* Two color bitmap; bits packed: rows are not padded to byte boundary. */
+ GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED
+ };
+
+/* Define blitting operators. */
+enum grub_video_blit_operators
+ {
+ /* Replace target bitmap data with source. */
+ GRUB_VIDEO_BLIT_REPLACE,
+ /* Blend target and source based on source's alpha value. */
+ GRUB_VIDEO_BLIT_BLEND
+ };
+
+struct grub_video_mode_info
+{
+ /* Width of the screen. */
+ unsigned int width;
+
+ /* Height of the screen. */
+ unsigned int height;
+
+ /* Mode type bitmask. Contains information like is it Index color or
+ RGB mode. */
+ grub_video_mode_type_t mode_type;
+
+ /* Bits per pixel. */
+ unsigned int bpp;
+
+ /* Bytes per pixel. */
+ unsigned int bytes_per_pixel;
+
+ /* Pitch of one scanline. How many bytes there are for scanline. */
+ unsigned int pitch;
+
+ /* In index color mode, number of colors. In RGB mode this is 256. */
+ unsigned int number_of_colors;
+
+ unsigned int mode_number;
+#define GRUB_VIDEO_MODE_NUMBER_INVALID 0xffffffff
+
+ /* Optimization hint how binary data is coded. */
+ enum grub_video_blit_format blit_format;
+
+ /* How many bits are reserved for red color. */
+ unsigned int red_mask_size;
+
+ /* What is location of red color bits. In Index Color mode, this is 0. */
+ unsigned int red_field_pos;
+
+ /* How many bits are reserved for green color. */
+ unsigned int green_mask_size;
+
+ /* What is location of green color bits. In Index Color mode, this is 0. */
+ unsigned int green_field_pos;
+
+ /* How many bits are reserved for blue color. */
+ unsigned int blue_mask_size;
+
+ /* What is location of blue color bits. In Index Color mode, this is 0. */
+ unsigned int blue_field_pos;
+
+ /* How many bits are reserved in color. */
+ unsigned int reserved_mask_size;
+
+ /* What is location of reserved color bits. In Index Color mode,
+ this is 0. */
+ unsigned int reserved_field_pos;
+
+ /* For 1-bit bitmaps, the background color. Used for bits = 0. */
+ grub_uint8_t bg_red;
+ grub_uint8_t bg_green;
+ grub_uint8_t bg_blue;
+ grub_uint8_t bg_alpha;
+
+ /* For 1-bit bitmaps, the foreground color. Used for bits = 1. */
+ grub_uint8_t fg_red;
+ grub_uint8_t fg_green;
+ grub_uint8_t fg_blue;
+ grub_uint8_t fg_alpha;
+};
+
+/* A 2D rectangle type. */
+struct grub_video_rect
+{
+ unsigned x;
+ unsigned y;
+ unsigned width;
+ unsigned height;
+};
+typedef struct grub_video_rect grub_video_rect_t;
+
+struct grub_video_signed_rect
+{
+ signed x;
+ signed y;
+ unsigned width;
+ unsigned height;
+};
+typedef struct grub_video_signed_rect grub_video_signed_rect_t;
+
+struct grub_video_palette_data
+{
+ grub_uint8_t r; /* Red color value (0-255). */
+ grub_uint8_t g; /* Green color value (0-255). */
+ grub_uint8_t b; /* Blue color value (0-255). */
+ grub_uint8_t a; /* Reserved bits value (0-255). */
+};
+
+typedef enum grub_video_driver_id
+ {
+ GRUB_VIDEO_DRIVER_NONE,
+ GRUB_VIDEO_DRIVER_VBE,
+ GRUB_VIDEO_DRIVER_EFI_UGA,
+ GRUB_VIDEO_DRIVER_EFI_GOP,
+ GRUB_VIDEO_DRIVER_SM712,
+ GRUB_VIDEO_DRIVER_VGA,
+ GRUB_VIDEO_DRIVER_CIRRUS,
+ GRUB_VIDEO_DRIVER_BOCHS,
+ GRUB_VIDEO_DRIVER_SDL
+ } grub_video_driver_id_t;
+
+typedef enum grub_video_adapter_prio
+ {
+ GRUB_VIDEO_ADAPTER_PRIO_FALLBACK = 60,
+ GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE_DIRTY = 70,
+ GRUB_VIDEO_ADAPTER_PRIO_FIRMWARE = 80,
+ GRUB_VIDEO_ADAPTER_PRIO_NATIVE = 100
+ } grub_video_adapter_prio_t;
+
+
+struct grub_video_adapter
+{
+ /* The next video adapter. */
+ struct grub_video_adapter *next;
+
+ /* The video adapter name. */
+ const char *name;
+ grub_video_driver_id_t id;
+
+ grub_video_adapter_prio_t prio;
+
+ /* Initialize the video adapter. */
+ grub_err_t (*init) (void);
+
+ /* Clean up the video adapter. */
+ grub_err_t (*fini) (void);
+
+ grub_err_t (*setup) (unsigned int width, unsigned int height,
+ grub_video_mode_type_t mode_type,
+ grub_video_mode_type_t mode_mask);
+
+ grub_err_t (*get_info) (struct grub_video_mode_info *mode_info);
+
+ grub_err_t (*get_info_and_fini) (struct grub_video_mode_info *mode_info,
+ void **framebuffer);
+
+ grub_err_t (*set_palette) (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data);
+
+ grub_err_t (*get_palette) (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data);
+
+ grub_err_t (*set_viewport) (unsigned int x, unsigned int y,
+ unsigned int width, unsigned int height);
+
+ grub_err_t (*get_viewport) (unsigned int *x, unsigned int *y,
+ unsigned int *width, unsigned int *height);
+
+ grub_video_color_t (*map_color) (grub_uint32_t color_name);
+
+ grub_video_color_t (*map_rgb) (grub_uint8_t red, grub_uint8_t green,
+ grub_uint8_t blue);
+
+ grub_video_color_t (*map_rgba) (grub_uint8_t red, grub_uint8_t green,
+ grub_uint8_t blue, grub_uint8_t alpha);
+
+ grub_err_t (*unmap_color) (grub_video_color_t color,
+ grub_uint8_t *red, grub_uint8_t *green,
+ grub_uint8_t *blue, grub_uint8_t *alpha);
+
+ grub_err_t (*fill_rect) (grub_video_color_t color, int x, int y,
+ unsigned int width, unsigned int height);
+
+ grub_err_t (*blit_bitmap) (struct grub_video_bitmap *bitmap,
+ enum grub_video_blit_operators oper,
+ int x, int y, int offset_x, int offset_y,
+ unsigned int width, unsigned int height);
+
+ grub_err_t (*blit_render_target) (struct grub_video_render_target *source,
+ enum grub_video_blit_operators oper,
+ int x, int y, int offset_x, int offset_y,
+ unsigned int width, unsigned int height);
+
+ grub_err_t (*scroll) (grub_video_color_t color, int dx, int dy);
+
+ grub_err_t (*swap_buffers) (void);
+
+ grub_err_t (*create_render_target) (struct grub_video_render_target **result,
+ unsigned int width, unsigned int height,
+ unsigned int mode_type);
+
+ grub_err_t (*delete_render_target) (struct grub_video_render_target *target);
+
+ grub_err_t (*set_active_render_target) (struct grub_video_render_target *target);
+
+ grub_err_t (*get_active_render_target) (struct grub_video_render_target **target);
+
+ int (*iterate) (int (*hook) (const struct grub_video_mode_info *info));
+
+ void (*print_adapter_specific_info) (void);
+};
+typedef struct grub_video_adapter *grub_video_adapter_t;
+
+extern grub_video_adapter_t EXPORT_VAR(grub_video_adapter_list);
+
+#ifndef GRUB_LST_GENERATOR
+/* Register video driver. */
+static inline void
+grub_video_register (grub_video_adapter_t adapter)
+{
+ grub_video_adapter_t *p;
+ for (p = &grub_video_adapter_list; *p && (*p)->prio > adapter->prio;
+ p = &((*p)->next));
+ adapter->next = *p;
+ *p = adapter;
+}
+#endif
+
+/* Unregister video driver. */
+static inline void
+grub_video_unregister (grub_video_adapter_t adapter)
+{
+ grub_list_remove (GRUB_AS_LIST_P (&grub_video_adapter_list),
+ GRUB_AS_LIST (adapter));
+}
+
+#define FOR_VIDEO_ADAPTERS(var) FOR_LIST_ELEMENTS((var), (grub_video_adapter_list))
+
+grub_err_t EXPORT_FUNC (grub_video_restore) (void);
+
+grub_err_t EXPORT_FUNC (grub_video_get_info) (struct grub_video_mode_info *mode_info);
+
+/* Framebuffer address may change as a part of normal operation
+ (e.g. double buffering). That's why you need to stop video subsystem to be
+ sure that framebuffer address doesn't change. To ensure this abstraction
+ grub_video_get_info_and_fini is the only function supplying framebuffer
+ address. */
+grub_err_t EXPORT_FUNC (grub_video_get_info_and_fini) (struct grub_video_mode_info *mode_info,
+ void **framebuffer);
+
+enum grub_video_blit_format grub_video_get_blit_format (struct grub_video_mode_info *mode_info);
+
+grub_err_t grub_video_set_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data);
+
+grub_err_t EXPORT_FUNC (grub_video_get_palette) (unsigned int start,
+ unsigned int count,
+ struct grub_video_palette_data *palette_data);
+
+grub_err_t EXPORT_FUNC (grub_video_set_viewport) (unsigned int x,
+ unsigned int y,
+ unsigned int width,
+ unsigned int height);
+
+grub_err_t EXPORT_FUNC (grub_video_get_viewport) (unsigned int *x,
+ unsigned int *y,
+ unsigned int *width,
+ unsigned int *height);
+
+grub_video_color_t EXPORT_FUNC (grub_video_map_color) (grub_uint32_t color_name);
+
+grub_video_color_t EXPORT_FUNC (grub_video_map_rgb) (grub_uint8_t red,
+ grub_uint8_t green,
+ grub_uint8_t blue);
+
+grub_video_color_t EXPORT_FUNC (grub_video_map_rgba) (grub_uint8_t red,
+ grub_uint8_t green,
+ grub_uint8_t blue,
+ grub_uint8_t alpha);
+
+grub_err_t EXPORT_FUNC (grub_video_unmap_color) (grub_video_color_t color,
+ grub_uint8_t *red,
+ grub_uint8_t *green,
+ grub_uint8_t *blue,
+ grub_uint8_t *alpha);
+
+grub_err_t EXPORT_FUNC (grub_video_fill_rect) (grub_video_color_t color,
+ int x, int y,
+ unsigned int width,
+ unsigned int height);
+
+grub_err_t EXPORT_FUNC (grub_video_blit_bitmap) (struct grub_video_bitmap *bitmap,
+ enum grub_video_blit_operators oper,
+ int x, int y,
+ int offset_x, int offset_y,
+ unsigned int width,
+ unsigned int height);
+
+grub_err_t EXPORT_FUNC (grub_video_blit_render_target) (struct grub_video_render_target *source,
+ enum grub_video_blit_operators oper,
+ int x, int y,
+ int offset_x,
+ int offset_y,
+ unsigned int width,
+ unsigned int height);
+
+grub_err_t grub_video_scroll (grub_video_color_t color, int dx, int dy);
+
+grub_err_t EXPORT_FUNC (grub_video_swap_buffers) (void);
+
+grub_err_t EXPORT_FUNC (grub_video_create_render_target) (struct grub_video_render_target **result,
+ unsigned int width,
+ unsigned int height,
+ unsigned int mode_type);
+
+grub_err_t EXPORT_FUNC (grub_video_delete_render_target) (struct grub_video_render_target *target);
+
+grub_err_t EXPORT_FUNC (grub_video_set_active_render_target) (struct grub_video_render_target *target);
+
+grub_err_t grub_video_get_active_render_target (struct grub_video_render_target **target);
+
+grub_err_t EXPORT_FUNC (grub_video_set_mode) (const char *modestring,
+ unsigned int modemask,
+ unsigned int modevalue);
+
+static inline int
+grub_video_check_mode_flag (grub_video_mode_type_t flags,
+ grub_video_mode_type_t mask,
+ grub_video_mode_type_t flag, int def)
+{
+ return (flag & mask) ? !! (flags & flag) : def;
+}
+
+grub_video_driver_id_t EXPORT_FUNC (grub_video_get_driver_id) (void);
+
+#endif /* ! GRUB_VIDEO_HEADER */
diff --git a/include/grub/video_fb.h b/include/grub/video_fb.h
new file mode 100644
index 0000000..6816f6f
--- /dev/null
+++ b/include/grub/video_fb.h
@@ -0,0 +1,136 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2005,2006,2007,2008 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_VIDEO_FB_HEADER
+#define GRUB_VIDEO_FB_HEADER 1
+
+#include <grub/symbol.h>
+#include <grub/types.h>
+#include <grub/err.h>
+#include <grub/video.h>
+
+/* FB module internal prototype (should not be used from elsewhere). */
+
+struct grub_video_fbblit_info;
+
+struct grub_video_fbrender_target;
+
+#define GRUB_VIDEO_FBSTD_NUMCOLORS 16
+extern struct grub_video_palette_data grub_video_fbstd_colors[GRUB_VIDEO_FBSTD_NUMCOLORS];
+
+grub_err_t
+grub_video_fb_init (void);
+
+grub_err_t
+grub_video_fb_fini (void);
+
+grub_err_t
+grub_video_fb_get_info (struct grub_video_mode_info *mode_info);
+
+grub_err_t
+grub_video_fb_get_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data);
+grub_err_t
+grub_video_fb_set_palette (unsigned int start, unsigned int count,
+ struct grub_video_palette_data *palette_data);
+grub_err_t
+grub_video_fb_set_viewport (unsigned int x, unsigned int y,
+ unsigned int width, unsigned int height);
+grub_err_t
+grub_video_fb_get_viewport (unsigned int *x, unsigned int *y,
+ unsigned int *width, unsigned int *height);
+
+grub_video_color_t
+grub_video_fb_map_color (grub_uint32_t color_name);
+
+grub_video_color_t
+grub_video_fb_map_rgb (grub_uint8_t red, grub_uint8_t green,
+ grub_uint8_t blue);
+
+grub_video_color_t
+grub_video_fb_map_rgba (grub_uint8_t red, grub_uint8_t green,
+ grub_uint8_t blue, grub_uint8_t alpha);
+
+grub_err_t
+grub_video_fb_unmap_color (grub_video_color_t color,
+ grub_uint8_t *red, grub_uint8_t *green,
+ grub_uint8_t *blue, grub_uint8_t *alpha);
+
+void
+grub_video_fb_unmap_color_int (struct grub_video_fbblit_info * source,
+ grub_video_color_t color,
+ grub_uint8_t *red, grub_uint8_t *green,
+ grub_uint8_t *blue, grub_uint8_t *alpha);
+
+grub_err_t
+grub_video_fb_fill_rect (grub_video_color_t color, int x, int y,
+ unsigned int width, unsigned int height);
+
+grub_err_t
+grub_video_fb_blit_bitmap (struct grub_video_bitmap *bitmap,
+ enum grub_video_blit_operators oper, int x, int y,
+ int offset_x, int offset_y,
+ unsigned int width, unsigned int height);
+
+grub_err_t
+grub_video_fb_blit_render_target (struct grub_video_fbrender_target *source,
+ enum grub_video_blit_operators oper,
+ int x, int y, int offset_x, int offset_y,
+ unsigned int width, unsigned int height);
+
+grub_err_t
+grub_video_fb_scroll (grub_video_color_t color, int dx, int dy);
+
+grub_err_t
+grub_video_fb_create_render_target (struct grub_video_fbrender_target **result,
+ unsigned int width, unsigned int height,
+ unsigned int mode_type __attribute__ ((unused)));
+
+grub_err_t
+grub_video_fb_create_render_target_from_pointer (struct grub_video_fbrender_target **result,
+ const struct grub_video_mode_info *mode_info,
+ void *ptr);
+
+grub_err_t
+grub_video_fb_delete_render_target (struct grub_video_fbrender_target *target);
+
+grub_err_t
+grub_video_fb_get_active_render_target (struct grub_video_fbrender_target **target);
+
+grub_err_t
+grub_video_fb_set_active_render_target (struct grub_video_fbrender_target *target);
+
+typedef grub_err_t
+(*grub_video_fb_doublebuf_update_screen_t) (struct grub_video_fbrender_target *front,
+ struct grub_video_fbrender_target *back);
+
+typedef grub_err_t (*grub_video_fb_set_page_t) (int page);
+
+grub_err_t
+grub_video_fb_setup (unsigned int mode_type, unsigned int mode_mask,
+ struct grub_video_mode_info *mode_info,
+ volatile void *page0_ptr,
+ grub_video_fb_set_page_t set_page_in,
+ volatile void *page1_ptr);
+grub_err_t
+grub_video_fb_swap_buffers (void);
+grub_err_t
+grub_video_fb_get_info_and_fini (struct grub_video_mode_info *mode_info,
+ void **framebuf);
+
+#endif /* ! GRUB_VIDEO_FB_HEADER */
diff --git a/include/grub/x86_64/at_keyboard.h b/include/grub/x86_64/at_keyboard.h
new file mode 100644
index 0000000..c632aa8
--- /dev/null
+++ b/include/grub/x86_64/at_keyboard.h
@@ -0,0 +1 @@
+#include <grub/i386/at_keyboard.h>
diff --git a/include/grub/x86_64/efi/boot.h b/include/grub/x86_64/efi/boot.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/include/grub/x86_64/efi/boot.h
diff --git a/include/grub/x86_64/efi/loader.h b/include/grub/x86_64/efi/loader.h
new file mode 100644
index 0000000..7c302e8
--- /dev/null
+++ b/include/grub/x86_64/efi/loader.h
@@ -0,0 +1,26 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2004,2006,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_LOADER_MACHINE_HEADER
+#define GRUB_LOADER_MACHINE_HEADER 1
+
+#include <grub/types.h>
+#include <grub/symbol.h>
+
+
+#endif /* ! GRUB_LOADER_MACHINE_HEADER */
diff --git a/include/grub/x86_64/efi/memory.h b/include/grub/x86_64/efi/memory.h
new file mode 100644
index 0000000..c9a61bb
--- /dev/null
+++ b/include/grub/x86_64/efi/memory.h
@@ -0,0 +1 @@
+#include <grub/efi/memory.h>
diff --git a/include/grub/x86_64/efi/serial.h b/include/grub/x86_64/efi/serial.h
new file mode 100644
index 0000000..2d85634
--- /dev/null
+++ b/include/grub/x86_64/efi/serial.h
@@ -0,0 +1 @@
+#include <grub/i386/coreboot/serial.h>
diff --git a/include/grub/x86_64/efi/time.h b/include/grub/x86_64/efi/time.h
new file mode 100644
index 0000000..7a9241f
--- /dev/null
+++ b/include/grub/x86_64/efi/time.h
@@ -0,0 +1,24 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2006,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_MACHINE_TIME_HEADER
+#define GRUB_MACHINE_TIME_HEADER 1
+
+#include <grub/efi/time.h>
+
+#endif /* ! GRUB_MACHINE_TIME_HEADER */
diff --git a/include/grub/x86_64/io.h b/include/grub/x86_64/io.h
new file mode 100644
index 0000000..9f465bc
--- /dev/null
+++ b/include/grub/x86_64/io.h
@@ -0,0 +1,19 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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/i386/io.h>
diff --git a/include/grub/x86_64/linux.h b/include/grub/x86_64/linux.h
new file mode 100644
index 0000000..19ea936
--- /dev/null
+++ b/include/grub/x86_64/linux.h
@@ -0,0 +1,19 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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/i386/linux.h>
diff --git a/include/grub/x86_64/macho.h b/include/grub/x86_64/macho.h
new file mode 100644
index 0000000..165b8da
--- /dev/null
+++ b/include/grub/x86_64/macho.h
@@ -0,0 +1 @@
+#include <grub/i386/macho.h>
diff --git a/include/grub/x86_64/memory.h b/include/grub/x86_64/memory.h
new file mode 100644
index 0000000..27fcd25
--- /dev/null
+++ b/include/grub/x86_64/memory.h
@@ -0,0 +1 @@
+#include <grub/i386/memory.h>
diff --git a/include/grub/x86_64/multiboot.h b/include/grub/x86_64/multiboot.h
new file mode 100644
index 0000000..957c7a5
--- /dev/null
+++ b/include/grub/x86_64/multiboot.h
@@ -0,0 +1 @@
+#include <grub/i386/multiboot.h>
diff --git a/include/grub/x86_64/pci.h b/include/grub/x86_64/pci.h
new file mode 100644
index 0000000..91a9924
--- /dev/null
+++ b/include/grub/x86_64/pci.h
@@ -0,0 +1,19 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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/i386/pci.h>
diff --git a/include/grub/x86_64/relocator.h b/include/grub/x86_64/relocator.h
new file mode 100644
index 0000000..247e7a1
--- /dev/null
+++ b/include/grub/x86_64/relocator.h
@@ -0,0 +1 @@
+#include <grub/i386/relocator.h>
diff --git a/include/grub/x86_64/setjmp.h b/include/grub/x86_64/setjmp.h
new file mode 100644
index 0000000..4ad968e
--- /dev/null
+++ b/include/grub/x86_64/setjmp.h
@@ -0,0 +1,27 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2006,2007,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_SETJMP_CPU_HEADER
+#define GRUB_SETJMP_CPU_HEADER 1
+
+typedef unsigned long grub_jmp_buf[8];
+
+int grub_setjmp (grub_jmp_buf env) __attribute__ ((returns_twice));
+void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn));
+
+#endif /* ! GRUB_SETJMP_CPU_HEADER */
diff --git a/include/grub/x86_64/time.h b/include/grub/x86_64/time.h
new file mode 100644
index 0000000..842882c
--- /dev/null
+++ b/include/grub/x86_64/time.h
@@ -0,0 +1,29 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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 KERNEL_CPU_TIME_HEADER
+#define KERNEL_CPU_TIME_HEADER 1
+
+static __inline void
+grub_cpu_idle (void)
+{
+ /* FIXME: this can't work until we handle interrupts. */
+/* __asm__ __volatile__ ("hlt"); */
+}
+
+#endif /* ! KERNEL_CPU_TIME_HEADER */
diff --git a/include/grub/x86_64/types.h b/include/grub/x86_64/types.h
new file mode 100644
index 0000000..bdee5a1
--- /dev/null
+++ b/include/grub/x86_64/types.h
@@ -0,0 +1,31 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2008 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_TYPES_CPU_HEADER
+#define GRUB_TYPES_CPU_HEADER 1
+
+/* The size of void *. */
+#define GRUB_TARGET_SIZEOF_VOID_P 8
+
+/* The size of long. */
+#define GRUB_TARGET_SIZEOF_LONG 8
+
+/* x86_64 is little-endian. */
+#undef GRUB_TARGET_WORDS_BIGENDIAN
+
+#endif /* ! GRUB_TYPES_CPU_HEADER */
diff --git a/include/grub/x86_64/xnu.h b/include/grub/x86_64/xnu.h
new file mode 100644
index 0000000..ae61733
--- /dev/null
+++ b/include/grub/x86_64/xnu.h
@@ -0,0 +1 @@
+#include <grub/i386/xnu.h>
diff --git a/include/grub/xnu.h b/include/grub/xnu.h
new file mode 100644
index 0000000..076aeb5
--- /dev/null
+++ b/include/grub/xnu.h
@@ -0,0 +1,116 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 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_XNU_H
+#define GRUB_XNU_H 1
+
+#include <grub/bitmap.h>
+
+/* Header of a hibernation image. */
+struct grub_xnu_hibernate_header
+{
+ /* Size of the image. Notice that file containing image is usually bigger. */
+ grub_uint64_t image_size;
+ grub_uint8_t unknown1[8];
+ /* Where to copy launchcode? */
+ grub_uint32_t launchcode_target_page;
+ /* How many pages of launchcode? */
+ grub_uint32_t launchcode_numpages;
+ /* Where to jump? */
+ grub_uint32_t entry_point;
+ /* %esp at start. */
+ grub_uint32_t stack;
+ grub_uint8_t unknown2[44];
+#define GRUB_XNU_HIBERNATE_MAGIC 0x73696d65
+ grub_uint32_t magic;
+ grub_uint8_t unknown3[28];
+ /* This value is non-zero if page is encrypted. Unsupported. */
+ grub_uint64_t encoffset;
+ grub_uint8_t unknown4[360];
+ /* The size of additional header used to locate image without parsing FS.
+ Used only to skip it.
+ */
+ grub_uint32_t extmapsize;
+} __attribute__ ((packed));
+
+/* In-memory structure for temporary keeping device tree. */
+struct grub_xnu_devtree_key
+{
+ char *name;
+ int datasize; /* -1 for not leaves. */
+ union
+ {
+ struct grub_xnu_devtree_key *first_child;
+ void *data;
+ };
+ struct grub_xnu_devtree_key *next;
+};
+
+/* A structure used in memory-map values. */
+struct
+grub_xnu_extdesc
+{
+ grub_uint32_t addr;
+ grub_uint32_t size;
+} __attribute__ ((packed));
+
+/* Header describing extension in the memory. */
+struct grub_xnu_extheader
+{
+ grub_uint32_t infoplistaddr;
+ grub_uint32_t infoplistsize;
+ grub_uint32_t binaryaddr;
+ grub_uint32_t binarysize;
+ grub_uint32_t nameaddr;
+ grub_uint32_t namesize;
+} __attribute__ ((packed));
+
+struct grub_xnu_devtree_key *grub_xnu_create_key (struct grub_xnu_devtree_key **parent,
+ char *name);
+
+extern struct grub_xnu_devtree_key *grub_xnu_devtree_root;
+
+void grub_xnu_free_devtree (struct grub_xnu_devtree_key *cur);
+
+grub_err_t grub_xnu_writetree_toheap (grub_addr_t *target, grub_size_t *size);
+struct grub_xnu_devtree_key *grub_xnu_create_value (struct grub_xnu_devtree_key **parent,
+ char *name);
+
+void grub_xnu_lock (void);
+void grub_xnu_unlock (void);
+grub_err_t grub_xnu_resume (char *imagename);
+grub_err_t grub_xnu_boot_resume (void);
+struct grub_xnu_devtree_key *grub_xnu_find_key (struct grub_xnu_devtree_key *parent,
+ char *name);
+grub_err_t grub_xnu_align_heap (int align);
+grub_err_t grub_xnu_scan_dir_for_kexts (char *dirname, char *osbundlerequired,
+ int maxrecursion);
+grub_err_t grub_xnu_load_kext_from_dir (char *dirname, char *osbundlerequired,
+ int maxrecursion);
+grub_err_t grub_xnu_heap_malloc (int size, void **src, grub_addr_t *target);
+grub_err_t grub_xnu_fill_devicetree (void);
+extern struct grub_relocator *grub_xnu_relocator;
+
+extern grub_size_t grub_xnu_heap_size;
+extern struct grub_video_bitmap *grub_xnu_bitmap;
+typedef enum {GRUB_XNU_BITMAP_CENTER, GRUB_XNU_BITMAP_STRETCH}
+ grub_xnu_bitmap_mode_t;
+extern grub_xnu_bitmap_mode_t grub_xnu_bitmap_mode;
+extern int grub_xnu_is_64bit;
+extern grub_addr_t grub_xnu_heap_target_start;
+#endif
diff --git a/include/grub/zfs/dmu.h b/include/grub/zfs/dmu.h
new file mode 100644
index 0000000..bee317e
--- /dev/null
+++ b/include/grub/zfs/dmu.h
@@ -0,0 +1,119 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_DMU_H
+#define _SYS_DMU_H
+
+/*
+ * This file describes the interface that the DMU provides for its
+ * consumers.
+ *
+ * The DMU also interacts with the SPA. That interface is described in
+ * dmu_spa.h.
+ */
+typedef enum dmu_object_type {
+ DMU_OT_NONE,
+ /* general: */
+ DMU_OT_OBJECT_DIRECTORY, /* ZAP */
+ DMU_OT_OBJECT_ARRAY, /* UINT64 */
+ DMU_OT_PACKED_NVLIST, /* UINT8 (XDR by nvlist_pack/unpack) */
+ DMU_OT_PACKED_NVLIST_SIZE, /* UINT64 */
+ DMU_OT_BPLIST, /* UINT64 */
+ DMU_OT_BPLIST_HDR, /* UINT64 */
+ /* spa: */
+ DMU_OT_SPACE_MAP_HEADER, /* UINT64 */
+ DMU_OT_SPACE_MAP, /* UINT64 */
+ /* zil: */
+ DMU_OT_INTENT_LOG, /* UINT64 */
+ /* dmu: */
+ DMU_OT_DNODE, /* DNODE */
+ DMU_OT_OBJSET, /* OBJSET */
+ /* dsl: */
+ DMU_OT_DSL_DIR, /* UINT64 */
+ DMU_OT_DSL_DIR_CHILD_MAP, /* ZAP */
+ DMU_OT_DSL_DS_SNAP_MAP, /* ZAP */
+ DMU_OT_DSL_PROPS, /* ZAP */
+ DMU_OT_DSL_DATASET, /* UINT64 */
+ /* zpl: */
+ DMU_OT_ZNODE, /* ZNODE */
+ DMU_OT_OLDACL, /* OLD ACL */
+ DMU_OT_PLAIN_FILE_CONTENTS, /* UINT8 */
+ DMU_OT_DIRECTORY_CONTENTS, /* ZAP */
+ DMU_OT_MASTER_NODE, /* ZAP */
+ DMU_OT_UNLINKED_SET, /* ZAP */
+ /* zvol: */
+ DMU_OT_ZVOL, /* UINT8 */
+ DMU_OT_ZVOL_PROP, /* ZAP */
+ /* other; for testing only! */
+ DMU_OT_PLAIN_OTHER, /* UINT8 */
+ DMU_OT_UINT64_OTHER, /* UINT64 */
+ DMU_OT_ZAP_OTHER, /* ZAP */
+ /* new object types: */
+ DMU_OT_ERROR_LOG, /* ZAP */
+ DMU_OT_SPA_HISTORY, /* UINT8 */
+ DMU_OT_SPA_HISTORY_OFFSETS, /* spa_his_phys_t */
+ DMU_OT_POOL_PROPS, /* ZAP */
+ DMU_OT_DSL_PERMS, /* ZAP */
+ DMU_OT_ACL, /* ACL */
+ DMU_OT_SYSACL, /* SYSACL */
+ DMU_OT_FUID, /* FUID table (Packed NVLIST UINT8) */
+ DMU_OT_FUID_SIZE, /* FUID table size UINT64 */
+ DMU_OT_NEXT_CLONES, /* ZAP */
+ DMU_OT_SCRUB_QUEUE, /* ZAP */
+ DMU_OT_USERGROUP_USED, /* ZAP */
+ DMU_OT_USERGROUP_QUOTA, /* ZAP */
+ DMU_OT_USERREFS, /* ZAP */
+ DMU_OT_DDT_ZAP, /* ZAP */
+ DMU_OT_DDT_STATS, /* ZAP */
+ DMU_OT_SA, /* System attr */
+ DMU_OT_SA_MASTER_NODE, /* ZAP */
+ DMU_OT_SA_ATTR_REGISTRATION, /* ZAP */
+ DMU_OT_SA_ATTR_LAYOUTS, /* ZAP */
+ DMU_OT_NUMTYPES
+} dmu_object_type_t;
+
+typedef enum dmu_objset_type {
+ DMU_OST_NONE,
+ DMU_OST_META,
+ DMU_OST_ZFS,
+ DMU_OST_ZVOL,
+ DMU_OST_OTHER, /* For testing only! */
+ DMU_OST_ANY, /* Be careful! */
+ DMU_OST_NUMTYPES
+} dmu_objset_type_t;
+
+/*
+ * The names of zap entries in the DIRECTORY_OBJECT of the MOS.
+ */
+#define DMU_POOL_DIRECTORY_OBJECT 1
+#define DMU_POOL_CONFIG "config"
+#define DMU_POOL_ROOT_DATASET "root_dataset"
+#define DMU_POOL_SYNC_BPLIST "sync_bplist"
+#define DMU_POOL_ERRLOG_SCRUB "errlog_scrub"
+#define DMU_POOL_ERRLOG_LAST "errlog_last"
+#define DMU_POOL_SPARES "spares"
+#define DMU_POOL_DEFLATE "deflate"
+#define DMU_POOL_HISTORY "history"
+#define DMU_POOL_PROPS "pool_props"
+#define DMU_POOL_L2CACHE "l2cache"
+
+#endif /* _SYS_DMU_H */
diff --git a/include/grub/zfs/dmu_objset.h b/include/grub/zfs/dmu_objset.h
new file mode 100644
index 0000000..57d21db
--- /dev/null
+++ b/include/grub/zfs/dmu_objset.h
@@ -0,0 +1,43 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
+ * Copyright (C) 2010 Robert Millan <rmh@gnu.org>
+ *
+ * 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/>.
+ */
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_DMU_OBJSET_H
+#define _SYS_DMU_OBJSET_H
+
+#include <grub/zfs/zil.h>
+
+#define OBJSET_PHYS_SIZE 2048
+#define OBJSET_PHYS_SIZE_V14 1024
+
+typedef struct objset_phys {
+ dnode_phys_t os_meta_dnode;
+ zil_header_t os_zil_header;
+ grub_uint64_t os_type;
+ grub_uint64_t os_flags;
+ char os_pad[OBJSET_PHYS_SIZE - sizeof (dnode_phys_t)*3 -
+ sizeof (zil_header_t) - sizeof (grub_uint64_t)*2];
+ dnode_phys_t os_userused_dnode;
+ dnode_phys_t os_groupused_dnode;
+} objset_phys_t;
+
+#endif /* _SYS_DMU_OBJSET_H */
diff --git a/include/grub/zfs/dnode.h b/include/grub/zfs/dnode.h
new file mode 100644
index 0000000..279c545
--- /dev/null
+++ b/include/grub/zfs/dnode.h
@@ -0,0 +1,80 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_DNODE_H
+#define _SYS_DNODE_H
+
+#include <grub/zfs/spa.h>
+
+/*
+ * Fixed constants.
+ */
+#define DNODE_SHIFT 9 /* 512 bytes */
+#define DN_MIN_INDBLKSHIFT 10 /* 1k */
+#define DN_MAX_INDBLKSHIFT 14 /* 16k */
+#define DNODE_BLOCK_SHIFT 14 /* 16k */
+#define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */
+#define DN_MAX_OBJECT_SHIFT 48 /* 256 trillion (zfs_fid_t limit) */
+#define DN_MAX_OFFSET_SHIFT 64 /* 2^64 bytes in a dnode */
+
+/*
+ * Derived constants.
+ */
+#define DNODE_SIZE (1 << DNODE_SHIFT)
+#define DN_MAX_NBLKPTR ((DNODE_SIZE - DNODE_CORE_SIZE) >> SPA_BLKPTRSHIFT)
+#define DN_MAX_BONUSLEN (DNODE_SIZE - DNODE_CORE_SIZE - (1 << SPA_BLKPTRSHIFT))
+#define DN_MAX_OBJECT (1ULL << DN_MAX_OBJECT_SHIFT)
+
+#define DNODES_PER_BLOCK_SHIFT (DNODE_BLOCK_SHIFT - DNODE_SHIFT)
+#define DNODES_PER_BLOCK (1ULL << DNODES_PER_BLOCK_SHIFT)
+#define DNODES_PER_LEVEL_SHIFT (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT)
+
+#define DNODE_FLAG_SPILL_BLKPTR (1<<2)
+
+#define DN_BONUS(dnp) ((void*)((dnp)->dn_bonus + \
+ (((dnp)->dn_nblkptr - 1) * sizeof (blkptr_t))))
+
+typedef struct dnode_phys {
+ grub_uint8_t dn_type; /* dmu_object_type_t */
+ grub_uint8_t dn_indblkshift; /* ln2(indirect block size) */
+ grub_uint8_t dn_nlevels; /* 1=dn_blkptr->data blocks */
+ grub_uint8_t dn_nblkptr; /* length of dn_blkptr */
+ grub_uint8_t dn_bonustype; /* type of data in bonus buffer */
+ grub_uint8_t dn_checksum; /* ZIO_CHECKSUM type */
+ grub_uint8_t dn_compress; /* ZIO_COMPRESS type */
+ grub_uint8_t dn_flags; /* DNODE_FLAG_* */
+ grub_uint16_t dn_datablkszsec; /* data block size in 512b sectors */
+ grub_uint16_t dn_bonuslen; /* length of dn_bonus */
+ grub_uint8_t dn_pad2[4];
+
+ /* accounting is protected by dn_dirty_mtx */
+ grub_uint64_t dn_maxblkid; /* largest allocated block ID */
+ grub_uint64_t dn_used; /* bytes (or sectors) of disk space */
+
+ grub_uint64_t dn_pad3[4];
+
+ blkptr_t dn_blkptr[1];
+ grub_uint8_t dn_bonus[DN_MAX_BONUSLEN - sizeof (blkptr_t)];
+ blkptr_t dn_spill;
+} dnode_phys_t;
+
+#endif /* _SYS_DNODE_H */
diff --git a/include/grub/zfs/dsl_dataset.h b/include/grub/zfs/dsl_dataset.h
new file mode 100644
index 0000000..c17bf80
--- /dev/null
+++ b/include/grub/zfs/dsl_dataset.h
@@ -0,0 +1,52 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_DSL_DATASET_H
+#define _SYS_DSL_DATASET_H
+
+typedef struct dsl_dataset_phys {
+ grub_uint64_t ds_dir_obj;
+ grub_uint64_t ds_prev_snap_obj;
+ grub_uint64_t ds_prev_snap_txg;
+ grub_uint64_t ds_next_snap_obj;
+ grub_uint64_t ds_snapnames_zapobj; /* zap obj of snaps; ==0 for snaps */
+ grub_uint64_t ds_num_children; /* clone/snap children; ==0 for head */
+ grub_uint64_t ds_creation_time; /* seconds since 1970 */
+ grub_uint64_t ds_creation_txg;
+ grub_uint64_t ds_deadlist_obj;
+ grub_uint64_t ds_used_bytes;
+ grub_uint64_t ds_compressed_bytes;
+ grub_uint64_t ds_uncompressed_bytes;
+ grub_uint64_t ds_unique_bytes; /* only relevant to snapshots */
+ /*
+ * The ds_fsid_guid is a 56-bit ID that can change to avoid
+ * collisions. The ds_guid is a 64-bit ID that will never
+ * change, so there is a small probability that it will collide.
+ */
+ grub_uint64_t ds_fsid_guid;
+ grub_uint64_t ds_guid;
+ grub_uint64_t ds_flags;
+ blkptr_t ds_bp;
+ grub_uint64_t ds_pad[8]; /* pad out to 320 bytes for good measure */
+} dsl_dataset_phys_t;
+
+#endif /* _SYS_DSL_DATASET_H */
diff --git a/include/grub/zfs/dsl_dir.h b/include/grub/zfs/dsl_dir.h
new file mode 100644
index 0000000..41d77c7
--- /dev/null
+++ b/include/grub/zfs/dsl_dir.h
@@ -0,0 +1,48 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_DSL_DIR_H
+#define _SYS_DSL_DIR_H
+
+typedef struct dsl_dir_phys {
+ grub_uint64_t dd_creation_time; /* not actually used */
+ grub_uint64_t dd_head_dataset_obj;
+ grub_uint64_t dd_parent_obj;
+ grub_uint64_t dd_clone_parent_obj;
+ grub_uint64_t dd_child_dir_zapobj;
+ /*
+ * how much space our children are accounting for; for leaf
+ * datasets, == physical space used by fs + snaps
+ */
+ grub_uint64_t dd_used_bytes;
+ grub_uint64_t dd_compressed_bytes;
+ grub_uint64_t dd_uncompressed_bytes;
+ /* Administrative quota setting */
+ grub_uint64_t dd_quota;
+ /* Administrative reservation setting */
+ grub_uint64_t dd_reserved;
+ grub_uint64_t dd_props_zapobj;
+ grub_uint64_t dd_deleg_zapobj; /* dataset permissions */
+ grub_uint64_t dd_pad[20]; /* pad out to 256 bytes for good measure */
+} dsl_dir_phys_t;
+
+#endif /* _SYS_DSL_DIR_H */
diff --git a/include/grub/zfs/sa_impl.h b/include/grub/zfs/sa_impl.h
new file mode 100644
index 0000000..a2b728d
--- /dev/null
+++ b/include/grub/zfs/sa_impl.h
@@ -0,0 +1,34 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+#ifndef _SYS_SA_IMPL_H
+#define _SYS_SA_IMPL_H
+
+typedef struct sa_hdr_phys {
+ grub_uint32_t sa_magic;
+ grub_uint16_t sa_layout_info;
+ grub_uint16_t sa_lengths[1];
+} sa_hdr_phys_t;
+
+#define SA_HDR_SIZE(hdr) BF32_GET_SB(hdr->sa_layout_info, 10, 16, 3, 0)
+#define SA_SIZE_OFFSET 0x8
+
+#endif /* _SYS_SA_IMPL_H */
diff --git a/include/grub/zfs/spa.h b/include/grub/zfs/spa.h
new file mode 100644
index 0000000..22ee03b
--- /dev/null
+++ b/include/grub/zfs/spa.h
@@ -0,0 +1,310 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc.
+ * Copyright 2010 Sun Microsystems, 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_ZFS_SPA_HEADER
+#define GRUB_ZFS_SPA_HEADER 1
+
+typedef enum grub_zfs_endian
+ {
+ UNKNOWN_ENDIAN = -2,
+ LITTLE_ENDIAN = -1,
+ BIG_ENDIAN = 0
+ } grub_zfs_endian_t;
+
+#define grub_zfs_to_cpu16(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu16(x) \
+ : grub_le_to_cpu16(x))
+#define grub_cpu_to_zfs16(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be16(x) \
+ : grub_cpu_to_le16(x))
+
+#define grub_zfs_to_cpu32(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu32(x) \
+ : grub_le_to_cpu32(x))
+#define grub_cpu_to_zfs32(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be32(x) \
+ : grub_cpu_to_le32(x))
+
+#define grub_zfs_to_cpu64(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu64(x) \
+ : grub_le_to_cpu64(x))
+#define grub_cpu_to_zfs64(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be64(x) \
+ : grub_cpu_to_le64(x))
+
+/*
+ * General-purpose 32-bit and 64-bit bitfield encodings.
+ */
+#define BF32_DECODE(x, low, len) P2PHASE((x) >> (low), 1U << (len))
+#define BF64_DECODE(x, low, len) P2PHASE((x) >> (low), 1ULL << (len))
+#define BF32_ENCODE(x, low, len) (P2PHASE((x), 1U << (len)) << (low))
+#define BF64_ENCODE(x, low, len) (P2PHASE((x), 1ULL << (len)) << (low))
+
+#define BF32_GET(x, low, len) BF32_DECODE(x, low, len)
+#define BF64_GET(x, low, len) BF64_DECODE(x, low, len)
+
+#define BF32_SET(x, low, len, val) \
+ ((x) ^= BF32_ENCODE((x >> low) ^ (val), low, len))
+#define BF64_SET(x, low, len, val) \
+ ((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len))
+
+#define BF32_GET_SB(x, low, len, shift, bias) \
+ ((BF32_GET(x, low, len) + (bias)) << (shift))
+#define BF64_GET_SB(x, low, len, shift, bias) \
+ ((BF64_GET(x, low, len) + (bias)) << (shift))
+
+#define BF32_SET_SB(x, low, len, shift, bias, val) \
+ BF32_SET(x, low, len, ((val) >> (shift)) - (bias))
+#define BF64_SET_SB(x, low, len, shift, bias, val) \
+ BF64_SET(x, low, len, ((val) >> (shift)) - (bias))
+
+/*
+ * We currently support nine block sizes, from 512 bytes to 128K.
+ * We could go higher, but the benefits are near-zero and the cost
+ * of COWing a giant block to modify one byte would become excessive.
+ */
+#define SPA_MINBLOCKSHIFT 9
+#define SPA_MAXBLOCKSHIFT 17
+#define SPA_MINBLOCKSIZE (1ULL << SPA_MINBLOCKSHIFT)
+#define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT)
+
+#define SPA_BLOCKSIZES (SPA_MAXBLOCKSHIFT - SPA_MINBLOCKSHIFT + 1)
+
+/*
+ * Size of block to hold the configuration data (a packed nvlist)
+ */
+#define SPA_CONFIG_BLOCKSIZE (1 << 14)
+
+/*
+ * The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB.
+ * The ASIZE encoding should be at least 64 times larger (6 more bits)
+ * to support up to 4-way RAID-Z mirror mode with worst-case gang block
+ * overhead, three DVAs per bp, plus one more bit in case we do anything
+ * else that expands the ASIZE.
+ */
+#define SPA_LSIZEBITS 16 /* LSIZE up to 32M (2^16 * 512) */
+#define SPA_PSIZEBITS 16 /* PSIZE up to 32M (2^16 * 512) */
+#define SPA_ASIZEBITS 24 /* ASIZE up to 64 times larger */
+
+/*
+ * All SPA data is represented by 128-bit data virtual addresses (DVAs).
+ * The members of the dva_t should be considered opaque outside the SPA.
+ */
+typedef struct dva {
+ grub_uint64_t dva_word[2];
+} dva_t;
+
+/*
+ * Each block has a 256-bit checksum -- strong enough for cryptographic hashes.
+ */
+typedef struct zio_cksum {
+ grub_uint64_t zc_word[4];
+} zio_cksum_t;
+
+/*
+ * Each block is described by its DVAs, time of birth, checksum, etc.
+ * The word-by-word, bit-by-bit layout of the blkptr is as follows:
+ *
+ * 64 56 48 40 32 24 16 8 0
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * 0 | vdev1 | GRID | ASIZE |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * 1 |G| offset1 |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * 2 | vdev2 | GRID | ASIZE |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * 3 |G| offset2 |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * 4 | vdev3 | GRID | ASIZE |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * 5 |G| offset3 |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * 6 |BDX|lvl| type | cksum | comp | PSIZE | LSIZE |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * 7 | padding |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * 8 | padding |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * 9 | physical birth txg |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * a | logical birth txg |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * b | fill count |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * c | checksum[0] |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * d | checksum[1] |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * e | checksum[2] |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * f | checksum[3] |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ *
+ * Legend:
+ *
+ * vdev virtual device ID
+ * offset offset into virtual device
+ * LSIZE logical size
+ * PSIZE physical size (after compression)
+ * ASIZE allocated size (including RAID-Z parity and gang block headers)
+ * GRID RAID-Z layout information (reserved for future use)
+ * cksum checksum function
+ * comp compression function
+ * G gang block indicator
+ * B byteorder (endianness)
+ * D dedup
+ * X unused
+ * lvl level of indirection
+ * type DMU object type
+ * phys birth txg of block allocation; zero if same as logical birth txg
+ * log. birth transaction group in which the block was logically born
+ * fill count number of non-zero blocks under this bp
+ * checksum[4] 256-bit checksum of the data this bp describes
+ */
+#define SPA_BLKPTRSHIFT 7 /* blkptr_t is 128 bytes */
+#define SPA_DVAS_PER_BP 3 /* Number of DVAs in a bp */
+
+typedef struct blkptr {
+ dva_t blk_dva[SPA_DVAS_PER_BP]; /* Data Virtual Addresses */
+ grub_uint64_t blk_prop; /* size, compression, type, etc */
+ grub_uint64_t blk_pad[2]; /* Extra space for the future */
+ grub_uint64_t blk_phys_birth; /* txg when block was allocated */
+ grub_uint64_t blk_birth; /* transaction group at birth */
+ grub_uint64_t blk_fill; /* fill count */
+ zio_cksum_t blk_cksum; /* 256-bit checksum */
+} blkptr_t;
+
+/*
+ * Macros to get and set fields in a bp or DVA.
+ */
+#define DVA_GET_ASIZE(dva) \
+ BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0)
+#define DVA_SET_ASIZE(dva, x) \
+ BF64_SET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0, x)
+
+#define DVA_GET_GRID(dva) BF64_GET((dva)->dva_word[0], 24, 8)
+#define DVA_SET_GRID(dva, x) BF64_SET((dva)->dva_word[0], 24, 8, x)
+
+#define DVA_GET_VDEV(dva) BF64_GET((dva)->dva_word[0], 32, 32)
+#define DVA_SET_VDEV(dva, x) BF64_SET((dva)->dva_word[0], 32, 32, x)
+
+#define DVA_GET_GANG(dva) BF64_GET((dva)->dva_word[1], 63, 1)
+#define DVA_SET_GANG(dva, x) BF64_SET((dva)->dva_word[1], 63, 1, x)
+
+#define BP_GET_LSIZE(bp) \
+ BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)
+#define BP_SET_LSIZE(bp, x) \
+ BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x)
+
+#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 8)
+#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 8, x)
+
+#define BP_GET_CHECKSUM(bp) BF64_GET((bp)->blk_prop, 40, 8)
+#define BP_SET_CHECKSUM(bp, x) BF64_SET((bp)->blk_prop, 40, 8, x)
+
+#define BP_GET_TYPE(bp) BF64_GET((bp)->blk_prop, 48, 8)
+#define BP_SET_TYPE(bp, x) BF64_SET((bp)->blk_prop, 48, 8, x)
+
+#define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5)
+#define BP_SET_LEVEL(bp, x) BF64_SET((bp)->blk_prop, 56, 5, x)
+
+#define BP_GET_PROP_BIT_61(bp) BF64_GET((bp)->blk_prop, 61, 1)
+#define BP_SET_PROP_BIT_61(bp, x) BF64_SET((bp)->blk_prop, 61, 1, x)
+
+#define BP_GET_DEDUP(bp) BF64_GET((bp)->blk_prop, 62, 1)
+#define BP_SET_DEDUP(bp, x) BF64_SET((bp)->blk_prop, 62, 1, x)
+
+#define BP_GET_BYTEORDER(bp) (0 - BF64_GET((bp)->blk_prop, 63, 1))
+#define BP_SET_BYTEORDER(bp, x) BF64_SET((bp)->blk_prop, 63, 1, x)
+
+#define BP_PHYSICAL_BIRTH(bp) \
+ ((bp)->blk_phys_birth ? (bp)->blk_phys_birth : (bp)->blk_birth)
+
+#define BP_SET_BIRTH(bp, logical, physical) \
+{ \
+ (bp)->blk_birth = (logical); \
+ (bp)->blk_phys_birth = ((logical) == (physical) ? 0 : (physical)); \
+}
+
+#define BP_GET_ASIZE(bp) \
+ (DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
+ DVA_GET_ASIZE(&(bp)->blk_dva[2]))
+
+#define BP_GET_UCSIZE(bp) \
+ ((BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata) ? \
+ BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp));
+
+#define BP_GET_NDVAS(bp) \
+ (!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \
+ !!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
+ !!DVA_GET_ASIZE(&(bp)->blk_dva[2]))
+
+#define BP_COUNT_GANG(bp) \
+ (DVA_GET_GANG(&(bp)->blk_dva[0]) + \
+ DVA_GET_GANG(&(bp)->blk_dva[1]) + \
+ DVA_GET_GANG(&(bp)->blk_dva[2]))
+
+#define DVA_EQUAL(dva1, dva2) \
+ ((dva1)->dva_word[1] == (dva2)->dva_word[1] && \
+ (dva1)->dva_word[0] == (dva2)->dva_word[0])
+
+#define BP_EQUAL(bp1, bp2) \
+ (BP_PHYSICAL_BIRTH(bp1) == BP_PHYSICAL_BIRTH(bp2) && \
+ DVA_EQUAL(&(bp1)->blk_dva[0], &(bp2)->blk_dva[0]) && \
+ DVA_EQUAL(&(bp1)->blk_dva[1], &(bp2)->blk_dva[1]) && \
+ DVA_EQUAL(&(bp1)->blk_dva[2], &(bp2)->blk_dva[2]))
+
+#define ZIO_CHECKSUM_EQUAL(zc1, zc2) \
+ (0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \
+ ((zc1).zc_word[1] - (zc2).zc_word[1]) | \
+ ((zc1).zc_word[2] - (zc2).zc_word[2]) | \
+ ((zc1).zc_word[3] - (zc2).zc_word[3])))
+
+#define DVA_IS_VALID(dva) (DVA_GET_ASIZE(dva) != 0)
+
+#define ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3) \
+{ \
+ (zcp)->zc_word[0] = w0; \
+ (zcp)->zc_word[1] = w1; \
+ (zcp)->zc_word[2] = w2; \
+ (zcp)->zc_word[3] = w3; \
+}
+
+#define BP_IDENTITY(bp) (&(bp)->blk_dva[0])
+#define BP_IS_GANG(bp) DVA_GET_GANG(BP_IDENTITY(bp))
+#define BP_IS_HOLE(bp) ((bp)->blk_birth == 0)
+
+/* BP_IS_RAIDZ(bp) assumes no block compression */
+#define BP_IS_RAIDZ(bp) (DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \
+ BP_GET_PSIZE(bp))
+
+#define BP_ZERO(bp) \
+{ \
+ (bp)->blk_dva[0].dva_word[0] = 0; \
+ (bp)->blk_dva[0].dva_word[1] = 0; \
+ (bp)->blk_dva[1].dva_word[0] = 0; \
+ (bp)->blk_dva[1].dva_word[1] = 0; \
+ (bp)->blk_dva[2].dva_word[0] = 0; \
+ (bp)->blk_dva[2].dva_word[1] = 0; \
+ (bp)->blk_prop = 0; \
+ (bp)->blk_pad[0] = 0; \
+ (bp)->blk_pad[1] = 0; \
+ (bp)->blk_phys_birth = 0; \
+ (bp)->blk_birth = 0; \
+ (bp)->blk_fill = 0; \
+ ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0); \
+}
+
+#define BP_SPRINTF_LEN 320
+
+#endif /* ! GRUB_ZFS_SPA_HEADER */
diff --git a/include/grub/zfs/uberblock_impl.h b/include/grub/zfs/uberblock_impl.h
new file mode 100644
index 0000000..1bf7f2b
--- /dev/null
+++ b/include/grub/zfs/uberblock_impl.h
@@ -0,0 +1,60 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_UBERBLOCK_IMPL_H
+#define _SYS_UBERBLOCK_IMPL_H
+
+/*
+ * The uberblock version is incremented whenever an incompatible on-disk
+ * format change is made to the SPA, DMU, or ZAP.
+ *
+ * Note: the first two fields should never be moved. When a storage pool
+ * is opened, the uberblock must be read off the disk before the version
+ * can be checked. If the ub_version field is moved, we may not detect
+ * version mismatch. If the ub_magic field is moved, applications that
+ * expect the magic number in the first word won't work.
+ */
+#define UBERBLOCK_MAGIC 0x00bab10c /* oo-ba-bloc! */
+#define UBERBLOCK_SHIFT 10 /* up to 1K */
+
+typedef struct uberblock {
+ grub_uint64_t ub_magic; /* UBERBLOCK_MAGIC */
+ grub_uint64_t ub_version; /* ZFS_VERSION */
+ grub_uint64_t ub_txg; /* txg of last sync */
+ grub_uint64_t ub_guid_sum; /* sum of all vdev guids */
+ grub_uint64_t ub_timestamp; /* UTC time of last sync */
+ blkptr_t ub_rootbp; /* MOS objset_phys_t */
+} uberblock_t;
+
+#define UBERBLOCK_SIZE (1ULL << UBERBLOCK_SHIFT)
+#define VDEV_UBERBLOCK_SHIFT UBERBLOCK_SHIFT
+
+/* XXX Uberblock_phys_t is no longer in the kernel zfs */
+typedef struct uberblock_phys {
+ uberblock_t ubp_uberblock;
+ char ubp_pad[UBERBLOCK_SIZE - sizeof (uberblock_t) -
+ sizeof (zio_eck_t)];
+ zio_eck_t ubp_zec;
+} uberblock_phys_t;
+
+
+#endif /* _SYS_UBERBLOCK_IMPL_H */
diff --git a/include/grub/zfs/vdev_impl.h b/include/grub/zfs/vdev_impl.h
new file mode 100644
index 0000000..9b5f0a7
--- /dev/null
+++ b/include/grub/zfs/vdev_impl.h
@@ -0,0 +1,69 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_VDEV_IMPL_H
+#define _SYS_VDEV_IMPL_H
+
+#define VDEV_SKIP_SIZE (8 << 10)
+#define VDEV_BOOT_HEADER_SIZE (8 << 10)
+#define VDEV_PHYS_SIZE (112 << 10)
+#define VDEV_UBERBLOCK_RING (128 << 10)
+
+/* ZFS boot block */
+#define VDEV_BOOT_MAGIC 0x2f5b007b10cULL
+#define VDEV_BOOT_VERSION 1 /* version number */
+
+typedef struct vdev_boot_header {
+ grub_uint64_t vb_magic; /* VDEV_BOOT_MAGIC */
+ grub_uint64_t vb_version; /* VDEV_BOOT_VERSION */
+ grub_uint64_t vb_offset; /* start offset (bytes) */
+ grub_uint64_t vb_size; /* size (bytes) */
+ char vb_pad[VDEV_BOOT_HEADER_SIZE - 4 * sizeof (grub_uint64_t)];
+} vdev_boot_header_t;
+
+typedef struct vdev_phys {
+ char vp_nvlist[VDEV_PHYS_SIZE - sizeof (zio_eck_t)];
+ zio_eck_t vp_zbt;
+} vdev_phys_t;
+
+typedef struct vdev_label {
+ char vl_pad[VDEV_SKIP_SIZE]; /* 8K */
+ vdev_boot_header_t vl_boot_header; /* 8K */
+ vdev_phys_t vl_vdev_phys; /* 112K */
+ char vl_uberblock[VDEV_UBERBLOCK_RING]; /* 128K */
+} vdev_label_t; /* 256K total */
+
+/*
+ * Size and offset of embedded boot loader region on each label.
+ * The total size of the first two labels plus the boot area is 4MB.
+ */
+#define VDEV_BOOT_OFFSET (2 * sizeof (vdev_label_t))
+#define VDEV_BOOT_SIZE (7ULL << 19) /* 3.5M */
+
+/*
+ * Size of label regions at the start and end of each leaf device.
+ */
+#define VDEV_LABEL_START_SIZE (2 * sizeof (vdev_label_t) + VDEV_BOOT_SIZE)
+#define VDEV_LABEL_END_SIZE (2 * sizeof (vdev_label_t))
+#define VDEV_LABELS 4
+
+#endif /* _SYS_VDEV_IMPL_H */
diff --git a/include/grub/zfs/zap_impl.h b/include/grub/zfs/zap_impl.h
new file mode 100644
index 0000000..e42727a
--- /dev/null
+++ b/include/grub/zfs/zap_impl.h
@@ -0,0 +1,111 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_ZAP_IMPL_H
+#define _SYS_ZAP_IMPL_H
+
+#define ZAP_MAGIC 0x2F52AB2ABULL
+
+#define ZAP_HASHBITS 28
+#define MZAP_ENT_LEN 64
+#define MZAP_NAME_LEN (MZAP_ENT_LEN - 8 - 4 - 2)
+#define MZAP_MAX_BLKSHIFT SPA_MAXBLOCKSHIFT
+#define MZAP_MAX_BLKSZ (1 << MZAP_MAX_BLKSHIFT)
+
+typedef struct mzap_ent_phys {
+ grub_uint64_t mze_value;
+ grub_uint32_t mze_cd;
+ grub_uint16_t mze_pad; /* in case we want to chain them someday */
+ char mze_name[MZAP_NAME_LEN];
+} mzap_ent_phys_t;
+
+typedef struct mzap_phys {
+ grub_uint64_t mz_block_type; /* ZBT_MICRO */
+ grub_uint64_t mz_salt;
+ grub_uint64_t mz_pad[6];
+ mzap_ent_phys_t mz_chunk[1];
+ /* actually variable size depending on block size */
+} mzap_phys_t;
+
+/*
+ * The (fat) zap is stored in one object. It is an array of
+ * 1<<FZAP_BLOCK_SHIFT byte blocks. The layout looks like one of:
+ *
+ * ptrtbl fits in first block:
+ * [zap_phys_t zap_ptrtbl_shift < 6] [zap_leaf_t] ...
+ *
+ * ptrtbl too big for first block:
+ * [zap_phys_t zap_ptrtbl_shift >= 6] [zap_leaf_t] [ptrtbl] ...
+ *
+ */
+
+#define ZBT_LEAF ((1ULL << 63) + 0)
+#define ZBT_HEADER ((1ULL << 63) + 1)
+#define ZBT_MICRO ((1ULL << 63) + 3)
+/* any other values are ptrtbl blocks */
+
+/*
+ * the embedded pointer table takes up half a block:
+ * block size / entry size (2^3) / 2
+ */
+#define ZAP_EMBEDDED_PTRTBL_SHIFT(zap) (FZAP_BLOCK_SHIFT(zap) - 3 - 1)
+
+/*
+ * The embedded pointer table starts half-way through the block. Since
+ * the pointer table itself is half the block, it starts at (64-bit)
+ * word number (1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap)).
+ */
+#define ZAP_EMBEDDED_PTRTBL_ENT(zap, idx) \
+ ((grub_uint64_t *)(zap)->zap_f.zap_phys) \
+ [(idx) + (1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap))]
+
+/*
+ * TAKE NOTE:
+ * If zap_phys_t is modified, zap_byteswap() must be modified.
+ */
+typedef struct zap_phys {
+ grub_uint64_t zap_block_type; /* ZBT_HEADER */
+ grub_uint64_t zap_magic; /* ZAP_MAGIC */
+
+ struct zap_table_phys {
+ grub_uint64_t zt_blk; /* starting block number */
+ grub_uint64_t zt_numblks; /* number of blocks */
+ grub_uint64_t zt_shift; /* bits to index it */
+ grub_uint64_t zt_nextblk; /* next (larger) copy start block */
+ grub_uint64_t zt_blks_copied; /* number source blocks copied */
+ } zap_ptrtbl;
+
+ grub_uint64_t zap_freeblk; /* the next free block */
+ grub_uint64_t zap_num_leafs; /* number of leafs */
+ grub_uint64_t zap_num_entries; /* number of entries */
+ grub_uint64_t zap_salt; /* salt to stir into hash function */
+ grub_uint64_t zap_normflags; /* flags for u8_textprep_str() */
+ grub_uint64_t zap_flags; /* zap_flag_t */
+ /*
+ * This structure is followed by padding, and then the embedded
+ * pointer table. The embedded pointer table takes up second
+ * half of the block. It is accessed using the
+ * ZAP_EMBEDDED_PTRTBL_ENT() macro.
+ */
+} zap_phys_t;
+
+#endif /* _SYS_ZAP_IMPL_H */
diff --git a/include/grub/zfs/zap_leaf.h b/include/grub/zfs/zap_leaf.h
new file mode 100644
index 0000000..1ef6540
--- /dev/null
+++ b/include/grub/zfs/zap_leaf.h
@@ -0,0 +1,103 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_ZAP_LEAF_H
+#define _SYS_ZAP_LEAF_H
+
+#define ZAP_LEAF_MAGIC 0x2AB1EAF
+
+/* chunk size = 24 bytes */
+#define ZAP_LEAF_CHUNKSIZE 24
+
+/*
+ * The amount of space within the chunk available for the array is:
+ * chunk size - space for type (1) - space for next pointer (2)
+ */
+#define ZAP_LEAF_ARRAY_BYTES (ZAP_LEAF_CHUNKSIZE - 3)
+
+typedef enum zap_chunk_type {
+ ZAP_CHUNK_FREE = 253,
+ ZAP_CHUNK_ENTRY = 252,
+ ZAP_CHUNK_ARRAY = 251,
+ ZAP_CHUNK_TYPE_MAX = 250
+} zap_chunk_type_t;
+
+/*
+ * TAKE NOTE:
+ * If zap_leaf_phys_t is modified, zap_leaf_byteswap() must be modified.
+ */
+typedef struct zap_leaf_phys {
+ struct zap_leaf_header {
+ grub_uint64_t lh_block_type; /* ZBT_LEAF */
+ grub_uint64_t lh_pad1;
+ grub_uint64_t lh_prefix; /* hash prefix of this leaf */
+ grub_uint32_t lh_magic; /* ZAP_LEAF_MAGIC */
+ grub_uint16_t lh_nfree; /* number free chunks */
+ grub_uint16_t lh_nentries; /* number of entries */
+ grub_uint16_t lh_prefix_len; /* num bits used to id this */
+
+/* above is accessable to zap, below is zap_leaf private */
+
+ grub_uint16_t lh_freelist; /* chunk head of free list */
+ grub_uint8_t lh_pad2[12];
+ } l_hdr; /* 2 24-byte chunks */
+
+ /*
+ * The header is followed by a hash table with
+ * ZAP_LEAF_HASH_NUMENTRIES(zap) entries. The hash table is
+ * followed by an array of ZAP_LEAF_NUMCHUNKS(zap)
+ * zap_leaf_chunk structures. These structures are accessed
+ * with the ZAP_LEAF_CHUNK() macro.
+ */
+
+ grub_uint16_t l_hash[1];
+} zap_leaf_phys_t;
+
+typedef union zap_leaf_chunk {
+ struct zap_leaf_entry {
+ grub_uint8_t le_type; /* always ZAP_CHUNK_ENTRY */
+ grub_uint8_t le_int_size; /* size of ints */
+ grub_uint16_t le_next; /* next entry in hash chain */
+ grub_uint16_t le_name_chunk; /* first chunk of the name */
+ grub_uint16_t le_name_length; /* bytes in name, incl null */
+ grub_uint16_t le_value_chunk; /* first chunk of the value */
+ grub_uint16_t le_value_length; /* value length in ints */
+ grub_uint32_t le_cd; /* collision differentiator */
+ grub_uint64_t le_hash; /* hash value of the name */
+ } l_entry;
+ struct zap_leaf_array {
+ grub_uint8_t la_type; /* always ZAP_CHUNK_ARRAY */
+ union
+ {
+ grub_uint8_t la_array[ZAP_LEAF_ARRAY_BYTES];
+ grub_uint64_t la_array64;
+ };
+ grub_uint16_t la_next; /* next blk or CHAIN_END */
+ } l_array;
+ struct zap_leaf_free {
+ grub_uint8_t lf_type; /* always ZAP_CHUNK_FREE */
+ grub_uint8_t lf_pad[ZAP_LEAF_ARRAY_BYTES];
+ grub_uint16_t lf_next; /* next in free list, or CHAIN_END */
+ } l_free;
+} zap_leaf_chunk_t;
+
+#endif /* _SYS_ZAP_LEAF_H */
diff --git a/include/grub/zfs/zfs.h b/include/grub/zfs/zfs.h
new file mode 100644
index 0000000..0576925
--- /dev/null
+++ b/include/grub/zfs/zfs.h
@@ -0,0 +1,123 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,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/>.
+ */
+ /*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef GRUB_ZFS_HEADER
+#define GRUB_ZFS_HEADER 1
+
+#include <grub/err.h>
+#include <grub/disk.h>
+
+/*
+ * On-disk version number.
+ */
+#define SPA_VERSION 28ULL
+
+/*
+ * The following are configuration names used in the nvlist describing a pool's
+ * configuration.
+ */
+#define ZPOOL_CONFIG_VERSION "version"
+#define ZPOOL_CONFIG_POOL_NAME "name"
+#define ZPOOL_CONFIG_POOL_STATE "state"
+#define ZPOOL_CONFIG_POOL_TXG "txg"
+#define ZPOOL_CONFIG_POOL_GUID "pool_guid"
+#define ZPOOL_CONFIG_CREATE_TXG "create_txg"
+#define ZPOOL_CONFIG_TOP_GUID "top_guid"
+#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree"
+#define ZPOOL_CONFIG_TYPE "type"
+#define ZPOOL_CONFIG_CHILDREN "children"
+#define ZPOOL_CONFIG_ID "id"
+#define ZPOOL_CONFIG_GUID "guid"
+#define ZPOOL_CONFIG_PATH "path"
+#define ZPOOL_CONFIG_DEVID "devid"
+#define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array"
+#define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift"
+#define ZPOOL_CONFIG_ASHIFT "ashift"
+#define ZPOOL_CONFIG_ASIZE "asize"
+#define ZPOOL_CONFIG_DTL "DTL"
+#define ZPOOL_CONFIG_STATS "stats"
+#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
+#define ZPOOL_CONFIG_ERRCOUNT "error_count"
+#define ZPOOL_CONFIG_NOT_PRESENT "not_present"
+#define ZPOOL_CONFIG_SPARES "spares"
+#define ZPOOL_CONFIG_IS_SPARE "is_spare"
+#define ZPOOL_CONFIG_NPARITY "nparity"
+#define ZPOOL_CONFIG_PHYS_PATH "phys_path"
+#define ZPOOL_CONFIG_L2CACHE "l2cache"
+#define ZPOOL_CONFIG_HOLE_ARRAY "hole_array"
+#define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children"
+#define ZPOOL_CONFIG_IS_HOLE "is_hole"
+#define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram"
+#define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats"
+#define ZPOOL_CONFIG_DDT_STATS "ddt_stats"
+/*
+ * The persistent vdev state is stored as separate values rather than a single
+ * 'vdev_state' entry. This is because a device can be in multiple states, such
+ * as offline and degraded.
+ */
+#define ZPOOL_CONFIG_OFFLINE "offline"
+#define ZPOOL_CONFIG_FAULTED "faulted"
+#define ZPOOL_CONFIG_DEGRADED "degraded"
+#define ZPOOL_CONFIG_REMOVED "removed"
+
+#define VDEV_TYPE_ROOT "root"
+#define VDEV_TYPE_MIRROR "mirror"
+#define VDEV_TYPE_REPLACING "replacing"
+#define VDEV_TYPE_RAIDZ "raidz"
+#define VDEV_TYPE_DISK "disk"
+#define VDEV_TYPE_FILE "file"
+#define VDEV_TYPE_MISSING "missing"
+#define VDEV_TYPE_HOLE "hole"
+#define VDEV_TYPE_SPARE "spare"
+#define VDEV_TYPE_L2CACHE "l2cache"
+
+/*
+ * pool state. The following states are written to disk as part of the normal
+ * SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining
+ * states are software abstractions used at various levels to communicate pool
+ * state.
+ */
+typedef enum pool_state {
+ POOL_STATE_ACTIVE = 0, /* In active use */
+ POOL_STATE_EXPORTED, /* Explicitly exported */
+ POOL_STATE_DESTROYED, /* Explicitly destroyed */
+ POOL_STATE_SPARE, /* Reserved for hot spare use */
+ POOL_STATE_L2CACHE, /* Level 2 ARC device */
+ POOL_STATE_UNINITIALIZED, /* Internal spa_t state */
+ POOL_STATE_UNAVAIL, /* Internal libzfs state */
+ POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */
+} pool_state_t;
+
+struct grub_zfs_data;
+
+grub_err_t grub_zfs_fetch_nvlist (grub_device_t dev, char **nvlist);
+grub_err_t grub_zfs_getmdnobj (grub_device_t dev, const char *fsfilename,
+ grub_uint64_t *mdnobj);
+
+char *grub_zfs_nvlist_lookup_string (char *nvlist, char *name);
+char *grub_zfs_nvlist_lookup_nvlist (char *nvlist, char *name);
+int grub_zfs_nvlist_lookup_uint64 (char *nvlist, char *name,
+ grub_uint64_t *out);
+char *grub_zfs_nvlist_lookup_nvlist_array (char *nvlist, char *name,
+ grub_size_t index);
+int grub_zfs_nvlist_lookup_nvlist_array_get_nelm (char *nvlist, char *name);
+
+#endif /* ! GRUB_ZFS_HEADER */
diff --git a/include/grub/zfs/zfs_acl.h b/include/grub/zfs/zfs_acl.h
new file mode 100644
index 0000000..2777382
--- /dev/null
+++ b/include/grub/zfs/zfs_acl.h
@@ -0,0 +1,59 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_FS_ZFS_ACL_H
+#define _SYS_FS_ZFS_ACL_H
+
+#ifndef _UID_T
+#define _UID_T
+typedef unsigned int uid_t; /* UID type */
+#endif /* _UID_T */
+
+typedef struct zfs_oldace {
+ grub_uint32_t z_fuid; /* "who" */
+ grub_uint32_t z_access_mask; /* access mask */
+ grub_uint16_t z_flags; /* flags, i.e inheritance */
+ grub_uint16_t z_type; /* type of entry allow/deny */
+} zfs_oldace_t;
+
+#define ACE_SLOT_CNT 6
+
+typedef struct zfs_znode_acl_v0 {
+ grub_uint64_t z_acl_extern_obj; /* ext acl pieces */
+ grub_uint32_t z_acl_count; /* Number of ACEs */
+ grub_uint16_t z_acl_version; /* acl version */
+ grub_uint16_t z_acl_pad; /* pad */
+ zfs_oldace_t z_ace_data[ACE_SLOT_CNT]; /* 6 standard ACEs */
+} zfs_znode_acl_v0_t;
+
+#define ZFS_ACE_SPACE (sizeof (zfs_oldace_t) * ACE_SLOT_CNT)
+
+typedef struct zfs_znode_acl {
+ grub_uint64_t z_acl_extern_obj; /* ext acl pieces */
+ grub_uint32_t z_acl_size; /* Number of bytes in ACL */
+ grub_uint16_t z_acl_version; /* acl version */
+ grub_uint16_t z_acl_count; /* ace count */
+ grub_uint8_t z_ace_data[ZFS_ACE_SPACE]; /* space for embedded ACEs */
+} zfs_znode_acl_t;
+
+
+#endif /* _SYS_FS_ZFS_ACL_H */
diff --git a/include/grub/zfs/zfs_znode.h b/include/grub/zfs/zfs_znode.h
new file mode 100644
index 0000000..efd6d10
--- /dev/null
+++ b/include/grub/zfs/zfs_znode.h
@@ -0,0 +1,70 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_FS_ZFS_ZNODE_H
+#define _SYS_FS_ZFS_ZNODE_H
+
+#include <grub/zfs/zfs_acl.h>
+
+#define MASTER_NODE_OBJ 1
+#define ZFS_ROOT_OBJ "ROOT"
+#define ZPL_VERSION_STR "VERSION"
+#define ZFS_SA_ATTRS "SA_ATTRS"
+
+#define ZPL_VERSION 5ULL
+
+#define ZFS_DIRENT_OBJ(de) BF64_GET(de, 0, 48)
+
+/*
+ * This is the persistent portion of the znode. It is stored
+ * in the "bonus buffer" of the file. Short symbolic links
+ * are also stored in the bonus buffer.
+ */
+typedef struct znode_phys {
+ grub_uint64_t zp_atime[2]; /* 0 - last file access time */
+ grub_uint64_t zp_mtime[2]; /* 16 - last file modification time */
+ grub_uint64_t zp_ctime[2]; /* 32 - last file change time */
+ grub_uint64_t zp_crtime[2]; /* 48 - creation time */
+ grub_uint64_t zp_gen; /* 64 - generation (txg of creation) */
+ grub_uint64_t zp_mode; /* 72 - file mode bits */
+ grub_uint64_t zp_size; /* 80 - size of file */
+ grub_uint64_t zp_parent; /* 88 - directory parent (`..') */
+ grub_uint64_t zp_links; /* 96 - number of links to file */
+ grub_uint64_t zp_xattr; /* 104 - DMU object for xattrs */
+ grub_uint64_t zp_rdev; /* 112 - dev_t for VBLK & VCHR files */
+ grub_uint64_t zp_flags; /* 120 - persistent flags */
+ grub_uint64_t zp_uid; /* 128 - file owner */
+ grub_uint64_t zp_gid; /* 136 - owning group */
+ grub_uint64_t zp_pad[4]; /* 144 - future */
+ zfs_znode_acl_t zp_acl; /* 176 - 263 ACL */
+ /*
+ * Data may pad out any remaining bytes in the znode buffer, eg:
+ *
+ * |<---------------------- dnode_phys (512) ------------------------>|
+ * |<-- dnode (192) --->|<----------- "bonus" buffer (320) ---------->|
+ * |<---- znode (264) ---->|<---- data (56) ---->|
+ *
+ * At present, we only use this space to store symbolic links.
+ */
+} znode_phys_t;
+
+#endif /* _SYS_FS_ZFS_ZNODE_H */
diff --git a/include/grub/zfs/zil.h b/include/grub/zfs/zil.h
new file mode 100644
index 0000000..45d16f4
--- /dev/null
+++ b/include/grub/zfs/zil.h
@@ -0,0 +1,56 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_ZIL_H
+#define _SYS_ZIL_H
+
+/*
+ * Intent log format:
+ *
+ * Each objset has its own intent log. The log header (zil_header_t)
+ * for objset N's intent log is kept in the Nth object of the SPA's
+ * intent_log objset. The log header points to a chain of log blocks,
+ * each of which contains log records (i.e., transactions) followed by
+ * a log block trailer (zil_trailer_t). The format of a log record
+ * depends on the record (or transaction) type, but all records begin
+ * with a common structure that defines the type, length, and txg.
+ */
+
+/*
+ * Intent log header - this on disk structure holds fields to manage
+ * the log. All fields are 64 bit to easily handle cross architectures.
+ */
+typedef struct zil_header {
+ grub_uint64_t zh_claim_txg; /* txg in which log blocks were claimed */
+ grub_uint64_t zh_replay_seq; /* highest replayed sequence number */
+ blkptr_t zh_log; /* log chain */
+ grub_uint64_t zh_claim_seq; /* highest claimed sequence number */
+ grub_uint64_t zh_flags; /* header flags */
+ grub_uint64_t zh_pad[4];
+} zil_header_t;
+
+/*
+ * zh_flags bit settings
+ */
+#define ZIL_REPLAY_NEEDED 0x1 /* replay needed - internal only */
+
+#endif /* _SYS_ZIL_H */
diff --git a/include/grub/zfs/zio.h b/include/grub/zfs/zio.h
new file mode 100644
index 0000000..797d4f9
--- /dev/null
+++ b/include/grub/zfs/zio.h
@@ -0,0 +1,84 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _ZIO_H
+#define _ZIO_H
+
+#include <grub/zfs/spa.h>
+
+#define ZEC_MAGIC 0x210da7ab10c7a11ULL /* zio data bloc tail */
+
+typedef struct zio_eck {
+ grub_uint64_t zec_magic; /* for validation, endianness */
+ zio_cksum_t zec_cksum; /* 256-bit checksum */
+} zio_eck_t;
+
+/*
+ * Gang block headers are self-checksumming and contain an array
+ * of block pointers.
+ */
+#define SPA_GANGBLOCKSIZE SPA_MINBLOCKSIZE
+#define SPA_GBH_NBLKPTRS ((SPA_GANGBLOCKSIZE - \
+ sizeof (zio_eck_t)) / sizeof (blkptr_t))
+#define SPA_GBH_FILLER ((SPA_GANGBLOCKSIZE - \
+ sizeof (zio_eck_t) - \
+ (SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\
+ sizeof (grub_uint64_t))
+
+#define ZIO_GET_IOSIZE(zio) \
+ (BP_IS_GANG((zio)->io_bp) ? \
+ SPA_GANGBLOCKSIZE : BP_GET_PSIZE((zio)->io_bp))
+
+typedef struct zio_gbh {
+ blkptr_t zg_blkptr[SPA_GBH_NBLKPTRS];
+ grub_uint64_t zg_filler[SPA_GBH_FILLER];
+ zio_eck_t zg_tail;
+} zio_gbh_phys_t;
+
+enum zio_checksum {
+ ZIO_CHECKSUM_INHERIT = 0,
+ ZIO_CHECKSUM_ON,
+ ZIO_CHECKSUM_OFF,
+ ZIO_CHECKSUM_LABEL,
+ ZIO_CHECKSUM_GANG_HEADER,
+ ZIO_CHECKSUM_ZILOG,
+ ZIO_CHECKSUM_FLETCHER_2,
+ ZIO_CHECKSUM_FLETCHER_4,
+ ZIO_CHECKSUM_SHA256,
+ ZIO_CHECKSUM_ZILOG2,
+ ZIO_CHECKSUM_FUNCTIONS
+};
+
+#define ZIO_CHECKSUM_ON_VALUE ZIO_CHECKSUM_FLETCHER_2
+#define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON
+
+enum zio_compress {
+ ZIO_COMPRESS_INHERIT = 0,
+ ZIO_COMPRESS_ON,
+ ZIO_COMPRESS_OFF,
+ ZIO_COMPRESS_LZJB,
+ ZIO_COMPRESS_EMPTY,
+ ZIO_COMPRESS_GZIP,
+ ZIO_COMPRESS_FUNCTIONS
+};
+
+#endif /* _ZIO_H */
diff --git a/include/grub/zfs/zio_checksum.h b/include/grub/zfs/zio_checksum.h
new file mode 100644
index 0000000..0ef5a3e
--- /dev/null
+++ b/include/grub/zfs/zio_checksum.h
@@ -0,0 +1,49 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
+ */
+/*
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_ZIO_CHECKSUM_H
+#define _SYS_ZIO_CHECKSUM_H
+
+/*
+ * Signature for checksum functions.
+ */
+typedef void zio_checksum_t(const void *data, grub_uint64_t size,
+ grub_zfs_endian_t endian, zio_cksum_t *zcp);
+
+/*
+ * Information about each checksum function.
+ */
+typedef struct zio_checksum_info {
+ zio_checksum_t *ci_func; /* checksum function for each byteorder */
+ int ci_correctable; /* number of correctable bits */
+ int ci_eck; /* uses zio embedded checksum? */
+ char *ci_name; /* descriptive name */
+} zio_checksum_info_t;
+
+extern void zio_checksum_SHA256 (const void *, grub_uint64_t,
+ grub_zfs_endian_t endian, zio_cksum_t *);
+extern void fletcher_2 (const void *, grub_uint64_t, grub_zfs_endian_t endian,
+ zio_cksum_t *);
+extern void fletcher_4 (const void *, grub_uint64_t, grub_zfs_endian_t endian,
+ zio_cksum_t *);
+
+#endif /* _SYS_ZIO_CHECKSUM_H */
diff --git a/include/multiboot.h b/include/multiboot.h
new file mode 100644
index 0000000..bd133ba
--- /dev/null
+++ b/include/multiboot.h
@@ -0,0 +1,274 @@
+/* multiboot.h - Multiboot header file. */
+/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY
+ * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef MULTIBOOT_HEADER
+#define MULTIBOOT_HEADER 1
+
+/* How many bytes from the start of the file we search for the header. */
+#define MULTIBOOT_SEARCH 8192
+#define MULTIBOOT_HEADER_ALIGN 4
+
+/* The magic field should contain this. */
+#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
+
+/* This should be in %eax. */
+#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
+
+/* Alignment of multiboot modules. */
+#define MULTIBOOT_MOD_ALIGN 0x00001000
+
+/* Alignment of the multiboot info structure. */
+#define MULTIBOOT_INFO_ALIGN 0x00000004
+
+/* Flags set in the 'flags' member of the multiboot header. */
+
+/* Align all boot modules on i386 page (4KB) boundaries. */
+#define MULTIBOOT_PAGE_ALIGN 0x00000001
+
+/* Must pass memory information to OS. */
+#define MULTIBOOT_MEMORY_INFO 0x00000002
+
+/* Must pass video information to OS. */
+#define MULTIBOOT_VIDEO_MODE 0x00000004
+
+/* This flag indicates the use of the address fields in the header. */
+#define MULTIBOOT_AOUT_KLUDGE 0x00010000
+
+/* Flags to be set in the 'flags' member of the multiboot info structure. */
+
+/* is there basic lower/upper memory information? */
+#define MULTIBOOT_INFO_MEMORY 0x00000001
+/* is there a boot device set? */
+#define MULTIBOOT_INFO_BOOTDEV 0x00000002
+/* is the command-line defined? */
+#define MULTIBOOT_INFO_CMDLINE 0x00000004
+/* are there modules to do something with? */
+#define MULTIBOOT_INFO_MODS 0x00000008
+
+/* These next two are mutually exclusive */
+
+/* is there a symbol table loaded? */
+#define MULTIBOOT_INFO_AOUT_SYMS 0x00000010
+/* is there an ELF section header table? */
+#define MULTIBOOT_INFO_ELF_SHDR 0X00000020
+
+/* is there a full memory map? */
+#define MULTIBOOT_INFO_MEM_MAP 0x00000040
+
+/* Is there drive info? */
+#define MULTIBOOT_INFO_DRIVE_INFO 0x00000080
+
+/* Is there a config table? */
+#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100
+
+/* Is there a boot loader name? */
+#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200
+
+/* Is there a APM table? */
+#define MULTIBOOT_INFO_APM_TABLE 0x00000400
+
+/* Is there video information? */
+#define MULTIBOOT_INFO_VBE_INFO 0x00000800
+#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000
+
+#ifndef ASM_FILE
+
+typedef unsigned char multiboot_uint8_t;
+typedef unsigned short multiboot_uint16_t;
+typedef unsigned int multiboot_uint32_t;
+typedef unsigned long long multiboot_uint64_t;
+
+struct multiboot_header
+{
+ /* Must be MULTIBOOT_MAGIC - see above. */
+ multiboot_uint32_t magic;
+
+ /* Feature flags. */
+ multiboot_uint32_t flags;
+
+ /* The above fields plus this one must equal 0 mod 2^32. */
+ multiboot_uint32_t checksum;
+
+ /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
+ multiboot_uint32_t header_addr;
+ multiboot_uint32_t load_addr;
+ multiboot_uint32_t load_end_addr;
+ multiboot_uint32_t bss_end_addr;
+ multiboot_uint32_t entry_addr;
+
+ /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */
+ multiboot_uint32_t mode_type;
+ multiboot_uint32_t width;
+ multiboot_uint32_t height;
+ multiboot_uint32_t depth;
+};
+
+/* The symbol table for a.out. */
+struct multiboot_aout_symbol_table
+{
+ multiboot_uint32_t tabsize;
+ multiboot_uint32_t strsize;
+ multiboot_uint32_t addr;
+ multiboot_uint32_t reserved;
+};
+typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
+
+/* The section header table for ELF. */
+struct multiboot_elf_section_header_table
+{
+ multiboot_uint32_t num;
+ multiboot_uint32_t size;
+ multiboot_uint32_t addr;
+ multiboot_uint32_t shndx;
+};
+typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
+
+struct multiboot_info
+{
+ /* Multiboot info version number */
+ multiboot_uint32_t flags;
+
+ /* Available memory from BIOS */
+ multiboot_uint32_t mem_lower;
+ multiboot_uint32_t mem_upper;
+
+ /* "root" partition */
+ multiboot_uint32_t boot_device;
+
+ /* Kernel command line */
+ multiboot_uint32_t cmdline;
+
+ /* Boot-Module list */
+ multiboot_uint32_t mods_count;
+ multiboot_uint32_t mods_addr;
+
+ union
+ {
+ multiboot_aout_symbol_table_t aout_sym;
+ multiboot_elf_section_header_table_t elf_sec;
+ } u;
+
+ /* Memory Mapping buffer */
+ multiboot_uint32_t mmap_length;
+ multiboot_uint32_t mmap_addr;
+
+ /* Drive Info buffer */
+ multiboot_uint32_t drives_length;
+ multiboot_uint32_t drives_addr;
+
+ /* ROM configuration table */
+ multiboot_uint32_t config_table;
+
+ /* Boot Loader Name */
+ multiboot_uint32_t boot_loader_name;
+
+ /* APM table */
+ multiboot_uint32_t apm_table;
+
+ /* Video */
+ multiboot_uint32_t vbe_control_info;
+ multiboot_uint32_t vbe_mode_info;
+ multiboot_uint16_t vbe_mode;
+ multiboot_uint16_t vbe_interface_seg;
+ multiboot_uint16_t vbe_interface_off;
+ multiboot_uint16_t vbe_interface_len;
+
+ multiboot_uint64_t framebuffer_addr;
+ multiboot_uint32_t framebuffer_pitch;
+ multiboot_uint32_t framebuffer_width;
+ multiboot_uint32_t framebuffer_height;
+ multiboot_uint8_t framebuffer_bpp;
+#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
+#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
+#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
+ multiboot_uint8_t framebuffer_type;
+ union
+ {
+ struct
+ {
+ multiboot_uint32_t framebuffer_palette_addr;
+ multiboot_uint16_t framebuffer_palette_num_colors;
+ };
+ struct
+ {
+ multiboot_uint8_t framebuffer_red_field_position;
+ multiboot_uint8_t framebuffer_red_mask_size;
+ multiboot_uint8_t framebuffer_green_field_position;
+ multiboot_uint8_t framebuffer_green_mask_size;
+ multiboot_uint8_t framebuffer_blue_field_position;
+ multiboot_uint8_t framebuffer_blue_mask_size;
+ };
+ };
+};
+typedef struct multiboot_info multiboot_info_t;
+
+struct multiboot_color
+{
+ multiboot_uint8_t red;
+ multiboot_uint8_t green;
+ multiboot_uint8_t blue;
+};
+
+struct multiboot_mmap_entry
+{
+ multiboot_uint32_t size;
+ multiboot_uint64_t addr;
+ multiboot_uint64_t len;
+#define MULTIBOOT_MEMORY_AVAILABLE 1
+#define MULTIBOOT_MEMORY_RESERVED 2
+#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
+#define MULTIBOOT_MEMORY_NVS 4
+#define MULTIBOOT_MEMORY_BADRAM 5
+ multiboot_uint32_t type;
+} __attribute__((packed));
+typedef struct multiboot_mmap_entry multiboot_memory_map_t;
+
+struct multiboot_mod_list
+{
+ /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
+ multiboot_uint32_t mod_start;
+ multiboot_uint32_t mod_end;
+
+ /* Module command line */
+ multiboot_uint32_t cmdline;
+
+ /* padding to take it to 16 bytes (must be zero) */
+ multiboot_uint32_t pad;
+};
+typedef struct multiboot_mod_list multiboot_module_t;
+
+/* APM BIOS info. */
+struct multiboot_apm_info
+{
+ grub_uint16_t version;
+ grub_uint16_t cseg;
+ grub_uint32_t offset;
+ grub_uint16_t cseg_16;
+ grub_uint16_t dseg;
+ grub_uint16_t flags;
+ grub_uint16_t cseg_len;
+ grub_uint16_t cseg_16_len;
+ grub_uint16_t dseg_len;
+};
+
+#endif /* ! ASM_FILE */
+
+#endif /* ! MULTIBOOT_HEADER */
diff --git a/include/multiboot2.h b/include/multiboot2.h
new file mode 100644
index 0000000..0e26a8e
--- /dev/null
+++ b/include/multiboot2.h
@@ -0,0 +1,366 @@
+/* multiboot2.h - Multiboot 2 header file. */
+/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY
+ * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef MULTIBOOT_HEADER
+#define MULTIBOOT_HEADER 1
+
+/* How many bytes from the start of the file we search for the header. */
+#define MULTIBOOT_SEARCH 32768
+#define MULTIBOOT_HEADER_ALIGN 8
+
+/* The magic field should contain this. */
+#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
+
+/* This should be in %eax. */
+#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
+
+/* Alignment of multiboot modules. */
+#define MULTIBOOT_MOD_ALIGN 0x00001000
+
+/* Alignment of the multiboot info structure. */
+#define MULTIBOOT_INFO_ALIGN 0x00000008
+
+/* Flags set in the 'flags' member of the multiboot header. */
+
+#define MULTIBOOT_TAG_ALIGN 8
+#define MULTIBOOT_TAG_TYPE_END 0
+#define MULTIBOOT_TAG_TYPE_CMDLINE 1
+#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2
+#define MULTIBOOT_TAG_TYPE_MODULE 3
+#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4
+#define MULTIBOOT_TAG_TYPE_BOOTDEV 5
+#define MULTIBOOT_TAG_TYPE_MMAP 6
+#define MULTIBOOT_TAG_TYPE_VBE 7
+#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8
+#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9
+#define MULTIBOOT_TAG_TYPE_APM 10
+#define MULTIBOOT_TAG_TYPE_EFI32 11
+#define MULTIBOOT_TAG_TYPE_EFI64 12
+#define MULTIBOOT_TAG_TYPE_SMBIOS 13
+#define MULTIBOOT_TAG_TYPE_ACPI_OLD 14
+#define MULTIBOOT_TAG_TYPE_ACPI_NEW 15
+#define MULTIBOOT_TAG_TYPE_NETWORK 16
+
+#define MULTIBOOT_HEADER_TAG_END 0
+#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1
+#define MULTIBOOT_HEADER_TAG_ADDRESS 2
+#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3
+#define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4
+#define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5
+#define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6
+
+#define MULTIBOOT_ARCHITECTURE_I386 0
+#define MULTIBOOT_ARCHITECTURE_MIPS32 4
+#define MULTIBOOT_HEADER_TAG_OPTIONAL 1
+
+#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
+#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
+
+#ifndef ASM_FILE
+
+typedef unsigned char multiboot_uint8_t;
+typedef unsigned short multiboot_uint16_t;
+typedef unsigned int multiboot_uint32_t;
+typedef unsigned long long multiboot_uint64_t;
+
+struct multiboot_header
+{
+ /* Must be MULTIBOOT_MAGIC - see above. */
+ multiboot_uint32_t magic;
+
+ /* ISA */
+ multiboot_uint32_t architecture;
+
+ /* Total header length. */
+ multiboot_uint32_t header_length;
+
+ /* The above fields plus this one must equal 0 mod 2^32. */
+ multiboot_uint32_t checksum;
+};
+
+struct multiboot_header_tag
+{
+ multiboot_uint16_t type;
+ multiboot_uint16_t flags;
+ multiboot_uint32_t size;
+};
+
+struct multiboot_header_tag_information_request
+{
+ multiboot_uint16_t type;
+ multiboot_uint16_t flags;
+ multiboot_uint32_t size;
+ multiboot_uint32_t requests[0];
+};
+
+struct multiboot_header_tag_address
+{
+ multiboot_uint16_t type;
+ multiboot_uint16_t flags;
+ multiboot_uint32_t size;
+ multiboot_uint32_t header_addr;
+ multiboot_uint32_t load_addr;
+ multiboot_uint32_t load_end_addr;
+ multiboot_uint32_t bss_end_addr;
+};
+
+struct multiboot_header_tag_entry_address
+{
+ multiboot_uint16_t type;
+ multiboot_uint16_t flags;
+ multiboot_uint32_t size;
+ multiboot_uint32_t entry_addr;
+};
+
+struct multiboot_header_tag_console_flags
+{
+ multiboot_uint16_t type;
+ multiboot_uint16_t flags;
+ multiboot_uint32_t size;
+ multiboot_uint32_t console_flags;
+};
+
+struct multiboot_header_tag_framebuffer
+{
+ multiboot_uint16_t type;
+ multiboot_uint16_t flags;
+ multiboot_uint32_t size;
+ multiboot_uint32_t width;
+ multiboot_uint32_t height;
+ multiboot_uint32_t depth;
+};
+
+struct multiboot_header_tag_module_align
+{
+ multiboot_uint16_t type;
+ multiboot_uint16_t flags;
+ multiboot_uint32_t size;
+ multiboot_uint32_t width;
+ multiboot_uint32_t height;
+ multiboot_uint32_t depth;
+};
+
+struct multiboot_color
+{
+ multiboot_uint8_t red;
+ multiboot_uint8_t green;
+ multiboot_uint8_t blue;
+};
+
+struct multiboot_mmap_entry
+{
+ multiboot_uint64_t addr;
+ multiboot_uint64_t len;
+#define MULTIBOOT_MEMORY_AVAILABLE 1
+#define MULTIBOOT_MEMORY_RESERVED 2
+#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
+#define MULTIBOOT_MEMORY_NVS 4
+#define MULTIBOOT_MEMORY_BADRAM 5
+ multiboot_uint32_t type;
+ multiboot_uint32_t zero;
+} __attribute__((packed));
+typedef struct multiboot_mmap_entry multiboot_memory_map_t;
+
+struct multiboot_tag
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+};
+
+struct multiboot_tag_string
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ char string[0];
+};
+
+struct multiboot_tag_module
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ multiboot_uint32_t mod_start;
+ multiboot_uint32_t mod_end;
+ char cmdline[0];
+};
+
+struct multiboot_tag_basic_meminfo
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ multiboot_uint32_t mem_lower;
+ multiboot_uint32_t mem_upper;
+};
+
+struct multiboot_tag_bootdev
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ multiboot_uint32_t biosdev;
+ multiboot_uint32_t slice;
+ multiboot_uint32_t part;
+};
+
+struct multiboot_tag_mmap
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ multiboot_uint32_t entry_size;
+ multiboot_uint32_t entry_version;
+ struct multiboot_mmap_entry entries[0];
+};
+
+struct multiboot_vbe_info_block
+{
+ multiboot_uint8_t external_specification[512];
+};
+
+struct multiboot_vbe_mode_info_block
+{
+ multiboot_uint8_t external_specification[256];
+};
+
+struct multiboot_tag_vbe
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+
+ multiboot_uint16_t vbe_mode;
+ multiboot_uint16_t vbe_interface_seg;
+ multiboot_uint16_t vbe_interface_off;
+ multiboot_uint16_t vbe_interface_len;
+
+ struct multiboot_vbe_info_block vbe_control_info;
+ struct multiboot_vbe_mode_info_block vbe_mode_info;
+};
+
+struct multiboot_tag_framebuffer_common
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+
+ multiboot_uint64_t framebuffer_addr;
+ multiboot_uint32_t framebuffer_pitch;
+ multiboot_uint32_t framebuffer_width;
+ multiboot_uint32_t framebuffer_height;
+ multiboot_uint8_t framebuffer_bpp;
+#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
+#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
+#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
+ multiboot_uint8_t framebuffer_type;
+ multiboot_uint16_t reserved;
+};
+
+struct multiboot_tag_framebuffer
+{
+ struct multiboot_tag_framebuffer_common common;
+
+ union
+ {
+ struct
+ {
+ multiboot_uint16_t framebuffer_palette_num_colors;
+ struct multiboot_color framebuffer_palette[0];
+ };
+ struct
+ {
+ multiboot_uint8_t framebuffer_red_field_position;
+ multiboot_uint8_t framebuffer_red_mask_size;
+ multiboot_uint8_t framebuffer_green_field_position;
+ multiboot_uint8_t framebuffer_green_mask_size;
+ multiboot_uint8_t framebuffer_blue_field_position;
+ multiboot_uint8_t framebuffer_blue_mask_size;
+ };
+ };
+};
+
+struct multiboot_tag_elf_sections
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ multiboot_uint32_t num;
+ multiboot_uint32_t entsize;
+ multiboot_uint32_t shndx;
+ char sections[0];
+};
+
+struct multiboot_tag_apm
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ multiboot_uint16_t version;
+ multiboot_uint16_t cseg;
+ multiboot_uint32_t offset;
+ multiboot_uint16_t cseg_16;
+ multiboot_uint16_t dseg;
+ multiboot_uint16_t flags;
+ multiboot_uint16_t cseg_len;
+ multiboot_uint16_t cseg_16_len;
+ multiboot_uint16_t dseg_len;
+};
+
+struct multiboot_tag_efi32
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ multiboot_uint32_t pointer;
+};
+
+struct multiboot_tag_efi64
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ multiboot_uint64_t pointer;
+};
+
+struct multiboot_tag_smbios
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ multiboot_uint8_t major;
+ multiboot_uint8_t minor;
+ multiboot_uint8_t reserved[6];
+ multiboot_uint8_t tables[0];
+};
+
+struct multiboot_tag_old_acpi
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ multiboot_uint8_t rsdp[0];
+};
+
+struct multiboot_tag_new_acpi
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ multiboot_uint8_t rsdp[0];
+};
+
+struct multiboot_tag_network
+{
+ multiboot_uint32_t type;
+ multiboot_uint32_t size;
+ multiboot_uint8_t dhcpack[0];
+};
+
+#endif /* ! ASM_FILE */
+
+#endif /* ! MULTIBOOT_HEADER */