VOOZH about

URL: https://cgit.git.savannah.gnu.org/cgit/grub.git/commit/?h=andrey%2Fext4_inline_data

⇱ grub.git - GNU GRUB


👁 cgit logo
index : grub.git
GNU GRUB
summaryrefslogtreecommitdiff
diff options
authorAndrei Borzenkov <arvidjaar@gmail.com>2016-07-11 07:23:13 +0300
committerAndrei Borzenkov <arvidjaar@gmail.com>2016-07-11 07:23:13 +0300
commite897f83635a9a8cc6824ae8c9b473f6773389224 (patch)
tree8d98ba6f4c2687f9d2ee9bc50ecb908ffeffe1ce
parentd4af83fc600d02dcfedae457353efbce8726b8d9 (diff)
parentb524fa27f56381bb0efa4944e36f50265113aee5 (diff)
Merge branch 'master' into andrey/ext4_inline_dataandrey/ext4_inline_data
Conflicts: grub-core/fs/ext2.c
Diffstat
-rw-r--r--.gitignore7
-rw-r--r--ChangeLog-2015 (renamed from ChangeLog)1272
-rw-r--r--INSTALL29
-rw-r--r--Makefile.am141
-rw-r--r--Makefile.util.def46
-rw-r--r--NEWS179
-rw-r--r--README2
-rw-r--r--TODO4
-rw-r--r--acinclude.m482
-rw-r--r--asm-tests/arm.S20
-rw-r--r--asm-tests/i386-pc.S14
-rw-r--r--asm-tests/i386.S4
-rw-r--r--asm-tests/mips.S11
-rw-r--r--asm-tests/powerpc.S8
-rw-r--r--asm-tests/sparc64.S9
-rwxr-xr-xautogen.sh15
-rwxr-xr-xbuild-aux/gitlog-to-changelog432
-rw-r--r--conf/Makefile.common30
-rw-r--r--conf/Makefile.extra-dist30
-rw-r--r--config.h.in19
-rw-r--r--configure.ac738
-rw-r--r--docs/grub-dev.texi14
-rw-r--r--docs/grub.texi127
-rw-r--r--gentpl.py29
-rw-r--r--grub-core/Makefile.am57
-rw-r--r--grub-core/Makefile.core.def159
-rw-r--r--grub-core/boot/decompressor/minilib.c11
-rw-r--r--grub-core/boot/i386/pc/boot.S42
-rw-r--r--grub-core/boot/i386/pc/cdboot.S4
-rw-r--r--grub-core/boot/i386/pc/diskboot.S2
-rw-r--r--grub-core/boot/i386/pc/lnxboot.S4
-rw-r--r--grub-core/boot/i386/pc/pxeboot.S2
-rw-r--r--grub-core/boot/i386/pc/startup_raw.S16
-rw-r--r--grub-core/boot/i386/qemu/boot.S10
-rw-r--r--grub-core/boot/mips/loongson/fwstart.S12
-rw-r--r--grub-core/boot/mips/startup_raw.S67
-rw-r--r--grub-core/boot/sparc64/ieee1275/boot.S10
-rw-r--r--grub-core/boot/sparc64/ieee1275/diskboot.S2
-rw-r--r--grub-core/bus/emu/pci.c7
-rw-r--r--grub-core/bus/usb/ehci.c115
-rw-r--r--grub-core/bus/usb/emu/usb.c203
-rw-r--r--grub-core/bus/usb/ohci.c13
-rw-r--r--grub-core/bus/usb/uhci.c4
-rw-r--r--grub-core/bus/usb/usbtrans.c28
-rw-r--r--grub-core/commands/acpi.c30
-rw-r--r--grub-core/commands/acpihalt.c66
-rw-r--r--grub-core/commands/boottime.c2
-rw-r--r--grub-core/commands/cacheinfo.c2
-rw-r--r--grub-core/commands/cat.c11
-rw-r--r--grub-core/commands/efi/lsefimmap.c47
-rw-r--r--grub-core/commands/efi/lsefisystab.c15
-rw-r--r--grub-core/commands/file.c98
-rw-r--r--grub-core/commands/fileXX.c12
-rw-r--r--grub-core/commands/gptsync.c8
-rw-r--r--grub-core/commands/hdparm.c1
-rw-r--r--grub-core/commands/i386/cmosdump.c2
-rw-r--r--grub-core/commands/i386/cmostest.c9
-rw-r--r--grub-core/commands/i386/coreboot/cb_timestamps.c10
-rw-r--r--grub-core/commands/i386/pc/play.c15
-rw-r--r--grub-core/commands/i386/pc/sendkey.c10
-rw-r--r--grub-core/commands/keylayouts.c4
-rw-r--r--grub-core/commands/legacycfg.c62
-rw-r--r--grub-core/commands/loadenv.c15
-rw-r--r--grub-core/commands/lsmmap.c2
-rw-r--r--grub-core/commands/macbless.c17
-rw-r--r--grub-core/commands/nativedisk.c14
-rw-r--r--grub-core/commands/parttool.c20
-rw-r--r--grub-core/commands/password_pbkdf2.c22
-rw-r--r--grub-core/commands/pcidump.c2
-rw-r--r--grub-core/commands/search.c4
-rw-r--r--grub-core/commands/search_wrap.c9
-rw-r--r--grub-core/commands/syslinuxcfg.c23
-rw-r--r--grub-core/commands/test.c8
-rw-r--r--grub-core/commands/tr.c2
-rw-r--r--grub-core/commands/verify.c102
-rw-r--r--grub-core/commands/wildcard.c8
-rw-r--r--grub-core/commands/xen/lsxen.c4
-rw-r--r--grub-core/disk/AFSplitter.c6
-rw-r--r--grub-core/disk/ahci.c79
-rw-r--r--grub-core/disk/ata.c6
-rw-r--r--grub-core/disk/cryptodisk.c98
-rw-r--r--grub-core/disk/diskfilter.c170
-rw-r--r--grub-core/disk/dmraid_nvidia.c17
-rw-r--r--grub-core/disk/efi/efidisk.c151
-rw-r--r--grub-core/disk/geli.c48
-rw-r--r--grub-core/disk/i386/pc/biosdisk.c19
-rw-r--r--grub-core/disk/ieee1275/nand.c5
-rw-r--r--grub-core/disk/ieee1275/ofdisk.c170
-rw-r--r--grub-core/disk/ldm.c4
-rw-r--r--grub-core/disk/luks.c19
-rw-r--r--grub-core/disk/lvm.c75
-rw-r--r--grub-core/disk/mdraid_linux.c12
-rw-r--r--grub-core/disk/raid6_recover.c20
-rw-r--r--grub-core/disk/scsi.c7
-rw-r--r--grub-core/disk/usbms.c4
-rw-r--r--grub-core/disk/xen/xendisk.c45
-rw-r--r--grub-core/efiemu/loadcore.c7
-rw-r--r--grub-core/efiemu/main.c2
-rw-r--r--grub-core/efiemu/mm.c25
-rw-r--r--grub-core/efiemu/prepare.c15
-rw-r--r--grub-core/font/font.c4
-rw-r--r--grub-core/fs/archelp.c7
-rw-r--r--grub-core/fs/bfs.c215
-rw-r--r--grub-core/fs/btrfs.c53
-rw-r--r--grub-core/fs/cbfs.c21
-rw-r--r--grub-core/fs/cpio_common.c11
-rw-r--r--grub-core/fs/ext2.c89
-rw-r--r--grub-core/fs/fat.c346
-rw-r--r--grub-core/fs/fshelp.c327
-rw-r--r--grub-core/fs/hfs.c200
-rw-r--r--grub-core/fs/hfsplus.c24
-rw-r--r--grub-core/fs/hfspluscomp.c16
-rw-r--r--grub-core/fs/iso9660.c13
-rw-r--r--grub-core/fs/minix.c80
-rw-r--r--grub-core/fs/nilfs2.c4
-rw-r--r--grub-core/fs/ntfs.c9
-rw-r--r--grub-core/fs/ntfscomp.c2
-rw-r--r--grub-core/fs/proc.c88
-rw-r--r--grub-core/fs/reiserfs.c43
-rw-r--r--grub-core/fs/sfs.c17
-rw-r--r--grub-core/fs/udf.c1
-rw-r--r--grub-core/fs/ufs.c13
-rw-r--r--grub-core/fs/xfs.c464
-rw-r--r--grub-core/fs/zfs/zfs.c192
-rw-r--r--grub-core/fs/zfs/zfs_lz4.c2
-rw-r--r--grub-core/fs/zfs/zfscrypt.c17
-rw-r--r--grub-core/fs/zfs/zfsinfo.c2
-rw-r--r--grub-core/genemuinit.sh4
-rw-r--r--grub-core/genemuinitheader.sh4
-rw-r--r--grub-core/genmod.sh.in11
-rw-r--r--grub-core/genmoddep.awk32
-rw-r--r--grub-core/gfxmenu/font.c15
-rw-r--r--grub-core/gfxmenu/gfxmenu.c8
-rw-r--r--grub-core/gfxmenu/gui_circular_progress.c88
-rw-r--r--grub-core/gfxmenu/gui_label.c4
-rw-r--r--grub-core/gfxmenu/gui_list.c3
-rw-r--r--grub-core/gfxmenu/gui_progress_bar.c16
-rw-r--r--grub-core/gfxmenu/icon_manager.c6
-rw-r--r--grub-core/gfxmenu/theme_loader.c6
-rw-r--r--grub-core/gmodule.pl.in2
-rw-r--r--grub-core/gnulib/argp-help.c12
-rw-r--r--grub-core/io/gzio.c24
-rw-r--r--grub-core/io/lzopio.c2
-rw-r--r--grub-core/kern/acpi.c119
-rw-r--r--grub-core/kern/arm/cache.S44
-rw-r--r--grub-core/kern/arm/cache.c161
-rw-r--r--grub-core/kern/arm/cache_armv6.S32
-rw-r--r--grub-core/kern/arm/compiler-rt.S (renamed from grub-core/kern/arm/misc.S)23
-rw-r--r--grub-core/kern/arm/dl.c21
-rw-r--r--grub-core/kern/arm/dl_helper.c63
-rw-r--r--grub-core/kern/arm/efi/init.c6
-rw-r--r--grub-core/kern/arm/efi/misc.c1
-rw-r--r--grub-core/kern/arm/uboot/startup.S58
-rw-r--r--grub-core/kern/arm64/dl.c18
-rw-r--r--grub-core/kern/arm64/dl_helper.c40
-rw-r--r--grub-core/kern/arm64/efi/init.c60
-rw-r--r--grub-core/kern/compiler-rt.c419
-rw-r--r--grub-core/kern/disk.c14
-rw-r--r--grub-core/kern/disk_common.c22
-rw-r--r--grub-core/kern/dl.c22
-rw-r--r--grub-core/kern/efi/acpi.c (renamed from grub-core/commands/efi/acpi.c)0
-rw-r--r--grub-core/kern/efi/efi.c432
-rw-r--r--grub-core/kern/efi/init.c11
-rw-r--r--grub-core/kern/efi/mm.c5
-rw-r--r--grub-core/kern/elf.c58
-rw-r--r--grub-core/kern/elfXX.c53
-rw-r--r--grub-core/kern/emu/argp_common.c1
-rw-r--r--grub-core/kern/emu/cache.c2
-rw-r--r--grub-core/kern/emu/hostdisk.c16
-rw-r--r--grub-core/kern/emu/hostfs.c1
-rw-r--r--grub-core/kern/emu/main.c52
-rw-r--r--grub-core/kern/emu/misc.c51
-rw-r--r--grub-core/kern/file.c11
-rw-r--r--grub-core/kern/generic/rtc_get_time_ms.c2
-rw-r--r--grub-core/kern/i386/coreboot/cbtable.c2
-rw-r--r--grub-core/kern/i386/coreboot/init.c5
-rw-r--r--grub-core/kern/i386/coreboot/mmap.c38
-rw-r--r--grub-core/kern/i386/coreboot/startup.S5
-rw-r--r--grub-core/kern/i386/efi/tsc.c40
-rw-r--r--grub-core/kern/i386/int.S11
-rw-r--r--grub-core/kern/i386/pc/acpi.c (renamed from grub-core/commands/i386/pc/acpi.c)10
-rw-r--r--grub-core/kern/i386/pc/init.c24
-rw-r--r--grub-core/kern/i386/pc/mmap.c40
-rw-r--r--grub-core/kern/i386/pc/startup.S2
-rw-r--r--grub-core/kern/i386/qemu/startup.S4
-rw-r--r--grub-core/kern/i386/realmode.S30
-rw-r--r--grub-core/kern/i386/tsc.c117
-rw-r--r--grub-core/kern/i386/tsc_pit.c84
-rw-r--r--grub-core/kern/i386/tsc_pmtimer.c88
-rw-r--r--grub-core/kern/i386/xen/tsc.c40
-rw-r--r--grub-core/kern/ieee1275/cmain.c4
-rw-r--r--grub-core/kern/ieee1275/init.c17
-rw-r--r--grub-core/kern/ieee1275/mmap.c5
-rw-r--r--grub-core/kern/ieee1275/openfw.c6
-rw-r--r--grub-core/kern/mips/arc/init.c2
-rw-r--r--grub-core/kern/mips/cache.S2
-rw-r--r--grub-core/kern/mips/dl.c4
-rw-r--r--grub-core/kern/mips/startup.S7
-rw-r--r--grub-core/kern/misc.c213
-rw-r--r--grub-core/kern/mm.c9
-rw-r--r--grub-core/kern/parser.c1
-rw-r--r--grub-core/kern/powerpc/compiler-rt.S130
-rw-r--r--grub-core/kern/rescue_parser.c15
-rw-r--r--grub-core/kern/sparc64/ieee1275/crt0.S2
-rw-r--r--grub-core/kern/uboot/init.c33
-rw-r--r--grub-core/kern/x86_64/dl.c4
-rw-r--r--grub-core/lib/arg.c22
-rw-r--r--grub-core/lib/arm64/setjmp.S3
-rw-r--r--grub-core/lib/crypto.c70
-rw-r--r--grub-core/lib/disk.c18
-rw-r--r--grub-core/lib/division.c74
-rw-r--r--grub-core/lib/fdt.c54
-rw-r--r--grub-core/lib/i386/backtrace.c8
-rw-r--r--grub-core/lib/i386/random.c103
-rw-r--r--grub-core/lib/i386/relocator.c12
-rw-r--r--grub-core/lib/ieee1275/datetime.c4
-rw-r--r--grub-core/lib/legacy_parse.c3
-rw-r--r--grub-core/lib/libgcrypt/cipher/rijndael.c36
-rw-r--r--grub-core/lib/mips/setjmp.S51
-rw-r--r--grub-core/lib/pbkdf2.c3
-rw-r--r--grub-core/lib/posix_wrap/string.h20
-rw-r--r--grub-core/lib/progress.c17
-rw-r--r--grub-core/lib/random.c120
-rw-r--r--grub-core/lib/reed_solomon.c3
-rw-r--r--grub-core/lib/relocator.c54
-rw-r--r--grub-core/lib/syslinux_parse.c236
-rw-r--r--grub-core/lib/x86_64/xen/relocator.S3
-rw-r--r--grub-core/loader/arm/linux.c189
-rw-r--r--grub-core/loader/arm64/fdt.c185
-rw-r--r--grub-core/loader/arm64/linux.c354
-rw-r--r--grub-core/loader/arm64/xen_boot.c499
-rw-r--r--grub-core/loader/efi/appleloader.c3
-rw-r--r--grub-core/loader/efi/chainloader.c5
-rw-r--r--grub-core/loader/i386/bsd.c29
-rw-r--r--grub-core/loader/i386/bsdXX.c144
-rw-r--r--grub-core/loader/i386/linux.c15
-rw-r--r--grub-core/loader/i386/multiboot_mbi.c34
-rw-r--r--grub-core/loader/i386/pc/linux.c25
-rw-r--r--grub-core/loader/i386/pc/plan9.c13
-rw-r--r--grub-core/loader/i386/pc/truecrypt.c2
-rw-r--r--grub-core/loader/i386/xen.c2
-rw-r--r--grub-core/loader/i386/xen_file.c9
-rw-r--r--grub-core/loader/i386/xen_fileXX.c31
-rw-r--r--grub-core/loader/i386/xnu.c62
-rw-r--r--grub-core/loader/ia64/efi/linux.c2
-rw-r--r--grub-core/loader/linux.c16
-rw-r--r--grub-core/loader/mips/linux.c2
-rw-r--r--grub-core/loader/multiboot.c30
-rw-r--r--grub-core/loader/multiboot_elfxx.c11
-rw-r--r--grub-core/loader/multiboot_mbi2.c35
-rw-r--r--grub-core/loader/powerpc/ieee1275/linux.c2
-rw-r--r--grub-core/loader/sparc64/ieee1275/linux.c46
-rw-r--r--grub-core/loader/xnu.c15
-rw-r--r--grub-core/mmap/efi/mmap.c25
-rw-r--r--grub-core/mmap/i386/uppermem.c6
-rw-r--r--grub-core/modinfo.sh.in36
-rw-r--r--grub-core/net/arp.c148
-rw-r--r--grub-core/net/bootp.c93
-rw-r--r--grub-core/net/dns.c23
-rw-r--r--grub-core/net/drivers/efi/efinet.c157
-rw-r--r--grub-core/net/drivers/emu/emunet.c2
-rw-r--r--grub-core/net/drivers/i386/pc/pxe.c3
-rw-r--r--grub-core/net/drivers/ieee1275/ofnet.c148
-rw-r--r--grub-core/net/http.c4
-rw-r--r--grub-core/net/icmp.c14
-rw-r--r--grub-core/net/icmp6.c151
-rw-r--r--grub-core/net/ip.c16
-rw-r--r--grub-core/net/net.c170
-rw-r--r--grub-core/net/netbuff.c20
-rw-r--r--grub-core/net/tcp.c28
-rw-r--r--grub-core/net/tftp.c30
-rw-r--r--grub-core/normal/auth.c7
-rw-r--r--grub-core/normal/charset.c1
-rw-r--r--grub-core/normal/cmdline.c1
-rw-r--r--grub-core/normal/color.c2
-rw-r--r--grub-core/normal/context.c5
-rw-r--r--grub-core/normal/main.c37
-rw-r--r--grub-core/normal/menu.c2
-rw-r--r--grub-core/normal/menu_entry.c23
-rw-r--r--grub-core/normal/menu_text.c18
-rw-r--r--grub-core/normal/misc.c5
-rw-r--r--grub-core/normal/term.c4
-rw-r--r--grub-core/osdep/apple/hostdisk.c4
-rw-r--r--grub-core/osdep/aros/config.c2
-rw-r--r--grub-core/osdep/aros/hostdisk.c4
-rw-r--r--grub-core/osdep/basic/random.c2
-rw-r--r--grub-core/osdep/bsd/hostdisk.c2
-rw-r--r--grub-core/osdep/devmapper/getroot.c189
-rw-r--r--grub-core/osdep/devmapper/hostdisk.c41
-rw-r--r--grub-core/osdep/freebsd/hostdisk.c16
-rw-r--r--grub-core/osdep/haiku/getroot.c2
-rw-r--r--grub-core/osdep/hurd/hostdisk.c4
-rw-r--r--grub-core/osdep/linux/blocklist.c3
-rw-r--r--grub-core/osdep/linux/getroot.c74
-rw-r--r--grub-core/osdep/linux/hostdisk.c19
-rw-r--r--grub-core/osdep/linux/ofpath.c18
-rw-r--r--grub-core/osdep/linux/platform.c39
-rw-r--r--grub-core/osdep/unix/config.c6
-rw-r--r--grub-core/osdep/unix/cputime.c9
-rw-r--r--grub-core/osdep/unix/getroot.c45
-rw-r--r--grub-core/osdep/unix/hostdisk.c28
-rw-r--r--grub-core/osdep/unix/password.c9
-rw-r--r--grub-core/osdep/unix/platform.c2
-rw-r--r--grub-core/osdep/unix/relpath.c7
-rw-r--r--grub-core/osdep/windows/config.c2
-rw-r--r--grub-core/osdep/windows/hostdisk.c2
-rw-r--r--grub-core/osdep/windows/init.c2
-rw-r--r--grub-core/osdep/windows/platform.c8
-rw-r--r--grub-core/partmap/acorn.c4
-rw-r--r--grub-core/partmap/bsdlabel.c2
-rw-r--r--grub-core/partmap/gpt.c2
-rw-r--r--grub-core/partmap/msdos.c12
-rw-r--r--grub-core/partmap/sun.c14
-rw-r--r--grub-core/partmap/sunpc.c10
-rw-r--r--grub-core/script/execute.c116
-rw-r--r--grub-core/script/lexer.c1
-rw-r--r--grub-core/script/parser.y1
-rw-r--r--grub-core/script/yylex.l2
-rw-r--r--grub-core/term/at_keyboard.c14
-rw-r--r--grub-core/term/efi/console.c120
-rw-r--r--grub-core/term/efi/serial.c5
-rw-r--r--grub-core/term/gfxterm.c2
-rw-r--r--grub-core/term/ns8250.c2
-rw-r--r--grub-core/term/serial.c25
-rw-r--r--grub-core/term/terminfo.c86
-rw-r--r--grub-core/term/tparm.c4
-rw-r--r--grub-core/term/usb_keyboard.c1
-rw-r--r--grub-core/tests/boot/kernel-8086.S4
-rw-r--r--grub-core/tests/bswap_test.c121
-rw-r--r--grub-core/tests/checksums.h594
-rw-r--r--grub-core/tests/cmdline_cat_test.c2
-rw-r--r--grub-core/tests/cmp_test.c190
-rw-r--r--grub-core/tests/ctz_test.c111
-rw-r--r--grub-core/tests/div_test.c75
-rw-r--r--grub-core/tests/lib/functional_test.c5
-rw-r--r--grub-core/tests/mul_test.c73
-rw-r--r--grub-core/tests/shift_test.c157
-rw-r--r--grub-core/tests/sleep_test.c9
-rw-r--r--grub-core/tests/video_checksum.c6
-rw-r--r--grub-core/video/bitmap_scale.c114
-rw-r--r--grub-core/video/bochs.c1
-rw-r--r--grub-core/video/capture.c1
-rw-r--r--grub-core/video/cirrus.c1
-rw-r--r--grub-core/video/fb/fbblit.c71
-rw-r--r--grub-core/video/i386/pc/vbe.c5
-rw-r--r--grub-core/video/readers/jpeg.c25
-rw-r--r--grub-core/video/readers/png.c29
-rw-r--r--include/grub/acpi.h39
-rw-r--r--include/grub/arm/linux.h14
-rw-r--r--include/grub/arm/reloc.h5
-rw-r--r--include/grub/arm/system.h13
-rw-r--r--include/grub/arm/uboot/kernel.h4
-rw-r--r--include/grub/arm64/fdtload.h (renamed from include/grub/libusb.h)30
-rw-r--r--include/grub/arm64/linux.h48
-rw-r--r--include/grub/arm64/reloc.h8
-rw-r--r--include/grub/cache.h10
-rw-r--r--include/grub/command.h1
-rw-r--r--include/grub/compiler-rt-emu.h260
-rw-r--r--include/grub/compiler-rt.h200
-rw-r--r--include/grub/compiler.h51
-rw-r--r--include/grub/crypto.h9
-rw-r--r--include/grub/cryptodisk.h4
-rw-r--r--include/grub/diskfilter.h5
-rw-r--r--include/grub/dl.h1
-rw-r--r--include/grub/efi/api.h157
-rw-r--r--include/grub/efi/efi.h4
-rw-r--r--include/grub/elf.h3
-rw-r--r--include/grub/emu/hostdisk.h8
-rw-r--r--include/grub/emu/misc.h11
-rw-r--r--include/grub/err.h2
-rw-r--r--include/grub/fdt.h33
-rw-r--r--include/grub/fshelp.h11
-rw-r--r--include/grub/hfsplus.h16
-rw-r--r--include/grub/i386/netbsd_bootinfo.h7
-rw-r--r--include/grub/i386/openbsd_bootarg.h2
-rw-r--r--include/grub/i386/pmtimer.h37
-rw-r--r--include/grub/i386/tsc.h42
-rw-r--r--include/grub/i386/xnu.h3
-rw-r--r--include/grub/ieee1275/ieee1275.h5
-rw-r--r--include/grub/ieee1275/ofdisk.h3
-rw-r--r--include/grub/libgcc.h97
-rw-r--r--include/grub/list.h4
-rw-r--r--include/grub/memory.h2
-rw-r--r--include/grub/mips/asm.h18
-rw-r--r--include/grub/mips/setjmp.h2
-rw-r--r--include/grub/misc.h142
-rw-r--r--include/grub/module_verifier.h20
-rw-r--r--include/grub/net.h30
-rw-r--r--include/grub/net/ip.h2
-rw-r--r--include/grub/net/netbuff.h1
-rw-r--r--include/grub/normal.h2
-rw-r--r--include/grub/offsets.h2
-rw-r--r--include/grub/osdep/hostfile_aros.h2
-rw-r--r--include/grub/osdep/hostfile_unix.h2
-rw-r--r--include/grub/osdep/hostfile_windows.h3
-rw-r--r--include/grub/procfs.h1
-rw-r--r--include/grub/random.h33
-rw-r--r--include/grub/term.h6
-rw-r--r--include/grub/time.h2
-rw-r--r--include/grub/types.h62
-rw-r--r--include/grub/util/install.h4
-rw-r--r--include/grub/util/misc.h2
-rw-r--r--include/grub/util/mkimage.h185
-rw-r--r--include/grub/util/resolve.h1
-rw-r--r--include/grub/video.h2
-rw-r--r--include/grub/x86_64/types.h6
-rw-r--r--include/grub/xen.h9
-rw-r--r--include/grub/zfs/spa.h31
-rw-r--r--include/multiboot2.h5
-rw-r--r--include/xen/arch-x86/xen-x86_32.h171
-rw-r--r--include/xen/arch-x86/xen-x86_64.h202
-rw-r--r--include/xen/arch-x86/xen.h273
-rw-r--r--include/xen/event_channel.h381
-rw-r--r--include/xen/grant_table.h662
-rw-r--r--include/xen/io/blkif.h608
-rw-r--r--include/xen/io/console.h51
-rw-r--r--include/xen/io/protocols.h40
-rw-r--r--include/xen/io/ring.h312
-rw-r--r--include/xen/io/xenbus.h80
-rw-r--r--include/xen/io/xs_wire.h138
-rw-r--r--include/xen/sched.h174
-rw-r--r--include/xen/xen-compat.h44
-rw-r--r--include/xen/xen.h899
-rwxr-xr-xlinguas.sh2
-rw-r--r--m4/extern-inline.m471
-rw-r--r--po/README6
-rw-r--r--po/Rules-translit10
-rw-r--r--po/cyrillic.sed80
-rw-r--r--po/exclude.pot361
-rw-r--r--po/greek.sed80
-rw-r--r--tests/ahci_test.in2
-rw-r--r--tests/ehci_test.in2
-rw-r--r--tests/ext234_test.in1
-rw-r--r--tests/fddboot_test.in2
-rw-r--r--tests/file_filter/file1
-rw-r--r--tests/file_filter/file.gzbin0 -> 33 bytes
-rw-r--r--tests/file_filter/file.gz.sigbin0 -> 96 bytes
-rw-r--r--tests/file_filter/file.lzopbin0 -> 67 bytes
-rw-r--r--tests/file_filter/file.lzop.sigbin0 -> 96 bytes
-rw-r--r--tests/file_filter/file.xzbin0 -> 72 bytes
-rw-r--r--tests/file_filter/file.xz.sigbin0 -> 96 bytes
-rw-r--r--tests/file_filter/keysbin0 -> 994 bytes
-rw-r--r--tests/file_filter/keys.pubbin0 -> 990 bytes
-rw-r--r--tests/file_filter/test.cfg6
-rw-r--r--tests/file_filter_test.in76
-rw-r--r--tests/grub_cmd_sleep.in5
-rw-r--r--tests/grub_cmd_test.in67
-rw-r--r--tests/hddboot_test.in3
-rw-r--r--tests/minixfs_test.in10
-rw-r--r--tests/ntfs_test.in7
-rw-r--r--tests/ohci_test.in2
-rw-r--r--tests/partmap_test.in9
-rw-r--r--tests/pata_test.in2
-rw-r--r--tests/printf_unit_test.c3
-rw-r--r--tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg (renamed from grub-core/gfxmenu/model.c)0
-rw-r--r--tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg52
-rw-r--r--tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg3
-rw-r--r--tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg12
-rw-r--r--tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg6
-rw-r--r--tests/syslinux/ubuntu10.04/isolinux/menu.cfg23
-rw-r--r--tests/syslinux/ubuntu10.04/isolinux/po4a.cfg3
-rw-r--r--tests/syslinux/ubuntu10.04/isolinux/prompt.cfg16
-rw-r--r--tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg4
-rw-r--r--tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg15
-rw-r--r--tests/syslinux/ubuntu10.04/isolinux/txt.cfg19
-rw-r--r--tests/syslinux/ubuntu10.04_grub.cfg.in236
-rw-r--r--tests/syslinux_test.in16
-rw-r--r--tests/test_sha512sum.in6
-rw-r--r--tests/uhci_test.in2
-rw-r--r--tests/util/grub-fs-tester.in116
-rw-r--r--tests/util/grub-shell.in96
-rw-r--r--tests/xfs_test.in1
-rw-r--r--util/editenv.c1
-rw-r--r--util/getroot.c24
-rw-r--r--util/glue-efi.c2
-rw-r--r--util/grub-editenv.c9
-rw-r--r--util/grub-file.c3
-rw-r--r--util/grub-fstest.c8
-rw-r--r--util/grub-gen-asciih.c15
-rw-r--r--util/grub-glue-efi.c9
-rw-r--r--util/grub-install-common.c51
-rw-r--r--util/grub-install.c77
-rw-r--r--util/grub-kbdcomp.in4
-rw-r--r--util/grub-macbless.c8
-rw-r--r--util/grub-mkconfig.in60
-rw-r--r--util/grub-mkconfig_lib.in6
-rw-r--r--util/grub-mkfont.c22
-rw-r--r--util/grub-mkimage.c33
-rw-r--r--util/grub-mkimage32.c22
-rw-r--r--util/grub-mkimage64.c22
-rw-r--r--util/grub-mkimagexx.c1143
-rw-r--r--util/grub-mklayout.c18
-rw-r--r--util/grub-mknetdir.c12
-rw-r--r--util/grub-mkpasswd-pbkdf2.c5
-rw-r--r--util/grub-mkrelpath.c4
-rw-r--r--util/grub-mkrescue.c173
-rw-r--r--util/grub-mkstandalone.c12
-rw-r--r--util/grub-module-verifier.c144
-rw-r--r--util/grub-module-verifier32.c2
-rw-r--r--util/grub-module-verifier64.c2
-rw-r--r--util/grub-module-verifierXX.c371
-rw-r--r--util/grub-mount.c18
-rw-r--r--util/grub-pe2elf.c2
-rw-r--r--util/grub-probe.c279
-rw-r--r--util/grub-reboot.in4
-rw-r--r--util/grub-render-label.c16
-rw-r--r--util/grub-script-check.c4
-rw-r--r--util/grub-set-default.in4
-rw-r--r--util/grub-setup.c8
-rw-r--r--util/grub-syslinux2cfg.c25
-rw-r--r--util/grub.d/00_header.in62
-rw-r--r--util/grub.d/10_hurd.in30
-rw-r--r--util/grub.d/10_illumos.in19
-rw-r--r--util/grub.d/10_kfreebsd.in39
-rw-r--r--util/grub.d/10_linux.in61
-rw-r--r--util/grub.d/10_netbsd.in41
-rw-r--r--util/grub.d/10_windows.in6
-rw-r--r--util/grub.d/10_xnu.in20
-rw-r--r--util/grub.d/20_linux_xen.in44
-rw-r--r--util/grub.d/30_os-prober.in42
-rw-r--r--util/import_gcry.py14
-rw-r--r--util/misc.c44
-rw-r--r--util/mkimage.c449
-rw-r--r--util/probe.c6
-rw-r--r--util/render-label.c4
-rw-r--r--util/resolve.c14
-rw-r--r--util/setup.c18
527 files changed, 21752 insertions, 6384 deletions
diff --git a/.gitignore b/.gitignore
index 2b0156acd..18ab8e812 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,6 +58,8 @@ grub-emu.exe
grub-emu-lite.exe
grub_emu_init.c
grub_emu_init.h
+/grub-file
+/grub-file.exe
grub-fstest
grub-fstest.exe
grub_fstest_init.c
@@ -66,6 +68,8 @@ grub_func_test
grub-install
grub-install.exe
grub-kbdcomp
+/grub-macbless
+/grub-macbless.exe
grub-macho2img
/grub-menulst2cfg
/grub-menulst2cfg.exe
@@ -120,6 +124,8 @@ grub-shell
grub-shell-tester
grub-sparc64-setup
grub-sparc64-setup.exe
+/grub-syslinux2cfg
+/grub-syslinux2cfg.exe
gzcompress_test
hddboot_test
help_test
@@ -194,6 +200,7 @@ grub-core/modinfo.sh
grub-core/*.module
grub-core/*.module.exe
grub-core/*.pp
+grub-core/kernel.img.bin
util/bash-completion.d/grub
grub-core/gnulib/alloca.h
grub-core/gnulib/arg-nonnull.h
diff --git a/ChangeLog b/ChangeLog-2015
index 57cfe89b3..869f6bfb8 100644
--- a/ChangeLog
+++ b/ChangeLog-2015
@@ -1,3 +1,1269 @@
+2015-01-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * tests/file_filter/file: Really add missing file.
+
+2015-01-23 Andrei Borzenkov <arvidjaar@gmail.com>
+
+ * grub-core/disk/xen/xendisk.c: Accept hdX as disk names on Xen to
+ allow legacy menu.lst processing.
+
+2015-01-22 Felix Janda <felix.janda@posteo.de>
+
+ Remove direct _llseek code and require long filesystem libc.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Remove potential division by 0 in gfxmenu.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/normal/menu_text.c (grub_menu_init_page): Avoid
+ returning 0 geometry to avoid divisions by 0.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/osdep/unix/cputime.c (grub_util_get_cpu_time_ms): Cache
+ sc_clk_tck and check it for sanity.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/efi/mm.c (grub_efi_get_memory_map): Never return a
+ descriptor_size==0 to avoid potential divisions by zero.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/osdep/haiku/getroot.c (grub_util_find_partition_start_os):
+ Avoid division by zero.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/generic/rtc_get_time_ms.c (grub_rtc_get_time_ms): Avoid
+ division by zero.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/loader/i386/xnu.c (guessfsb): Avoid division by 0.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that
+ no division by 0 occurs.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * include/grub/misc.h (grub_div_roundup): Remove as it's unused.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/term/gfxterm.c: Avoid division by zero.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Avoid division by zero in serial.
+
+ * grub-core/term/serial.c (grub_cmd_serial): Ensure speed is not 0.
+ * grub-core/term/ns8250.c (serial_get_divisor): Exit if speed is 0.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/video/readers/jpeg.c: Avoid sivision by zero.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/diskfilter.c: Validate volumes to avoid division
+ by zero.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * include/grub/term.h: Avoid returining 0-sized terminal
+ as it may lead to division by zero.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/fs/zfs.c: Avoid divisions by zero.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/fs/btrfs.c: Avoid divisions by zero.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/lib/pbkdf2.c (grub_crypto_pbkdf2): Check that hash len is not 0.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/osdep/linux/blocklist.c (grub_install_get_blocklist): Check
+ blocksize validity.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/i386/pc/biosdisk.c: Check disk size sanity.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/ieee1275/nand.c (grub_nand_open): Check block size
+ validity.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/dmraid_nvidia.c (grub_dmraid_nv_detect): Do not
+ divide by zero.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/fs/hfs.c (grub_hfs_mount): Additional filesystem
+ sanity checks.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/fs/minix.c: Additional filesystem
+ sanity checks.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/fs/ext2.c (grub_ext2_mount): Additional
+ checks for superblock validity.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/fs/ufs.c (grub_ufs_mount): Check
+ that sblock.ino_per_group is not 0.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Reject NILFS2 superblocks with over 1GiB blocks.
+
+ * grub-core/fs/nilfs2.c (grub_nilfs2_valid_sb): Check that
+ block size is <= 1GiB.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/ata.c (grub_ata_setaddress): Check that geometry
+ is sane when using CHS addressing.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/AFSplitter.c (AF_merge): Check that mdlen is not 0.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/commands/i386/pc/play.c (grub_cmd_play): Avoid
+ division by zero.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/bus/usb/usbtrans.c (grub_usb_bulk_maxpacket): Avoid
+ potentially returning 0.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/fs/minix.c (grub_minix_read_file): Avoid reading past
+ the end of file.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/fs/fshelp.c (grub_fshelp_read_file): Don't attempt to read
+ past the end of file.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/script/lexer.c (grub_script_lexer_yywrap): Update len
+ synchronously with line.
+
+2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Replace explicit sizeof divisions by ARRAY_SIZE.
+
+2015-01-19 Kris Moore <kris@pcbsd.org>
+
+ * grub-core/disk/geli.c: Support GELI v6 and v7.
+
+2014-12-09 Andrei Borzenkov <arvidjaar@gmail.com>
+
+ * grub-core/term/serial.c (grub_cmd_serial): Fix --rtscts
+ option processing.
+
+2014-12-07 David Kozub <zub.272@gmail.com>
+
+ * grub-core/kern/arm/misc.S: fix unaligned 64bit local variable
+ in __aeabi_uidivmod
+ Fixes Savannah bug #43632.
+
+2014-12-07 Peter Nelson <peterdn>
+
+ * grub-core/fs/ext2.c (grub_ext2_read_block): Support large sparse
+ chunks.
+
+2014-12-07 Andrei Borzenkov <arvidjaar@gmail.com>
+
+ * util/grub-mkconfig_lib.in (version_test_gt): Remove redundant
+ non-portable '-n' echo option.
+ * util/grub.d/10_kfreebsd.in: Change how list is built to avoid
+ non-portable 'echo -n.
+ * util/grub.d/10_linux.in: Likewise (closes 43668).
+ * util/grub.d/20_linux_xen.in: Likewise.
+ * util/grub.d/30_os-prober.in: Print spaces directly to avoid
+ non-portable 'echo -n'.
+
+2014-12-07 Curtis Larsen <larsen@dixie.edu>
+
+ * grub-core/net/tcp.c (grub_net_recv_tcp_packet): Fix double
+ free when multiple empty segments were received (closes 42765).
+
+2014-12-05 Andrei Borzenkov <arvidjaar@gmail.com>
+
+ * tests/util/grub-shell.in: Support --files also for netboot.
+ * tests/file_filter_test.in: New file with file filters tests.
+ * Makefile.util.def: Add file_filter_test.
+ * conf/Makefile.extra-dist: ... and here.
+ * tests/file_filter/file.gz: Test file for file_filter_test.
+ * tests/file_filter/file.gz.sig: Likewise.
+ * tests/file_filter/file.lzop: Likewise.
+ * tests/file_filter/file.lzop.sig: Likewise.
+ * tests/file_filter/file.xz: Likewise.
+ * tests/file_filter/file.xz.sig: Likewise.
+ * tests/file_filter/keys: Likewise.
+ * tests/file_filter/keys.pub: Likewise.
+ * tests/file_filter/test.cfg: Likewise.
+ * grub-core/commands/verify.c: Fix memory corruption doing
+ signature check for network files (closes 43601).
+
+2014-12-01 Andrei Borzenkov <arvidjaar@gmail.com>
+
+ * grub-core/loader/i386/xen_fileXX.c (grub_xen_get_infoXX): Fix
+ memory leak (CID 73645, 73782).
+ * grub-core/fs/zfs/zfsinfo.c (print_vdev_info): Fix memory leak
+ (CID 73635).
+
+2014-11-30 Andrei Borzenkov <arvidjaar@gmail.com>
+
+ * grub-core/lib/syslinux_parse.c (free_menu): Do not free
+ inline array (CID 73610).
+
+2014-11-28 Andrei Borzenkov <arvidjaar@gmail.com>
+
+ * grub-core/io/lzopio.c (test_header): Fix double free (CID 73665)
+ * grub-core/disk/geli.c (configure_ciphers): Fix memory leaks
+ (Coverity CID 73813, 73710)
+ * grub-core/disk/luks.c (configure_ciphers): Fix memory leaks
+ and use after free (Coverity CID 73813, 73710, 73730)
+ * grub-core/disk/luks.c (luks_recover_key): Fix memory leak (Coverity
+ CID 73854)
+ * util/grub-install-common.c (grub_install_get_target): Check return
+ value of grub_util_fd_read (Coverity CID 73819).
+ * util/grub-mkstandalone.c (add_tar_file): Fix out of bound access
+ to hd.magic (Coverity CID 73587, 73888, bug 43690).
+
+2014-11-20 Andrei Borzenkov <arvidjaar@gmail.com>
+
+ * tests/util/grub-fs-tester.in: Consistently print output
+ of grub ls if test fails.
+
+2014-11-07 Leif Lindholm <leif.lindholm@linaro.org>
+
+ * grub-core/kern/efi/init.c: check value of *path before
+ dereferencing.
+
+2014-11-03 Michael Chang <mchang@suse.com>
+
+ * grub-core/net/icmp6.c (grub_net_recv_icmp6_packet): Fix size
+ of neighbor solicitation packet in grub_netbuff_pull.
+
+2014-10-14 Andrei Borzenkov <arvidjaar@gmail.com>
+
+ * grub-core/loader/arm/linux.c: Use full initializer for initrd_ctx to
+ avoid fatal warnings with older gcc (probably before 4.7).
+ * grub-core/loader/arm64/linux.c: Likewise.
+ * grub-core/loader/i386/linux.c: Likewise.
+ * grub-core/loader/i386/pc/linux.c: Likewise.
+ * grub-core/loader/ia64/efi/linux.c: Likewise.
+ * grub-core/loader/mips/linux.c: Likewise.
+ * grub-core/loader/powerpc/ieee1275/linux.c: Likewise.
+ * grub-core/loader/sparc64/ieee1275/linux.c: Likewise.
+
+2014-09-25 Colin Watson <cjwatson@ubuntu.com>
+
+ Fix in-tree --platform=none
+
+ * configure.ac: Only remove include/grub/cpu and
+ include/grub/machine in the --platform=none case, not all of
+ include/grub.
+
+2014-09-23 Colin Watson <cjwatson@ubuntu.com>
+
+ Add a new "none" platform that only builds utilities
+
+ * configure.ac: Add "none" platform. Default to it for unsupported
+ CPUs rather than stopping with a fatal error. Don't downgrade
+ x86_64-none to i386. Define COND_real_platform Automake conditional
+ if the platform is anything other than "none". Don't do any include
+ directory linking for "none".
+ * Makefile.am: Skip building grub-core and all bootcheck targets if
+ !COND_real_platform.
+ * include/grub/time.h: Don't include <grub/cpu/time.h> if GRUB_UTIL
+ is defined.
+
+2014-09-22 Andrei Borzenkov <arvidjaar@gmail.com>
+
+ Use grub_cpu_to_XXX_compile_time for constants.
+
+2014-09-21 Valentin Dornauer <valentin@unimplemented.org>
+
+ The AML parser implements only a small subset of possible AML
+ opcodes. On the Fujitsu Lifebook E744 this and another bug in
+ the parser (incorrect handling of TermArg data types) would lead
+ to the laptop not turning off (_S5 not found).
+
+ * grub-core/commands/acpihalt.c: Support OpAlias in the AML parser;
+ in skip_ext_op(), handle some Type2Opcodes more correctly (TermArgs
+ aren't always simply strings!); Add function to skip TermArgs
+ * include/grub/acpi.h: Add new opcodes
+
+2014-09-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/normal/main.c: Don't drop to rescue console in
+ case of password-protected prompt and no menu entries.
+
+2014-09-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/commands/keylayouts.c: Ignore unknown keys.
+
+2014-09-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/gmodule.pl.in: Accept newer binutils which output
+ empty column rather than 0x0.
+
+2014-09-21 Michael Chang <mchang@suse.com>
+
+ * grub-core/osdep/unix/config.c: Remove extraneous comma.
+
+2014-09-21 Peter Jones <pjones@redhat.com>
+
+ * grub-core/loader/arm/linux.c: Initialized initrd_ctx so
+ we don't free a random pointer from the stack.
+ * grub-core/loader/arm64/linux.c: Likewise.
+ * grub-core/loader/i386/linux.c: Likewise.
+ * grub-core/loader/i386/pc/linux.c: Likewise.
+ * grub-core/loader/ia64/efi/linux.c: Likewise.
+ * grub-core/loader/mips/linux.c: Likewise.
+ * grub-core/loader/powerpc/ieee1275/linux.c: Likewise.
+ * grub-core/loader/sparc64/ieee1275/linux.c: Likewise.
+
+2014-09-15 Khem Raj <raj.khem@gmail.com>
+
+ * grub-core/kern/emu/hostfs.c: use _DEFAULT_SOURCE in addition to
+ _BSD_SOURCE to avoid warnings under glibc 2.20+.
+
+2014-09-08 Michael Chang <mchang@suse.com>
+
+ * grub-core/fs/btrfs.c (grub_btrfs_extent_read): Fix extent size
+ check; comparing &data->extent against addresses in the region it
+ points to is unpredictable.
+
+2014-09-07 Colin Watson <cjwatson@ubuntu.com>
+
+ Support grub-emu on x32 (ILP32 but with x86-64 instruction set)
+
+ * configure.ac: Remove -m64 from checks for -mcmodel=large and
+ -mno-red-zone. These are always either unnecessary (x86_64-emu) or
+ already in TARGET_CFLAGS at this point, and they produce incorrect
+ results when building for x32.
+ * grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Cast
+ pointers to Elf64_Xword via grub_addr_t, in order to work on x32.
+ * include/grub/x86_64/types.h (GRUB_TARGET_SIZEOF_VOID_P,
+ GRUB_TARGET_SIZEOF_LONG): Define to 4 on x32.
+
+2014-09-07 Colin Watson <cjwatson@ubuntu.com>
+
+ * configure.ac: Remove several unnecessary semicolons.
+
+2014-08-25 Colin Watson <cjwatson@ubuntu.com>
+
+ * grub-core/kern/mips/arc/init.c (grub_machine_get_bootlocation):
+ Initialise pend to pacify GCC.
+
+2014-08-14 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * util/grub-mkconfig.in: Fix typo (gettext_print instead of
+ gettext_printf).
+
+2014-08-13 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/term/at_keyboard.c: Retry probing keyboard if
+ scancode setup failed.
+
+2014-08-10 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/disk_common.c: Clump disk size to 1EiB.
+
+2014-08-10 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Add
+ safety to avoid triggerring VirtualBox bug.
+
+2014-08-10 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/fs/cbfs.c: Don't probe disks of unknow size.
+
+ Fixes hang on virtualbox.
+
+2014-07-08 Colin Watson <cjwatson@ubuntu.com>
+
+ * util/grub.d/10_hurd.in: Make kernel list progression not fail on
+ kernels whose paths contain regex metacharacters.
+ * util/grub.d/10_kfreebsd.in: Likewise.
+ * util/grub.d/10_linux.in: Likewise.
+ * util/grub.d/20_linux_xen.in: Likewise.
+
+ Reported by: Heimo Stranner.
+
+2014-06-26 Colin Watson <cjwatson@ubuntu.com>
+
+ * docs/grub-dev.texi (Finding your way around): The build system no
+ longer uses AutoGen directly.
+
+2014-06-21 Роман Пехов <roman_pekhov>
+
+ * grub-core/commands/loadenv.c (check_blocklists): Fix overlap check.
+
+2014-06-21 Glenn Washburn <development@efficientek.com>
+
+ * util/grub-install.c: Fix handling of --disk-module.
+
+2014-06-21 Stephane Rochoy <sheda>
+
+ * grub-core/loader/i386/bsd.c (grub_netbsd_boot): Pass pointer to
+ EFI system table.
+
+2014-06-21 Stephane Rochoy <sheda>
+
+ * grub-core/commands/efi/lsefisystab.c (grub_cmd_lsefisystab): Show
+ EFI system table physical address.
+
+2014-06-21 Trevor Woerner <trevor.woerner@linaro.org>
+
+ * util/grub-gen-asciih.c (add_glyph): Fix uninitialised variable.
+
+2014-06-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/commands/verify.c (grub_pubkey_open): Trust procfs.
+
+2014-06-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/commands/verify.c (grub_pubkey_open): Fix memdisk
+ check.
+
+2014-04-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/misc.c (__bzero): Don't compile in GRUB_UTIL.
+
+ Reported by: Yves Blusseau <blusseau@zetam.org>.
+
+2014-04-20 Piotr Krysiuk <piotras@gmail.com>
+
+ * grub-core/lib/i386/relocator.c: Allow loading old kernels by placing
+ GDT in conventional memory.
+
+2014-04-10 Colin Watson <cjwatson@ubuntu.com>
+
+ * util/grub.d/30_os-prober.in: Tolerate devices with no filesystem
+ UUID. Other parts of grub-mkconfig tolerate these, they were
+ previously allowed here up to commit
+ 55e706c918922def17f5012c23cfe88c4c645208, and they can arise in
+ practice when the system has active LVM snapshots.
+ Fixes Ubuntu bug #1287436.
+
+2014-04-10 Colin Watson <cjwatson@ubuntu.com>
+
+ * grub-core/disk/lvm.c (grub_lvm_detect): Search for
+ "logical_volumes" block a little more accurately.
+
+2014-04-06 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/lib/syslinux_parse.c: Fix timeout quoting.
+
+2014-04-04 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * include/grub/libgcc.h: Remove ctzsi2 and ctzdi2. They're no longer
+ pulled from libgcc.
+
+2014-04-04 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Replace few instances of memcmp/memcpy in the code that should be
+ grub_memcmp/grub_memcpy.
+
+2014-04-03 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Support NVMe
+ device names.
+
+2014-03-31 Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
+
+ btrfs: fix get_root key comparison failures due to endianness
+
+ * grub-core/fs/btrfs.c (get_root): Convert
+ GRUB_BTRFS_ROOT_VOL_OBJECTID to little-endian.
+
+2014-03-31 Colin Watson <cjwatson@ubuntu.com>
+
+ Fix partmap, cryptodisk, and abstraction handling in grub-mkconfig.
+
+ Commit 588744d0dc655177d5883bdcb8f72ff5160109ed caused grub-mkconfig
+ no longer to be forgiving of trailing spaces on grub-probe output
+ lines, which among other things means that util/grub.d/10_linux.in
+ no longer detects LVM. To fix this, make grub-probe's output
+ delimiting more consistent. As a bonus, this improves the coverage
+ of the -0 option.
+
+ Fixes Debian bug #735935.
+
+ * grub-core/disk/cryptodisk.c
+ (grub_util_cryptodisk_get_abstraction): Add a user-data argument.
+ * grub-core/disk/diskfilter.c (grub_diskfilter_get_partmap):
+ Likewise.
+ * include/grub/cryptodisk.h (grub_util_cryptodisk_get_abstraction):
+ Update prototype.
+ * include/grub/diskfilter.h (grub_diskfilter_get_partmap): Likewise.
+ * util/grub-install.c (push_partmap_module, push_cryptodisk_module,
+ probe_mods): Adjust for extra user-data arguments.
+ * util/grub-probe.c (do_print, probe_partmap, probe_cryptodisk_uuid,
+ probe_abstraction): Use configured delimiter. Update callers.
+
+2014-03-31 Colin Watson <cjwatson@ubuntu.com>
+
+ * util/grub-probe,c (options): Make -0 work again (broken by
+ conversion to argp).
+ (main): Simplify logic.
+
+2014-03-26 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/lib/relocator.c: Fix the case when end of leftover is used.
+
+2014-03-26 Fu Wei <fu.wei@linaro.org>
+
+ * grub-core/loader/arm64/linux.c: Remove redundant "0x".
+
+2014-02-28 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * include/grub/i386/openbsd_bootarg.h: Add addr and frequency fields.
+ * grub-core/loader/i386/bsd.c (grub_cmd_openbsd): Fill addr field.
+
+ Suggested by: Markus Müller.
+
+2014-02-28 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/i386/pc/mmap.c: Fallback to EISA memory map
+ if E820 failed to return any regions.
+
+2014-02-28 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/mmap/i386/uppermem.c (lower_hook) [COREBOOT]: Ignore low
+ tables for low memory calculations.
+
+2014-02-28 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): Limit
+ location to 640K.
+
+2014-02-28 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/i386/coreboot/mmap.c: Filter out 0xa0000-0x100000
+ region.
+
+2014-02-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/ahci.c: Ignore NPORTS field and rely on PI
+ exclusively.
+
+2014-02-04 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
+
+ Add bootpath parser for open firmware.
+
+ It enables net boot even when there is no bootp/dhcp server.
+
+ * grub-core/net/drivers/ieee1275/ofnet.c: Add grub_ieee1275_parse_bootpath
+ and call it at grub_ieee1275_net_config_real.
+ * grub-core/kern/ieee1275/init.c: Add bootpath to
+ grub_ieee1275_net_config.
+ * include/grub/ieee1275/ieee1275.h: Likewise.
+
+
+2014-02-04 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
+
+ Add grub_env_set_net_property function.
+
+ * grub-core/net/bootp.c: Remove set_env_limn_ro.
+ * grub-core/net/net.c: Add grub_env_set_net_property.
+ * include/grub/net.h: Likewise.
+
+2014-02-03 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * util/grub-mkrescue.c: Build fix for argp.h with older gcc.
+
+2014-02-03 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * util/grub-mkfont.c: Build fix for argp.h with older gcc.
+
+2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/ahci.c: Increase timeout. Some SSDs take up to
+ 7 seconds to recover if last poweroff was bad.
+
+2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/ahci.c: Properly handle transactions with no
+ transferred data.
+
+2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/ahci.c: Add safety cleanups.
+
+2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/ahci.c: Allocate and clean space for all possible 32
+ slots to avoid pointing to uninited area.
+
+2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/ahci.c: Do not enable I/O decoding and keep
+ enabling busmaster for the end.
+
+2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * util/grub-mkfont.c: Downgrade warnings about unhandled features
+ to debug.
+
+2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/term/at_keyboard.c: Tolerate missing keyboard.
+
+2014-01-29 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
+
+ * .gitignore: add missing files and .exe variants.
+
+2014-01-26 Mike Gilbert <floppym@gentoo.org>
+
+ grub-install: support for partitioned partx loop devices.
+
+ * grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Detect
+ /dev/loopX as being the parent of /dev/loopXpY.
+
+2014-01-26 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/term/serial.c (grub_serial_register): Fix invalid free.
+ Ensure that pointers are inited to NULL and that pointers are not
+ accessed after free.
+
+2014-01-25 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * include/grub/crypto.h: Replace __attribute__ ((format (printf)) with
+ __attribute__ ((format (__printf__)) to fix compilation under MinGW-w64.
+ * include/grub/emu/misc.h: ... and here.
+ * include/grub/err.h: ... and here.
+ * util/import_gcry.py: ... and here (in files g10lib.h).
+
+2014-01-25 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * util/grub-mkimage.c: Make prefix argument mandatory.
+
+2014-01-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Fix several translatable strings.
+
+ Suggested by: D. Prévot.
+
+2014-01-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * util/grub-install.c: List available targets.
+
+2014-01-23 Colin Watson <cjwatson@ubuntu.com>
+
+ * util/grub-install.c (write_to_disk): Add an info message.
+
+2014-01-21 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * Makefile.am: Allow adding extra files to generated Windows ZIP
+ archive by setting GRUB_WINDOWS_EXTRA_DIST.
+
+2014-01-21 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * configure.ac: Look for DejaVuSans also in /usr/share/fonts/truetype.
+ Show detected font path in summary.
+
+2014-01-21 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
+
+ * grub-core/net/arp.c (grub_net_arp_send_request): Increase network try
+ interval gradually.
+ * grub-core/net/icmp6.c (grub_net_icmp6_send_request): Likewise.
+ * grub-core/net/net.c (grub_net_fs_read_real): Likewise.
+ * grub-core/net/tftp.c (tftp_open): Likewise.
+ * include/grub/net.h (GRUB_NET_INTERVAL_ADDITION): New define.
+
+2014-01-21 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
+
+ * grub-core/net/net.c (receive_packets): Change stop condition to avoid
+ infinite loops.
+
+ In net/net.c there is a while (1) that only exits if there is a stop
+ condition and more then 10 packages or if there is no package received.
+
+ If GRUB is idle and enter in this loop, the only condition to leave is
+ if it doesn't have incoming packages. In a network with heavy traffic
+ this never happens.
+
+2014-01-19 Colin Watson <cjwatson@ubuntu.com>
+
+ * grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Ignore
+ EPERM when modifying kern.geom.debugflags. It is only a problem for
+ such things as installing GRUB to the MBR, in which case there'll be
+ an error later anyway, not for opening files during tests.
+
+2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * grub-core/Makefile.am: Build grub_emu_init.[ch] from MODULE_FILES
+ instead of MOD_FILES.
+ * grub-core/genemuinit.sh: Simplify stripping of suffix so it works
+ both with and without .exe.
+ * grub-core/genemuinitheader.sh: Same.
+
+2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * util/grub-install.c: Fix a typo.
+
+2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/normal/main.c (read_config_file): Buffer config file.
+ Reduces boot time.
+
+2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * acinclude.m4 (grub_CHECK_LINK_DIR): Check that we can also remove
+ symbolic link to directory. It fails in Msys shell on Windows 2003.
+
+2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * Makefile.am (default_payload.elf): Add modules
+ multiboot cbmemc linux16 gzio echo help.
+
+2014-01-18 Mike Gilbert <floppym@gentoo.org>
+
+ * Makefile.util.def: Link grub-ofpathname with zfs libs.
+
+2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/commands/macbless.c: Rename FILE and DIR to avoid
+ conflicts.
+
+ Reported by: Andrey Borzenkov.
+
+2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * include/grub/misc.h: Move macros for compiler features to ...
+ * include/grub/compiler.h: ... new file.
+ * include/grub/list.h: Include <grub/compiler.h> instead of <grub/misc.h>.
+ * grub-core/commands/fileXX.c: Include <grub/misc.h>.
+ * grub-core/efiemu/prepare.c: Include <grub/misc.h>.
+ * grub-core/loader/i386/xen_file.c: Include <grub/misc.h>.
+ * grub-core/loader/i386/xen_fileXX.c: Include <grub/misc.h>.
+ * grub-core/video/capture.c: Include <grub/misc.h>.
+ * include/grub/command.h: Include <grub/misc.h>.
+ * include/grub/dl.h: Include <grub/misc.h>.
+ * include/grub/procfs.h: Include <grub/misc.h>.
+
+2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * configure.ac: Add support for BUILD_EXEEXT and use it ...
+ * Makefile.am: ... here.
+ * Makefile.util.def: ... and here.
+ * grub-core/Makefile.am: ... and here.
+
+2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * include/grub/osdep/hostfile_windows.h: Use _W64 instead of
+ FILE_OFFSET_BITS to differentiate between native MinGW and Mingw W64.
+
+2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/term/terminfo.c: Recognize keys F1-F12.
+
+2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * configure.ac: Add support for BUILD_LDFLAGS.
+ * Makefile.am: Use BUILD_LDFLAGS for build time programs here ...
+ * grub-core/Makefile.am: ... and here.
+ * INSTALL: Mention BUILD_LDFLAGS.
+
+2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * util/grub-mount.c: Extend GCC warning workaround to grub-mount.
+
+2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/efi/efi.c: Ensure that the result starts with /
+ and has no //.
+
+2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * NEWS: Add few missing entries.
+
+2014-01-17 Colin Watson <cjwatson@ubuntu.com>
+
+ * util/grub.d/00_header.in (make_timeout): Use && rather than test
+ -a.
+ * util/grub.d/10_windows.in: Likewise.
+ * util/grub.d/10_netbsd.in (netbsd_load_fs_module): Use || rather
+ than test -o.
+ * util/grub.d/30_os-prober.in: Use && rather than test -a, and ||
+ rather than test -o.
+
+2014-01-17 Colin Watson <cjwatson@ubuntu.com>
+
+ * grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Remove
+ redundant preprocessor conditional.
+
+2014-01-08 Colin Watson <cjwatson@ubuntu.com>
+
+ * Makefile.util.def (grub-macbless): Change mansection to 8.
+
+2014-01-07 Leif Lindholm <leif.lindholm@linaro.org>
+
+ * grub-core/loader/arm64/linux.c: correctly set device path end length.
+
+2014-01-07 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * util/grub-install.c: Use bootaa64.efi instead of bootaarch64.efi on
+ arm64 to comply with EFI specification. Also use grubaa64.efi for
+ consistency.
+ * util/grub-mkrescue.c: Change to use bootaa64.efi too.
+
+2014-01-07 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * include/grub/osdep/hostfile_windows.h: Do not redefine fseeko/ftello
+ on MinGW-64 when compiling for 32 bits.
+
+2013-12-30 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * grub-core/Makefile.core.def: strip .eh_frame section for arm64-efi.
+
+2013-12-30 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * NEWS: Add few missing entries. Correct existing ones.
+
+2013-12-28 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Don't abort() on unavailable coreboot tables if not running on coreboot.
+
+2013-12-28 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * grub-core/kern/emu/misc.c: Remove unused error.h; fixes compilation
+ on mingw.
+
+2013-12-28 Colin Watson <cjwatson@ubuntu.com>
+
+ * NEWS: The cmosclean command in fact dates back to 1.99. Remove
+ mention of it from 2.02.
+
+2013-12-27 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/arm/cache_armv6.S: Remove .arch directive.
+
+ As these functions are used on pre-ARMv6 CPUs as well we don't want
+ to make assembler assume that architecture is higher than default one.
+
+2013-12-27 Colin Watson <cjwatson@ubuntu.com>
+
+ * NEWS: First draft of 2.02 entry.
+
+2013-12-27 Colin Watson <cjwatson@ubuntu.com>
+
+ * INSTALL (Cross-compiling the GRUB): Fix some spelling mistakes.
+ * docs/grub.texi (Getting the source code): Likewise.
+
+2013-12-25 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * grub-core/osdep/windows/platform.c (get_platform): Fix EFI
+ detection.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * configure.ac: Set version to 2.02~beta2.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/efi/efidisk.c (name_devices): Skip Apple ghosts.
+
+2013-12-24 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * util/grub-probe.c: Improve help message and simplify list handling.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Fix buffer overflow in grub_efi_print_device_path.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Show SATA device path.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Revert grub-file usage in grub-mkconfig.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Make newly-created files other than grub.cfg world-readable.
+
+2013-12-24 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * util/grub.d/00_header.in: Improve compatibility with old config.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Make rijndael.c respect aliasing rules.
+
+ Trivial backport of dfb4673da8ee52d95e0a62c9f49ca8599943f22e.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Make grub_util_device_is_mapped_stat available in grub-emu core.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Add -Qn to TARGET_CFLAGS if it's supported.
+ Fixes compilation on cygwin.
+
+ Reported by: Andrey Borzenkov.
+ Suggested by: Andrey Borzenkov.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Save TARGET_CC version in modinfo.sh.
+
+ Suggested by: Andrey Borzenkov.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Make grub_util_devmapper_part_to_disk and grub_util_find_partition_start
+ follow the same algorithm to avoid method mismatch. Don't assume
+ DMRAID- UUID to mean full disk but instead check that mapping is linear.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Declare GRUB_EFI_VENDOR_APPLE_GUID.
+
+2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Dump type and vendor specific data when printing device path.
+
+2013-12-23 Colin Watson <cjwatson@debian.org>
+
+ Update some documentation to refer to Git rather than Bazaar.
+
+ * docs/grub.texi (Obtaining and Building GRUB): Refer to Git rather
+ than Bazaar.
+ * po/README: Likewise. Fix spelling mistake.
+
+2013-12-23 Colin Watson <cjwatson@ubuntu.com>
+
+ Don't distribute config.h.
+
+ * Makefile.am (platform_HEADERS): Move to ...
+ (nodist_platform_HEADERS): ... here. Fixes gettext_strings_test
+ failure when building from a distributed tarball.
+
+2013-12-23 Colin Watson <cjwatson@ubuntu.com>
+
+ * configure.ac: Fix spelling.
+ * grub-core/commands/parttool.c: Fix grammar.
+ * grub-core/disk/ldm.c: Use consistent capitalisation for "LDM
+ Embedding Partition".
+
+2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ ARM64 support for grub-mkrescue.
+
+2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Install modinfo.sh to keep build information around.
+
+2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/modinfo.sh.in: Add build config information.
+
+2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ ARM64 grub-file and grub-mkconfig support.
+
+2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Remove leftover options defines.
+
+2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * include/grub/arm64/linux.h: Remove leftovers. Add missing prefixes.
+
+2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/loader/arm64/linux.c: Add missing bracket.
+
+2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Add arm64-efi recognition to grub-file.
+
+2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Fix ia64-efi recognition in grub-file.
+
+2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Recognize raspberry pi kernel in grub-file.
+
+2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Enable cache on ARM U-Boot port.
+
+ Without it the port is reidiculously slow.
+
+2013-12-23 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Fix ARM cache maintainance.
+
+ More code was converted from ASM to C for easier handling.
+
+2013-12-22 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/arm/cache.c (grub_arm_disable_caches_mmu): Use v6
+ algorithm on v5.
+
+ Suggested by: Leif Lindholm.
+
+2013-12-22 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * util/grub-mkconfig.in: Fix Xen platform conditions.
+
+2013-12-22 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ * util/grub-mkrescue.c: Split single help message string in several
+ strings used in previous shell version.
+
+2013-12-22 Leif Lindholm <leif.lindholm@linaro.org>
+
+ Add arm64 Linux loader.
+
+2013-12-22 Leif Lindholm <leif.lindholm@linaro.org>
+
+ Add grub_fdt_create_empty_tree() and grub_fdt_set_prop64().
+
+2013-12-22 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Add module loading and parsing boot time checkpoints.
+
+2013-12-22 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/loader/arm/linux.c: Pass arguments through on ATAG
+ platforms.
+
+2013-12-22 Lars Wendler <polynomial-c@gentoo.org>
+
+ * util/grub-mkconfig.in: Skip non-executable files.
+
+2013-12-22 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Workaround buggy timer in raspberry pie by using our own timer
+ implementation.
+
+2013-12-22 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * include/grub/arm/uboot/kernel.h (GRUB_KERNEL_MACHINE_HEAP_SIZE):
+ Increase to 16 MiB to allow loading the whole memdisk.
+
+2013-12-22 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Fix ARM Linux Loader on non-FDT platforms.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * configure.ac: Choose link format based on host_os on emu.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/osdep/unix/getroot.c: Non-unix build fix.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/emu/main.c: Build fix for emu.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Build fixes for argp.h with older gcc.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * util/grub-glue-efi.c: Use "universal binary" rather "fat binary"
+ in strings.
+
+ Suggested by: David Prévot.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * include/grub/crypto.h (grub_crypto_xor): Fix cast-align warning.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Enable -Wformat=2 if it's supported.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * configure.ac: Add -Wmissing-include-dirs -Wmissing-prototypes
+ -Wmissing-declarations if supported.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/commands/macbless.c (grub_mac_bless_inode): Pass inode as
+ u32 as both HFS and HFS+ have 32-bit inodes.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * include/grub/misc.h (grub_strtol): Fix overflow.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * include/grub/term.h (grub_unicode_estimate_width): Use grub_size_t
+ as return type in both conditionals.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * include/grub/video.h (grub_video_rgba_color_rgb): Fix prototype
+ to use uint8_t for color.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * util/misc.c (grub_util_get_image_size): Check for overflow.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/raid6_recover.c (grub_raid_block_mulx): Use grub_size_t
+ for size.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/disk/lvm.c: Use grub_size_t for sizes and grub_ssize_t
+ for pointer difference.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * util/import_gcry.py: Skip sample keys.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * util/misc.c (grub_qsort_strcmp): Don't discard const attribute.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * configure.ac: Remove duplicate warning arguments.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Add missing static qualifiers.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Add missing includes.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Inline printf templates when possible to enable format checking.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * include/grub/crypto.h: Don't discard const attribute.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/net/bootp.c (grub_cmd_dhcpopt): Use snprintf where it
+ was intended.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/lib/crypto.c: Don't discard const attribute.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/lib/disk.c: Fix potential overflow.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/lib/arg.c: Don't discard const attribute.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/dl.c: Don't discard const attribute.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/disk.c: Fix potential overflow.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * conf/Makefile.common: Don't include non-existing directory
+ grub-core/lib/libgcrypt-grub/include.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Clarify several translatable messages.
+
+2013-12-21 David Prévot <david@tilapin.org>
+
+ Correct some translatable strings.
+
+2013-12-21 Colin Watson <cjwatson@ubuntu.com>
+
+ * util/grub-mkrescue.c: Rephrase mkrescue description.
+
+2013-12-21 Vladimir Serbinenko <phcoder@gmail.com>
+2013-12-21 Colin Watson <cjwatson@ubuntu.com>
+
+ Clarify several translatable messages.
+
+2013-12-20 Colin Watson <cjwatson@ubuntu.com>
+
+ Be more verbose about some configure failures.
+
+2013-12-20 Colin Watson <cjwatson@ubuntu.com>
+
+ Fix various build problems on GNU/Hurd.
+
+ * grub-core/osdep/unix/getroot.c (strip_extra_slashes): Move inside
+ !defined (__GNU__).
+ (xgetcwd): Likewise.
+ * include/grub/emu/hostdisk.h (grub_util_hurd_get_disk_info)
+ [__GNU__]: Add prototype.
+ * util/getroot.c (grub_util_biosdisk_get_grub_dev) [__GNU__]: Format
+ long int using %ld rather than %d.
+
+2013-12-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * util/grub-install.c: Inform user about install platform.
+
+2013-12-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * configure.ac: Set version to 2.02~beta1.
+
+2013-12-18 Allen Pais <allen.pais@oracle.com>
+2013-12-18 Bob Picco <bob.picco@oracle.com>
+
+ * grub-core/boot/sparc64/ieee1275/boot.S: Fix order of fields.
+
+2013-12-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Make grub_zlib_decompress handle incomplete chunks.
+
+ Fixes squash4.
+
+2013-12-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/Makefile.am: Don't attempt to export grub_bios_interrupt
+ on i386-multiboot.
+
2013-12-18 Aleš Nesrsta <starous@volny.cz>
* grub-core/disk/usbms.c: Retry on unknown errors.
@@ -31,10 +1297,6 @@
2013-12-18 Vladimir Serbinenko <phcoder@gmail.com>
- Use -Wl,--no-relax rather than -mno-relax for uniformity.
-
-2013-12-18 Vladimir Serbinenko <phcoder@gmail.com>
-
* INSTALL: Update comment as to why sparc64 clang isn't usable.
2013-12-18 Vladimir Serbinenko <phcoder@gmail.com>
@@ -486,7 +1748,7 @@
2013-12-14 Vladimir Serbinenko <phcoder@gmail.com>
- * .gitignore: Add .exe variants. Add missing files. Remove few outdated
+ * .gitignore: add .exe variants. add missing files. remove few outdated
entries.
2013-12-14 Vladimir Serbinenko <phcoder@gmail.com>
diff --git a/INSTALL b/INSTALL
index afc957ca9..e5b081105 100644
--- a/INSTALL
+++ b/INSTALL
@@ -13,6 +13,9 @@ configuring the GRUB.
* GCC 4.1.3 or later
Note: older versions may work but support is limited
+
+ Experimental support for clang 3.3 or later (results in much bigger binaries)
+ for i386, x86_64, arm (except thumb), arm64, mips(el), powerpc, sparc64
Note: clang 3.2 or later works for i386 and x86_64 targets but results in
much bigger binaries.
earlier versions not tested
@@ -26,7 +29,8 @@ configuring the GRUB.
fail.
Note: clang 3.2 or later works for powerpc
earlier versions not tested
- Note: clang doesn't support -mno-app-regs and so can't be used for sparc64
+ Note: clang 3.5 or later works for sparc64
+ earlier versions return "error: unable to interface with target machine"
Note: clang has no support for ia64 and hence you can't compile GRUB
for ia64 with clang
* GNU Make
@@ -35,6 +39,7 @@ configuring the GRUB.
* GNU binutils 2.9.1.0.23 or later
* Flex 2.5.35 or later
* Other standard GNU/Unix tools
+* a libc with large file support (e.g. glibc 2.1 or later)
On GNU/Linux, you also need:
@@ -99,6 +104,9 @@ The simplest way to compile this package is:
3. Type `./autogen.sh'.
+ * autogen.sh uses python. By default invocation is "python" but can be
+ overriden by setting variable $PYTHON.
+
4. Type `./configure' to configure the package for your system.
If you're using `csh' on an old version of System V, you might
need to type `sh ./configure' instead to prevent `csh' from trying
@@ -140,7 +148,7 @@ If build and host are different make check isn't available.
If build and host are different man pages are not generated.
As an example imagine you have a build system running on FreeBSD on sparc
-which prepares packages for developpers running amd64 GNU/Linux laptop and
+which prepares packages for developers running amd64 GNU/Linux laptop and
they need to make images for ARM board running U-boot. In this case:
build=sparc64-freebsd
@@ -149,7 +157,7 @@ target=arm-uboot
For this example the configure line might look like (more details below)
(some options are optional and included here for completeness but some rarely
-used options are omited):
+used options are omitted):
./configure BUILD_CC=gcc BUILD_FREETYPE=freetype-config --host=amd64-linux-gnu
CC=amd64-linux-gnu-gcc CFLAGS="-g -O2" FREETYPE=amd64-linux-gnu-freetype-config
@@ -168,14 +176,15 @@ corresponding platform are not needed for the platform in question.
generate sin and cos tables.
2. BUILD_CFLAGS= for C options for build.
3. BUILD_CPPFLAGS= for C preprocessor options for build.
- 4. BUILD_FREETYPE= for freetype-config for build (optional).
+ 4. BUILD_LDFLAGS= for linker options for build.
+ 5. BUILD_FREETYPE= for freetype-config for build (optional).
- For host
1. --host= to autoconf name of host.
2. CC= for gcc able to compile for host
- 3. CFLAGS= for C options for host.
- 4. CPPFLAGS= for C preprocessor options for host.
- 5. LDFLAGS= for linker options for host.
+ 3. HOST_CFLAGS= for C options for host.
+ 4. HOST_CPPFLAGS= for C preprocessor options for host.
+ 5. HOST_LDFLAGS= for linker options for host.
6. FREETYPE= for freetype-config for host (optional).
7. Libdevmapper if any must be in standard linker folders (-ldevmapper) (optional).
8. Libfuse if any must be in standard linker folders (-lfuse) (optional).
@@ -196,9 +205,9 @@ corresponding platform are not needed for the platform in question.
11. TARGET_RANLIB= for ranlib for target.
- Additionally for emu, for host and target.
- 1. SDL is looked for in stadard linker directories (-lSDL) (optional)
- 2. libpciaccess is looked for in stadard linker directories (-lpciaccess) (optional)
- 3. libusb is looked for in stadard linker directories (-lusb) (optional)
+ 1. SDL is looked for in standard linker directories (-lSDL) (optional)
+ 2. libpciaccess is looked for in standard linker directories (-lpciaccess) (optional)
+ 3. libusb is looked for in standard linker directories (-lusb) (optional)
- Platform-agnostic tools and data.
1. make is the tool you execute after ./configure.
diff --git a/Makefile.am b/Makefile.am
index b11306679..00a9663b3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,11 @@
AUTOMAKE_OPTIONS = subdir-objects -Wno-portability
DEPDIR = .deps-util
-SUBDIRS = grub-core/gnulib . grub-core po docs util/bash-completion.d
+SUBDIRS = grub-core/gnulib .
+if COND_real_platform
+SUBDIRS += grub-core
+endif
+SUBDIRS += po docs util/bash-completion.d
include $(top_srcdir)/conf/Makefile.common
include $(top_srcdir)/conf/Makefile.extra-dist
@@ -66,35 +70,40 @@ endif
starfield_theme_files = $(srcdir)/themes/starfield/blob_w.png $(srcdir)/themes/starfield/boot_menu_c.png $(srcdir)/themes/starfield/boot_menu_e.png $(srcdir)/themes/starfield/boot_menu_ne.png $(srcdir)/themes/starfield/boot_menu_n.png $(srcdir)/themes/starfield/boot_menu_nw.png $(srcdir)/themes/starfield/boot_menu_se.png $(srcdir)/themes/starfield/boot_menu_s.png $(srcdir)/themes/starfield/boot_menu_sw.png $(srcdir)/themes/starfield/boot_menu_w.png $(srcdir)/themes/starfield/slider_c.png $(srcdir)/themes/starfield/slider_n.png $(srcdir)/themes/starfield/slider_s.png $(srcdir)/themes/starfield/starfield.png $(srcdir)/themes/starfield/terminal_box_c.png $(srcdir)/themes/starfield/terminal_box_e.png $(srcdir)/themes/starfield/terminal_box_ne.png $(srcdir)/themes/starfield/terminal_box_n.png $(srcdir)/themes/starfield/terminal_box_nw.png $(srcdir)/themes/starfield/terminal_box_se.png $(srcdir)/themes/starfield/terminal_box_s.png $(srcdir)/themes/starfield/terminal_box_sw.png $(srcdir)/themes/starfield/terminal_box_w.png $(srcdir)/themes/starfield/theme.txt $(srcdir)/themes/starfield/README $(srcdir)/themes/starfield/COPYING.CC-BY-SA-3.0
-build-grub-mkfont: util/grub-mkfont.c grub-core/unidata.c grub-core/kern/emu/misc.c util/misc.c
- $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-mkfont\" $^ $(build_freetype_cflags) $(build_freetype_libs)
-CLEANFILES += build-grub-mkfont
+build-grub-mkfont$(BUILD_EXEEXT): util/grub-mkfont.c grub-core/unidata.c grub-core/kern/emu/misc.c util/misc.c
+ $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-mkfont\" $^ $(build_freetype_cflags) $(build_freetype_libs)
+CLEANFILES += build-grub-mkfont$(BUILD_EXEEXT)
-garbage-gen: util/garbage-gen.c
- $(BUILD_CC) -o $@ $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $^
-CLEANFILES += garbage-gen
+garbage-gen$(BUILD_EXEEXT): util/garbage-gen.c
+ $(BUILD_CC) -o $@ $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $^
+CLEANFILES += garbage-gen$(BUILD_EXEEXT)
EXTRA_DIST += util/garbage-gen.c
-build-grub-gen-asciih: util/grub-gen-asciih.c
- $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
-CLEANFILES += build-grub-gen-asciih
+build-grub-gen-asciih$(BUILD_EXEEXT): util/grub-gen-asciih.c
+ $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
+CLEANFILES += build-grub-gen-asciih$(BUILD_EXEEXT)
-build-grub-gen-widthspec: util/grub-gen-widthspec.c
- $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
-CLEANFILES += build-grub-gen-widthspec
+build-grub-gen-widthspec$(BUILD_EXEEXT): util/grub-gen-widthspec.c
+ $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
+CLEANFILES += build-grub-gen-widthspec$(BUILD_EXEEXT)
if COND_STARFIELD
starfield_DATA = dejavu_10.pf2 dejavu_12.pf2 dejavu_bold_14.pf2 dejavu_14.pf2 dejavu_16.pf2 $(starfield_theme_files)
-dejavu_10.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
- ./build-grub-mkfont -s 10 -o $@ $(DJVU_FONT_SOURCE)
-dejavu_12.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
- ./build-grub-mkfont -s 12 -o $@ $(DJVU_FONT_SOURCE)
-dejavu_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
- ./build-grub-mkfont -s 14 -o $@ $(DJVU_FONT_SOURCE)
-dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
- ./build-grub-mkfont -b -s 14 -o $@ $(DJVU_FONT_SOURCE)
-dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont
- ./build-grub-mkfont -s 16 -o $@ $(DJVU_FONT_SOURCE)
+dejavu_10.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
+ ./build-grub-mkfont$(BUILD_EXEEXT) -s 10 -o $@ $(DJVU_FONT_SOURCE)
+CLEANFILES += dejavu_10.pf2
+dejavu_12.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
+ ./build-grub-mkfont$(BUILD_EXEEXT) -s 12 -o $@ $(DJVU_FONT_SOURCE)
+CLEANFILES += dejavu_12.pf2
+dejavu_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
+ ./build-grub-mkfont$(BUILD_EXEEXT) -s 14 -o $@ $(DJVU_FONT_SOURCE)
+CLEANFILES += dejavu_14.pf2
+dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
+ ./build-grub-mkfont$(BUILD_EXEEXT) -b -s 14 -o $@ $(DJVU_FONT_SOURCE)
+CLEANFILES += dejavu_bold_14.pf2
+dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
+ ./build-grub-mkfont$(BUILD_EXEEXT) -s 16 -o $@ $(DJVU_FONT_SOURCE)
+CLEANFILES += dejavu_16.pf2
else
starfield_DATA =
endif
@@ -102,36 +111,38 @@ endif
EXTRA_DIST += $(starfield_theme_files)
EXTRA_DIST += $(srcdir)/themes/starfield/src/slider_s.xcf $(srcdir)/themes/starfield/src/slider_n.xcf $(srcdir)/themes/starfield/src/slider_c.xcf $(srcdir)/themes/starfield/src/blob_nw.xcf $(srcdir)/themes/starfield/src/bootmenu/center.xcf $(srcdir)/themes/starfield/src/bootmenu/corner.xcf $(srcdir)/themes/starfield/src/bootmenu/side.xcf $(srcdir)/themes/starfield/src/terminalbox/side.xcf $(srcdir)/themes/starfield/src/terminalbox/corner.xcf $(srcdir)/themes/starfield/src/terminalbox/center.xcf
-unicode.pf2: $(FONT_SOURCE) build-grub-mkfont
- ./build-grub-mkfont -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1)
+unicode.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
+ ./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1)
CLEANFILES += unicode.pf2
# Arrows and lines are needed to draw the menu, so always include them
UNICODE_ARROWS=0x2190-0x2193
UNICODE_LINES=0x2501-0x251B
-ascii.pf2: $(FONT_SOURCE) build-grub-mkfont
- ./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
+ascii.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
+ ./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
CLEANFILES += ascii.pf2
-euro.pf2: $(FONT_SOURCE) build-grub-mkfont
- ./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
+euro.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
+ ./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
CLEANFILES += euro.pf2
-ascii.h: $(FONT_SOURCE) build-grub-gen-asciih
- ./build-grub-gen-asciih $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
+ascii.h: $(FONT_SOURCE) build-grub-gen-asciih$(BUILD_EXEEXT)
+ ./build-grub-gen-asciih$(BUILD_EXEEXT) $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
CLEANFILES += ascii.h
-widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec
- ./build-grub-gen-widthspec $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
+widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec$(BUILD_EXEEXT)
+ ./build-grub-gen-widthspec$(BUILD_EXEEXT) $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
CLEANFILES += widthspec.h
# Install config.h into platformdir
-platform_HEADERS = config.h
+nodist_platform_HEADERS = config.h
pkgdata_DATA += grub-mkconfig_lib
+if COND_real_platform
+
if COND_i386_coreboot
QEMU32=qemu-system-i386
endif
@@ -334,33 +345,35 @@ bootcheck-ntldr: ntldr.bin $(srcdir)/grub-core/tests/boot/ntldr.cfg grub-shell
./grub-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/ntldr.bin=ntldr.bin $(srcdir)/grub-core/tests/boot/ntldr.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null
if COND_i386_efi
-BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386
+# NetBSD has no support for finding ACPI on EFI
+BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386
endif
if COND_x86_64_efi
-BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386
+# NetBSD has no support for finding ACPI on EFI
+BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386
endif
if COND_i386_multiboot
-# FreeBSD requires ACPI
-BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64
+# *BSD requires ACPI
+BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64
endif
-if COND_i386_coreboot
-# Freebsd requires ACPI
-BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64
-endif
if COND_i386_qemu
-# FreeBSD requires ACPI
-BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64
+# *BSD requires ACPI
+BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64
+endif
+
+if COND_i386_coreboot
+BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386
endif
if COND_i386_pc
#pc chainloader by definition is only for i386-pc
#ntldr and bootmgr require BIOS.
-#legacy protocol makes early BIOS calls.
-# NetBSD crashes early on non-BIOS
+#legacy protocol (linux16) makes early BIOS calls.
+# 32-bit NetBSD crashes early on non-BIOS
BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 bootcheck-pc-chainloader bootcheck-ntldr bootcheck-linux16-i386 bootcheck-linux16-x86_64 bootcheck-knetbsd-i386
endif
@@ -383,12 +396,10 @@ if COND_powerpc_ieee1275
BOOTCHECKS = bootcheck-linux-ppc
endif
-EXTRA_DIST += grub-core/tests/boot/kbsd.init-i386.S grub-core/tests/boot/kbsd.init-x86_64.S grub-core/tests/boot/kbsd.spec.txt grub-core/tests/boot/kernel-8086.S grub-core/tests/boot/kernel-i386.S grub-core/tests/boot/kfreebsd-aout.cfg grub-core/tests/boot/kfreebsd.cfg grub-core/tests/boot/kfreebsd.init-i386.S grub-core/tests/boot/kfreebsd.init-x86_64.S grub-core/tests/boot/knetbsd.cfg grub-core/tests/boot/kopenbsd.cfg grub-core/tests/boot/kopenbsdlabel.txt grub-core/tests/boot/linux16.cfg grub-core/tests/boot/linux.cfg grub-core/tests/boot/linux.init-i386.S grub-core/tests/boot/linux.init-mips.S grub-core/tests/boot/linux.init-ppc.S grub-core/tests/boot/linux.init-x86_64.S grub-core/tests/boot/linux-ppc.cfg grub-core/tests/boot/multiboot2.cfg grub-core/tests/boot/multiboot.cfg grub-core/tests/boot/ntldr.cfg grub-core/tests/boot/pc-chainloader.cfg grub-core/tests/boot/qemu-shutdown-x86.S
-
.PHONY: bootcheck-linux-i386 bootcheck-linux-x86_64 \
bootcheck-kfreebsd-i386 bootcheck-kfreebsd-x86_64 \
bootcheck-knetbsd-i386 bootcheck-knetbsd-x86_64 \
- bootcheck-linux-mips
+ bootcheck-linux-mips FORCE
# Randomly generated
SUCCESSFUL_BOOT_STRING=3e49994fd5d82b7c9298d672d774080d
@@ -398,10 +409,15 @@ BOOTCHECK_TIMEOUT=180
bootcheck: $(BOOTCHECKS)
if COND_i386_coreboot
-default_payload.elf: grub-mkstandalone grub-mkimage
- pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg
+default_payload.elf: grub-mkstandalone grub-mkimage FORCE
+ test -f $@ && rm $@ || true
+ pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) password_pbkdf2 $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg
+endif
+
endif
+EXTRA_DIST += grub-core/tests/boot/kbsd.init-i386.S grub-core/tests/boot/kbsd.init-x86_64.S grub-core/tests/boot/kbsd.spec.txt grub-core/tests/boot/kernel-8086.S grub-core/tests/boot/kernel-i386.S grub-core/tests/boot/kfreebsd-aout.cfg grub-core/tests/boot/kfreebsd.cfg grub-core/tests/boot/kfreebsd.init-i386.S grub-core/tests/boot/kfreebsd.init-x86_64.S grub-core/tests/boot/knetbsd.cfg grub-core/tests/boot/kopenbsd.cfg grub-core/tests/boot/kopenbsdlabel.txt grub-core/tests/boot/linux16.cfg grub-core/tests/boot/linux.cfg grub-core/tests/boot/linux.init-i386.S grub-core/tests/boot/linux.init-mips.S grub-core/tests/boot/linux.init-ppc.S grub-core/tests/boot/linux.init-x86_64.S grub-core/tests/boot/linux-ppc.cfg grub-core/tests/boot/multiboot2.cfg grub-core/tests/boot/multiboot.cfg grub-core/tests/boot/ntldr.cfg grub-core/tests/boot/pc-chainloader.cfg grub-core/tests/boot/qemu-shutdown-x86.S
+
windowsdir=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows
windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
test -d $(windowsdir) && rm -rf $(windowsdir) || true
@@ -420,10 +436,33 @@ windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
for x in $(starfield_DATA); do \
cp -fp $$x $(windowsdir)/themes/starfield/$$(basename $$x); \
done
+ for x in $(GRUB_WINDOWS_EXTRA_DIST); do \
+ cp -fp $$x $(windowsdir); \
+ done
windowszip=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows.zip
windowszip: windowsdir
test -f $(windowszip) && rm $(windowszip) || true
zip -r $(windowszip) $(windowsdir)
+ rm -rf $(windowsdir)
EXTRA_DIST += linguas.sh
+
+changelog_start_date = 2015-01-23
+gitlog_to_changelog = $(top_srcdir)/build-aux/gitlog-to-changelog
+
+ChangeLog: FORCE
+ if test -d $(top_srcdir)/.git; then \
+ $(gitlog_to_changelog) --srcdir=$(top_srcdir) --since=$(changelog_start_date) > '$@.tmp'; \
+ rm -f '$@'; mv '$@.tmp' '$@'; \
+ else \
+ touch $@; \
+ fi
+
+EXTRA_DIST += ChangeLog ChangeLog-2015
+
+syslinux_test: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg
+
+tests/syslinux/ubuntu10.04_grub.cfg: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg.in
+ (for x in tests/syslinux/ubuntu10.04_grub.cfg.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+CLEANFILES += tests/syslinux/ubuntu10.04_grub.cfg
diff --git a/Makefile.util.def b/Makefile.util.def
index 27c48e5f8..f9caccb97 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -48,6 +48,7 @@ library = {
common = grub-core/partmap/gpt.c;
common = grub-core/partmap/msdos.c;
common = grub-core/fs/proc.c;
+ common = grub-core/fs/archelp.c;
};
library = {
@@ -91,7 +92,6 @@ library = {
common = grub-core/fs/bfs.c;
common = grub-core/fs/btrfs.c;
common = grub-core/fs/cbfs.c;
- common = grub-core/fs/archelp.c;
common = grub-core/fs/cpio.c;
common = grub-core/fs/cpio_be.c;
common = grub-core/fs/odc.c;
@@ -172,6 +172,8 @@ program = {
common = util/grub-mkimage.c;
common = util/mkimage.c;
+ common = util/grub-mkimage32.c;
+ common = util/grub-mkimage64.c;
common = util/resolve.c;
common = grub-core/kern/emu/argp_common.c;
common = grub-core/osdep/init.c;
@@ -384,7 +386,7 @@ program = {
ldadd = libgrubgcry.a;
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
- ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBGEOM)';
+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};
program = {
@@ -405,7 +407,7 @@ program = {
program = {
name = grub-macbless;
installdir = sbin;
- mansection = 1;
+ mansection = 8;
common = util/grub-macbless.c;
common = grub-core/osdep/init.c;
common = grub-core/kern/emu/argp_common.c;
@@ -414,7 +416,7 @@ program = {
ldadd = libgrubgcry.a;
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
- ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
+ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};
data = {
@@ -439,42 +441,49 @@ script = {
name = '10_hurd';
common = util/grub.d/10_hurd.in;
installdir = grubconf;
+ condition = COND_HOST_HURD;
};
script = {
name = '10_kfreebsd';
common = util/grub.d/10_kfreebsd.in;
installdir = grubconf;
+ condition = COND_HOST_KFREEBSD;
};
script = {
name = '10_illumos';
common = util/grub.d/10_illumos.in;
installdir = grubconf;
+ condition = COND_HOST_ILLUMOS;
};
script = {
name = '10_netbsd';
common = util/grub.d/10_netbsd.in;
installdir = grubconf;
+ condition = COND_HOST_NETBSD;
};
script = {
name = '10_linux';
common = util/grub.d/10_linux.in;
installdir = grubconf;
+ condition = COND_HOST_LINUX;
};
script = {
name = '10_xnu';
common = util/grub.d/10_xnu.in;
installdir = grubconf;
+ condition = COND_HOST_XNU;
};
script = {
name = '20_linux_xen';
common = util/grub.d/20_linux_xen.in;
installdir = grubconf;
+ condition = COND_HOST_LINUX;
};
script = {
@@ -503,6 +512,8 @@ program = {
common = util/render-label.c;
common = util/glue-efi.c;
common = util/mkimage.c;
+ common = util/grub-mkimage32.c;
+ common = util/grub-mkimage64.c;
common = util/grub-install-common.c;
common = util/setup_bios.c;
common = util/setup_sparc.c;
@@ -545,6 +556,8 @@ program = {
common = util/render-label.c;
common = util/glue-efi.c;
common = util/mkimage.c;
+ common = util/grub-mkimage32.c;
+ common = util/grub-mkimage64.c;
common = util/grub-install-common.c;
common = util/setup_bios.c;
common = util/setup_sparc.c;
@@ -588,6 +601,8 @@ program = {
common = util/grub-install.c;
common = util/probe.c;
common = util/mkimage.c;
+ common = util/grub-mkimage32.c;
+ common = util/grub-mkimage64.c;
common = util/grub-install-common.c;
common = util/setup_bios.c;
common = util/setup_sparc.c;
@@ -606,7 +621,6 @@ program = {
common = grub-core/disk/host.c;
common = util/resolve.c;
- enable = noemu;
common = grub-core/kern/emu/argp_common.c;
common = grub-core/osdep/init.c;
@@ -626,6 +640,8 @@ program = {
common = util/grub-mknetdir.c;
common = util/mkimage.c;
+ common = util/grub-mkimage32.c;
+ common = util/grub-mkimage64.c;
common = util/grub-install-common.c;
common = util/setup_bios.c;
common = util/setup_sparc.c;
@@ -701,7 +717,7 @@ script = {
name = grub-fs-tester;
common = tests/util/grub-fs-tester.in;
installdir = noinst;
- dependencies = garbage-gen;
+ dependencies = 'garbage-gen$(BUILD_EXEEXT)';
};
script = {
@@ -1143,6 +1159,24 @@ script = {
common = tests/grub_cmd_tr.in;
};
+script = {
+ testcase;
+ name = file_filter_test;
+ common = tests/file_filter_test.in;
+};
+
+script = {
+ testcase;
+ name = grub_cmd_test;
+ common = tests/grub_cmd_test.in;
+};
+
+script = {
+ testcase;
+ name = syslinux_test;
+ common = tests/syslinux_test.in;
+};
+
program = {
testcase;
name = example_unit_test;
diff --git a/NEWS b/NEWS
index 4bb5f9801..572eadb3e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,179 @@
+New in 2.02:
+
+* New/improved filesystem and disk support:
+ * Big-endian UFS1.
+ * Experimental 64-bit ext2 support.
+ * Various fixes for non-512-byte sector devices.
+ * New `proc' filesystem framework, used by LUKS disks.
+ * Fix DM-RAID partition handling.
+ * New `nativedisk' command to switch from firmware to native disk drivers.
+ * Compressed HFS+.
+ * DragonFly BSD labels.
+ * CBFS (coreboot).
+ * Handle partitioned LVM properly.
+ * Use LVM UUIDs whenever possible.
+ * GPT PReP.
+ * New `progress' module that shows progress information while reading
+ files.
+ * ZFS features support.
+ * ZFS LZ4 support.
+ * XFS V5 format support.
+ * LVM RAID1 support.
+
+* New/improved terminal and video support:
+ * Monochrome text (matching `hercules' in GRUB Legacy).
+ * Morse code output using system speaker.
+ * `spkmodem' output (simple data protocol using system speaker).
+ * Handle Japanese special keys.
+ * coreboot framebuffer.
+ * Serial on ARC.
+ * Native vt100 handling for grub-emu, replacing the use of the curses
+ library.
+ * New gfxmenu options for terminal window positioning, theme background
+ image handling, and scrollbar padding, plus `item_pixmap_style' and
+ `highlight_overlay'.
+ * Support several more image types (paletted and greyscale).
+
+* Boot protocol improvements:
+ * Support Apple FAT binaries on non-Apple platforms.
+ * Improve FreeDOS direct loading support compatibility.
+ * Enable `linux16' on all x86 platforms, not just BIOS.
+ * New TrueCrypt ISO loader.
+ * multiboot2 boot-services EFI specification.
+ * multiboot2 EFI memory map specification.
+ * multiboot2 full-file specfication.
+
+* New/improved network support:
+ * New variables `net_default_*' containing properties of the default
+ interface.
+ * Autoload `http' and `tftp' modules if necessary.
+ * Improve TFTP robustness.
+ * Parse `nd' disk names in GRUB Legacy configuration files.
+ * Issue separate DNS queries for IPv4 and IPv6.
+ * Support IPv6 Router Advertisement to configure default router.
+
+* Coreboot improvements:
+ * CBFS support both in on-disk images (loopback) and flash.
+ * Ability to launch another payload from flash or disk
+ * Coreboot framebuffer
+ * CBMEMC support (both logging and inspecting logs)
+ * Command for inspecting coreboot timestamps (`coreboot_boottime').
+ * Command for inspecting coreboot tables (`lscoreboot').
+ * New target default_payload.elf.
+ * Increased maximal core size.
+ * Prefer pmtimer for TSC calibration.
+
+* New/improved platform support:
+ * New `efifwsetup' and `lsefi' commands on EFI platforms.
+ * New `cmosdump' and `cmosset' commands on platforms with CMOS support.
+ * New command `pcidump' for PCI platforms.
+ * Improve opcode parsing in ACPI halt implementation.
+ * Use the TSC as a possible time source on i386-ieee1275.
+ * Merge PowerPC grub-mkrescue implementation with the common one.
+ * Support grub-mkrescue on i386-ieee1275, sparc64, bootinfo machines such
+ as pSeries, and mips-arc.
+ * Make grub-mkrescue better support Apple Intel Macs on CD.
+ * Enable GRUB Legacy configuration file parsing on EFI.
+ * Support halt for Loongson 2E.
+ * ARM U-Boot and EFI ports.
+ * Reorganise platform-dependent code in utilities to avoid #ifdef mess.
+ * AROS and Haiku support for userspace utilities.
+ * Xen PV port.
+ * Fix EFI stack alignment.
+ * ARM64 EFI port.
+ * On Linux, read partition start offsets from sysfs if possible.
+ * New grub-macbless utility, and better integration with Mac firmware in
+ grub-install.
+ * Support Yeeloong 3A.
+ * Add `cpuid --pae' option to detect Physical Address Extension on x86.
+ * Support for USB debug dongles.
+ * Support for *-emu on all platforms (previously only i386/x86_64 worked).
+ * Support *-emu on Windows.
+ * New platform `none' which builds only user level utilities. This is now
+ default if target CPU is not supported.
+ * Support for booting little-endian Linux kernel on powerpc.
+ * Support network boot with Oracle sun4v vnet devices.
+ * Added SAS disks to the IEEE 1275 Open Firmware device list.
+ * Try multiple methods for TSC (timestamp counter) calibration - PIT, pmtimer,
+ EFI Stall. If everything fails, use hardcoded frequency 800MHz.
+ * Support Hyper-V Gen2 platforms which lack PIT for TSC calibration.
+ * Map UEFI Persistent Memory to E820 persistent memory.
+ * New Xen loader on ARM64.
+ * Respect alignment requirement for block device IO buffers on EFI.
+
+* Security:
+ * Add optional facility to enforce that all files read by the core image
+ from disk have a valid detached digital signature.
+
+* Performance:
+ * Avoid costly division operations in many places.
+ * New boot time analysis framework (`./configure --enable-boot-time').
+ * Initialise USB ports in parallel.
+ * New `testspeed' command to test file read speed.
+ * Speed-up gfxterm by storing intermediate results in more compact format.
+ * Lazy LVM/mdraid scan.
+ * Disk hints.
+
+* Scripting:
+ * New `eval' and `tr' commands.
+ * grub-script-check fails on scripts containing no commands.
+
+* Installation and other utility improvements:
+ * Add option to compress files on installation or image creation.
+ * Using grub-reboot no longer requires setting `GRUB_DEFAULT=saved'.
+ * Support probing EFI System Partition (requires os-prober >= 1.58).
+ * Fix inconsistent use of `GRUB_CRYPTODISK_ENABLE' and
+ `GRUB_ENABLE_CRYPTODISK'; the latter is now used consistently.
+ * grub-mount handles symbolic links to directories.
+ * Support disabling submenus with `GRUB_DISABLE_SUBMENU' configuration key
+ for grub-mkconfig.
+ * grub-install, grub-mknetdir, grub-mkrescue, and grub-mkstandalone
+ rewritten in C. They should now work in supported non-Unix-like
+ environments.
+ * Native mingw support.
+ * Ability to install on EFI under windows.
+ * Reorganise timeout handling using new `timeout_style' environment
+ variable and `GRUB_TIMEOUT_STYLE' configuration key for grub-mkconfig.
+ Menu hotkeys pressed during a hidden timeout now boot the corresponding
+ menu entry immediately.
+ * New `file' command and grub-file utility to check file types.
+ * New syslinux configuration file parser.
+ * Set menu entry class to primary OS name returned by os-prober to display
+ OS specific icon.
+ * On Linux x86 detect EFI word size in grub-install and automatically select
+ correct platform (x86_64-efi or i386-efi) to install. Requires Linux kernel
+ 4.0 or higher.
+
+* Build system:
+ * Remove all uses of nested functions; GRUB no longer requires an
+ executable stack.
+ * Fix documentation build with Texinfo >= 5.1.
+ * More robust and documented cross-compiling support.
+ * Partial clang support for some platforms (experimental).
+ * Partial mingw64 x86_64-efi compile support (highly experimental).
+ * Partial mingw32 i386-* (other than already present i386-pc)
+ compile support (highly experimental).
+ * Support for grub-mkpasswd on Windows.
+ * Eliminate the use of AutoGen. This allowed some performance
+ improvements to the build system.
+ * Remove variable length arrays.
+ * OpenBSD compile and tools support (NetBSD and FreeBSD were already supported).
+ * Fix build with FreeType >= 2.5.1.
+ * Make gentpl.py compatible with Python 3. It now requires at least
+ Python 2.6.
+ * modinfo.sh contains build information now.
+ * Added many new tests to improve robustness.
+ * Target is built without libgcc now. Necessary builtins are reimplemented
+ directly. This removes requirement for target-specific runtime on build
+ system.
+ * emu libusb support removed (was broken and unmaintained).
+ * powerpc64le compile support.
+ * Use fixed timestamp when generating GRUB image for reproducible builds.
+ * Verify at build time that modules contain only supported relocations and their
+ structure matches what boot-time module loader expects.
+
+* Revision control moved to git.
+
New in 2.00:
* Appearance:
@@ -24,7 +200,6 @@ New in 2.00:
* IEEE1275 serial.
* EFI serial.
* Network stack for BIOS, IEEE1275, EMU and EFI, including TFTP, HTTP and DNS.
- * VBE on coreboot support.
* New filesystem, filters and disks formats:
* DVH partition map.
@@ -48,7 +223,7 @@ New in 2.00:
* multidevice, mirrored and raidz(2,3) ZFS support.
* RAID LVM (internal RAIDing) support.
* ZFS crypto support.
- * ZLE and GZIP on ZFS support.
+ * ZLE, LZ4 and GZIP on ZFS support.
* Support ZFS up to 33.
* HFS string is now treated like mac-roman and not UTF-8
* HFS mtime support.
diff --git a/README b/README
index b30a4b68b..685b01657 100644
--- a/README
+++ b/README
@@ -12,8 +12,6 @@ The URL is <http://www.gnu.org/software/grub/grub.html>.
More extensive documentation is available in the Info manual,
accessible using 'info grub' after building and installing GRUB 2.
-Please look at the GRUB Wiki <http://grub.enbug.org> for testing
-procedures.
There are a number of important user-visible differences from the
first version of GRUB, now known as GRUB Legacy. For a summary, please
diff --git a/TODO b/TODO
index 6ec1521cd..a9b6d3523 100644
--- a/TODO
+++ b/TODO
@@ -7,7 +7,3 @@ glance. So write to <grub-devel@gnu.org> first.
For bug tracking, refer to:
http://savannah.gnu.org/bugs/?group=grub
-
-Our wiki also lists some areas that need work:
-
- http://grub.enbug.org/
diff --git a/acinclude.m4 b/acinclude.m4
index 32d5477d1..526f97a3a 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -93,7 +93,7 @@ else
fi
grub_cv_prog_objcopy_absolute=yes
for link_addr in 0x2000 0x8000 0x7C00; do
- if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then :
+ if AC_TRY_COMMAND([${CC-cc} ${TARGET_CFLAGS} ${TARGET_LDFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then :
else
AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr])
fi
@@ -210,80 +210,6 @@ fi
])
-dnl Mass confusion!
-dnl Older versions of GAS interpret `.code16' to mean ``generate 32-bit
-dnl instructions, but implicitly insert addr32 and data32 bytes so
-dnl that the code works in real mode''.
-dnl
-dnl Newer versions of GAS interpret `.code16' to mean ``generate 16-bit
-dnl instructions,'' which seems right. This requires the programmer
-dnl to explicitly insert addr32 and data32 instructions when they want
-dnl them.
-dnl
-dnl We only support the newer versions, because the old versions cause
-dnl major pain, by requiring manual assembly to get 16-bit instructions into
-dnl asm files.
-AC_DEFUN([grub_I386_ASM_ADDR32],
-[AC_REQUIRE([AC_PROG_CC])
-AC_REQUIRE([grub_I386_ASM_PREFIX_REQUIREMENT])
-AC_MSG_CHECKING([for .code16 addr32 assembler support])
-AC_CACHE_VAL(grub_cv_i386_asm_addr32,
-[cat > conftest.s.in <<\EOF
- .code16
-l1: @ADDR32@ movb %al, l1
-EOF
-
-if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then
- sed -e s/@ADDR32@/addr32/ < conftest.s.in > conftest.s
-else
- sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s
-fi
-
-if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
- grub_cv_i386_asm_addr32=yes
-else
- grub_cv_i386_asm_addr32=no
-fi
-
-rm -f conftest*])
-
-AC_MSG_RESULT([$grub_cv_i386_asm_addr32])])
-
-dnl Later versions of GAS requires that addr32 and data32 prefixes
-dnl appear in the same lines as the instructions they modify, while
-dnl earlier versions requires that they appear in separate lines.
-AC_DEFUN([grub_I386_ASM_PREFIX_REQUIREMENT],
-[AC_REQUIRE([AC_PROG_CC])
-AC_MSG_CHECKING(dnl
-[whether addr32 must be in the same line as the instruction])
-AC_CACHE_VAL(grub_cv_i386_asm_prefix_requirement,
-[cat > conftest.s <<\EOF
- .code16
-l1: addr32 movb %al, l1
-EOF
-
-if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
- grub_cv_i386_asm_prefix_requirement=yes
-else
- grub_cv_i386_asm_prefix_requirement=no
-fi
-
-rm -f conftest*])
-
-if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then
- grub_tmp_addr32="addr32"
- grub_tmp_data32="data32"
-else
- grub_tmp_addr32="addr32;"
- grub_tmp_data32="data32;"
-fi
-
-ADDR32=$grub_tmp_addr32
-DATA32=$grub_tmp_data32
-
-AC_MSG_RESULT([$grub_cv_i386_asm_prefix_requirement])])
-
-
dnl Check what symbol is defined as a bss start symbol.
dnl Written by Michael Hohmoth and Yoshinori K. Okuji.
AC_DEFUN([grub_CHECK_BSS_START_SYMBOL],
@@ -418,15 +344,15 @@ else
[fi]
])
-dnl Check if ln can handle directories properly (mingw).
+dnl Check if ln -s can handle directories properly (mingw).
AC_DEFUN([grub_CHECK_LINK_DIR],[
-AC_MSG_CHECKING([whether ln can handle directories properly])
+AC_MSG_CHECKING([whether ln -s can handle directories properly])
[mkdir testdir 2>/dev/null
case $srcdir in
[\\/$]* | ?:[\\/]* ) reldir=$srcdir/include/grub/util ;;
*) reldir=../$srcdir/include/grub/util ;;
esac
-if ln -s $reldir testdir/util 2>/dev/null ; then]
+if ln -s $reldir testdir/util 2>/dev/null && rm -f testdir/util 2>/dev/null ; then]
AC_MSG_RESULT([yes])
[link_dir=yes
else
diff --git a/asm-tests/arm.S b/asm-tests/arm.S
new file mode 100644
index 000000000..97c2546bf
--- /dev/null
+++ b/asm-tests/arm.S
@@ -0,0 +1,20 @@
+/* on arm clang doesn't support .arch directive */
+
+ .text
+ .syntax unified
+
+#if !defined (__thumb2__)
+ .arch armv7a
+ .arm
+#else
+ .arch armv7
+ .thumb
+#endif
+ mcr p15, 0, r11, c7, c14, 2
+
+ /* clang restricts access to dsb/isb despite .arch */
+ dsb
+ isb
+
+
+
diff --git a/asm-tests/i386-pc.S b/asm-tests/i386-pc.S
new file mode 100644
index 000000000..f6f9a88be
--- /dev/null
+++ b/asm-tests/i386-pc.S
@@ -0,0 +1,14 @@
+/* on x86 old clang doesn't support .code16
+ newer clang supports it but creates 6-byte jumps instead of 3-byte ones
+ which makes us go over boot sector size. */
+
+ .code16
+ jmp far
+ .org 4
+ jmp nearer
+ .org 6
+ .space 100
+nearer:
+ .space 200
+far:
+ .byte 0
diff --git a/asm-tests/i386.S b/asm-tests/i386.S
new file mode 100644
index 000000000..30adc4fe2
--- /dev/null
+++ b/asm-tests/i386.S
@@ -0,0 +1,4 @@
+/* on x86 old clang doesn't support .code16 */
+
+ .code16
+ movb %al, %bl
diff --git a/asm-tests/mips.S b/asm-tests/mips.S
new file mode 100644
index 000000000..1312d47d5
--- /dev/null
+++ b/asm-tests/mips.S
@@ -0,0 +1,11 @@
+/* on mips clang doesn't support privilegied instructions, doubleword store/load
+ and crashes with hand-written assembly
+ */
+
+ .set mips3
+ sync
+ ld $t2, 0($t1)
+
+a:
+ addiu $t1, $s0, (b - a)
+b: nop
diff --git a/asm-tests/powerpc.S b/asm-tests/powerpc.S
new file mode 100644
index 000000000..396a6cce9
--- /dev/null
+++ b/asm-tests/powerpc.S
@@ -0,0 +1,8 @@
+/* clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly
+ used by gcrypt */
+/* Cache invalidation loop is a fair test. */
+ li 5, 0
+1: icbi 5, 3
+ addi 5, 5, 32
+ cmpw 5, 4
+ blt 1b
diff --git a/asm-tests/sparc64.S b/asm-tests/sparc64.S
new file mode 100644
index 000000000..03c5fe02a
--- /dev/null
+++ b/asm-tests/sparc64.S
@@ -0,0 +1,9 @@
+ .text
+1:
+ /* A small list of examples of what clang doesn't support. */
+ clr %o0
+ lduw [%o4 + 4], %o4
+ and %o6, ~0xff, %o6
+ stw %o5, [%o3]
+ bne,pt %icc, 1b
+ nop
diff --git a/autogen.sh b/autogen.sh
index 7424428d6..7537561ad 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -2,6 +2,9 @@
set -e
+# Set ${PYTHON} to plain 'python' if not set already
+: ${PYTHON:=python}
+
export LC_COLLATE=C
unset LC_ALL
@@ -9,10 +12,10 @@ find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './b
find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in
echo "Importing unicode..."
-python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
+${PYTHON} util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
echo "Importing libgcrypt..."
-python util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
+${PYTHON} util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
sed -n -f util/import_gcrypth.sed < grub-core/lib/libgcrypt/src/gcrypt.h.in > include/grub/gcrypt/gcrypt.h
if [ -f include/grub/gcrypt/g10lib.h ]; then
rm include/grub/gcrypt/g10lib.h
@@ -20,14 +23,14 @@ fi
if [ -d grub-core/lib/libgcrypt-grub/mpi/generic ]; then
rm -rf grub-core/lib/libgcrypt-grub/mpi/generic
fi
-ln -s ../../../grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h
+cp grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h
cp -R grub-core/lib/libgcrypt/mpi/generic grub-core/lib/libgcrypt-grub/mpi/generic
for x in mpi-asm-defs.h mpih-add1.c mpih-sub1.c mpih-mul1.c mpih-mul2.c mpih-mul3.c mpih-lshift.c mpih-rshift.c; do
if [ -h grub-core/lib/libgcrypt-grub/mpi/"$x" ] || [ -f grub-core/lib/libgcrypt-grub/mpi/"$x" ]; then
rm grub-core/lib/libgcrypt-grub/mpi/"$x"
fi
- ln -s generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
+ cp grub-core/lib/libgcrypt-grub/mpi/generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x"
done
echo "Generating Automake input..."
@@ -54,8 +57,8 @@ for extra in contrib/*/Makefile.core.def; do
fi
done
-python gentpl.py $UTIL_DEFS > Makefile.util.am
-python gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
+${PYTHON} gentpl.py $UTIL_DEFS > Makefile.util.am
+${PYTHON} gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
for extra in contrib/*/Makefile.common; do
if test -e "$extra"; then
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
new file mode 100755
index 000000000..78afff4e8
--- /dev/null
+++ b/build-aux/gitlog-to-changelog
@@ -0,0 +1,432 @@
+eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
+ & eval 'exec perl -wS "$0" $argv:q'
+ if 0;
+# Convert git log output to ChangeLog format.
+
+my $VERSION = '2012-07-29 06:11'; # UTC
+# The definition above must lie within the first 8 lines in order
+# for the Emacs time-stamp write hook (at end) to update it.
+# If you change this file with Emacs, please let the write hook
+# do its job. Otherwise, update this string manually.
+
+# Copyright (C) 2008-2014 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Written by Jim Meyering
+
+use strict;
+use warnings;
+use Getopt::Long;
+use POSIX qw(strftime);
+
+(my $ME = $0) =~ s|.*/||;
+
+# use File::Coda; # http://meyering.net/code/Coda/
+END {
+ defined fileno STDOUT or return;
+ close STDOUT and return;
+ warn "$ME: failed to close standard output: $!\n";
+ $? ||= 1;
+}
+
+sub usage ($)
+{
+ my ($exit_code) = @_;
+ my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
+ if ($exit_code != 0)
+ {
+ print $STREAM "Try '$ME --help' for more information.\n";
+ }
+ else
+ {
+ print $STREAM <<EOF;
+Usage: $ME [OPTIONS] [ARGS]
+
+Convert git log output to ChangeLog format. If present, any ARGS
+are passed to "git log". To avoid ARGS being parsed as options to
+$ME, they may be preceded by '--'.
+
+OPTIONS:
+
+ --amend=FILE FILE maps from an SHA1 to perl code (i.e., s/old/new/) that
+ makes a change to SHA1's commit log text or metadata.
+ --append-dot append a dot to the first line of each commit message if
+ there is no other punctuation or blank at the end.
+ --no-cluster never cluster commit messages under the same date/author
+ header; the default is to cluster adjacent commit messages
+ if their headers are the same and neither commit message
+ contains multiple paragraphs.
+ --srcdir=DIR the root of the source tree, from which the .git/
+ directory can be derived.
+ --since=DATE convert only the logs since DATE;
+ the default is to convert all log entries.
+ --format=FMT set format string for commit subject and body;
+ see 'man git-log' for the list of format metacharacters;
+ the default is '%s%n%b%n'
+ --strip-tab remove one additional leading TAB from commit message lines.
+ --strip-cherry-pick remove data inserted by "git cherry-pick";
+ this includes the "cherry picked from commit ..." line,
+ and the possible final "Conflicts:" paragraph.
+ --help display this help and exit
+ --version output version information and exit
+
+EXAMPLE:
+
+ $ME --since=2008-01-01 > ChangeLog
+ $ME -- -n 5 foo > last-5-commits-to-branch-foo
+
+SPECIAL SYNTAX:
+
+The following types of strings are interpreted specially when they appear
+at the beginning of a log message line. They are not copied to the output.
+
+ Copyright-paperwork-exempt: Yes
+ Append the "(tiny change)" notation to the usual "date name email"
+ ChangeLog header to mark a change that does not require a copyright
+ assignment.
+ Co-authored-by: Joe User <user\@example.com>
+ List the specified name and email address on a second
+ ChangeLog header, denoting a co-author.
+ Signed-off-by: Joe User <user\@example.com>
+ These lines are simply elided.
+
+In a FILE specified via --amend, comment lines (starting with "#") are ignored.
+FILE must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1 (alone on
+a line) referring to a commit in the current project, and CODE refers to one
+or more consecutive lines of Perl code. Pairs must be separated by one or
+more blank line.
+
+Here is sample input for use with --amend=FILE, from coreutils:
+
+3a169f4c5d9159283548178668d2fae6fced3030
+# fix typo in title:
+s/all tile types/all file types/
+
+1379ed974f1fa39b12e2ffab18b3f7a607082202
+# Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself.
+# Change the author to be Paul. Note the escaped "@":
+s,Jim .*>,Paul Eggert <eggert\\\@cs.ucla.edu>,
+
+EOF
+ }
+ exit $exit_code;
+}
+
+# If the string $S is a well-behaved file name, simply return it.
+# If it contains white space, quotes, etc., quote it, and return the new string.
+sub shell_quote($)
+{
+ my ($s) = @_;
+ if ($s =~ m![^\w+/.,-]!)
+ {
+ # Convert each single quote to '\''
+ $s =~ s/\'/\'\\\'\'/g;
+ # Then single quote the string.
+ $s = "'$s'";
+ }
+ return $s;
+}
+
+sub quoted_cmd(@)
+{
+ return join (' ', map {shell_quote $_} @_);
+}
+
+# Parse file F.
+# Comment lines (starting with "#") are ignored.
+# F must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1
+# (alone on a line) referring to a commit in the current project, and
+# CODE refers to one or more consecutive lines of Perl code.
+# Pairs must be separated by one or more blank line.
+sub parse_amend_file($)
+{
+ my ($f) = @_;
+
+ open F, '<', $f
+ or die "$ME: $f: failed to open for reading: $!\n";
+
+ my $fail;
+ my $h = {};
+ my $in_code = 0;
+ my $sha;
+ while (defined (my $line = <F>))
+ {
+ $line =~ /^\#/
+ and next;
+ chomp $line;
+ $line eq ''
+ and $in_code = 0, next;
+
+ if (!$in_code)
+ {
+ $line =~ /^([0-9a-fA-F]{40})$/
+ or (warn "$ME: $f:$.: invalid line; expected an SHA1\n"),
+ $fail = 1, next;
+ $sha = lc $1;
+ $in_code = 1;
+ exists $h->{$sha}
+ and (warn "$ME: $f:$.: duplicate SHA1\n"),
+ $fail = 1, next;
+ }
+ else
+ {
+ $h->{$sha} ||= '';
+ $h->{$sha} .= "$line\n";
+ }
+ }
+ close F;
+
+ $fail
+ and exit 1;
+
+ return $h;
+}
+
+# git_dir_option $SRCDIR
+#
+# From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR
+# is undef). Return as a list (0 or 1 element).
+sub git_dir_option($)
+{
+ my ($srcdir) = @_;
+ my @res = ();
+ if (defined $srcdir)
+ {
+ my $qdir = shell_quote $srcdir;
+ my $cmd = "cd $qdir && git rev-parse --show-toplevel";
+ my $qcmd = shell_quote $cmd;
+ my $git_dir = qx($cmd);
+ defined $git_dir
+ or die "$ME: cannot run $qcmd: $!\n";
+ $? == 0
+ or die "$ME: $qcmd had unexpected exit code or signal ($?)\n";
+ chomp $git_dir;
+ push @res, "--git-dir=$git_dir/.git";
+ }
+ @res;
+}
+
+{
+ my $since_date;
+ my $format_string = '%s%n%b%n';
+ my $amend_file;
+ my $append_dot = 0;
+ my $cluster = 1;
+ my $strip_tab = 0;
+ my $strip_cherry_pick = 0;
+ my $srcdir;
+ GetOptions
+ (
+ help => sub { usage 0 },
+ version => sub { print "$ME version $VERSION\n"; exit },
+ 'since=s' => \$since_date,
+ 'format=s' => \$format_string,
+ 'amend=s' => \$amend_file,
+ 'append-dot' => \$append_dot,
+ 'cluster!' => \$cluster,
+ 'strip-tab' => \$strip_tab,
+ 'strip-cherry-pick' => \$strip_cherry_pick,
+ 'srcdir=s' => \$srcdir,
+ ) or usage 1;
+
+ defined $since_date
+ and unshift @ARGV, "--since=$since_date";
+
+ # This is a hash that maps an SHA1 to perl code (i.e., s/old/new/)
+ # that makes a correction in the log or attribution of that commit.
+ my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {};
+
+ my @cmd = ('git',
+ git_dir_option $srcdir,
+ qw(log --log-size),
+ '--pretty=format:%H:%ct %an <%ae>%n%n'.$format_string, @ARGV);
+ open PIPE, '-|', @cmd
+ or die ("$ME: failed to run '". quoted_cmd (@cmd) ."': $!\n"
+ . "(Is your Git too old? Version 1.5.1 or later is required.)\n");
+
+ my $prev_multi_paragraph;
+ my $prev_date_line = '';
+ my @prev_coauthors = ();
+ while (1)
+ {
+ defined (my $in = <PIPE>)
+ or last;
+ $in =~ /^log size (\d+)$/
+ or die "$ME:$.: Invalid line (expected log size):\n$in";
+ my $log_nbytes = $1;
+
+ my $log;
+ my $n_read = read PIPE, $log, $log_nbytes;
+ $n_read == $log_nbytes
+ or die "$ME:$.: unexpected EOF\n";
+
+ # Extract leading hash.
+ my ($sha, $rest) = split ':', $log, 2;
+ defined $sha
+ or die "$ME:$.: malformed log entry\n";
+ $sha =~ /^[0-9a-fA-F]{40}$/
+ or die "$ME:$.: invalid SHA1: $sha\n";
+
+ # If this commit's log requires any transformation, do it now.
+ my $code = $amend_code->{$sha};
+ if (defined $code)
+ {
+ eval 'use Safe';
+ my $s = new Safe;
+ # Put the unpreprocessed entry into "$_".
+ $_ = $rest;
+
+ # Let $code operate on it, safely.
+ my $r = $s->reval("$code")
+ or die "$ME:$.:$sha: failed to eval \"$code\":\n$@\n";
+
+ # Note that we've used this entry.
+ delete $amend_code->{$sha};
+
+ # Update $rest upon success.
+ $rest = $_;
+ }
+
+ # Remove lines inserted by "git cherry-pick".
+ if ($strip_cherry_pick)
+ {
+ $rest =~ s/^\s*Conflicts:\n.*//sm;
+ $rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m;
+ }
+
+ my @line = split "\n", $rest;
+ my $author_line = shift @line;
+ defined $author_line
+ or die "$ME:$.: unexpected EOF\n";
+ $author_line =~ /^(\d+) (.*>)$/
+ or die "$ME:$.: Invalid line "
+ . "(expected date/author/email):\n$author_line\n";
+
+ # Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog
+ # `(tiny change)' annotation.
+ my $tiny = (grep (/^Copyright-paperwork-exempt:\s+[Yy]es$/, @line)
+ ? ' (tiny change)' : '');
+
+ my $date_line = sprintf "%s %s$tiny\n",
+ strftime ("%F", localtime ($1)), $2;
+
+ my @coauthors = grep /^Co-authored-by:.*$/, @line;
+ # Omit meta-data lines we've already interpreted.
+ @line = grep !/^(?:Signed-off-by:[ ].*>$
+ |Co-authored-by:[ ]
+ |Copyright-paperwork-exempt:[ ]
+ )/x, @line;
+
+ # Remove leading and trailing blank lines.
+ if (@line)
+ {
+ while ($line[0] =~ /^\s*$/) { shift @line; }
+ while ($line[$#line] =~ /^\s*$/) { pop @line; }
+ }
+
+ # Record whether there are two or more paragraphs.
+ my $multi_paragraph = grep /^\s*$/, @line;
+
+ # Format 'Co-authored-by: A U Thor <email@example.com>' lines in
+ # standard multi-author ChangeLog format.
+ for (@coauthors)
+ {
+ s/^Co-authored-by:\s*/\t /;
+ s/\s*</ </;
+
+ /<.*?@.*\..*>/
+ or warn "$ME: warning: missing email address for "
+ . substr ($_, 5) . "\n";
+ }
+
+ # If clustering of commit messages has been disabled, if this header
+ # would be different from the previous date/name/email/coauthors header,
+ # or if this or the previous entry consists of two or more paragraphs,
+ # then print the header.
+ if ( ! $cluster
+ || $date_line ne $prev_date_line
+ || "@coauthors" ne "@prev_coauthors"
+ || $multi_paragraph
+ || $prev_multi_paragraph)
+ {
+ $prev_date_line eq ''
+ or print "\n";
+ print $date_line;
+ @coauthors
+ and print join ("\n", @coauthors), "\n";
+ }
+ $prev_date_line = $date_line;
+ @prev_coauthors = @coauthors;
+ $prev_multi_paragraph = $multi_paragraph;
+
+ # If there were any lines
+ if (@line == 0)
+ {
+ warn "$ME: warning: empty commit message:\n $date_line\n";
+ }
+ else
+ {
+ if ($append_dot)
+ {
+ # If the first line of the message has enough room, then
+ if (length $line[0] < 72)
+ {
+ # append a dot if there is no other punctuation or blank
+ # at the end.
+ $line[0] =~ /[[:punct:]\s]$/
+ or $line[0] .= '.';
+ }
+ }
+
+ # Remove one additional leading TAB from each line.
+ $strip_tab
+ and map { s/^\t// } @line;
+
+ # Prefix each non-empty line with a TAB.
+ @line = map { length $_ ? "\t$_" : '' } @line;
+
+ print "\n", join ("\n", @line), "\n";
+ }
+
+ defined ($in = <PIPE>)
+ or last;
+ $in ne "\n"
+ and die "$ME:$.: unexpected line:\n$in";
+ }
+
+ close PIPE
+ or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n";
+ # FIXME-someday: include $PROCESS_STATUS in the diagnostic
+
+ # Complain about any unused entry in the --amend=F specified file.
+ my $fail = 0;
+ foreach my $sha (keys %$amend_code)
+ {
+ warn "$ME:$amend_file: unused entry: $sha\n";
+ $fail = 1;
+ }
+
+ exit $fail;
+}
+
+# Local Variables:
+# mode: perl
+# indent-tabs-mode: nil
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "my $VERSION = '"
+# time-stamp-format: "%:y-%02m-%02d %02H:%02M"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "'; # UTC"
+# End:
diff --git a/conf/Makefile.common b/conf/Makefile.common
index 6128797ed..11296b550 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -7,12 +7,7 @@ unexport LC_ALL
# Platform specific options
if COND_sparc64_ieee1275
- CFLAGS_PLATFORM += -mno-app-regs
- LDFLAGS_PLATFORM = -Wl,-melf64_sparc -Wl,--no-relax
-endif
-if COND_sparc64_emu
- CFLAGS_PLATFORM += -mno-app-regs
- LDFLAGS_PLATFORM = -Wl,--no-relax
+ LDFLAGS_PLATFORM = -Wl,-melf64_sparc
endif
if COND_arm
if !COND_emu
@@ -22,9 +17,9 @@ endif
if COND_arm64
CFLAGS_PLATFORM += -mcmodel=large
endif
-
-#FIXME: discover and check XEN headers
-CPPFLAGS_XEN = -I/usr/include
+if COND_powerpc_ieee1275
+ CFLAGS_PLATFORM += -mcpu=powerpc
+endif
# Other options
@@ -35,26 +30,23 @@ CPPFLAGS_DEFAULT += -I$(top_builddir)
CPPFLAGS_DEFAULT += -I$(top_srcdir)
CPPFLAGS_DEFAULT += -I$(top_srcdir)/include
CPPFLAGS_DEFAULT += -I$(top_builddir)/include
-CPPFLAGS_DEFAULT += -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/include
CPPFLAGS_DEFAULT += -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/src/
CCASFLAGS_DEFAULT = $(CPPFLAGS_DEFAULT) -DASM_FILE=1
BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT)
-LDADD_KERNEL = $(TARGET_LIBGCC)
-
-CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
-LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC)
+CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
+LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC)
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
-STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version
+STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx
-CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
-LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
+CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
+LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
-CFLAGS_IMAGE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -fno-builtin
-LDFLAGS_IMAGE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S
+CFLAGS_IMAGE = $(CFLAGS_PLATFORM) -fno-builtin
+LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S
CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
index 51f08c1f9..b16bd9253 100644
--- a/conf/Makefile.extra-dist
+++ b/conf/Makefile.extra-dist
@@ -5,6 +5,7 @@ EXTRA_DIST += gentpl.py
EXTRA_DIST += Makefile.util.def
EXTRA_DIST += Makefile.utilgcry.def
+EXTRA_DIST += asm-tests
EXTRA_DIST += unicode
EXTRA_DIST += util/import_gcry.py
@@ -36,7 +37,6 @@ EXTRA_DIST += grub-core/lib/libgcrypt
EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic
EXTRA_DIST += $(shell find $(top_srcdir)/include -name '*.h')
EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/lib -name '*.h')
-EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/gnulib -name '*.h')
EXTRA_DIST += grub-core/efiemu/runtime/config.h
EXTRA_DIST += grub-core/lib/LzmaDec.c
@@ -50,8 +50,13 @@ EXTRA_DIST += util/import_gcrypth.sed
EXTRA_DIST += util/bin2h.c
EXTRA_DIST += util/grub-gen-asciih.c
EXTRA_DIST += util/grub-gen-widthspec.c
+EXTRA_DIST += util/grub-module-verifier.c
+EXTRA_DIST += util/grub-module-verifier32.c
+EXTRA_DIST += util/grub-module-verifier64.c
+EXTRA_DIST += util/grub-module-verifierXX.c
EXTRA_DIST += util/grub-pe2elf.c
+
EXTRA_DIST += m4/gnulib-cache.m4
EXTRA_DIST += m4/glibc2.m4
EXTRA_DIST += m4/gnulib-tool.m4
@@ -110,3 +115,26 @@ EXTRA_DIST += tests/dfly-mbr-mbexample.mbr.img.gz
EXTRA_DIST += tests/dfly-mbr-mbexample.dfly.img.gz
EXTRA_DIST += coreboot.cfg
+
+EXTRA_DIST += tests/file_filter/file
+EXTRA_DIST += tests/file_filter/file.gz
+EXTRA_DIST += tests/file_filter/file.gz.sig
+EXTRA_DIST += tests/file_filter/file.lzop
+EXTRA_DIST += tests/file_filter/file.lzop.sig
+EXTRA_DIST += tests/file_filter/file.xz
+EXTRA_DIST += tests/file_filter/file.xz.sig
+EXTRA_DIST += tests/file_filter/keys
+EXTRA_DIST += tests/file_filter/keys.pub
+EXTRA_DIST += tests/file_filter/test.cfg
+EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/prompt.cfg
+EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg
+EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg
+EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg
+EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg
+EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/txt.cfg
+EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/menu.cfg
+EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg
+EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg
+EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/po4a.cfg
+EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg
+EXTRA_DIST += tests/syslinux/ubuntu10.04_grub.cfg.in
diff --git a/config.h.in b/config.h.in
index 33a3a2487..9e8f9911b 100644
--- a/config.h.in
+++ b/config.h.in
@@ -7,11 +7,20 @@
#endif
#define GCRYPT_NO_DEPRECATED 1
+#define HAVE_MEMMOVE 1
/* Define to 1 to enable disk cache statistics. */
#define DISK_CACHE_STATS @DISK_CACHE_STATS@
#define BOOT_TIME_STATS @BOOT_TIME_STATS@
+/* We don't need those. */
+#define MINILZO_CFG_SKIP_LZO_PTR 1
+#define MINILZO_CFG_SKIP_LZO_UTIL 1
+#define MINILZO_CFG_SKIP_LZO_STRING 1
+#define MINILZO_CFG_SKIP_LZO_INIT 1
+#define MINILZO_CFG_SKIP_LZO1X_1_COMPRESS 1
+#define MINILZO_CFG_SKIP_LZO1X_DECOMPRESS 1
+
#if defined (GRUB_BUILD)
#undef ENABLE_NLS
#define BUILD_SIZEOF_LONG @BUILD_SIZEOF_LONG@
@@ -31,10 +40,6 @@
#define HAVE_FONT_SOURCE @HAVE_FONT_SOURCE@
/* Define if C symbols get an underscore after compilation. */
#define HAVE_ASM_USCORE @HAVE_ASM_USCORE@
-/* Define it to \"addr32\" or \"addr32;\" to make GAS happy. */
-#define ADDR32 @ADDR32@
-/* Define it to \"data32\" or \"data32;\" to make GAS happy. */
-#define DATA32 @DATA32@
/* Define it to one of __bss_start, edata and _edata. */
#define BSS_START_SYMBOL @BSS_START_SYMBOL@
/* Define it to either end or _end. */
@@ -51,12 +56,6 @@
#define PACKAGE_NAME "@PACKAGE_NAME@"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
-/* Default boot directory name" */
-#define GRUB_BOOT_DIR_NAME "@bootdirname@"
-/* Default grub directory name */
-#define GRUB_DIR_NAME "@grubdirname@"
-/* Define to 1 if GCC generates calls to __register_frame_info(). */
-#define NEED_REGISTER_FRAME_INFO @NEED_REGISTER_FRAME_INFO@
#define GRUB_TARGET_CPU "@GRUB_TARGET_CPU@"
#define GRUB_PLATFORM "@GRUB_PLATFORM@"
diff --git a/configure.ac b/configure.ac
index b03144471..9ddfc5323 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,20 +26,20 @@ dnl This is necessary because the target type in autoconf does not
dnl describe such a system very well.
dnl
dnl The current strategy is to use variables with no prefix (such as
-dnl CC, CFLAGS, etc.) for the host type as well as the build type,
-dnl because GRUB does not need to use those variables for the build
-dnl type, so there is no conflict. Variables with the prefix "TARGET_"
-dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
-dnl type.
+dnl CC, CFLAGS, etc.) for the host type, variables with prefix "BUILD_"
+dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables
+dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are
+dnl used for the target type. See INSTALL for full list of variables.
-AC_INIT([GRUB],[2.00],[bug-grub@gnu.org])
+AC_INIT([GRUB],[2.02~beta3],[bug-grub@gnu.org])
AC_CONFIG_AUX_DIR([build-aux])
# We don't want -g -O2 by default in CFLAGS
: ${CFLAGS=""}
-# Checks for host and target systems.
+# Checks for build, host and target systems.
+AC_CANONICAL_BUILD
AC_CANONICAL_HOST
save_program_prefix="${program_prefix}"
AC_CANONICAL_TARGET
@@ -78,30 +78,27 @@ fi
# Default HOST_CPPFLAGS
HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
-HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
-TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
-TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
case "$target_cpu" in
i[[3456]]86) target_cpu=i386 ;;
amd64) target_cpu=x86_64 ;;
sparc) target_cpu=sparc64 ;;
mipsel|mips64el)
- target_cpu=mipsel;
- machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
+ target_cpu=mipsel
+ machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1"
;;
mips|mips64)
- target_cpu=mips;
- machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
+ target_cpu=mips
+ machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1"
;;
arm*)
- target_cpu=arm;
+ target_cpu=arm
;;
aarch64*)
- target_cpu=arm64;
+ target_cpu=arm64
;;
esac
@@ -119,13 +116,17 @@ if test "x$with_platform" = x; then
x86_64-*) platform=pc ;;
powerpc-*) platform=ieee1275 ;;
powerpc64-*) platform=ieee1275 ;;
+ powerpc64le-*) platform=ieee1275 ;;
sparc64-*) platform=ieee1275 ;;
mipsel-*) platform=loongson ;;
mips-*) platform=arc ;;
ia64-*) platform=efi ;;
arm-*) platform=uboot ;;
arm64-*) platform=efi ;;
- *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
+ *)
+ AC_MSG_WARN([unsupported CPU: "$target_cpu" - only building utilities])
+ platform=none
+ ;;
esac
else
platform="$with_platform"
@@ -135,8 +136,10 @@ case "$target_cpu"-"$platform" in
x86_64-efi) ;;
x86_64-emu) ;;
x86_64-xen) ;;
+ x86_64-none) ;;
x86_64-*) target_cpu=i386 ;;
powerpc64-ieee1275) target_cpu=powerpc ;;
+ powerpc64le-ieee1275) target_cpu=powerpc ;;
esac
# Check if the platform is supported, make final adjustments.
@@ -167,6 +170,7 @@ case "$target_cpu"-"$platform" in
arm-efi) ;;
arm64-efi) ;;
*-emu) ;;
+ *-none) ;;
*) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
esac
@@ -178,7 +182,7 @@ if test x$platform != xemu ; then
fi
if test x"$target_cpu-$platform" = xsparc64-emu ; then
- target_m64=1 ;
+ target_m64=1
fi
case "$target_os" in
@@ -214,20 +218,14 @@ case "$platform" in
qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
- loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
- qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
+ loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1" ;;
+ qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1" ;;
arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
esac
-case "$target_cpu" in
- arm) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM=1" ;;
- arm64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM64=1" ;;
- mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
- sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
-esac
if test x${target_cpu} = xmipsel ; then
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
else
- machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,` -DGRUB_TARGET_CPU_`echo ${target_cpu} | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`=1"
+ machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
fi
case "${target_cpu}-$platform" in
@@ -317,7 +315,7 @@ AC_PROG_LN_S
if test "x$LEX" = "x:"; then
AC_MSG_ERROR([flex is not found])
else
- version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
+ version=`$LEX --version | $AWK '{ split($2,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
if test -n "$version" -a "$version" -ge 20535; then
:
else
@@ -355,6 +353,9 @@ if test x"$target_cpu-$platform" = xsparc64-emu ; then
HOST_CFLAGS="$HOST_CFLAGS -m64"
fi
+CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
+HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64"
+
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long)
@@ -367,6 +368,14 @@ case "$host_os" in
;;
esac
+case "$host_os" in
+ cygwin | windows* | mingw32* | aros*)
+ ;;
+ *)
+ AC_CHECK_SIZEOF(off_t)
+ test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required]);;
+esac
+
if test x$USE_NLS = xno; then
HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
fi
@@ -379,7 +388,8 @@ fi
# Check for functions and headers.
AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
-AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h)
+AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
+AC_HEADER_MAJOR
AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
#include <sys/param.h>
@@ -429,11 +439,21 @@ case "$build_os" in
haiku*) BUILD_LIBM= ;;
*) BUILD_LIBM=-lm ;;
esac
+
+dnl FIXME proper test seems to require too deep dive into Autoconf internals.
+dnl For now just list known platforms that we support.
+
+case "$build_os" in
+ cygwin*|mingw32*|mingw64*) BUILD_EXEEXT=.exe ;;
+ *) BUILD_EXEEXT= ;;
+esac
+AC_SUBST(BUILD_EXEEXT)
+
# For gnulib.
gl_INIT
-WARN_FLAGS="-Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wpointer-arith -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes"
-EXTRA_WARN_FLAGS="-Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign"
+WARN_FLAGS="-Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes"
+EXTRA_WARN_FLAGS="-Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2"
HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
@@ -483,6 +503,7 @@ AC_SUBST(HOST_CC)
AC_SUBST(BUILD_CC)
AC_SUBST(BUILD_CFLAGS)
AC_SUBST(BUILD_CPPFLAGS)
+AC_SUBST(BUILD_LDFLAGS)
AC_SUBST(TARGET_CC)
AC_SUBST(TARGET_NM)
AC_SUBST(TARGET_RANLIB)
@@ -509,6 +530,8 @@ if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
fi
+TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)"
+
AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
@@ -529,7 +552,7 @@ int main (void);
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
-AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang]
+AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang],
[
CFLAGS="$TARGET_CFLAGS"
AC_COMPILE_IFELSE(
@@ -540,36 +563,149 @@ AC_COMPILE_IFELSE(
]])],
[grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
-# on x86 clang doesn't support .code16
-# on arm clang doesn't support .arch directive
-# on mips clang doesn't support privilegied instructions, doubleword store/load
-# and crashes with hand-written assembly
-if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \
- || test "x$target_cpu" = xx86_64 || test "x$target_cpu" = xarm \
- || test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ); then
- TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
+if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
+ AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
+ grub_cv_target_cc_big_endian=no
+ for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
+ "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \
+ "-EB" "-mbig-endian"; do
+ if test x"$grub_cv_target_cc_big_endian" != xno ; then
+ break
+ fi
+ CFLAGS="$TARGET_CFLAGS $cand -Werror"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__)
+#error still little endian
+#endif
+asm (".globl start; start:");
+asm (".globl _start; _start:");
+asm (".globl __start; __start:");
+void __main (void);
+void __main (void) {}
+int main (void);
+]], [[]])],
+ [grub_cv_target_cc_big_endian="$cand"], [])
+ done
+ ])
+
+ if test x"$grub_cv_target_cc_big_endian" = xno ; then
+ AC_MSG_ERROR([could not force big-endian])
+ fi
+
+ skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')"
+
+ TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
+ TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
+ TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
+ TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
+elif test x$target_cpu = xmipsel; then
+ AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [
+ grub_cv_target_cc_little_endian=no
+ for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
+ "-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \
+ "-EL"; do
+ if test x"$grub_cv_target_cc_little_endian" != xno ; then
+ break
+ fi
+ CFLAGS="$TARGET_CFLAGS $cand -Werror"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
+#error still big endian
+#endif
+asm (".globl start; start:");
+asm (".globl _start; _start:");
+asm (".globl __start; __start:");
+void __main (void);
+void __main (void) {}
+int main (void);
+]], [[]])],
+ [grub_cv_target_cc_little_endian="$cand"], [])
+ done
+ ])
+
+ if test x"$grub_cv_target_cc_little_endian" = xno ; then
+ AC_MSG_ERROR([could not force little-endian])
+ fi
+
+ skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')"
+
+ TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
+ TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
+ TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
+ TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
fi
-if test "x$grub_cv_cc_target_clang" = xyes && test "x$target_cpu" = xpowerpc; then
-AC_CACHE_CHECK([if clang can handle ame instruction], [grub_cv_cc_target_clang_ame]
-[
-CFLAGS="$TARGET_CFLAGS"
-AC_COMPILE_IFELSE(
-[AC_LANG_PROGRAM([], [[
- unsigned int a = 0, b = 0;
- asm volatile ("{ame|addme} %0,%1" : "=r" (a) : "r" (b));
- if (a)
- return 1;
-]])],
-[grub_cv_cc_target_clang_ame=yes], [grub_cv_cc_target_clang_ame=no])])
- # clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly
- # used by gcrypt
- if test x$grub_cv_cc_target_clang_ame = xno ; then
- TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
- TARGET_CFLAGS="$TARGET_CFLAGS -no-integrated-as"
- fi
+# GRUB code is N32-compliant but it's experimental and we would prefer to
+# avoid having too much variety when it doesn't result in any real improvement.
+# Moreover N64 isn't supported.
+if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
+ AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
+ grub_cv_target_cc_mips_o32_abi=no
+ for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
+ if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
+ break
+ fi
+ CFLAGS="$TARGET_CFLAGS $arg -Werror"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
+#error not o32 ABI
+#endif
+asm (".globl start; start:");
+asm (".globl _start; _start:");
+asm (".globl __start; __start:");
+void __main (void);
+void __main (void) {}
+int main (void);
+]], [[]])],
+ [grub_cv_target_cc_mips_o32_abi="$arg"], [])
+ done
+ ])
+
+ if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
+ AC_MSG_ERROR([could not force MIPS o32 ABI])
+ fi
+
+ TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
+ TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
fi
+AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
+test_program=
+case "x$target_cpu-$platform" in
+ xmips-* | xmipsel-*)
+ test_program=mips
+ ;;
+ xi386-pc)
+ test_program=i386-pc
+ ;;
+ xi386-* | xx86_64-*)
+ test_program=i386
+ ;;
+ xpowerpc-* | xsparc64-* | xarm-*)
+ test_program=$target_cpu
+ ;;
+esac
+if test x"$test_program" = x ; then
+ grub_cv_cc_target_asm_compile=
+else
+ found=no
+ for arg in "" "-no-integrated-as"; do
+ cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
+ echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
+ if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
+ grub_cv_cc_target_asm_compile="$arg"
+ found=yes
+ break
+ fi
+ done
+ if test x"$found" = xno ; then
+ AC_MSG_ERROR([could not compile assembly])
+ fi
+fi
+])
+
+TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
+
if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
fi
@@ -648,7 +784,103 @@ fi
if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
# Some toolchains enable these features by default, but they need
# registers that aren't set up properly in GRUB.
- TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
+ TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
+fi
+
+# GRUB doesn't use float or doubles at all. Yet some toolchains may decide
+# that floats are a good fit to run instead of what's written in the code.
+# Given that floating point unit is disabled (if present to begin with)
+# when GRUB is running which may result in various hard crashes.
+if test x"$platform" != xemu ; then
+ AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
+ grub_cv_target_cc_soft_float=no
+ if test "x$target_cpu" = xarm64; then
+ CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
+ fi
+ if test "x$target_cpu" = xia64; then
+ CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], [])
+ fi
+ for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \
+ "-Xclang -msoft-float -Xclang -no-implicit-float" \
+ "-Xclang -msoft-float" "-msoft-float"; do
+ if test x"$grub_cv_target_cc_soft_float" != xno ; then
+ break
+ fi
+ CFLAGS="$TARGET_CFLAGS $cand -Werror"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_target_cc_soft_float="$cand"], [])
+ done
+ ])
+
+ if test x"$grub_cv_target_cc_soft_float" = xno ; then
+ AC_MSG_ERROR([could not force soft-float])
+ fi
+
+ case x"$grub_cv_target_cc_soft_float" in
+ x*"-Xclang"*)
+ # A trick so that clang doesn't see it on link stаge
+ TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float"
+ ;;
+ *)
+ TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
+ ;;
+ esac
+ TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
+
+fi
+
+if test x"$target_cpu" = xsparc64 ; then
+ AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [
+ grub_cv_target_cc_mno_app_regs=no
+ for cand in "-mllvm -sparc-reserve-app-registers" \
+ "-mno-app-regs"; do
+ if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then
+ break
+ fi
+ CFLAGS="$TARGET_CFLAGS $cand -Werror"
+ CPPFLAGS="$TARGET_CPPFLAGS"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_target_cc_mno_app_regs="$cand"], [])
+ done
+ ])
+
+ if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then
+ AC_MSG_ERROR([could not reserve application registers])
+ fi
+ if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then
+ # A trick so that clang doesn't see it on link stаge
+ TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs"
+ else
+ TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs"
+ fi
+
+ AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
+ grub_cv_target_cc_mno_relax=no
+ for cand in "-mno-relax" "-Wl,--no-relax"; do
+ if test x"$grub_cv_target_cc_mno_relax" != xno ; then
+ break
+ fi
+ LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static"
+ CFLAGS="$TARGET_CFLAGS -Werror"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+ asm (".globl start; start:");
+ void __main (void);
+ void __main (void) {}
+ int main (void);
+ ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
+ done
+ ])
+ LDFLAGS="$TARGET_LDFLAGS"
+ CFLAGS="$TARGET_CFLAGS"
+
+ if test x"$grub_cv_target_cc_mno_relax" = xno ; then
+ AC_MSG_ERROR([could not find no-relax options])
+ fi
+ TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax"
fi
# By default, GCC 4.4 generates .eh_frame sections containing unwind
@@ -679,12 +911,24 @@ if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xy
TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
fi
+AC_CACHE_CHECK([whether -mno-stack-arg-probe works], [grub_cv_cc_mno_stack_arg_probe], [
+ CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_cc_mno_stack_arg_probe=yes],
+ [grub_cv_cc_mno_stack_arg_probe=no])
+])
+
+if test "x$grub_cv_cc_mno_stack_arg_probe" = xyes; then
+ TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
+fi
+
+
# By default, GCC 4.6 generates .eh_frame sections containing unwind
# information in some cases where it previously did not. GRUB doesn't need
# these and they just use up vital space. Restore the old compiler
# behaviour.
AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
- CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
+ CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_fno_asynchronous_unwind_tables=yes],
[grub_cv_cc_fno_asynchronous_unwind_tables=no])
@@ -694,77 +938,49 @@ if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
fi
-AC_ARG_ENABLE([efiemu],
- [AS_HELP_STRING([--enable-efiemu],
- [build and install the efiemu runtimes (default=guessed)])])
-if test x"$enable_efiemu" = xno ; then
- efiemu_excuse="explicitly disabled"
-fi
-if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
- efiemu_excuse="not available on cygwin"
-fi
-if test x"$target_cpu" != xi386 ; then
- efiemu_excuse="only available on i386"
-fi
-if test x"$platform" = xefi ; then
- efiemu_excuse="not available on efi"
-fi
-if test x"$efiemu_excuse" = x ; then
- AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
- CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
- [grub_cv_cc_efiemu=yes],
- [grub_cv_cc_efiemu=no])
- ])
- if test x$grub_cv_cc_efiemu = xno; then
- efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
- fi
-fi
-if test x"$efiemu_excuse" = x ; then
- AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
- grub_cv_target_cc_efiemu64_link_format=unknown
- for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
- CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
- LDFLAGS="-m64 -Wl,$format -nostdlib -static"
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[
- asm (".globl start; start:");
- asm (".globl _start; _start:");
- asm (".globl __start; __start:");
- void __main (void);
- void __main (void) {}
- ]], [[]])], [flag=1], [flag=0])
- if test x"$flag" = x1; then
- grub_cv_target_cc_efiemu64_link_format="$format"
- break;
- fi
- done])
- if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
- efiemu_excuse="no suitable link format for efiemu64 found"
- else
- EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
- fi
-fi
-if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
- AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
-fi
-if test x"$efiemu_excuse" = x ; then
-enable_efiemu=yes
-else
-enable_efiemu=no
+AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [
+ CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_cc_fno_unwind_tables=yes],
+ [grub_cv_cc_fno_unwind_tables=no])
+])
+
+if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then
+ TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
fi
-AC_SUBST([enable_efiemu])
-AC_SUBST([EFIEMU64_LINK_FORMAT])
+
CFLAGS="$TARGET_CFLAGS"
-if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
+
+if test x"$platform" = xemu ; then
+ TARGET_OBJ2ELF=
+ grub_cv_target_cc_link_format=
+ case "$host_os" in
+ *darwin* | *mac*)
+ grub_cv_target_cc_link_format="-arch,${target_cpu}"
+ TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
+ ;;
+ *windows* | *cygwin* | *mingw*)
+ if test x${target_cpu} = xi386 ; then
+ grub_cv_target_cc_link_format=-mi386pe
+ TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
+ fi
+ if test x${target_cpu} = xx86_64 ; then
+ grub_cv_target_cc_link_format=-mi386pep
+ TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
+ fi
+ TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
+ ;;
+ esac
+elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
grub_cv_target_cc_link_format=unknown
for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -mi386pe -mi386pep -arch,${target_cpu}; do
- if test x${target_cpu} != xi386 && test x$format = xi386pe; then
+ if test x${target_cpu} != xi386 && test x$format = x-mi386pe; then
continue
fi
- if test x${target_cpu} != xx86_64 && test x$format = xi386pep; then
+ if test x${target_cpu} != xx86_64 && test x$format = x-mi386pep; then
continue
fi
CFLAGS="$TARGET_CFLAGS"
@@ -778,7 +994,7 @@ if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
]], [[]])], [flag=1], [flag=0])
if test x"$flag" = x1; then
grub_cv_target_cc_link_format="$format"
- break;
+ break
fi
done])
if test x"$grub_cv_target_cc_link_format" = xunknown; then
@@ -786,10 +1002,10 @@ if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
fi
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
- TARGET_OBJ2ELF='./build-grub-pe2elf';
+ TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
fi
if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
- TARGET_OBJ2ELF='./build-grub-pep2elf';
+ TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
fi
fi
@@ -826,22 +1042,89 @@ else
TARGET_IMG_CFLAGS=
fi
+CFLAGS="$TARGET_CFLAGS"
+
+AC_ARG_ENABLE([efiemu],
+ [AS_HELP_STRING([--enable-efiemu],
+ [build and install the efiemu runtimes (default=guessed)])])
+if test x"$enable_efiemu" = xno ; then
+ efiemu_excuse="explicitly disabled"
+fi
+
+if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
+ efiemu_excuse="not available on cygwin"
+fi
+if test x"$target_cpu" != xi386 ; then
+ efiemu_excuse="only available on i386"
+fi
+if test x"$platform" = xefi ; then
+ efiemu_excuse="not available on efi"
+fi
+
+if test x"$efiemu_excuse" = x ; then
+ AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
+ CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_cc_efiemu=yes],
+ [grub_cv_cc_efiemu=no])
+ ])
+ if test x$grub_cv_cc_efiemu = xno; then
+ efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
+ fi
+fi
+if test x"$efiemu_excuse" = x ; then
+ AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
+ grub_cv_target_cc_efiemu64_link_format=unknown
+ for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
+ CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
+ LDFLAGS="-m64 -Wl,$format -nostdlib -static"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+ asm (".globl start; start:");
+ asm (".globl _start; _start:");
+ asm (".globl __start; __start:");
+ void __main (void);
+ void __main (void) {}
+ ]], [[]])], [flag=1], [flag=0])
+ if test x"$flag" = x1; then
+ grub_cv_target_cc_efiemu64_link_format="$format"
+ break
+ fi
+ done])
+ if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
+ efiemu_excuse="no suitable link format for efiemu64 found"
+ else
+ EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
+ fi
+fi
+if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
+ AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)])
+fi
+if test x"$efiemu_excuse" = x ; then
+enable_efiemu=yes
+else
+enable_efiemu=no
+fi
+AC_SUBST([enable_efiemu])
+AC_SUBST([EFIEMU64_LINK_FORMAT])
+
+CFLAGS="$TARGET_CFLAGS"
+
AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
LDFLAGS="$TARGET_LDFLAGS"
-if test "$target_cpu" = x86_64 || test "$target_cpu-$platform" = sparc64-emu ; then
+if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then
# Use large model to support 4G memory
AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
- CFLAGS="$TARGET_CFLAGS -m64 -mcmodel=large"
+ CFLAGS="$TARGET_CFLAGS -mcmodel=large"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_mcmodel=yes],
[grub_cv_cc_mcmodel=no])
])
if test "x$grub_cv_cc_mcmodel" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
- elif test "$target_cpu-$platform" = sparc64-emu; then
+ elif test "$target_cpu" = sparc64; then
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
fi
fi
@@ -849,7 +1132,7 @@ fi
if test "$target_cpu"-"$platform" = x86_64-efi; then
# EFI writes to stack below %rsp, we must not use the red zone
AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
- CFLAGS="$TARGET_CFLAGS -m64 -mno-red-zone"
+ CFLAGS="$TARGET_CFLAGS -mno-red-zone"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_no_red_zone=yes],
[grub_cv_cc_no_red_zone=no])
@@ -879,23 +1162,21 @@ if test "x$target_cpu" = xarm; then
])
if test "x$grub_cv_cc_mthumb_interwork" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork"
+ # Clang defaults to thumb interworking
elif test "x$grub_cv_cc_target_clang" = xno ; then
AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork])
- else
- CFLAGS="$TARGET_CFLAGS"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
-#if defined (__thumb__) && !defined (__thumb2__)
-#error thumb without interworking
-#endif
-]])],
- [no_interwork_ok=yes],
- [no_interwork_ok=no])
- if test x$no_interwork_ok = xno ; then
- AC_MSG_ERROR([attempt to compile to thumb with no thumb interwork])
- fi
fi
fi
+AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [
+ CFLAGS="$TARGET_CFLAGS -Qn -Werror"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_target_cc_qn=yes],
+ [grub_cv_target_cc_qn=no])])
+if test "x$grub_cv_target_cc_qn" = xyes; then
+ TARGET_CFLAGS="$TARGET_CFLAGS -Qn"
+fi
+
#
# Compiler features.
#
@@ -905,9 +1186,9 @@ CFLAGS="$TARGET_CFLAGS"
# Position independent executable.
grub_CHECK_PIE
[# Need that, because some distributions ship compilers that include
-# `-fPIE' in the default specs.
+# `-fPIE' or '-fpie' in the default specs.
if [ x"$pie_possible" = xyes ]; then
- TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
+ TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie"
fi]
CFLAGS="$TARGET_CFLAGS"
@@ -958,7 +1239,7 @@ if test "$target_cpu" = arm; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
if test x"$flag" = x1; then
grub_cv_target_cc_strict_align="$arg"
- break;
+ break
fi
done])
@@ -981,22 +1262,17 @@ fi
# Set them to their new values for the tests below.
CC="$TARGET_CC"
-if test "x$TARGET_APPLE_LINKER" = x1 ; then
+if test x"$platform" = xemu ; then
+CFLAGS="$TARGET_CFLAGS -Wno-error"
+elif test "x$TARGET_APPLE_LINKER" = x1 ; then
CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
else
CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
fi
CPPFLAGS="$TARGET_CPPFLAGS"
-if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then
-TARGET_LIBGCC=
-else
-TARGET_LIBGCC=-lgcc
-fi
-
-LIBS="$TARGET_LIBGCC"
grub_ASM_USCORE
-if test "x$TARGET_APPLE_LINKER" = x0 ; then
+if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then
if test x$grub_cv_asm_uscore = xyes; then
DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main"
else
@@ -1006,7 +1282,9 @@ CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM"
fi
# Check for libgcc symbols
-AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x)
+if test x"$platform" = xemu; then
+AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms)
+fi
if test "x$TARGET_APPLE_LINKER" = x1 ; then
CFLAGS="$TARGET_CFLAGS -nostdlib -static"
@@ -1031,8 +1309,6 @@ if test "x$target_cpu" = xi386; then
grub_CHECK_END_SYMBOL
fi
CFLAGS="$TARGET_CFLAGS"
- grub_I386_ASM_PREFIX_REQUIREMENT
- grub_I386_ASM_ADDR32
fi
grub_PROG_NM_WORKS
@@ -1110,10 +1386,6 @@ else
fi
AC_SUBST([BOOT_TIME_STATS])
-AC_ARG_ENABLE([grub-emu-usb],
- [AS_HELP_STRING([--enable-grub-emu-usb],
- [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
-
AC_ARG_ENABLE([grub-emu-sdl],
[AS_HELP_STRING([--enable-grub-emu-sdl],
[build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
@@ -1124,36 +1396,8 @@ AC_ARG_ENABLE([grub-emu-pci],
if test "$platform" = emu; then
-if test x"$enable_grub_emu_usb" != xyes ; then
- grub_emu_usb_excuse="not enabled"
-fi
-
-if test x"$enable_grub_emu_pci" = xyes ; then
- grub_emu_usb_excuse="conflicts with PCI support"
-fi
-
-[if [ x"$grub_emu_usb_excuse" = x ]; then
- # Check for libusb libraries.]
-AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
- [grub_emu_usb_excuse=["need libusb library"]])
- AC_SUBST([LIBUSB])
-[fi]
-[if [ x"$grub_emu_usb_excuse" = x ]; then
- # Check for headers.]
- AC_CHECK_HEADERS([usb.h], [],
- [grub_emu_usb_excuse=["need libusb headers"]])
-[fi]
-if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
- AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
-fi
-if test x"$grub_emu_usb_excuse" = x ; then
-enable_grub_emu_usb=yes
-else
-enable_grub_emu_usb=no
-fi
-
if test x"$enable_grub_emu_sdl" = xno ; then
- grub_emu_sdl_excuse="explicitely disabled"
+ grub_emu_sdl_excuse="explicitly disabled"
fi
[if [ x"$grub_emu_sdl_excuse" = x ]; then
# Check for libSDL libraries.]
@@ -1169,7 +1413,7 @@ AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
[fi]
if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
- AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
+ AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)])
fi
if test x"$grub_emu_sdl_excuse" = x ; then
enable_grub_emu_sdl=yes
@@ -1181,10 +1425,6 @@ if test x"$enable_grub_emu_pci" != xyes ; then
grub_emu_pci_excuse="not enabled"
fi
-if test x"$enable_grub_emu_usb" = xyes ; then
- grub_emu_pci_excuse="conflicts with USB support"
-fi
-
[if [ x"$grub_emu_pci_excuse" = x ]; then
# Check for libpci libraries.]
AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
@@ -1193,7 +1433,7 @@ fi
[fi]
[if [ x"$grub_emu_pci_excuse" = x ]; then
# Check for headers.]
- AC_CHECK_HEADERS([pci/pci.h], [],
+ AC_CHECK_HEADERS([pciaccess.h], [],
[grub_emu_pci_excuse=["need libpciaccess headers"]])
[fi]
@@ -1205,14 +1445,12 @@ enable_grub_emu_pci=no
fi
AC_SUBST([enable_grub_emu_sdl])
-AC_SUBST([enable_grub_emu_usb])
AC_SUBST([enable_grub_emu_pci])
else
# Ignore --enable-emu-* if platform is not emu
enable_grub_emu_sdl=no
-enable_grub_emu_usb=no
enable_grub_emu_pci=no
fi
@@ -1249,7 +1487,7 @@ if test x"$grub_mkfont_excuse" = x ; then
fi
if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
- AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
+ AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled ($grub_mkfont_excuse)])
fi
if test x"$grub_mkfont_excuse" = x ; then
enable_grub_mkfont=yes
@@ -1264,10 +1502,12 @@ SAVED_CC="$CC"
SAVED_CPP="$CPP"
SAVED_CFLAGS="$CFLAGS"
SAVED_CPPFLAGS="$CPPFLAGS"
+SAVED_LDFLAGS="$LDFLAGS"
CC="$BUILD_CC"
CPP="$BUILD_CPP"
CFLAGS="$BUILD_CFLAGS"
CPPFLAGS="$BUILD_CPPFLAGS"
+LDFLAGS="$BUILD_LDFAGS"
unset ac_cv_c_bigendian
unset ac_cv_header_ft2build_h
@@ -1308,7 +1548,7 @@ if test x"$grub_build_mkfont_excuse" = x ; then
fi
if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
- AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled])
+ AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled ($grub_build_mkfont_excuse)])
fi
if test x"$grub_build_mkfont_excuse" = x ; then
enable_build_grub_mkfont=yes
@@ -1316,7 +1556,11 @@ else
enable_build_grub_mkfont=no
fi
if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
- AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont])
+ if test x"$grub_build_mkfont_excuse" = x ; then
+ AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont])
+ else
+ AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont ($grub_build_mkfont_excuse)])
+ fi
fi
AC_SUBST([build_freetype_cflags])
@@ -1326,6 +1570,7 @@ CC="$SAVED_CC"
CPP="$SAVED_CPP"
CFLAGS="$SAVED_CFLAGS"
CPPFLAGS="$SAVED_CPPFLAGS"
+LDFLAGS="$SAVED_LDFLAGS"
DJVU_FONT_SOURCE=
@@ -1345,7 +1590,7 @@ fi
if test x"$starfield_excuse" = x; then
for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
- for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
+ for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do
if test -f "$dir/DejaVuSans.$ext"; then
DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
break 2
@@ -1359,7 +1604,7 @@ if test x"$starfield_excuse" = x; then
fi
if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
- AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied])
+ AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied ($starfield_excuse)])
fi
AC_SUBST([DJVU_FONT_SOURCE])
@@ -1372,7 +1617,7 @@ for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
# PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
- continue;
+ continue
fi
FONT_SOURCE="$dir/unifont.$ext"
break 2
@@ -1385,7 +1630,11 @@ if test x"$enable_build_grub_mkfont" = xno ; then
fi
if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
- AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont])
+ if test x"$grub_build_mkfont_excuse" = x ; then
+ AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont])
+ else
+ AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)])
+ fi
fi
AC_SUBST([FONT_SOURCE])
@@ -1410,14 +1659,14 @@ fi
if test x"$grub_mount_excuse" = x ; then
# Check for fuse headers.
SAVED_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
+ CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26"
AC_CHECK_HEADERS([fuse/fuse.h], [],
[grub_mount_excuse=["need FUSE headers"]])
CPPFLAGS="$SAVED_CPPFLAGS"
fi
if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
- AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
+ AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled ($grub_mount_excuse)])
fi
if test x"$grub_mount_excuse" = x ; then
enable_grub_mount=yes
@@ -1453,7 +1702,7 @@ if test x"$device_mapper_excuse" = x ; then
fi
if test x"$device_mapper_excuse" = x ; then
- LIBDEVMAPPER="-ldevmapper";
+ LIBDEVMAPPER="-ldevmapper"
AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
[Define to 1 if you have the devmapper library.])
fi
@@ -1485,7 +1734,7 @@ AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
fi
if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
- AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied])
+ AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied ($liblzma_excuse)])
fi
@@ -1522,7 +1771,7 @@ if test x"$libzfs_excuse" = x ; then
fi
if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
- AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied])
+ AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied ($libzfs_excuse)])
fi
if test x"$libzfs_excuse" = x ; then
@@ -1545,13 +1794,10 @@ AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
[AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
AC_SUBST(HAVE_ASM_USCORE)
-AC_SUBST(ADDR32)
-AC_SUBST(DATA32)
AC_SUBST(BSS_START_SYMBOL)
AC_SUBST(END_SYMBOL)
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
-AC_SUBST(NEED_REGISTER_FRAME_INFO)
AC_ARG_ENABLE([werror],
[AS_HELP_STRING([--disable-werror],
@@ -1561,15 +1807,15 @@ if test x"$enable_werror" != xno ; then
HOST_CFLAGS="$HOST_CFLAGS -Werror"
fi
-if test "x$grub_cv_cc_target_clang" = xno; then
- TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc"
-else
- TARGET_LDFLAGS_STATIC_LIBGCC=
-fi
-
TARGET_CPP="$TARGET_CC -E"
TARGET_CCAS=$TARGET_CC
+# Includes which include make-time substitutions. They must come last
+# as to avoid executing top_builddir in shell.
+HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
+TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
+TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
+
GRUB_TARGET_CPU="${target_cpu}"
GRUB_PLATFORM="${platform}"
@@ -1577,12 +1823,11 @@ AC_SUBST(GRUB_TARGET_CPU)
AC_SUBST(GRUB_PLATFORM)
AC_SUBST(TARGET_OBJCONV)
-AC_SUBST(TARGET_LIBGCC)
-AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC)
AC_SUBST(TARGET_CPP)
AC_SUBST(TARGET_CCAS)
AC_SUBST(TARGET_OBJ2ELF)
AC_SUBST(TARGET_MODULE_FORMAT)
+AC_SUBST(TARGET_CC_VERSION)
AC_SUBST(TARGET_CFLAGS)
AC_SUBST(TARGET_LDFLAGS)
@@ -1605,8 +1850,8 @@ AC_SUBST(BUILD_LIBM)
# Automake conditionals
#
+AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
-AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes])
AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
@@ -1632,10 +1877,15 @@ AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
+AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
+AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
+AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
+AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
+AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
+AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
-AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
@@ -1672,24 +1922,30 @@ AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
# Output files.
-cpudir="${target_cpu}"
-if test x${cpudir} = xmipsel; then
- cpudir=mips;
-fi
-grub_CHECK_LINK_DIR
-if test x"$link_dir" = xyes ; then
- AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
- if test "$platform" != emu ; then
- AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
+if test "$platform" != none; then
+ cpudir="${target_cpu}"
+ if test x${cpudir} = xmipsel; then
+ cpudir=mips;
fi
-else
- mkdir -p include/grub 2>/dev/null
- rm -rf include/grub/cpu
- cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
- if test "$platform" != emu ; then
- rm -rf include/grub/machine
- cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
+ grub_CHECK_LINK_DIR
+ if test x"$link_dir" = xyes ; then
+ AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
+ if test "$platform" != emu ; then
+ AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
+ fi
+ else
+ mkdir -p include/grub 2>/dev/null
+ rm -rf include/grub/cpu
+ cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
+ if test "$platform" != emu ; then
+ rm -rf include/grub/machine
+ cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
+ fi
fi
+else
+ # Just enough to stop the compiler failing with -I$(srcdir)/include.
+ mkdir -p include 2>/dev/null
+ rm -rf include/grub/cpu include/grub/machine
fi
AC_CONFIG_FILES([Makefile])
@@ -1707,11 +1963,6 @@ echo "*******************************************************"
echo GRUB2 will be compiled with following components:
echo Platform: "$target_cpu"-"$platform"
if [ x"$platform" = xemu ]; then
-if [ x"$grub_emu_usb_excuse" = x ]; then
-echo USB support for grub-emu: Yes
-else
-echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
-fi
if [ x"$grub_emu_sdl_excuse" = x ]; then
echo SDL support for grub-emu: Yes
else
@@ -1762,6 +2013,7 @@ echo grub-mount: No "($grub_mount_excuse)"
fi
if [ x"$starfield_excuse" = x ]; then
echo starfield theme: Yes
+echo With DejaVuSans font from $DJVU_FONT_SOURCE
else
echo starfield theme: No "($starfield_excuse)"
fi
diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi
index c79685052..a9f4de631 100644
--- a/docs/grub-dev.texi
+++ b/docs/grub-dev.texi
@@ -108,16 +108,16 @@ The branches available are:
@table @samp
@item master
- Main developpement branch.
+ Main development branch.
@item grub-legacy
GRUB 0.97 codebase. Kept for reference and legal reasons
@item multiboot
Multiboot specfication
@item multiboot2
Multiboot2 specfication
-@item developper branches
- Prefixed with developper name. Every developper of a team manages his own branches.
- Developper branches do not need changelog entries.
+@item developer branches
+ Prefixed with developer name. Every developer of a team manages his own branches.
+ Developer branches do not need changelog entries.
@end table
Once you have used @kbd{git clone} to fetch an initial copy of a branch, you
@@ -228,12 +228,12 @@ The opening @samp{/*} and closing @samp{*/} should be placed together on a line
Here is a brief map of the GRUB code base.
GRUB uses Autoconf and Automake, with most of the Automake input generated
-by AutoGen. The top-level build rules are in @file{configure.ac},
+by a Python script. The top-level build rules are in @file{configure.ac},
@file{grub-core/Makefile.core.def}, and @file{Makefile.util.def}. Each
block in a @file{*.def} file represents a build target, and specifies the
source files used to build it on various platforms. The @file{*.def} files
-are processed into AutoGen input by @file{gentpl.py} (which you only need to
-look at if you are extending the build system). If you are adding a new
+are processed into Automake input by @file{gentpl.py} (which you only need
+to look at if you are extending the build system). If you are adding a new
module which follows an existing pattern, such as a new command or a new
filesystem implementation, it is usually easiest to grep
@file{grub-core/Makefile.core.def} and @file{Makefile.util.def} for an
diff --git a/docs/grub.texi b/docs/grub.texi
index 91fa1de5d..82f6fa459 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -2538,6 +2538,8 @@ team are:
85:3
@item Asus EeePC 1005PE
84:1 (unconfirmed)
+@item LENOVO ThinkPad T410s (2912W1C)
+101:3
@end table
To take full advantage of this function, install GRUB into the MBR
@@ -3038,6 +3040,8 @@ These variables have special meaning to GRUB.
* cmdpath::
* color_highlight::
* color_normal::
+* config_directory::
+* config_file::
* debug::
* default::
* fallback::
@@ -3180,6 +3184,22 @@ matching colors of first half.
to support whole rgb24 palette but currently there is no compelling reason
to go beyond the current 16 colors.
+
+@node config_directory
+@subsection config_directory
+
+This variable is automatically set by GRUB to the directory part of
+current configuration file name (@pxref{config_file}).
+
+
+@node config_file
+@subsection config_file
+
+This variable is automatically set by GRUB to the name of configuration file that is being
+processed by commands @command{configfile} (@pxref{configfile}) or @command{normal}
+(@pxref{normal}). It is restored to the previous value when command completes.
+
+
@node debug
@subsection debug
@@ -3839,6 +3859,11 @@ you forget a command, you can run the command @command{help}
@comment * vbeinfo:: List available video modes
* verify_detached:: Verify detached digital signature
* videoinfo:: List available video modes
+@comment * xen_*:: Xen boot commands
+* xen_hypervisor:: Load xen hypervisor binary
+* xen_linux:: Load dom0 kernel for xen hypervisor
+* xen_initrd:: Load dom0 initrd for dom0 kernel
+* xen_xsm:: Load xen security module for xen hypervisor
@end menu
@@ -4050,12 +4075,15 @@ after @command{configfile} returns.
@node cpuid
@subsection cpuid
-@deffn Command cpuid [-l]
+@deffn Command cpuid [-l] [-p]
Check for CPU features. This command is only available on x86 systems.
With the @option{-l} option, return true if the CPU supports long mode
(64-bit).
+With the @option{-p} option, return true if the CPU supports Physical
+Address Extension (PAE).
+
If invoked without options, this command currently behaves as if it had been
invoked with @option{-l}. This may change in the future.
@end deffn
@@ -5019,6 +5047,8 @@ the length of @var{string} is zero
@var{expression} is false
@item @var{expression1} @code{-a} @var{expression2}
both @var{expression1} and @var{expression2} are true
+@item @var{expression1} @var{expression2}
+both @var{expression1} and @var{expression2} are true. This syntax is not POSIX-compliant and is not recommended.
@item @var{expression1} @code{-o} @var{expression2}
either @var{expression1} or @var{expression2} is true
@end table
@@ -5102,6 +5132,39 @@ successfully. If validation fails, it is set to a non-zero value.
List available video modes. If resolution is given, show only matching modes.
@end deffn
+@node xen_hypervisor
+@subsection xen_hypervisor
+
+@deffn Command xen_hypervisor file [arguments] @dots{}
+Load a Xen hypervisor binary from @var{file}. The rest of the line is passed
+verbatim as the @dfn{kernel command-line}. Any other binaries must be
+reloaded after using this command.
+@end deffn
+
+@node xen_linux
+@subsection xen_linux
+
+@deffn Command xen_linux file [arguments]
+Load a dom0 kernel image for xen hypervisor at the booting process of xen.
+The rest of the line is passed verbatim as the module command line.
+@end deffn
+
+@node xen_initrd
+@subsection xen_initrd
+
+@deffn Command xen_initrd file
+Load a initrd image for dom0 kernel at the booting process of xen.
+@end deffn
+
+@node xen_xsm
+@subsection xen_xsm
+
+@deffn Command xen_xsm file
+Load a xen security module for xen hypervisor at the booting process of xen.
+See @uref{http://wiki.xen.org/wiki/XSM} for more detail.
+@end deffn
+
+
@node Networking commands
@section The list of networking commands
@@ -5162,8 +5225,10 @@ by @var{shortname} which can be used to remove it (@pxref{net_del_route}).
Perform configuration of @var{card} using DHCP protocol. If no card name
is specified, try to configure all existing cards. If configuration was
successful, interface with name @var{card}@samp{:dhcp} and configured
-address is added to @var{card}. If server provided gateway information in
-DHCP ACK packet, it is added as route entry with the name @var{card}@samp{:dhcp:gw}. Additionally the following DHCP options are recognized and processed:
+address is added to @var{card}.
+@comment If server provided gateway information in
+@comment DHCP ACK packet, it is added as route entry with the name @var{card}@samp{:dhcp:gw}.
+Additionally the following DHCP options are recognized and processed:
@table @samp
@item 1 (Subnet Mask)
@@ -5426,10 +5491,12 @@ In order to enable authentication support, the @samp{superusers} environment
variable must be set to a list of usernames, separated by any of spaces,
commas, semicolons, pipes, or ampersands. Superusers are permitted to use
the GRUB command line, edit menu entries, and execute any menu entry. If
-@samp{superusers} is set, then use of the command line is automatically
-restricted to superusers.
+@samp{superusers} is set, then use of the command line and editing of menu
+entries are automatically restricted to superusers. Setting @samp{superusers}
+to empty string effectively disables both access to CLI and editing of menu
+entries.
-Other users may be given access to specific menu entries by giving a list of
+Other users may be allowed to execute specific menu entries by giving a list of
usernames (as above) using the @option{--users} option to the
@samp{menuentry} command (@pxref{menuentry}). If the @option{--unrestricted}
option is used for a menu entry, then that entry is unrestricted.
@@ -5609,6 +5676,16 @@ BadRAM is the ability to mark some of the RAM as ``bad''. Note: due to protocol
limitations mips-loongson (with Linux protocol)
and mips-qemu_mips can use only memory up to first hole.
+Bootlocation is ability of GRUB to automatically detect where it boots from.
+``disk'' means the detection is limited to detecting the disk with partition
+being discovered on install time. ``partition'' means that disk and partiton
+can be automatically discovered. ``file'' means that boot image file name as
+well as disk and partition can be discovered. For consistency default install ignores
+partition and relies solely on disk detection. If no bootlocation discovery is available
+or boot and grub-root disks are different, UUID is used instead. On ARC if no device
+to install to is specified, UUID is used instead as well.
+
+
@multitable @columnfractions .20 .20 .20 .20 .20
@item @tab BIOS @tab Coreboot @tab Multiboot @tab Qemu
@item video @tab yes @tab yes @tab yes @tab yes
@@ -5625,6 +5702,7 @@ and mips-qemu_mips can use only memory up to first hole.
@item badram @tab yes @tab yes @tab yes @tab yes
@item compression @tab always @tab pointless @tab no @tab no
@item exit @tab yes @tab no @tab no @tab no
+@item bootlocation @tab disk @tab no @tab no @tab no
@end multitable
@multitable @columnfractions .20 .20 .20 .20 .20
@@ -5643,6 +5721,7 @@ and mips-qemu_mips can use only memory up to first hole.
@item badram @tab yes @tab yes @tab no @tab yes
@item compression @tab no @tab no @tab no @tab no
@item exit @tab yes @tab yes @tab yes @tab yes
+@item bootlocation @tab file @tab file @tab file, ignored @tab file
@end multitable
@multitable @columnfractions .20 .20 .20 .20 .20
@@ -5661,24 +5740,26 @@ and mips-qemu_mips can use only memory up to first hole.
@item badram @tab yes (*) @tab no @tab no @tab no
@item compression @tab configurable @tab no @tab no @tab configurable
@item exit @tab no @tab yes @tab yes @tab yes
+@item bootlocation @tab no @tab partition @tab file @tab file (*)
@end multitable
@multitable @columnfractions .20 .20 .20 .20 .20
-@item @tab MIPS qemu @tab emu
-@item video @tab no @tab yes
-@item console charset @tab CP437 @tab Unicode (*)
-@item network @tab no @tab yes
-@item ATA/AHCI @tab yes @tab no
-@item AT keyboard @tab yes @tab no
-@item Speaker @tab no @tab no
-@item USB @tab N/A @tab yes
-@item chainloader @tab yes @tab no
-@item cpuid @tab no @tab no
-@item hints @tab guess @tab no
-@item PCI @tab no @tab no
-@item badram @tab yes (*) @tab no
-@item compression @tab configurable @tab no
-@item exit @tab no @tab yes
+@item @tab MIPS qemu @tab emu @tab xen
+@item video @tab no @tab yes @tab no
+@item console charset @tab CP437 @tab Unicode (*) @tab ASCII
+@item network @tab no @tab yes @tab no
+@item ATA/AHCI @tab yes @tab no @tab no
+@item AT keyboard @tab yes @tab no @tab no
+@item Speaker @tab no @tab no @tab no
+@item USB @tab N/A @tab yes @tab no
+@item chainloader @tab yes @tab no @tab yes
+@item cpuid @tab no @tab no @tab yes
+@item hints @tab guess @tab no @tab no
+@item PCI @tab no @tab no @tab no
+@item badram @tab yes (*) @tab no @tab no
+@item compression @tab configurable @tab no @tab no
+@item exit @tab no @tab yes @tab no
+@item bootlocation @tab no @tab file @tab no
@end multitable
@node Platform-specific operations
@@ -5848,7 +5929,7 @@ Following variables must be defined:
@multitable @columnfractions .30 .65
@item GRUB_PAYLOADS_DIR @tab directory containing the required kernels
-@item GRUB_CBFSTOOL @tab cbfstoll from Coreboot package (for coreboot platform only)
+@item GRUB_CBFSTOOL @tab cbfstool from Coreboot package (for coreboot platform only)
@item GRUB_COREBOOT_ROM @tab empty Coreboot ROM
@item GRUB_QEMU_OPTS @tab additional options to be supplied to QEMU
@end multitable
@@ -6385,7 +6466,7 @@ just do:
@end group
@end example
-Also, the latest version is available using Bazaar. See
+Also, the latest version is available using Git. See
@uref{http://www.gnu.org/software/grub/grub-download.html} for more
information.
diff --git a/gentpl.py b/gentpl.py
index bdcae1a1c..f08bcc404 100644
--- a/gentpl.py
+++ b/gentpl.py
@@ -76,7 +76,13 @@ for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i)
# Flattened Device Trees (FDT)
GROUPS["fdt"] = [ "arm64_efi", "arm_uboot", "arm_efi" ]
-# Miscelaneous groups schedulded to disappear in future
+# Needs software helpers for division
+# Must match GRUB_DIVISION_IN_SOFTWARE in misc.h
+GROUPS["softdiv"] = GROUPS["arm"] + ["ia64_efi"]
+GROUPS["no_softdiv"] = GRUB_PLATFORMS[:]
+for i in GROUPS["softdiv"]: GROUPS["no_softdiv"].remove(i)
+
+# Miscellaneous groups scheduled to disappear in future
GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"]
GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc")
@@ -600,7 +606,7 @@ def foreach_enabled_platform(defn, closure):
# enable = emu;
# enable = i386;
# enable = mips_loongson;
-# emu_condition = COND_GRUB_EMU_USB;
+# emu_condition = COND_GRUB_EMU_SDL;
# };
#
def under_platform_specific_conditionals(defn, platform, closure):
@@ -723,9 +729,11 @@ def kernel(defn, platform):
"""if test x$(TARGET_APPLE_LINKER) = x1; then \
$(TARGET_STRIP) -S -x $(""" + cname(defn) + """) -o $@.bin $<; \
$(TARGET_OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -ed2022 -ed2016 -wd1106 -nu -nd $@.bin $@; \
+ rm -f $@.bin; \
elif test ! -z '$(TARGET_OBJ2ELF)'; then \
""" + "$(TARGET_STRIP) $(" + cname(defn) + "_STRIPFLAGS) -o $@.bin $< && \
$(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); \
+ rm -f $@.bin; \
else """ + "$(TARGET_STRIP) $(" + cname(defn) + "_STRIPFLAGS) -o $@ $<; \
fi"""))
@@ -753,7 +761,7 @@ def image(defn, platform):
if test x$(TARGET_APPLE_LINKER) = x1; then \
$(MACHO2IMG) $< $@; \
else \
- $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \
+ $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .ARM.exidx $< $@; \
fi
""")
@@ -828,6 +836,20 @@ def data(defn, platform):
var_add("dist_" + installdir(defn) + "_DATA", platform_sources(defn, platform))
gvar_add("dist_noinst_DATA", extra_dist(defn))
+def transform_data(defn, platform):
+ name = defn['name']
+
+ var_add(installdir(defn) + "_DATA", name)
+
+ rule(name, "$(top_builddir)/config.status " + platform_sources(defn, platform) + platform_dependencies(defn, platform), """
+(for x in """ + platform_sources(defn, platform) + """; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
+chmod a+x """ + name + """
+""")
+
+ gvar_add("CLEANFILES", name)
+ gvar_add("EXTRA_DIST", extra_dist(defn))
+ gvar_add("dist_noinst_DATA", platform_sources(defn, platform))
+
def script(defn, platform):
name = defn['name']
@@ -875,6 +897,7 @@ rules("library", library)
rules("program", program)
rules("script", script)
rules("data", data)
+rules("transform_data", transform_data)
write_output(section='decl')
write_output()
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
index 04764384b..04e9395fd 100644
--- a/grub-core/Makefile.am
+++ b/grub-core/Makefile.am
@@ -26,20 +26,26 @@ CFLAGS_LIBRARY += $(CFLAGS_PLATFORM) -fno-builtin
CPPFLAGS_LIBRARY += $(CPPFLAGS_PLATFORM)
CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM)
-build-grub-pep2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
- $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=64 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pep2elf\" $^
+build-grub-pep2elf$(BUILD_EXEEXT): $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
+ $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=64 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pep2elf\" $^
+CLEANFILES += build-grub-pep2elf$(BUILD_EXEEXT)
-build-grub-pe2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
- $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=32 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^
+build-grub-pe2elf$(BUILD_EXEEXT): $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
+ $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=32 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^
+CLEANFILES += build-grub-pe2elf$(BUILD_EXEEXT)
# gentrigtables
-gentrigtables: gentrigtables.c
- $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< $(BUILD_LIBM)
-CLEANFILES += gentrigtables
+gentrigtables$(BUILD_EXEEXT): gentrigtables.c
+ $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $< $(BUILD_LIBM)
+CLEANFILES += gentrigtables$(BUILD_EXEEXT)
+
+build-grub-module-verifier$(BUILD_EXEEXT): $(top_srcdir)/util/grub-module-verifier.c $(top_srcdir)/util/grub-module-verifier32.c $(top_srcdir)/util/grub-module-verifier64.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
+ $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-module-verifier\" $^
+CLEANFILES += build-grub-module-verifier$(BUILD_EXEEXT)
# trigtables.c
-trigtables.c: gentrigtables gentrigtables.c $(top_srcdir)/configure.ac
- ./gentrigtables > $@
+trigtables.c: gentrigtables$(BUILD_EXEEXT) gentrigtables.c $(top_srcdir)/configure.ac
+ ./gentrigtables$(BUILD_EXEEXT) > $@
CLEANFILES += trigtables.c
# XXX Use Automake's LEX & YACC support
@@ -74,6 +80,11 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h
+if COND_emu
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt-emu.h
+else
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt.h
+endif
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h
@@ -81,9 +92,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h
-if !COND_clang
-KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
-endif
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h
if COND_i386_pc
@@ -97,7 +105,9 @@ if COND_i386_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h
endif
if COND_i386_coreboot
@@ -108,11 +118,12 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
endif
if COND_i386_multiboot
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
-KERNEL_HEADER_FILES += $(top_builddir)/include/grub/i386/pc/int.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
endif
if COND_i386_qemu
@@ -151,11 +162,14 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h
endif
if COND_ia64_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
endif
if COND_mips
@@ -222,17 +236,21 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/uboot/uboot.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/uboot/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h
endif
if COND_arm_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
endif
if COND_arm64_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
endif
if COND_emu
@@ -245,9 +263,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
if COND_GRUB_EMU_SDL
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h
endif
-if COND_GRUB_EMU_USB
-KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libusb.h
-endif
if COND_GRUB_EMU_PCI
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libpciaccess.h
endif
@@ -291,12 +306,12 @@ grub_emu-grub_emu_init.$(OBJEXT):grub_emu_init.h
kern/emu/grub_emu_dyn-main.$(OBJEXT):grub_emu_init.h
grub_emu_dyn-grub_emu_init.$(OBJEXT):grub_emu_init.h
-grub_emu_init.h: genemuinitheader.sh $(MOD_FILES)
- rm -f $@; echo $(MOD_FILES) | sh $(srcdir)/genemuinitheader.sh $(TARGET_NM) > $@
+grub_emu_init.h: genemuinitheader.sh $(MODULE_FILES)
+ rm -f $@; echo $(MODULE_FILES) | sh $(srcdir)/genemuinitheader.sh $(TARGET_NM) > $@
CLEANFILES += grub_emu_init.h
-grub_emu_init.c: grub_emu_init.h genemuinit.sh $(MOD_FILES)
- rm -f $@; echo $(MOD_FILES) | sh $(srcdir)/genemuinit.sh $(TARGET_NM) > $@
+grub_emu_init.c: grub_emu_init.h genemuinit.sh $(MODULE_FILES)
+ rm -f $@; echo $(MODULE_FILES) | sh $(srcdir)/genemuinit.sh $(TARGET_NM) > $@
CLEANFILES += grub_emu_init.c
endif
@@ -381,7 +396,7 @@ moddep.lst: syminfo.lst genmoddep.awk video.lst
platform_DATA += moddep.lst
CLEANFILES += config.log syminfo.lst moddep.lst
-$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT)
+$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-grub-module-verifier$(BUILD_EXEEXT)
TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@
platform_DATA += $(MOD_FILES)
platform_DATA += modinfo.sh
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index e5e558c99..58b4208b0 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -1,43 +1,43 @@
AutoGen definitions Makefile.tpl;
-script = {
+transform_data = {
installdir = noinst;
name = gensyminfo.sh;
common = gensyminfo.sh.in;
};
-script = {
+transform_data = {
installdir = noinst;
name = genmod.sh;
common = genmod.sh.in;
};
-script = {
+transform_data = {
installdir = noinst;
name = modinfo.sh;
common = modinfo.sh.in;
};
-script = {
+transform_data = {
installdir = platform;
name = gmodule.pl;
common = gmodule.pl.in;
};
-script = {
+transform_data = {
installdir = platform;
name = gdb_grub;
common = gdb_grub.in;
};
-script = {
+transform_data = {
installdir = platform;
name = grub.chrp;
common = boot/powerpc/grub.chrp.in;
enable = powerpc_ieee1275;
};
-script = {
+transform_data = {
installdir = platform;
name = bootinfo.txt;
common = boot/powerpc/bootinfo.txt.in;
@@ -59,14 +59,11 @@ kernel = {
ia64_efi_ldflags = '-Wl,-r,-d';
ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
- x86_64_xen_cppflags = '$(CPPFLAGS_XEN)';
- i386_xen_cppflags = '$(CPPFLAGS_XEN)';
-
arm_efi_ldflags = '-Wl,-r,-d';
arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
arm64_efi_ldflags = '-Wl,-r,-d';
- arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
+ arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
@@ -83,8 +80,6 @@ kernel = {
x86_64_xen_ldflags = '$(TARGET_IMG_LDFLAGS)';
x86_64_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0';
- ldadd = '$(LDADD_KERNEL)';
-
mips_loongson_ldflags = '-Wl,-Ttext,0x80200000';
powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
@@ -95,7 +90,7 @@ kernel = {
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
emu_cflags = '$(CFLAGS_GNULIB)';
emu_cppflags = '$(CPPFLAGS_GNULIB)';
- arm_uboot_ldflags = '-Wl,-Ttext=0x08000000';
+ arm_uboot_ldflags = '-Wl,-r,-d';
arm_uboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
i386_pc_startup = kern/i386/pc/startup.S;
@@ -132,6 +127,7 @@ kernel = {
common = kern/rescue_reader.c;
common = kern/term.c;
+ noemu = kern/compiler-rt.c;
noemu = kern/mm.c;
noemu = kern/time.c;
noemu = kern/generic/millisleep.c;
@@ -159,6 +155,8 @@ kernel = {
terminfoinkernel = commands/extcmd.c;
terminfoinkernel = lib/arg.c;
+ softdiv = lib/division.c;
+
i386 = kern/i386/dl.c;
i386_xen = kern/i386/dl.c;
@@ -173,8 +171,20 @@ kernel = {
efi = kern/efi/init.c;
efi = kern/efi/mm.c;
efi = term/efi/console.c;
+ efi = kern/acpi.c;
+ efi = kern/efi/acpi.c;
+ i386_coreboot = kern/i386/pc/acpi.c;
+ i386_multiboot = kern/i386/pc/acpi.c;
+ i386_coreboot = kern/acpi.c;
+ i386_multiboot = kern/acpi.c;
x86 = kern/i386/tsc.c;
+ x86 = kern/i386/tsc_pit.c;
+ i386_efi = kern/i386/efi/tsc.c;
+ x86_64_efi = kern/i386/efi/tsc.c;
+ i386_efi = kern/i386/tsc_pmtimer.c;
+ i386_coreboot = kern/i386/tsc_pmtimer.c;
+ x86_64_efi = kern/i386/tsc_pmtimer.c;
i386_efi = kern/i386/efi/init.c;
i386_efi = bus/pci.c;
@@ -186,6 +196,7 @@ kernel = {
x86_64_efi = bus/pci.c;
xen = kern/i386/tsc.c;
+ xen = kern/i386/xen/tsc.c;
x86_64_xen = kern/x86_64/xen/hypercall.S;
i386_xen = kern/i386/xen/hypercall.S;
xen = kern/xen/init.c;
@@ -202,7 +213,7 @@ kernel = {
arm_efi = kern/arm/efi/init.c;
arm_efi = kern/arm/efi/misc.c;
- arm64_efi = kern/arm/efi/init.c;
+ arm64_efi = kern/arm64/efi/init.c;
i386_pc = kern/i386/pc/init.c;
i386_pc = kern/i386/pc/mmap.c;
@@ -252,6 +263,7 @@ kernel = {
powerpc_ieee1275 = kern/powerpc/cache.S;
powerpc_ieee1275 = kern/powerpc/dl.c;
+ powerpc_ieee1275 = kern/powerpc/compiler-rt.S;
sparc64_ieee1275 = kern/sparc64/cache.S;
sparc64_ieee1275 = kern/sparc64/dl.c;
@@ -263,7 +275,7 @@ kernel = {
arm = kern/arm/cache_armv7.S;
extra_dist = kern/arm/cache.S;
arm = kern/arm/cache.c;
- arm = kern/arm/misc.S;
+ arm = kern/arm/compiler-rt.S;
arm64 = kern/arm64/cache.c;
arm64 = kern/arm64/cache_flush.S;
@@ -441,13 +453,13 @@ image = {
common = lib/xzembed/xz_dec_bcj.c;
common = lib/xzembed/xz_dec_lzma2.c;
common = lib/xzembed/xz_dec_stream.c;
+ common = kern/compiler-rt.c;
cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1';
objcopyflags = '-O binary';
- mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
- ldadd = '$(TARGET_LIBGCC)';
- cflags = '-Wno-unreachable-code $(TARGET_LDFLAGS_STATIC_LIBGCC)';
+ mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
+ cflags = '-Wno-unreachable-code';
enable = mips;
};
@@ -459,9 +471,7 @@ image = {
cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1';
objcopyflags = '-O binary';
- mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
- ldadd = '$(TARGET_LIBGCC)';
- cflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC)';
+ mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
enable = mips;
};
@@ -479,7 +489,7 @@ image = {
name = fwstart;
mips_loongson = boot/mips/loongson/fwstart.S;
objcopyflags = '-O binary';
- ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
+ ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
enable = mips_loongson;
};
@@ -487,7 +497,7 @@ image = {
name = fwstart_fuloong2f;
mips_loongson = boot/mips/loongson/fuloong2f.S;
objcopyflags = '-O binary';
- ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
+ ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
enable = mips_loongson;
};
@@ -510,13 +520,6 @@ module = {
};
module = {
- name = libusb;
- emu = bus/usb/emu/usb.c;
- enable = emu;
- condition = COND_GRUB_EMU_USB;
-};
-
-module = {
name = lsspd;
mips_loongson = commands/mips/loongson/lsspd.c;
enable = mips_loongson;
@@ -531,13 +534,6 @@ module = {
};
module = {
- name = emuusb;
- common = bus/usb/usb.c;
- enable = emu;
- condition = COND_GRUB_EMU_USB;
-};
-
-module = {
name = usbserial_common;
common = bus/usb/serial/common.c;
enable = usb;
@@ -618,7 +614,6 @@ module = {
module = {
name = lsxen;
common = commands/xen/lsxen.c;
- cppflags = '$(CPPFLAGS_XEN)';
enable = xen;
};
@@ -683,10 +678,8 @@ module = {
name = acpi;
common = commands/acpi.c;
- efi = commands/efi/acpi.c;
- i386_pc = commands/i386/pc/acpi.c;
- i386_coreboot = commands/i386/pc/acpi.c;
- i386_multiboot = commands/i386/pc/acpi.c;
+ i386_pc = kern/acpi.c;
+ i386_pc = kern/i386/pc/acpi.c;
enable = efi;
enable = i386_pc;
@@ -839,7 +832,6 @@ module = {
i386_coreboot = lib/i386/halt.c;
i386_qemu = lib/i386/halt.c;
xen = lib/xen/halt.c;
- xen_cppflags = '$(CPPFLAGS_XEN)';
efi = lib/efi/halt.c;
ieee1275 = lib/ieee1275/halt.c;
emu = lib/emu/halt.c;
@@ -860,7 +852,6 @@ module = {
mips_loongson = lib/mips/loongson/reboot.c;
mips_qemu_mips = lib/mips/qemu_mips/reboot.c;
xen = lib/xen/reboot.c;
- xen_cppflags = '$(CPPFLAGS_XEN)';
uboot = lib/uboot/reboot.c;
common = commands/reboot.c;
};
@@ -1462,7 +1453,6 @@ module = {
module = {
name = gfxmenu;
common = gfxmenu/gfxmenu.c;
- common = gfxmenu/model.c;
common = gfxmenu/view.c;
common = gfxmenu/font.c;
common = gfxmenu/icon_manager.c;
@@ -1541,7 +1531,6 @@ module = {
i386_xen = lib/i386/xen/relocator.S;
x86_64_xen = lib/x86_64/xen/relocator.S;
xen = lib/i386/relocator_common_c.c;
- xen_cppflags = '$(CPPFLAGS_XEN)';
extra_dist = lib/i386/relocator_common.S;
extra_dist = kern/powerpc/cache_flush.S;
@@ -1562,7 +1551,6 @@ module = {
sparc64_ieee1275 = lib/ieee1275/cmos.c;
powerpc_ieee1275 = lib/ieee1275/cmos.c;
xen = lib/xen/datetime.c;
- xen_cppflags = '$(CPPFLAGS_XEN)';
mips_arc = lib/arc/datetime.c;
enable = noemu;
@@ -1662,29 +1650,67 @@ module = {
};
module = {
+ name = xen_boot;
+ common = lib/cmdline.c;
+ arm64 = loader/arm64/xen_boot.c;
+ enable = arm64;
+};
+
+module = {
name = linux;
x86 = loader/i386/linux.c;
xen = loader/i386/xen.c;
- xen_cppflags = '$(CPPFLAGS_XEN)';
i386_pc = lib/i386/pc/vesa_modes_table.c;
mips = loader/mips/linux.c;
powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c;
ia64_efi = loader/ia64/efi/linux.c;
arm = loader/arm/linux.c;
- arm = lib/fdt.c;
+ arm64 = loader/arm64/linux.c;
common = loader/linux.c;
common = lib/cmdline.c;
enable = noemu;
};
module = {
+ name = fdt;
+ arm64 = loader/arm64/fdt.c;
+ common = lib/fdt.c;
+ enable = fdt;
+};
+
+module = {
name = xnu;
x86 = loader/xnu_resume.c;
x86 = loader/i386/xnu.c;
x86 = loader/xnu.c;
- enable = x86;
+ /* Code is pretty generic but relies on RNG which
+ is available only on few platforms. It's not a
+ big deal as xnu needs ACPI anyway and we have
+ RNG on all platforms with ACPI.
+ */
+ enable = i386_multiboot;
+ enable = i386_coreboot;
+ enable = i386_pc;
+ enable = i386_efi;
+ enable = x86_64_efi;
+};
+
+module = {
+ name = random;
+ x86 = lib/i386/random.c;
+ common = lib/random.c;
+
+ i386_multiboot = kern/i386/tsc_pmtimer.c;
+ i386_coreboot = kern/i386/tsc_pmtimer.c;
+ i386_pc = kern/i386/tsc_pmtimer.c;
+
+ enable = i386_multiboot;
+ enable = i386_coreboot;
+ enable = i386_pc;
+ enable = i386_efi;
+ enable = x86_64_efi;
};
module = {
@@ -1969,11 +1995,42 @@ module = {
};
module = {
+ name = div;
+ common = lib/division.c;
+ enable = no_softdiv;
+};
+
+module = {
name = div_test;
common = tests/div_test.c;
};
module = {
+ name = mul_test;
+ common = tests/mul_test.c;
+};
+
+module = {
+ name = shift_test;
+ common = tests/shift_test.c;
+};
+
+module = {
+ name = cmp_test;
+ common = tests/cmp_test.c;
+};
+
+module = {
+ name = ctz_test;
+ common = tests/ctz_test.c;
+};
+
+module = {
+ name = bswap_test;
+ common = tests/bswap_test.c;
+};
+
+module = {
name = videotest_checksum;
common = tests/videotest_checksum.c;
};
diff --git a/grub-core/boot/decompressor/minilib.c b/grub-core/boot/decompressor/minilib.c
index 94edfd561..fc46ee07b 100644
--- a/grub-core/boot/decompressor/minilib.c
+++ b/grub-core/boot/decompressor/minilib.c
@@ -21,7 +21,7 @@
#include <grub/decompressor.h>
void *
-memset (void *s, int c, grub_size_t len)
+grub_memset (void *s, int c, grub_size_t len)
{
grub_uint8_t *ptr;
for (ptr = s; len; ptr++, len--)
@@ -68,15 +68,6 @@ grub_memcmp (const void *s1, const void *s2, grub_size_t n)
return 0;
}
-int memcmp (const void *s1, const void *s2, grub_size_t n)
- __attribute__ ((alias ("grub_memcmp")));
-
-void *memmove (void *dest, const void *src, grub_size_t n)
- __attribute__ ((alias ("grub_memmove")));
-
-void *memcpy (void *dest, const void *src, grub_size_t n)
- __attribute__ ((alias ("grub_memmove")));
-
void *grub_decompressor_scratch;
void
diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S
index b4975e2d0..2bd0b2d28 100644
--- a/grub-core/boot/i386/pc/boot.S
+++ b/grub-core/boot/i386/pc/boot.S
@@ -165,8 +165,8 @@ start:
* this area.
*/
- . = _start + GRUB_BOOT_MACHINE_BPB_START
- . = _start + 4
+ .org GRUB_BOOT_MACHINE_BPB_START
+ .org 4
#endif
#ifdef HYBRID_BOOT
floppy
@@ -174,23 +174,23 @@ start:
scratch
#endif
- . = _start + GRUB_BOOT_MACHINE_BPB_END
+ .org GRUB_BOOT_MACHINE_BPB_END
/*
* End of BIOS parameter block.
*/
-kernel_address:
+LOCAL(kernel_address):
.word GRUB_BOOT_MACHINE_KERNEL_ADDR
#ifndef HYBRID_BOOT
- . = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
-kernel_sector:
+ .org GRUB_BOOT_MACHINE_KERNEL_SECTOR
+LOCAL(kernel_sector):
.long 1
-kernel_sector_high:
+LOCAL(kernel_sector_high):
.long 0
#endif
- . = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE
+ .org GRUB_BOOT_MACHINE_BOOT_DRIVE
boot_drive:
.byte 0xff /* the disk to load kernel from */
/* 0xff means use the boot drive */
@@ -208,7 +208,7 @@ LOCAL(after_BPB):
* possible boot drive. If GRUB is installed into a floppy,
* this does nothing (only jump).
*/
- . = _start + GRUB_BOOT_MACHINE_DRIVE_CHECK
+ .org GRUB_BOOT_MACHINE_DRIVE_CHECK
boot_drive_check:
jmp 3f /* grub-setup may overwrite this jump */
testb $0x80, %dl
@@ -275,7 +275,7 @@ real_start:
andw $1, %cx
jz LOCAL(chs_mode)
-lba_mode:
+LOCAL(lba_mode):
xorw %ax, %ax
movw %ax, 4(%si)
@@ -290,9 +290,9 @@ lba_mode:
movw $0x0010, (%si)
/* the absolute address */
- movl kernel_sector, %ebx
+ movl LOCAL(kernel_sector), %ebx
movl %ebx, 8(%si)
- movl kernel_sector_high, %ebx
+ movl LOCAL(kernel_sector_high), %ebx
movl %ebx, 12(%si)
/* the segment of buffer address */
@@ -361,13 +361,13 @@ LOCAL(final_init):
setup_sectors:
/* load logical sector start (top half) */
- movl kernel_sector_high, %eax
+ movl LOCAL(kernel_sector_high), %eax
orl %eax, %eax
jnz LOCAL(geometry_error)
/* load logical sector start (bottom half) */
- movl kernel_sector, %eax
+ movl LOCAL(kernel_sector), %eax
/* zero %edx */
xorl %edx, %edx
@@ -452,7 +452,7 @@ LOCAL(copy_buffer):
popa
/* boot kernel */
- jmp *(kernel_address)
+ jmp *(LOCAL(kernel_address))
/* END OF MAIN LOOP */
@@ -511,13 +511,13 @@ LOCAL(message):
*/
#ifdef HYBRID_BOOT
- . = _start + 0x1b0
-kernel_sector:
+ .org 0x1b0
+LOCAL(kernel_sector):
.long 1
-kernel_sector_high:
+LOCAL(kernel_sector_high):
.long 0
#endif
- . = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
+ .org GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
nt_magic:
.long 0
.word 0
@@ -528,7 +528,7 @@ nt_magic:
* sneaky, huh?
*/
- . = _start + GRUB_BOOT_MACHINE_PART_START
+ .org GRUB_BOOT_MACHINE_PART_START
#ifndef HYBRID_BOOT
floppy
@@ -536,7 +536,7 @@ nt_magic:
scratch
#endif
- . = _start + GRUB_BOOT_MACHINE_PART_END
+ .org GRUB_BOOT_MACHINE_PART_END
/* the last 2 bytes in the sector 0 contain the signature */
.word GRUB_BOOT_MACHINE_SIGNATURE
diff --git a/grub-core/boot/i386/pc/cdboot.S b/grub-core/boot/i386/pc/cdboot.S
index 92df7c76f..de4f80929 100644
--- a/grub-core/boot/i386/pc/cdboot.S
+++ b/grub-core/boot/i386/pc/cdboot.S
@@ -43,7 +43,7 @@ _start:
LOCAL(next):
jmp 1f
- . = start + 8
+ .org 8
bi_pvd:
.long 0 /* LBA of primary volume descriptor. */
@@ -168,6 +168,6 @@ err_noboot_msg:
err_cdfail_msg:
.ascii "cdrom read fails\0"
- . = start + 0x7FF
+ .org 0x7FF
.byte 0
diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S
index d030a14c9..1ee4cf5b2 100644
--- a/grub-core/boot/i386/pc/diskboot.S
+++ b/grub-core/boot/i386/pc/diskboot.S
@@ -362,7 +362,7 @@ LOCAL(message):
.word 0
.word 0
- . = _start + 0x200 - GRUB_BOOT_MACHINE_LIST_SIZE
+ .org 0x200 - GRUB_BOOT_MACHINE_LIST_SIZE
LOCAL(firstlist): /* this label has to be before the first list entry!!! */
/* fill the first data listing with the default */
blocklist_default_start:
diff --git a/grub-core/boot/i386/pc/lnxboot.S b/grub-core/boot/i386/pc/lnxboot.S
index 87e56a2fd..2dda0e06b 100644
--- a/grub-core/boot/i386/pc/lnxboot.S
+++ b/grub-core/boot/i386/pc/lnxboot.S
@@ -41,7 +41,7 @@ data_start:
xorl %ebp, %ebp
jmp LOCAL(linux_next)
- . = data_start + 0x1F1
+ .org 0x1F1
setup_sects:
.byte CODE_SECTORS
@@ -292,4 +292,4 @@ LOCAL(fail):
err_int15_msg:
.ascii "move memory fails\0"
- . = _start + CODE_SECTORS * 512
+ .org (CODE_SECTORS * 512 + 512)
diff --git a/grub-core/boot/i386/pc/pxeboot.S b/grub-core/boot/i386/pc/pxeboot.S
index 446bfc781..b695b24d0 100644
--- a/grub-core/boot/i386/pc/pxeboot.S
+++ b/grub-core/boot/i386/pc/pxeboot.S
@@ -38,5 +38,5 @@ start:
/* This region is a junk. Do you say that this is wasteful?
But I like that the memory layout of the body is consistent
among different kernels rather than scamping just for 1.5KB. */
- . = _start + 0x8200 - 0x7C00 - 0x200 - 1
+ .org 0x8200 - 0x7C00 - 0x200 - 1
.byte 0
diff --git a/grub-core/boot/i386/pc/startup_raw.S b/grub-core/boot/i386/pc/startup_raw.S
index 279674030..8bce7985c 100644
--- a/grub-core/boot/i386/pc/startup_raw.S
+++ b/grub-core/boot/i386/pc/startup_raw.S
@@ -50,23 +50,23 @@ LOCAL (base):
* This is a special data area.
*/
- . = _start + GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
+ .org GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
LOCAL(compressed_size):
.long 0
- . = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
+ .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
LOCAL(uncompressed_size):
.long 0
- . = _start + GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY
+ .org GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY
reed_solomon_redundancy:
.long 0
- . = _start + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH
+ .org GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH
.short (LOCAL(reed_solomon_part) - _start)
/*
* This is the area for all of the special variables.
*/
- . = _start + GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE
+ .org GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE
LOCAL(boot_dev):
.byte 0xFF, 0xFF, 0xFF
LOCAL(boot_drive):
@@ -89,13 +89,13 @@ LOCAL (codestart):
sti /* we're safe again */
/* save the boot drive */
- ADDR32 movb %dl, LOCAL(boot_drive)
+ movb %dl, LOCAL(boot_drive)
/* reset disk system (%ah = 0) */
int $0x13
/* transition to protected mode */
- DATA32 call real_to_prot
+ calll real_to_prot
/* The ".code32" directive takes GAS out of 16-bit mode. */
.code32
@@ -149,7 +149,7 @@ gate_a20_try_bios:
movw $0x2401, %ax
int $0x15
- DATA32 call real_to_prot
+ calll real_to_prot
.code32
popl %ebp
diff --git a/grub-core/boot/i386/qemu/boot.S b/grub-core/boot/i386/qemu/boot.S
index bdd68c704..8c3a1db71 100644
--- a/grub-core/boot/i386/qemu/boot.S
+++ b/grub-core/boot/i386/qemu/boot.S
@@ -31,7 +31,7 @@ _start:
jmp 1f
- . = _start + GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR
+ .org GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR
VARIABLE(grub_core_entry_addr)
.long 0
1:
@@ -48,8 +48,9 @@ VARIABLE(grub_core_entry_addr)
/* Transition to protected mode. We use pushl to force generation
of a flat return address. */
pushl $1f
- DATA32 jmp real_to_prot
+ jmp real_to_prot
.code32
+1:
/* Ensure A20 is enabled. We're in qemu, so control port A works
and there is no need to wait since there is no real logic, it's
all emulated. */
@@ -57,7 +58,6 @@ VARIABLE(grub_core_entry_addr)
andb $(~0x03), %al
orb $0x02, %al
outb $0x92
-1:
movl EXT_C(grub_core_entry_addr), %edx
jmp *%edx
@@ -66,9 +66,9 @@ VARIABLE(grub_core_entry_addr)
/* Intel, in its infinite wisdom, decided to put the i8086 entry point
*right here* and this is why we need this kludge. */
- . = GRUB_BOOT_MACHINE_SIZE - 16
+ .org GRUB_BOOT_MACHINE_SIZE - 16
.code16
jmp _start
- . = GRUB_BOOT_MACHINE_SIZE
+ .org GRUB_BOOT_MACHINE_SIZE
diff --git a/grub-core/boot/mips/loongson/fwstart.S b/grub-core/boot/mips/loongson/fwstart.S
index 6ae326990..28c634614 100644
--- a/grub-core/boot/mips/loongson/fwstart.S
+++ b/grub-core/boot/mips/loongson/fwstart.S
@@ -162,7 +162,7 @@ retry_cs5536:
b continue
- . = start + GRUB_CPU_LOONGSON_FLASH_TLB_REFILL - GRUB_CPU_LOONGSON_FLASH_START
+ .org GRUB_CPU_LOONGSON_FLASH_TLB_REFILL - GRUB_CPU_LOONGSON_FLASH_START
tlb_refill:
mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC
mfc0 $s2, GRUB_CPU_LOONGSON_COP0_BADVADDR
@@ -196,13 +196,13 @@ tlb_refill:
b fatal
addiu $a0, $a0, %lo(unhandled_tlb_refill)
- . = start + GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR - GRUB_CPU_LOONGSON_FLASH_START
+ .org GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR - GRUB_CPU_LOONGSON_FLASH_START
cache_error:
lui $a0, %hi(unhandled_cache_error)
b fatal
addiu $a0, $a0, %lo(unhandled_cache_error)
- . = start + GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - GRUB_CPU_LOONGSON_FLASH_START
+ .org GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - GRUB_CPU_LOONGSON_FLASH_START
other_exception:
mfc0 $s0, GRUB_CPU_LOONGSON_COP0_CAUSE
mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC
@@ -344,7 +344,7 @@ printhex:
nop
srl $t1, $a0, 28
addiu $t1, $t1, -10
- blt $t1, $zero, 2f
+ bltz $t1, 2f
sll $a0, $a0, 4
addiu $t1, $t1, 'A'-10-'0'
2: addiu $t1, $t1, '0'+10
@@ -398,7 +398,7 @@ read_spd:
move $t2, $a0
move $t3, $ra
lui $a0, %hi(read_spd_fail)
- addiu $a0, $a0, %hi(read_spd_fail)
+ addiu $a0, $a0, %lo(read_spd_fail)
/* Send START. */
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F)
@@ -547,7 +547,7 @@ gpio_dump:
#endif
gpio_dump_end:
- .p2align
+ .p2align 3
write_dumpreg:
ld $t2, 0($t6)
diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S
index 29e93c17e..6a81b3733 100644
--- a/grub-core/boot/mips/startup_raw.S
+++ b/grub-core/boot/mips/startup_raw.S
@@ -22,6 +22,7 @@
#include <grub/machine/memory.h>
#include <grub/machine/kernel.h>
#include <grub/offsets.h>
+#include <grub/mips/asm.h>
#define BASE_ADDR 8
@@ -39,13 +40,13 @@ start:
bal codestart
nop
base:
- . = _start + GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
+ .org GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
compressed_size:
.long 0
- . = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
+ .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
uncompressed_size:
.long 0
- . = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR
+ .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR
uncompressed_addr:
.long 0
codestart:
@@ -118,50 +119,50 @@ parsestr:
move $v0, $zero
move $t3, $t1
3:
- lb $t4, 0($t2)
- lb $t5, 0($t3)
+ lb GRUB_ASM_T4, 0($t2)
+ lb GRUB_ASM_T5, 0($t3)
addiu $t2, $t2, 1
addiu $t3, $t3, 1
- beq $t5, $zero, 1f
+ beq GRUB_ASM_T5, $zero, 1f
nop
- beq $t5, $t4, 3b
+ beq GRUB_ASM_T5, GRUB_ASM_T4, 3b
nop
- bne $t4, $zero, 1f
+ bne GRUB_ASM_T4, $zero, 1f
nop
addiu $t3, $t3, 0xffff
digcont:
- lb $t5, 0($t3)
+ lb GRUB_ASM_T5, 0($t3)
/* Substract '0' from digit. */
- addiu $t5, $t5, 0xffd0
- bltz $t5, 1f
+ addiu GRUB_ASM_T5, GRUB_ASM_T5, 0xffd0
+ bltz GRUB_ASM_T5, 1f
nop
- addiu $t4, $t5, 0xfff7
- bgtz $t4, 1f
+ addiu GRUB_ASM_T4, GRUB_ASM_T5, 0xfff7
+ bgtz GRUB_ASM_T4, 1f
nop
/* Multiply $v0 by 10 with bitshifts. */
sll $v0, $v0, 1
- sll $t4, $v0, 2
- addu $v0, $v0, $t4
- addu $v0, $v0, $t5
+ sll GRUB_ASM_T4, $v0, 2
+ addu $v0, $v0, GRUB_ASM_T4
+ addu $v0, $v0, GRUB_ASM_T5
addiu $t3, $t3, 1
b digcont
nop
1:
jr $ra
nop
-busclockstr: .asciiz "busclock="
-cpuclockstr: .asciiz "cpuclock="
-memsizestr: .asciiz "memsize="
-highmemsizestr: .asciiz "highmemsize="
-machtype_yeeloong_str1: .asciiz "machtype=8.9"
-machtype_yeeloong_str2: .asciiz "machtype=lemote-yeeloong-"
-machtype_fuloong2f_str: .asciiz "machtype=lemote-fuloong-2f"
-machtype_fuloong2e_str: .asciiz "machtype=lemote-fuloong-2e"
-pmon_yeeloong_str: .asciiz "PMON_VER=LM8"
-pmon_fuloong2f_str: .asciiz "PMON_VER=LM6"
-pmon_yeeloong_verstr: .asciiz "Version=LM8"
-pmon_fuloong2f_verstr: .asciiz "Version=LM6"
+busclockstr: .asciz "busclock="
+cpuclockstr: .asciz "cpuclock="
+memsizestr: .asciz "memsize="
+highmemsizestr: .asciz "highmemsize="
+machtype_yeeloong_str1: .asciz "machtype=8.9"
+machtype_yeeloong_str2: .asciz "machtype=lemote-yeeloong-"
+machtype_fuloong2f_str: .asciz "machtype=lemote-fuloong-2f"
+machtype_fuloong2e_str: .asciz "machtype=lemote-fuloong-2e"
+pmon_yeeloong_str: .asciz "PMON_VER=LM8"
+pmon_fuloong2f_str: .asciz "PMON_VER=LM6"
+pmon_yeeloong_verstr: .asciz "Version=LM8"
+pmon_fuloong2f_verstr: .asciz "Version=LM6"
.p2align 2
argdone:
@@ -182,10 +183,10 @@ argdone:
b argdone
addiu $a1, $a1, 4
do_check:
- lb $t4, 0($t7)
- beq $t4, $zero, 1f
+ lb GRUB_ASM_T4, 0($t7)
+ beq GRUB_ASM_T4, $zero, 1f
lb $t3, 0($t6)
- bne $t3, $t4, 2f
+ bne $t3, GRUB_ASM_T4, 2f
addiu $t6, $t6, 1
b do_check
addiu $t7, $t7, 1
@@ -222,8 +223,8 @@ cmdlinedone:
1:
beq $t1, $t3, 2f
- lb $t4, 0($t2)
- sb $t4, 0($t1)
+ lb GRUB_ASM_T4, 0($t2)
+ sb GRUB_ASM_T4, 0($t1)
addiu $t1, $t1, 1
b 1b
addiu $t2, $t2, 1
diff --git a/grub-core/boot/sparc64/ieee1275/boot.S b/grub-core/boot/sparc64/ieee1275/boot.S
index efe090e0c..586efb401 100644
--- a/grub-core/boot/sparc64/ieee1275/boot.S
+++ b/grub-core/boot/sparc64/ieee1275/boot.S
@@ -41,18 +41,18 @@ pic_base:
* After loading in that block we will execute it by jumping to the
* load address plus the size of the prepended A.OUT header (32 bytes).
*/
- . = _start + GRUB_BOOT_MACHINE_BOOT_DEVPATH
+ .org GRUB_BOOT_MACHINE_BOOT_DEVPATH
boot_path:
- . = _start + GRUB_BOOT_MACHINE_KERNEL_BYTE
-kernel_byte: .xword (2 << 9)
+ .org GRUB_BOOT_MACHINE_KERNEL_BYTE
boot_path_end:
+kernel_byte: .xword (2 << 9)
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
#else
#define boot_path (_start + 512 + SCRATCH_PAD_BOOT_SIZE)
#define boot_path_end (_start + 1024)
#include <grub/offsets.h>
- . = _start + 8
+ .org 8
kernel_byte: .xword (2 << 9)
kernel_size: .word 512
kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS
@@ -224,7 +224,7 @@ bootpath_known:
#else
nop
#endif
- . = _start + GRUB_BOOT_MACHINE_CODE_END
+ .org GRUB_BOOT_MACHINE_CODE_END
/* the last 4 bytes in the sector 0 contain the signature */
.word GRUB_BOOT_MACHINE_SIGNATURE
diff --git a/grub-core/boot/sparc64/ieee1275/diskboot.S b/grub-core/boot/sparc64/ieee1275/diskboot.S
index e020f6221..35e02c1b6 100644
--- a/grub-core/boot/sparc64/ieee1275/diskboot.S
+++ b/grub-core/boot/sparc64/ieee1275/diskboot.S
@@ -136,7 +136,7 @@ lastlist:
.word 0
.word 0
- . = _start + (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE)
+ .org (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE)
blocklist_default_start:
.word 0
.word 2
diff --git a/grub-core/bus/emu/pci.c b/grub-core/bus/emu/pci.c
index 9d3296395..267f2622d 100644
--- a/grub-core/bus/emu/pci.c
+++ b/grub-core/bus/emu/pci.c
@@ -55,7 +55,8 @@ grub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base,
int err;
err = pci_device_map_range (dev, base, size, PCI_DEV_MAP_FLAG_WRITABLE, &addr);
if (err)
- grub_util_error ("mapping 0x%x failed (error %d)\n", base, err);
+ grub_util_error ("mapping 0x%llx failed (error %d)",
+ (unsigned long long) base, err);
return addr;
}
@@ -66,12 +67,12 @@ grub_pci_device_unmap_range (grub_pci_device_t dev, void *mem,
pci_device_unmap_range (dev, mem, size);
}
-GRUB_MOD_INIT (pci)
+GRUB_MOD_INIT (emupci)
{
pci_system_init ();
}
-GRUB_MOD_FINI (pci)
+GRUB_MOD_FINI (emupci)
{
pci_system_cleanup ();
}
diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c
index c0feefafe..5f4297bb2 100644
--- a/grub-core/bus/usb/ehci.c
+++ b/grub-core/bus/usb/ehci.c
@@ -29,6 +29,7 @@
#include <grub/loader.h>
#include <grub/cs5536.h>
#include <grub/disk.h>
+#include <grub/cache.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -337,6 +338,21 @@ struct grub_ehci
static struct grub_ehci *ehci;
+static void
+sync_all_caches (struct grub_ehci *e)
+{
+ if (!e)
+ return;
+ if (e->td_virt)
+ grub_arch_sync_dma_caches (e->td_virt, sizeof (struct grub_ehci_td) *
+ GRUB_EHCI_N_TD);
+ if (e->qh_virt)
+ grub_arch_sync_dma_caches (e->qh_virt, sizeof (struct grub_ehci_qh) *
+ GRUB_EHCI_N_QH);
+ if (e->framelist_virt)
+ grub_arch_sync_dma_caches (e->framelist_virt, 4096);
+}
+
/* EHCC registers access functions */
static inline grub_uint32_t
grub_ehci_ehcc_read32 (struct grub_ehci *e, grub_uint32_t addr)
@@ -437,6 +453,8 @@ grub_ehci_reset (struct grub_ehci *e)
{
grub_uint64_t maxtime;
+ sync_all_caches (e);
+
grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
GRUB_EHCI_CMD_HC_RESET
| grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND));
@@ -670,23 +688,23 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
for (i = 0; i < (GRUB_EHCI_N_TD - 1); i++)
{
e->td_virt[i].link_td = e->td_phys + (i + 1) * sizeof (struct grub_ehci_td);
- e->td_virt[i].next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
- e->td_virt[i].alt_next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
+ e->td_virt[i].next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
+ e->td_virt[i].alt_next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
}
e->td_virt[GRUB_EHCI_N_TD - 1].next_td =
- grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
+ grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
e->td_virt[GRUB_EHCI_N_TD - 1].alt_next_td =
- grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
+ grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
e->tdfree_virt = e->td_virt;
/* Set Terminate in first QH, which is used in framelist */
- e->qh_virt[0].qh_hptr = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE | GRUB_EHCI_HPTR_TYPE_QH);
- e->qh_virt[0].td_overlay.next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
+ e->qh_virt[0].qh_hptr = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE | GRUB_EHCI_HPTR_TYPE_QH);
+ e->qh_virt[0].td_overlay.next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
e->qh_virt[0].td_overlay.alt_next_td =
- grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
+ grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
/* Also set Halted bit in token */
- e->qh_virt[0].td_overlay.token = grub_cpu_to_le32 (GRUB_EHCI_STATUS_HALTED);
+ e->qh_virt[0].td_overlay.token = grub_cpu_to_le32_compile_time (GRUB_EHCI_STATUS_HALTED);
/* Set the H bit in first QH used for AL */
- e->qh_virt[1].ep_char = grub_cpu_to_le32 (GRUB_EHCI_H);
+ e->qh_virt[1].ep_char = grub_cpu_to_le32_compile_time (GRUB_EHCI_H);
/* Set Terminate into TD in rest of QHs and set horizontal link
* pointer to itself - these QHs will be used for asynchronous
* schedule and they should have valid value in horiz. link */
@@ -697,12 +715,12 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
e->qh_chunk) &
GRUB_EHCI_POINTER_MASK) | GRUB_EHCI_HPTR_TYPE_QH);
e->qh_virt[i].td_overlay.next_td =
- grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
+ grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
e->qh_virt[i].td_overlay.alt_next_td =
- grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
+ grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
/* Also set Halted bit in token */
e->qh_virt[i].td_overlay.token =
- grub_cpu_to_le32 (GRUB_EHCI_STATUS_HALTED);
+ grub_cpu_to_le32_compile_time (GRUB_EHCI_STATUS_HALTED);
}
/* Note: QH 0 and QH 1 are reserved and must not be used anywhere.
@@ -840,6 +858,8 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
e->next = ehci;
ehci = e;
+ sync_all_caches (e);
+
grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: OK at all\n");
grub_dprintf ("ehci",
@@ -991,7 +1011,7 @@ grub_ehci_find_qh (struct grub_ehci *e, grub_usb_transfer_t transfer)
target = ((transfer->endpoint << GRUB_EHCI_EP_NUM_OFF) |
transfer->devaddr) & GRUB_EHCI_TARGET_MASK;
target = grub_cpu_to_le32 (target);
- mask = grub_cpu_to_le32 (GRUB_EHCI_TARGET_MASK);
+ mask = grub_cpu_to_le32_compile_time (GRUB_EHCI_TARGET_MASK);
/* low speed interrupt transfers are linked to the periodic */
/* schedule, everything else to the asynchronous schedule */
@@ -1020,6 +1040,7 @@ grub_ehci_find_qh (struct grub_ehci *e, grub_usb_transfer_t transfer)
/* Found proper existing (and linked) QH, do setup of QH */
grub_dprintf ("ehci", "find_qh: found, QH=%p\n", qh_iter);
grub_ehci_setup_qh (qh_iter, transfer);
+ sync_all_caches (e);
return qh_iter;
}
@@ -1121,7 +1142,7 @@ grub_ehci_free_tds (struct grub_ehci *e, grub_ehci_td_t td,
token = grub_le_to_cpu32 (td->token);
to_transfer = (token & GRUB_EHCI_TOTAL_MASK) >> GRUB_EHCI_TOTAL_OFF;
- /* Check state of TD - if it did not transfered
+ /* Check state of TD - if it did not transfer
* whole data then set last_trans - it should be last executed TD
* in case when something went wrong. */
if (transfer && (td->size != to_transfer))
@@ -1200,7 +1221,7 @@ grub_ehci_transaction (struct grub_ehci *e,
grub_memset ((void *) td, 0, sizeof (struct grub_ehci_td));
/* Don't point to any TD yet, just terminate. */
- td->next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
+ td->next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
/* Set alternate pointer. When short packet occurs, alternate TD
* will not be really fetched because it is not active. But don't
* forget, EHCI will try to fetch alternate TD every scan of AL
@@ -1289,16 +1310,28 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
grub_ehci_td_t td_prev = NULL;
int i;
struct grub_ehci_transfer_controller_data *cdata;
+ grub_uint32_t status;
+
+ sync_all_caches (e);
/* Check if EHCI is running and AL is enabled */
- if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS)
- & GRUB_EHCI_ST_HC_HALTED) != 0)
+ status = grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS);
+ if ((status & GRUB_EHCI_ST_HC_HALTED) != 0)
/* XXX: Fix it: Currently we don't do anything to restart EHCI */
- return GRUB_USB_ERR_INTERNAL;
- if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS)
+ {
+ grub_dprintf ("ehci", "setup_transfer: halted, status = 0x%x\n",
+ status);
+ return GRUB_USB_ERR_INTERNAL;
+ }
+ status = grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS);
+ if ((status
& (GRUB_EHCI_ST_AS_STATUS | GRUB_EHCI_ST_PS_STATUS)) == 0)
/* XXX: Fix it: Currently we don't do anything to restart EHCI */
- return GRUB_USB_ERR_INTERNAL;
+ {
+ grub_dprintf ("ehci", "setup_transfer: no AS/PS, status = 0x%x\n",
+ status);
+ return GRUB_USB_ERR_INTERNAL;
+ }
/* Allocate memory for controller transfer data. */
cdata = grub_malloc (sizeof (*cdata));
@@ -1310,6 +1343,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
cdata->qh_virt = grub_ehci_find_qh (e, transfer);
if (!cdata->qh_virt)
{
+ grub_dprintf ("ehci", "setup_transfer: no QH\n");
grub_free (cdata);
return GRUB_USB_ERR_INTERNAL;
}
@@ -1319,15 +1353,16 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
cdata->td_alt_virt = grub_ehci_alloc_td (e);
if (!cdata->td_alt_virt)
{
+ grub_dprintf ("ehci", "setup_transfer: no TDs\n");
grub_free (cdata);
return GRUB_USB_ERR_INTERNAL;
}
/* Fill whole alternate TD by zeros (= inactive) and set
* Terminate bits and Halt bit */
grub_memset ((void *) cdata->td_alt_virt, 0, sizeof (struct grub_ehci_td));
- cdata->td_alt_virt->next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
- cdata->td_alt_virt->alt_next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
- cdata->td_alt_virt->token = grub_cpu_to_le32 (GRUB_EHCI_STATUS_HALTED);
+ cdata->td_alt_virt->next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
+ cdata->td_alt_virt->alt_next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
+ cdata->td_alt_virt->token = grub_cpu_to_le32_compile_time (GRUB_EHCI_STATUS_HALTED);
/* Allocate appropriate number of TDs and set */
for (i = 0; i < transfer->transcnt; i++)
@@ -1345,6 +1380,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
grub_ehci_free_tds (e, cdata->td_first_virt, NULL, &actual);
grub_free (cdata);
+ grub_dprintf ("ehci", "setup_transfer: no TD\n");
return GRUB_USB_ERR_INTERNAL;
}
@@ -1364,7 +1400,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
cdata->td_last_virt = td;
cdata->td_last_phys = grub_dma_virt2phys (td, e->td_chunk);
/* Last TD should not have set alternate TD */
- cdata->td_last_virt->alt_next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
+ cdata->td_last_virt->alt_next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
grub_dprintf ("ehci", "setup_transfer: cdata=%p, qh=%p\n",
cdata,cdata->qh_virt);
@@ -1377,14 +1413,16 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
/* Start transfer: */
/* Unlink possible alternate pointer in QH */
cdata->qh_virt->td_overlay.alt_next_td =
- grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
+ grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
/* Link new TDs with QH via next_td */
cdata->qh_virt->td_overlay.next_td =
grub_cpu_to_le32 (grub_dma_virt2phys
(cdata->td_first_virt, e->td_chunk));
/* Reset Active and Halted bits in QH to activate Advance Queue,
* i.e. reset token */
- cdata->qh_virt->td_overlay.token = grub_cpu_to_le32 (0);
+ cdata->qh_virt->td_overlay.token = grub_cpu_to_le32_compile_time (0);
+
+ sync_all_caches (e);
/* Finito */
transfer->controller_data = cdata;
@@ -1408,9 +1446,9 @@ grub_ehci_pre_finish_transfer (grub_usb_transfer_t transfer)
* safely manipulate with QH TD part. */
cdata->qh_virt->td_overlay.token = (cdata->qh_virt->td_overlay.token
|
- grub_cpu_to_le32
+ grub_cpu_to_le32_compile_time
(GRUB_EHCI_STATUS_HALTED)) &
- grub_cpu_to_le32 (~GRUB_EHCI_STATUS_ACTIVE);
+ grub_cpu_to_le32_compile_time (~GRUB_EHCI_STATUS_ACTIVE);
/* Print debug data here if necessary */
@@ -1434,6 +1472,8 @@ grub_ehci_parse_notrun (grub_usb_controller_t dev,
grub_ehci_free_td (e, cdata->td_alt_virt);
grub_free (cdata);
+ sync_all_caches (e);
+
/* Additionally, do something with EHCI to make it running (what?) */
/* Try enable EHCI and AL */
grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
@@ -1469,6 +1509,8 @@ grub_ehci_parse_halt (grub_usb_controller_t dev,
grub_ehci_free_td (e, cdata->td_alt_virt);
grub_free (cdata);
+ sync_all_caches (e);
+
/* Evaluation of error code - currently we don't have GRUB USB error
* codes for some EHCI states, GRUB_USB_ERR_DATA is used for them.
* Order of evaluation is critical, specially bubble/stall. */
@@ -1502,6 +1544,8 @@ grub_ehci_parse_success (grub_usb_controller_t dev,
grub_ehci_free_td (e, cdata->td_alt_virt);
grub_free (cdata);
+ sync_all_caches (e);
+
return GRUB_USB_ERR_NONE;
}
@@ -1515,6 +1559,8 @@ grub_ehci_check_transfer (grub_usb_controller_t dev,
transfer->controller_data;
grub_uint32_t token, token_ftd;
+ sync_all_caches (e);
+
grub_dprintf ("ehci",
"check_transfer: EHCI STATUS=%08x, cdata=%p, qh=%p\n",
grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS),
@@ -1581,6 +1627,9 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev,
int i;
grub_uint64_t maxtime;
grub_uint32_t qh_phys;
+
+ sync_all_caches (e);
+
grub_uint32_t interrupt =
cdata->qh_virt->ep_cap & GRUB_EHCI_SMASK_MASK;
@@ -1600,6 +1649,7 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev,
grub_ehci_free_tds (e, cdata->td_first_virt, transfer, &actual);
grub_ehci_free_td (e, cdata->td_alt_virt);
grub_free (cdata);
+ sync_all_caches (e);
grub_dprintf ("ehci", "cancel_transfer: end - EHCI not running\n");
return GRUB_USB_ERR_NONE;
}
@@ -1622,6 +1672,8 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev,
/* Unlink QH from AL */
e->qh_virt[i].qh_hptr = cdata->qh_virt->qh_hptr;
+ sync_all_caches (e);
+
/* If this is an interrupt transfer, we just wait for the periodic
* schedule to advance a few times and then assume that the EHCI
* controller has read the updated QH. */
@@ -1676,6 +1728,8 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev,
grub_dprintf ("ehci", "cancel_transfer: end\n");
+ sync_all_caches (e);
+
return GRUB_USB_ERR_NONE;
}
@@ -1777,11 +1831,6 @@ grub_ehci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
status = grub_ehci_port_read (e, port);
- grub_dprintf ("ehci", "detect_dev: EHCI STATUS: %08x\n",
- grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS));
- grub_dprintf ("ehci", "detect_dev: iobase=%p, port=%d, status=0x%02x\n",
- e->iobase, port, status);
-
/* Connect Status Change bit - it detects change of connection */
if (status & GRUB_EHCI_PORT_CONNECT_CH)
{
diff --git a/grub-core/bus/usb/emu/usb.c b/grub-core/bus/usb/emu/usb.c
deleted file mode 100644
index 3ad2fc312..000000000
--- a/grub-core/bus/usb/emu/usb.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/* usb.c -- libusb USB support for GRUB. */
-/*
- * 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 <config.h>
-#include <grub/misc.h>
-#include <grub/mm.h>
-#include <usb.h>
-#include <grub/usb.h>
-#include <grub/dl.h>
-
-GRUB_MOD_LICENSE ("GPLv3+");
-
-
-static struct grub_usb_controller_dev usb_controller =
-{
- .name = "libusb"
-};
-
-static struct grub_usb_device *grub_usb_devs[128];
-
-struct usb_bus *busses;
-
-static grub_err_t
-grub_libusb_devices (void)
-
-{
- struct usb_bus *bus;
- int last = 0;
-
- busses = usb_get_busses();
-
- for (bus = busses; bus; bus = bus->next)
- {
- struct usb_device *usbdev;
- struct grub_usb_device *dev;
-
- for (usbdev = bus->devices; usbdev; usbdev = usbdev->next)
- {
- struct usb_device_descriptor *desc = &usbdev->descriptor;
- grub_err_t err;
-
- if (! desc->bcdUSB)
- continue;
-
- dev = grub_malloc (sizeof (*dev));
- if (! dev)
- return grub_errno;
-
- dev->data = usbdev;
-
- /* Fill in all descriptors. */
- err = grub_usb_device_initialize (dev);
- if (err)
- {
- grub_errno = GRUB_ERR_NONE;
- continue;
- }
-
- /* Register the device. */
- grub_usb_devs[last++] = dev;
- }
- }
-
- return GRUB_USB_ERR_NONE;
-}
-
-void
-grub_usb_poll_devices (void)
-{
- /* TODO: recheck grub_usb_devs */
-}
-
-
-int
-grub_usb_iterate (grub_usb_iterate_hook_t hook, void *hook_data)
-{
- int i;
-
- for (i = 0; i < 128; i++)
- {
- if (grub_usb_devs[i])
- {
- if (hook (grub_usb_devs[i], hook_data))
- return 1;
- }
- }
-
- return 0;
-}
-
-grub_usb_err_t
-grub_usb_root_hub (grub_usb_controller_t controller __attribute__((unused)))
-{
- return GRUB_USB_ERR_NONE;
-}
-
-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 idx, grub_size_t size, char *data)
-{
- usb_dev_handle *devh;
- struct usb_device *d = dev->data;
-
- devh = usb_open (d);
- if (usb_control_msg (devh, reqtype, request,
- value, idx, data, size, 20) < 0)
- {
- usb_close (devh);
- return GRUB_USB_ERR_STALL;
- }
-
- usb_close (devh);
-
- return GRUB_USB_ERR_NONE;
-}
-
-grub_usb_err_t
-grub_usb_bulk_read (grub_usb_device_t dev,
- int endpoint, grub_size_t size, char *data)
-{
- usb_dev_handle *devh;
- struct usb_device *d = dev->data;
-
- devh = usb_open (d);
- if (usb_claim_interface (devh, 0) < 1)
- {
- usb_close (devh);
- return GRUB_USB_ERR_STALL;
- }
-
- if (usb_bulk_read (devh, endpoint, data, size, 20) < 1)
- {
- usb_close (devh);
- return GRUB_USB_ERR_STALL;
- }
-
- usb_release_interface (devh, 0);
- usb_close (devh);
-
- return GRUB_USB_ERR_NONE;
-}
-
-grub_usb_err_t
-grub_usb_bulk_write (grub_usb_device_t dev,
- int endpoint, grub_size_t size, char *data)
-{
- usb_dev_handle *devh;
- struct usb_device *d = dev->data;
-
- devh = usb_open (d);
- if (usb_claim_interface (devh, 0) < 0)
- goto fail;
-
- if (usb_bulk_write (devh, endpoint, data, size, 20) < 0)
- goto fail;
-
- if (usb_release_interface (devh, 0) < 0)
- goto fail;
-
- usb_close (devh);
-
- return GRUB_USB_ERR_NONE;
-
- fail:
- usb_close (devh);
- return GRUB_USB_ERR_STALL;
-}
-
-GRUB_MOD_INIT (libusb)
-{
- usb_init();
- usb_find_busses();
- usb_find_devices();
-
- if (grub_libusb_devices ())
- return;
-
- grub_usb_controller_dev_register (&usb_controller);
-
- return;
-}
-
-GRUB_MOD_FINI (libusb)
-{
- return;
-}
diff --git a/grub-core/bus/usb/ohci.c b/grub-core/bus/usb/ohci.c
index 946a4ed7d..f0be533d4 100644
--- a/grub-core/bus/usb/ohci.c
+++ b/grub-core/bus/usb/ohci.c
@@ -314,7 +314,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
grub_memset ((void *) o->ed_ctrl, 0, sizeof (struct grub_ohci_ed)
* GRUB_OHCI_CTRL_EDS);
for (j=0; j < GRUB_OHCI_CTRL_EDS; j++)
- o->ed_ctrl[j].target = grub_cpu_to_le32 (1 << 14); /* skip */
+ o->ed_ctrl[j].target = grub_cpu_to_le32_compile_time (1 << 14); /* skip */
grub_dprintf ("ohci", "EDs-C: chunk=%p, virt=%p, phys=0x%02x\n",
o->ed_ctrl_chunk, o->ed_ctrl, o->ed_ctrl_addr);
@@ -329,7 +329,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
/* Preset EDs */
grub_memset ((void*)o->ed_bulk, 0, sizeof(struct grub_ohci_ed) * GRUB_OHCI_BULK_EDS);
for (j=0; j < GRUB_OHCI_BULK_EDS; j++)
- o->ed_bulk[j].target = grub_cpu_to_le32 (1 << 14); /* skip */
+ o->ed_bulk[j].target = grub_cpu_to_le32_compile_time (1 << 14); /* skip */
grub_dprintf ("ohci", "EDs-B: chunk=%p, virt=%p, phys=0x%02x\n",
o->ed_bulk_chunk, o->ed_bulk, o->ed_bulk_addr);
@@ -750,7 +750,10 @@ grub_ohci_setup_transfer (grub_usb_controller_t dev,
{
cdata->td_head_virt = grub_ohci_alloc_td (o);
if (!cdata->td_head_virt)
- return GRUB_USB_ERR_INTERNAL; /* We don't need de-allocate ED */
+ {
+ grub_free (cdata);
+ return GRUB_USB_ERR_INTERNAL; /* We don't need de-allocate ED */
+ }
/* We can set td_head only when ED is not active, i.e.
* when it is newly allocated. */
cdata->ed_virt->td_head
@@ -1349,10 +1352,10 @@ grub_ohci_fini_hw (int noreturn __attribute__ ((unused)))
/* Set skip in all EDs */
if (o->ed_bulk)
for (i=0; i < GRUB_OHCI_BULK_EDS; i++)
- o->ed_bulk[i].target |= grub_cpu_to_le32 (1 << 14); /* skip */
+ o->ed_bulk[i].target |= grub_cpu_to_le32_compile_time (1 << 14); /* skip */
if (o->ed_ctrl)
for (i=0; i < GRUB_OHCI_CTRL_EDS; i++)
- o->ed_ctrl[i].target |= grub_cpu_to_le32 (1 << 14); /* skip */
+ o->ed_ctrl[i].target |= grub_cpu_to_le32_compile_time (1 << 14); /* skip */
/* We should wait for next SOF to be sure that all EDs are
* unaccessed by OHCI. But OHCI can be non-functional, so
diff --git a/grub-core/bus/usb/uhci.c b/grub-core/bus/usb/uhci.c
index a95fdfe07..7c5811fd6 100644
--- a/grub-core/bus/usb/uhci.c
+++ b/grub-core/bus/usb/uhci.c
@@ -625,9 +625,7 @@ grub_uhci_check_transfer (grub_usb_controller_t dev,
return GRUB_USB_ERR_NONE;
}
- grub_dprintf ("uhci", "t status=0x%02x\n", errtd->ctrl_status);
-
- if (!(errtd->ctrl_status & (1 << 23)))
+ if (errtd && !(errtd->ctrl_status & (1 << 23)))
{
grub_usb_err_t err = GRUB_USB_ERR_NONE;
diff --git a/grub-core/bus/usb/usbtrans.c b/grub-core/bus/usb/usbtrans.c
index 557e71c2e..9266e4931 100644
--- a/grub-core/bus/usb/usbtrans.c
+++ b/grub-core/bus/usb/usbtrans.c
@@ -24,6 +24,7 @@
#include <grub/usb.h>
#include <grub/usbtrans.h>
#include <grub/time.h>
+#include <grub/cache.h>
static inline unsigned int
@@ -31,7 +32,7 @@ grub_usb_bulk_maxpacket (grub_usb_device_t dev,
struct grub_usb_desc_endp *endpoint)
{
/* Use the maximum packet size given in the endpoint descriptor. */
- if (dev->initialized && endpoint)
+ if (dev->initialized && endpoint && (unsigned int) endpoint->maxpacket)
return endpoint->maxpacket;
return 64;
@@ -101,6 +102,8 @@ grub_usb_control_msg (grub_usb_device_t dev,
data_addr = grub_dma_get_phys (data_chunk);
grub_memcpy ((char *) data, data_in, size);
+ grub_arch_sync_dma_caches (data, size);
+
grub_dprintf ("usb",
"control: reqtype=0x%02x req=0x%02x val=0x%02x idx=0x%02x size=%lu\n",
reqtype, request, value, index, (unsigned long)size);
@@ -161,6 +164,8 @@ grub_usb_control_msg (grub_usb_device_t dev,
setupdata->value = value;
setupdata->index = index;
setupdata->length = size;
+ grub_arch_sync_dma_caches (setupdata, sizeof (*setupdata));
+
transfer->transactions[0].size = sizeof (*setupdata);
transfer->transactions[0].pid = GRUB_USB_TRANSFER_TYPE_SETUP;
transfer->transactions[0].data = setupdata_addr;
@@ -202,11 +207,13 @@ grub_usb_control_msg (grub_usb_device_t dev,
grub_free (transfer->transactions);
grub_free (transfer);
- grub_dma_free (data_chunk);
grub_dma_free (setupdata_chunk);
+ grub_arch_sync_dma_caches (data, size0);
grub_memcpy (data_in, (char *) data, size0);
+ grub_dma_free (data_chunk);
+
return err;
}
@@ -236,7 +243,10 @@ grub_usb_bulk_setup_readwrite (grub_usb_device_t dev,
data = grub_dma_get_virt (data_chunk);
data_addr = grub_dma_get_phys (data_chunk);
if (type == GRUB_USB_TRANSFER_TYPE_OUT)
- grub_memcpy ((char *) data, data_in, size);
+ {
+ grub_memcpy ((char *) data, data_in, size);
+ grub_arch_sync_dma_caches (data, size);
+ }
/* Create a transfer. */
transfer = grub_malloc (sizeof (struct grub_usb_transfer));
@@ -306,13 +316,17 @@ grub_usb_bulk_finish_readwrite (grub_usb_transfer_t transfer)
dev->toggle[transfer->endpoint] = toggle;
if (transfer->dir == GRUB_USB_TRANSFER_TYPE_IN)
- grub_memcpy (transfer->data, (void *)
- grub_dma_get_virt (transfer->data_chunk),
- transfer->size + 1);
+ {
+ grub_arch_sync_dma_caches (grub_dma_get_virt (transfer->data_chunk),
+ transfer->size + 1);
+ grub_memcpy (transfer->data, (void *)
+ grub_dma_get_virt (transfer->data_chunk),
+ transfer->size + 1);
+ }
grub_free (transfer->transactions);
- grub_free (transfer);
grub_dma_free (transfer->data_chunk);
+ grub_free (transfer);
}
static grub_usb_err_t
diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c
index 97c2cf282..b5c2f27c1 100644
--- a/grub-core/commands/acpi.c
+++ b/grub-core/commands/acpi.c
@@ -61,18 +61,6 @@ static const struct grub_arg_option options[] = {
{0, 0, 0, 0, 0, 0}
};
-/* Simple checksum by summing all bytes. Used by ACPI and SMBIOS. */
-grub_uint8_t
-grub_byte_checksum (void *base, grub_size_t size)
-{
- grub_uint8_t *ptr;
- grub_uint8_t ret = 0;
- for (ptr = (grub_uint8_t *) base; ptr < ((grub_uint8_t *) base) + size;
- ptr++)
- ret += *ptr;
- return ret;
-}
-
/* rev1 is 1 if ACPIv1 is to be generated, 0 otherwise.
rev2 contains the revision of ACPIv2+ to generate or 0 if none. */
static int rev1, rev2;
@@ -131,6 +119,8 @@ grub_acpi_get_rsdpv1 (void)
return grub_machine_acpi_get_rsdpv1 ();
}
+#if defined (__i386__) || defined (__x86_64__)
+
static inline int
iszero (grub_uint8_t *reg, int size)
{
@@ -141,7 +131,6 @@ iszero (grub_uint8_t *reg, int size)
return 1;
}
-#if defined (__i386__) || defined (__x86_64__)
/* Context for grub_acpi_create_ebda. */
struct grub_acpi_create_ebda_ctx {
int ebda_len;
@@ -179,8 +168,10 @@ grub_acpi_create_ebda (void)
struct grub_acpi_rsdp_v20 *v2;
ebda = (grub_uint8_t *) (grub_addr_t) ((*((grub_uint16_t *)0x40e)) << 4);
+ grub_dprintf ("acpi", "EBDA @%p\n", ebda);
if (ebda)
ebda_kb_len = *(grub_uint16_t *) ebda;
+ grub_dprintf ("acpi", "EBDA length 0x%x\n", ebda_kb_len);
if (ebda_kb_len > 16)
ebda_kb_len = 0;
ctx.ebda_len = (ebda_kb_len + 1) << 10;
@@ -227,7 +218,7 @@ grub_acpi_create_ebda (void)
grub_dprintf ("acpi", "Copying rsdpv2 to %p\n", target);
v2inebda = target;
target += v2->length;
- target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
+ target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
v2 = 0;
break;
}
@@ -246,7 +237,7 @@ grub_acpi_create_ebda (void)
grub_dprintf ("acpi", "Copying rsdpv1 to %p\n", target);
v1inebda = target;
target += sizeof (struct grub_acpi_rsdp_v10);
- target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
+ target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
v1 = 0;
break;
}
@@ -265,7 +256,7 @@ grub_acpi_create_ebda (void)
grub_memcpy (target, v2, v2->length);
v2inebda = target;
target += v2->length;
- target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
+ target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
v2 = 0;
break;
}
@@ -282,7 +273,7 @@ grub_acpi_create_ebda (void)
grub_memcpy (target, v1, sizeof (struct grub_acpi_rsdp_v10));
v1inebda = target;
target += sizeof (struct grub_acpi_rsdp_v10);
- target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
+ target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
v1 = 0;
break;
}
@@ -494,6 +485,8 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
if (! rsdp)
rsdp = grub_machine_acpi_get_rsdpv1 ();
+ grub_dprintf ("acpi", "RSDP @%p\n", rsdp);
+
if (rsdp)
{
grub_uint32_t *entry_ptr;
@@ -600,6 +593,9 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
if (! table->addr)
{
free_tables ();
+ grub_free (exclude);
+ grub_free (load_only);
+ grub_free (table);
return grub_errno;
}
table->next = acpi_tables;
diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c
index 09421a6c6..9cc7f18e3 100644
--- a/grub-core/commands/acpihalt.c
+++ b/grub-core/commands/acpihalt.c
@@ -26,6 +26,8 @@
#define grub_dprintf(cond, args...) printf ( args )
#define grub_printf printf
+#define grub_util_fopen fopen
+#define grub_memcmp memcmp
typedef uint64_t grub_uint64_t;
typedef uint32_t grub_uint32_t;
typedef uint16_t grub_uint16_t;
@@ -136,6 +138,49 @@ skip_data_ref_object (const grub_uint8_t *ptr, const grub_uint8_t *end)
}
static inline grub_uint32_t
+skip_term (const grub_uint8_t *ptr, const grub_uint8_t *end)
+{
+ grub_uint32_t add;
+ const grub_uint8_t *ptr0 = ptr;
+
+ switch(*ptr)
+ {
+ case GRUB_ACPI_OPCODE_ADD:
+ case GRUB_ACPI_OPCODE_AND:
+ case GRUB_ACPI_OPCODE_CONCAT:
+ case GRUB_ACPI_OPCODE_CONCATRES:
+ case GRUB_ACPI_OPCODE_DIVIDE:
+ case GRUB_ACPI_OPCODE_INDEX:
+ case GRUB_ACPI_OPCODE_LSHIFT:
+ case GRUB_ACPI_OPCODE_MOD:
+ case GRUB_ACPI_OPCODE_MULTIPLY:
+ case GRUB_ACPI_OPCODE_NAND:
+ case GRUB_ACPI_OPCODE_NOR:
+ case GRUB_ACPI_OPCODE_OR:
+ case GRUB_ACPI_OPCODE_RSHIFT:
+ case GRUB_ACPI_OPCODE_SUBTRACT:
+ case GRUB_ACPI_OPCODE_TOSTRING:
+ case GRUB_ACPI_OPCODE_XOR:
+ /*
+ * Parameters for these opcodes: TermArg, TermArg Target, see ACPI
+ * spec r5.0, page 828f.
+ */
+ ptr++;
+ ptr += add = skip_term (ptr, end);
+ if (!add)
+ return 0;
+ ptr += add = skip_term (ptr, end);
+ if (!add)
+ return 0;
+ ptr += skip_name_string (ptr, end);
+ break;
+ default:
+ return skip_data_ref_object (ptr, end);
+ }
+ return ptr - ptr0;
+}
+
+static inline grub_uint32_t
skip_ext_op (const grub_uint8_t *ptr, const grub_uint8_t *end)
{
const grub_uint8_t *ptr0 = ptr;
@@ -156,10 +201,10 @@ skip_ext_op (const grub_uint8_t *ptr, const grub_uint8_t *end)
ptr++;
ptr += skip_name_string (ptr, end);
ptr++;
- ptr += add = skip_data_ref_object (ptr, end);
+ ptr += add = skip_term (ptr, end);
if (!add)
return 0;
- ptr += add = skip_data_ref_object (ptr, end);
+ ptr += add = skip_term (ptr, end);
if (!add)
return 0;
break;
@@ -180,6 +225,7 @@ skip_ext_op (const grub_uint8_t *ptr, const grub_uint8_t *end)
return ptr - ptr0;
}
+
static int
get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end,
grub_uint8_t *scope, int scope_len)
@@ -202,6 +248,7 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end,
if (!add)
return -1;
break;
+ case GRUB_ACPI_OPCODE_CREATE_DWORD_FIELD:
case GRUB_ACPI_OPCODE_CREATE_WORD_FIELD:
case GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD:
{
@@ -214,8 +261,8 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end,
}
case GRUB_ACPI_OPCODE_NAME:
ptr++;
- if ((!scope || memcmp (scope, "\\", scope_len) == 0) &&
- (memcmp (ptr, "_S5_", 4) == 0 || memcmp (ptr, "\\_S5_", 4) == 0))
+ if ((!scope || grub_memcmp (scope, "\\", scope_len) == 0) &&
+ (grub_memcmp (ptr, "_S5_", 4) == 0 || grub_memcmp (ptr, "\\_S5_", 4) == 0))
{
int ll;
grub_uint8_t *ptr2 = ptr;
@@ -250,6 +297,17 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end,
if (!add)
return -1;
break;
+ case GRUB_ACPI_OPCODE_ALIAS:
+ ptr++;
+ /* We need to skip two name strings */
+ ptr += add = skip_name_string (ptr, end);
+ if (!add)
+ return -1;
+ ptr += add = skip_name_string (ptr, end);
+ if (!add)
+ return -1;
+ break;
+
case GRUB_ACPI_OPCODE_SCOPE:
{
int scope_sleep_type;
diff --git a/grub-core/commands/boottime.c b/grub-core/commands/boottime.c
index 7370d271c..dcc078c2a 100644
--- a/grub-core/commands/boottime.c
+++ b/grub-core/commands/boottime.c
@@ -56,7 +56,7 @@ GRUB_MOD_INIT(boottime)
{
cmd_boottime =
grub_register_command ("boottime", grub_cmd_boottime,
- 0, N_("Get boot time statistics."));
+ 0, N_("Show boot time statistics."));
}
GRUB_MOD_FINI(boottime)
diff --git a/grub-core/commands/cacheinfo.c b/grub-core/commands/cacheinfo.c
index ead6ff82c..d34a34696 100644
--- a/grub-core/commands/cacheinfo.c
+++ b/grub-core/commands/cacheinfo.c
@@ -23,6 +23,8 @@
#include <grub/i18n.h>
#include <grub/disk.h>
+GRUB_MOD_LICENSE ("GPLv3+");
+
static grub_err_t
grub_rescue_cmd_info (struct grub_command *cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
diff --git a/grub-core/commands/cat.c b/grub-core/commands/cat.c
index 8a7f1af78..88d904436 100644
--- a/grub-core/commands/cat.c
+++ b/grub-core/commands/cat.c
@@ -140,10 +140,13 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args)
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
}
- grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
- for (j = 0; j < utcount; j++)
- grub_printf ("<%x>", (unsigned int) utbuf[j]);
- grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
+ if (utcount)
+ {
+ grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
+ for (j = 0; j < utcount; j++)
+ grub_printf ("<%x>", (unsigned int) utbuf[j]);
+ grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
+ }
grub_xputs ("\n");
grub_refresh ();
diff --git a/grub-core/commands/efi/lsefimmap.c b/grub-core/commands/efi/lsefimmap.c
index 215b45bff..c85ff7f36 100644
--- a/grub-core/commands/efi/lsefimmap.c
+++ b/grub-core/commands/efi/lsefimmap.c
@@ -51,7 +51,7 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
grub_printf
("Type Physical start - end #Pages "
- " Size Attributes\n");
+ " Size Attributes\n");
memory_map_end = ADD_MEMORY_DESCRIPTOR (memory_map, map_size);
for (desc = memory_map;
desc < memory_map_end;
@@ -74,7 +74,8 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
"ACPI-nvs",
"MMIO ",
"IO-ports",
- "PAL-code"
+ "PAL-code",
+ "persist ",
};
if (desc->type < ARRAY_SIZE (types_str))
grub_printf ("%s ", types_str[desc->type]);
@@ -87,21 +88,29 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
desc->physical_start + (desc->num_pages << 12) - 1,
desc->num_pages);
- size = desc->num_pages;
- size <<= (12 - 10);
- if (size < 1024)
- grub_printf (" %4" PRIuGRUB_UINT64_T "KB", size);
+ size = desc->num_pages << 12; /* 4 KiB page size */
+ /*
+ * Since size is a multiple of 4 KiB, no need to handle units
+ * of just Bytes (which would use a mask of 0x3ff).
+ *
+ * 14 characters would support the largest possible number of 4 KiB
+ * pages that are not a multiple of larger units (e.g., MiB):
+ * 17592186044415 (0xffffff_fffff000), but that uses a lot of
+ * whitespace for a rare case. 6 characters usually suffices;
+ * columns will be off if not, but this is preferable to rounding.
+ */
+ if (size & 0xfffff)
+ grub_printf (" %6" PRIuGRUB_UINT64_T "KiB", size >> 10);
+ else if (size & 0x3fffffff)
+ grub_printf (" %6" PRIuGRUB_UINT64_T "MiB", size >> 20);
+ else if (size & 0xffffffffff)
+ grub_printf (" %6" PRIuGRUB_UINT64_T "GiB", size >> 30);
+ else if (size & 0x3ffffffffffff)
+ grub_printf (" %6" PRIuGRUB_UINT64_T "TiB", size >> 40);
+ else if (size & 0xfffffffffffffff)
+ grub_printf (" %6" PRIuGRUB_UINT64_T "PiB", size >> 50);
else
- {
- size /= 1024;
- if (size < 1024)
- grub_printf (" %4" PRIuGRUB_UINT64_T "MB", size);
- else
- {
- size /= 1024;
- grub_printf (" %4" PRIuGRUB_UINT64_T "GB", size);
- }
- }
+ grub_printf (" %6" PRIuGRUB_UINT64_T "EiB", size >> 60);
attr = desc->attribute;
if (attr & GRUB_EFI_MEMORY_RUNTIME)
@@ -122,6 +131,12 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
grub_printf (" RP");
if (attr & GRUB_EFI_MEMORY_XP)
grub_printf (" XP");
+ if (attr & GRUB_EFI_MEMORY_NV)
+ grub_printf (" NV");
+ if (attr & GRUB_EFI_MEMORY_MORE_RELIABLE)
+ grub_printf (" MR");
+ if (attr & GRUB_EFI_MEMORY_RO)
+ grub_printf (" RO");
grub_printf ("\n");
}
diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c
index eda8c5ff3..df1030221 100644
--- a/grub-core/commands/efi/lsefisystab.c
+++ b/grub-core/commands/efi/lsefisystab.c
@@ -37,10 +37,20 @@ static const struct guid_mapping guid_mappings[] =
{
{ GRUB_EFI_ACPI_20_TABLE_GUID, "ACPI-2.0"},
{ GRUB_EFI_ACPI_TABLE_GUID, "ACPI-1.0"},
+ { GRUB_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID,
+ "CRC32 GUIDED SECTION EXTRACTION"},
+ { GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID, "DEBUG IMAGE INFO"},
+ { GRUB_EFI_DXE_SERVICES_TABLE_GUID, "DXE SERVICES"},
+ { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"},
+ { GRUB_EFI_HOB_LIST_GUID, "HOB LIST"},
+ { GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID, "LZMA CUSTOM DECOMPRESS"},
+ { GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID, "MEMORY TYPE INFO"},
+ { GRUB_EFI_MPS_TABLE_GUID, "MPS"},
{ GRUB_EFI_SAL_TABLE_GUID, "SAL"},
{ GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"},
- { GRUB_EFI_MPS_TABLE_GUID, "MPS"},
- { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"}
+ { GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID, "SYSTEM RESOURCE TABLE"},
+ { GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID, "TIANO CUSTOM DECOMPRESS"},
+ { GRUB_EFI_TSC_FREQUENCY_GUID, "TSC FREQUENCY"},
};
static grub_err_t
@@ -52,6 +62,7 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
grub_efi_configuration_table_t *t;
unsigned int i;
+ grub_printf ("Address: %p\n", st);
grub_printf ("Signature: %016" PRIxGRUB_UINT64_T " revision: %08x\n",
st->hdr.signature, st->hdr.revision);
{
diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
index 474b3fd21..12fba99e0 100644
--- a/grub-core/commands/file.c
+++ b/grub-core/commands/file.c
@@ -36,62 +36,66 @@ GRUB_MOD_LICENSE ("GPLv3+");
static const struct grub_arg_option options[] = {
{"is-i386-xen-pae-domu", 0, 0,
- N_("Check if FILE can be booted as i386 PAE xen unprivilegied guest"),
+ N_("Check if FILE can be booted as i386 PAE Xen unprivileged guest kernel"),
0, 0},
{"is-x86_64-xen-domu", 0, 0,
- N_("Check if FILE can be booted as x86_64 xen unprivilegied guest"), 0, 0},
+ N_("Check if FILE can be booted as x86_64 Xen unprivileged guest kernel"), 0, 0},
{"is-x86-xen-dom0", 0, 0,
- N_("Check if FILE can be used as xen x86 privilegied guest kernel"), 0, 0},
+ N_("Check if FILE can be used as Xen x86 privileged guest kernel"), 0, 0},
{"is-x86-multiboot", 0, 0,
N_("Check if FILE can be used as x86 multiboot kernel"), 0, 0},
{"is-x86-multiboot2", 0, 0,
N_("Check if FILE can be used as x86 multiboot2 kernel"), 0, 0},
{"is-arm-linux", 0, 0,
- N_("Check if FILE is ARM linux"), 0, 0},
+ N_("Check if FILE is ARM Linux"), 0, 0},
+ {"is-arm64-linux", 0, 0,
+ N_("Check if FILE is ARM64 Linux"), 0, 0},
{"is-ia64-linux", 0, 0,
- N_("Check if FILE is IA64 linux"), 0, 0},
+ N_("Check if FILE is IA64 Linux"), 0, 0},
{"is-mips-linux", 0, 0,
- N_("Check if FILE is MIPS linux"), 0, 0},
+ N_("Check if FILE is MIPS Linux"), 0, 0},
{"is-mipsel-linux", 0, 0,
- N_("Check if FILE is MIPSEL linux"), 0, 0},
+ N_("Check if FILE is MIPSEL Linux"), 0, 0},
{"is-sparc64-linux", 0, 0,
- N_("Check if FILE is SPARC64 linux"), 0, 0},
+ N_("Check if FILE is SPARC64 Linux"), 0, 0},
{"is-powerpc-linux", 0, 0,
- N_("Check if FILE is POWERPC linux"), 0, 0},
+ N_("Check if FILE is POWERPC Linux"), 0, 0},
{"is-x86-linux", 0, 0,
- N_("Check if FILE is x86 linux"), 0, 0},
+ N_("Check if FILE is x86 Linux"), 0, 0},
{"is-x86-linux32", 0, 0,
- N_("Check if FILE is x86 linux supporting 32-bit protocol"), 0, 0},
+ N_("Check if FILE is x86 Linux supporting 32-bit protocol"), 0, 0},
{"is-x86-kfreebsd", 0, 0,
- N_("Check if FILE is x86 kfreebsd"), 0, 0},
+ N_("Check if FILE is x86 kFreeBSD"), 0, 0},
{"is-i386-kfreebsd", 0, 0,
- N_("Check if FILE is i386 kfreebsd"), 0, 0},
+ N_("Check if FILE is i386 kFreeBSD"), 0, 0},
{"is-x86_64-kfreebsd", 0, 0,
- N_("Check if FILE is x86_64 kfreebsd"), 0, 0},
+ N_("Check if FILE is x86_64 kFreeBSD"), 0, 0},
{"is-x86-knetbsd", 0, 0,
- N_("Check if FILE is x86 knetbsd"), 0, 0},
+ N_("Check if FILE is x86 kNetBSD"), 0, 0},
{"is-i386-knetbsd", 0, 0,
- N_("Check if FILE is i386 knetbsd"), 0, 0},
+ N_("Check if FILE is i386 kNetBSD"), 0, 0},
{"is-x86_64-knetbsd", 0, 0,
- N_("Check if FILE is x86_64 knetbsd"), 0, 0},
+ N_("Check if FILE is x86_64 kNetBSD"), 0, 0},
{"is-i386-efi", 0, 0,
N_("Check if FILE is i386 EFI file"), 0, 0},
{"is-x86_64-efi", 0, 0,
- N_("Check if FILE is x86-64 EFI file"), 0, 0},
+ N_("Check if FILE is x86_64 EFI file"), 0, 0},
{"is-ia64-efi", 0, 0,
N_("Check if FILE is IA64 EFI file"), 0, 0},
+ {"is-arm64-efi", 0, 0,
+ N_("Check if FILE is ARM64 EFI file"), 0, 0},
{"is-arm-efi", 0, 0,
N_("Check if FILE is ARM EFI file"), 0, 0},
{"is-hibernated-hiberfil", 0, 0,
N_("Check if FILE is hiberfil.sys in hibernated state"), 0, 0},
{"is-x86_64-xnu", 0, 0,
- N_("Check if FILE is x86_64 xnu (Mac OS X kernel)"), 0, 0},
+ N_("Check if FILE is x86_64 XNU (Mac OS X kernel)"), 0, 0},
{"is-i386-xnu", 0, 0,
- N_("Check if FILE is i386 xnu (Mac OS X kernel)"), 0, 0},
+ N_("Check if FILE is i386 XNU (Mac OS X kernel)"), 0, 0},
{"is-xnu-hibr", 0, 0,
- N_("Check if FILE is xnu (Mac OS X kernel) hibernated image"), 0, 0},
+ N_("Check if FILE is XNU (Mac OS X kernel) hibernated image"), 0, 0},
{"is-x86-bios-bootsector", 0, 0,
N_("Check if FILE is BIOS bootsector"), 0, 0},
{0, 0, 0, 0, 0, 0}
@@ -105,6 +109,7 @@ enum
IS_MULTIBOOT,
IS_MULTIBOOT2,
IS_ARM_LINUX,
+ IS_ARM64_LINUX,
IS_IA64_LINUX,
IS_MIPS_LINUX,
IS_MIPSEL_LINUX,
@@ -121,6 +126,7 @@ enum
IS_32_EFI,
IS_64_EFI,
IS_IA_EFI,
+ IS_ARM64_EFI,
IS_ARM_EFI,
IS_HIBERNATED,
IS_XNU64,
@@ -377,14 +383,40 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
}
case IS_ARM_LINUX:
{
- grub_uint32_t sig;
+ grub_uint32_t sig, sig_pi;
+ if (grub_file_read (file, &sig_pi, 4) != 4)
+ break;
+ /* Raspberry pi. */
+ if (sig_pi == grub_cpu_to_le32_compile_time (0xea000006))
+ {
+ ret = 1;
+ break;
+ }
+
if (grub_file_seek (file, 0x24) == (grub_size_t) -1)
break;
if (grub_file_read (file, &sig, 4) != 4)
break;
- if (sig != grub_cpu_to_le32_compile_time (0x016f2818))
+ if (sig == grub_cpu_to_le32_compile_time (0x016f2818))
+ {
+ ret = 1;
+ break;
+ }
+ break;
+ }
+ case IS_ARM64_LINUX:
+ {
+ grub_uint32_t sig;
+
+ if (grub_file_seek (file, 0x38) == (grub_size_t) -1)
break;
- ret = 1;
+ if (grub_file_read (file, &sig, 4) != 4)
+ break;
+ if (sig == grub_cpu_to_le32_compile_time (0x644d5241))
+ {
+ ret = 1;
+ break;
+ }
break;
}
case IS_PAE_DOMU ... IS_DOM0:
@@ -444,8 +476,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
be at least 12 bytes and aligned on a 4-byte boundary. */
for (header = buffer;
((char *) header <=
- (char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12))
- || (header = 0); header += step)
+ (char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12));
+ header += step)
{
if (header[0] == magic
&& !(grub_le_to_cpu32 (header[0])
@@ -453,11 +485,12 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
+ grub_le_to_cpu32 (header[2])
+ (type == IS_MULTIBOOT2
? grub_le_to_cpu32 (header[3]) : 0)))
- break;
+ {
+ ret = 1;
+ break;
+ }
}
- if (header != 0)
- ret = 1;
grub_free (buffer);
break;
}
@@ -535,6 +568,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
case IS_32_EFI:
case IS_64_EFI:
case IS_IA_EFI:
+ case IS_ARM64_EFI:
case IS_ARM_EFI:
{
char signature[4];
@@ -573,11 +607,15 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
&& coff_head.machine !=
grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_IA64))
break;
+ if (type == IS_ARM64_EFI
+ && coff_head.machine !=
+ grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_ARM64))
+ break;
if (type == IS_ARM_EFI
&& coff_head.machine !=
grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_ARMTHUMB_MIXED))
break;
- if (type == IS_64_EFI || type == IS_64_EFI)
+ if (type == IS_IA_EFI || type == IS_64_EFI || type == IS_ARM64_EFI)
{
struct grub_pe64_optional_header o64;
if (grub_file_read (file, &o64, sizeof (o64)) != sizeof (o64))
diff --git a/grub-core/commands/fileXX.c b/grub-core/commands/fileXX.c
index c9857ff67..c17d26ce6 100644
--- a/grub-core/commands/fileXX.c
+++ b/grub-core/commands/fileXX.c
@@ -18,6 +18,7 @@
#include <grub/fileid.h>
#include <grub/elfload.h>
+#include <grub/misc.h>
#pragma GCC diagnostic ignored "-Wcast-align"
@@ -39,10 +40,10 @@ grub_file_check_netbsdXX (grub_elf_t elf)
return 0;
if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1)
- return 0;
+ goto fail;
if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize)
- return 0;
+ goto fail;
s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize);
stroff = s->sh_offset;
@@ -53,18 +54,21 @@ grub_file_check_netbsdXX (grub_elf_t elf)
char name[sizeof(".note.netbsd.ident")];
grub_memset (name, 0, sizeof (name));
if (grub_file_seek (elf->file, stroff + s->sh_name) == (grub_off_t) -1)
- return grub_errno;
+ goto fail;
if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name))
{
if (grub_errno)
- return grub_errno;
+ goto fail;
continue;
}
if (grub_memcmp (name, ".note.netbsd.ident",
sizeof(".note.netbsd.ident")) != 0)
continue;
+ grub_free (s0);
return 1;
}
+ fail:
+ grub_free (s0);
return 0;
}
diff --git a/grub-core/commands/gptsync.c b/grub-core/commands/gptsync.c
index 3db62887b..444e24874 100644
--- a/grub-core/commands/gptsync.c
+++ b/grub-core/commands/gptsync.c
@@ -101,7 +101,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
}
/* Check if it is valid. */
- if (mbr.signature != grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE))
+ if (mbr.signature != grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE))
{
grub_device_close (dev);
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
@@ -216,7 +216,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
first_sector--;
mbr.entries[0].flag = 0;
mbr.entries[0].type = GRUB_PC_PARTITION_TYPE_GPT_DISK;
- mbr.entries[0].start = grub_cpu_to_le32 (1);
+ mbr.entries[0].start = grub_cpu_to_le32_compile_time (1);
lba_to_chs (1,
&(mbr.entries[0].start_sector),
&(mbr.entries[0].start_cylinder),
@@ -227,7 +227,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
&(mbr.entries[0].end_head));
mbr.entries[0].length = grub_cpu_to_le32 (first_sector);
- mbr.signature = grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE);
+ mbr.signature = grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE);
if (grub_disk_write (dev->disk, 0, 0, sizeof (mbr), &mbr))
{
@@ -235,6 +235,8 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
return grub_errno;
}
+ grub_device_close (dev);
+
grub_printf_ (N_("New MBR is written to `%s'\n"), args[0]);
return GRUB_ERR_NONE;
diff --git a/grub-core/commands/hdparm.c b/grub-core/commands/hdparm.c
index 3fb08912d..f6b178eae 100644
--- a/grub-core/commands/hdparm.c
+++ b/grub-core/commands/hdparm.c
@@ -329,6 +329,7 @@ grub_cmd_hdparm (grub_extcmd_context_t ctxt, int argc, char **args)
break;
}
default:
+ grub_disk_close (disk);
return grub_error (GRUB_ERR_IO, "not an ATA device");
}
diff --git a/grub-core/commands/i386/cmosdump.c b/grub-core/commands/i386/cmosdump.c
index 952d200a4..626485ccb 100644
--- a/grub-core/commands/i386/cmosdump.c
+++ b/grub-core/commands/i386/cmosdump.c
@@ -55,7 +55,7 @@ GRUB_MOD_INIT(cmosdump)
{
cmd = grub_register_command ("cmosdump", grub_cmd_cmosdump,
0,
- N_("Dump CMOS contents."));
+ N_("Show raw dump of the CMOS contents."));
}
GRUB_MOD_FINI(cmosdump)
diff --git a/grub-core/commands/i386/cmostest.c b/grub-core/commands/i386/cmostest.c
index 6f7271bf9..c839b704d 100644
--- a/grub-core/commands/i386/cmostest.c
+++ b/grub-core/commands/i386/cmostest.c
@@ -45,7 +45,7 @@ static grub_err_t
grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[])
{
- int byte, bit;
+ int byte = 0, bit = 0;
grub_err_t err;
grub_uint8_t value;
@@ -67,7 +67,7 @@ static grub_err_t
grub_cmd_cmosclean (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[])
{
- int byte, bit;
+ int byte = 0, bit = 0;
grub_err_t err;
grub_uint8_t value;
@@ -85,7 +85,7 @@ static grub_err_t
grub_cmd_cmosset (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[])
{
- int byte, bit;
+ int byte = 0, bit = 0;
grub_err_t err;
grub_uint8_t value;
@@ -109,9 +109,10 @@ GRUB_MOD_INIT(cmostest)
N_("Test bit at BYTE:BIT in CMOS."));
cmd_clean = grub_register_command ("cmosclean", grub_cmd_cmosclean,
N_("BYTE:BIT"),
- N_("Clean bit at BYTE:BIT in CMOS."));
+ N_("Clear bit at BYTE:BIT in CMOS."));
cmd_set = grub_register_command ("cmosset", grub_cmd_cmosset,
N_("BYTE:BIT"),
+ /* TRANSLATORS: A bit may be either set (1) or clear (0). */
N_("Set bit at BYTE:BIT in CMOS."));
}
diff --git a/grub-core/commands/i386/coreboot/cb_timestamps.c b/grub-core/commands/i386/coreboot/cb_timestamps.c
index 5299ad4d8..e72f38d6e 100644
--- a/grub-core/commands/i386/coreboot/cb_timestamps.c
+++ b/grub-core/commands/i386/coreboot/cb_timestamps.c
@@ -39,9 +39,17 @@ static const char *descs[] = {
[2] = "before RAM init",
[3] = "after RAM init",
[4] = "end of romstage",
+ [5] = "start of verified boot",
+ [6] = "end of verified boot",
[8] = "start of RAM copy",
[9] = "end of RAM copy",
[10] = "start of ramstage",
+ [11] = "start of bootblock",
+ [12] = "end of bootblock",
+ [13] = "starting to load romstage",
+ [14] = "finished loading romstage",
+ [15] = "starting LZMA decompress (ignore for x86)",
+ [16] = "finished LZMA decompress (ignore for x86)",
[30] = "device enumerate",
[40] = "device configure",
[50] = "device enable",
@@ -109,7 +117,7 @@ GRUB_MOD_INIT(cbtime)
{
cmd_boottime =
grub_register_command ("coreboot_boottime", grub_cmd_coreboot_boottime,
- 0, N_("Get coreboot boot time statistics."));
+ 0, N_("Show coreboot boot time statistics."));
}
GRUB_MOD_FINI(cbtime)
diff --git a/grub-core/commands/i386/pc/play.c b/grub-core/commands/i386/pc/play.c
index 40798c96c..7712e2a36 100644
--- a/grub-core/commands/i386/pc/play.c
+++ b/grub-core/commands/i386/pc/play.c
@@ -107,6 +107,14 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
return grub_errno;
}
+ if (!tempo)
+ {
+ grub_file_close (file);
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid tempo in %s"),
+ args[0]);
+ return grub_errno;
+ }
+
tempo = grub_le_to_cpu32 (tempo);
grub_dprintf ("play","tempo = %d\n", tempo);
@@ -131,6 +139,13 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
tempo = grub_strtoul (args[0], &end, 0);
+ if (!tempo)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid tempo in %s"),
+ args[0]);
+ return grub_errno;
+ }
+
if (*end)
/* Was not a number either, assume it was supposed to be a file name. */
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), args[0]);
diff --git a/grub-core/commands/i386/pc/sendkey.c b/grub-core/commands/i386/pc/sendkey.c
index d985cb33f..26d9acd3d 100644
--- a/grub-core/commands/i386/pc/sendkey.c
+++ b/grub-core/commands/i386/pc/sendkey.c
@@ -292,7 +292,7 @@ find_key_code (char *key)
{
unsigned i;
- for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(keysym_table); i++)
{
if (keysym_table[i].unshifted_name
&& grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
@@ -311,7 +311,7 @@ find_ascii_code (char *key)
{
unsigned i;
- for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(keysym_table); i++)
{
if (keysym_table[i].unshifted_name
&& grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
@@ -352,15 +352,13 @@ grub_cmd_sendkey (grub_extcmd_context_t ctxt, int argc, char **args)
{
unsigned i;
- for (i = 0; i < sizeof (simple_flag_offsets)
- / sizeof (simple_flag_offsets[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(simple_flag_offsets); i++)
grub_sendkey_set_simple_flag (simple_flag_offsets[i],
grub_sendkey_parse_op(state[i]));
}
/* Set noled. */
- noled = (state[sizeof (simple_flag_offsets)
- / sizeof (simple_flag_offsets[0])].set);
+ noled = (state[ARRAY_SIZE(simple_flag_offsets)].set);
return GRUB_ERR_NONE;
}
diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c
index da04389e3..f4b773020 100644
--- a/grub-core/commands/keylayouts.c
+++ b/grub-core/commands/keylayouts.c
@@ -173,8 +173,10 @@ grub_term_map_key (grub_keyboard_key_t code, int status)
key = map_key_core (code, status, &alt_gr_consumed);
- if (key == 0 || key == GRUB_TERM_SHIFT)
+ if (key == 0 || key == GRUB_TERM_SHIFT) {
grub_printf ("Unknown key 0x%x detected\n", code);
+ return GRUB_TERM_NO_KEY;
+ }
if (status & GRUB_TERM_STATUS_CAPS)
{
diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c
index e42a9d83e..dd9d9f18f 100644
--- a/grub-core/commands/legacycfg.c
+++ b/grub-core/commands/legacycfg.c
@@ -57,14 +57,20 @@ legacy_file (const char *filename)
file = grub_file_open (filename);
if (! file)
- return grub_errno;
+ {
+ grub_free (suffix);
+ return grub_errno;
+ }
menu = grub_env_get_menu ();
if (! menu)
{
menu = grub_zalloc (sizeof (*menu));
if (! menu)
- return grub_errno;
+ {
+ grub_free (suffix);
+ return grub_errno;
+ }
grub_env_set_menu (menu);
}
@@ -77,6 +83,7 @@ legacy_file (const char *filename)
if (!buf && grub_errno)
{
grub_file_close (file);
+ grub_free (suffix);
return grub_errno;
}
@@ -173,6 +180,8 @@ legacy_file (const char *filename)
if (!args)
{
grub_file_close (file);
+ grub_free (suffix);
+ grub_free (entrysrc);
return grub_errno;
}
args[0] = entryname;
@@ -244,6 +253,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
struct grub_command *cmd;
char **cutargs;
int cutargc;
+ grub_err_t err = GRUB_ERR_NONE;
for (i = 0; i < 2; i++)
{
@@ -305,6 +315,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
cutargs = grub_malloc (sizeof (cutargs[0]) * (argc - 1));
+ if (!cutargs)
+ return grub_errno;
cutargc = argc - 1;
grub_memcpy (cutargs + 1, args + 2, sizeof (cutargs[0]) * (argc - 2));
cutargs[0] = args[0];
@@ -324,7 +336,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
if (!(cmd->func) (cmd, cutargc, cutargs))
{
kernel_type = LINUX;
- return GRUB_ERR_NONE;
+ goto out;
}
}
grub_errno = GRUB_ERR_NONE;
@@ -339,7 +351,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
if (!(cmd->func) (cmd, argc, args))
{
kernel_type = MULTIBOOT;
- return GRUB_ERR_NONE;
+ goto out;
}
}
grub_errno = GRUB_ERR_NONE;
@@ -376,6 +388,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
if (part && grub_strcmp (part->partmap->name, "msdos") == 0)
bsd_slice = part->number;
}
+ if (dev)
+ grub_device_close (dev);
}
/* k*BSD didn't really work well with grub-legacy. */
@@ -402,7 +416,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
if (!(cmd->func) (cmd, cutargc, cutargs))
{
kernel_type = KFREEBSD;
- return GRUB_ERR_NONE;
+ goto out;
}
}
grub_errno = GRUB_ERR_NONE;
@@ -411,6 +425,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
char **bsdargs;
int bsdargc;
char bsddevname[sizeof ("wdXXXXXXXXXXXXY")];
+ int found = 0;
+
if (bsd_device == -1)
{
bsdargs = cutargs;
@@ -421,6 +437,11 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
char rbuf[3] = "-r";
bsdargc = cutargc + 2;
bsdargs = grub_malloc (sizeof (bsdargs[0]) * bsdargc);
+ if (!bsdargs)
+ {
+ err = grub_errno;
+ goto out;
+ }
grub_memcpy (bsdargs, args, argc * sizeof (bsdargs[0]));
bsdargs[argc] = rbuf;
bsdargs[argc + 1] = bsddevname;
@@ -436,7 +457,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
if (!(cmd->func) (cmd, bsdargc, bsdargs))
{
kernel_type = KNETBSD;
- return GRUB_ERR_NONE;
+ found = 1;
+ goto free_bsdargs;
}
}
grub_errno = GRUB_ERR_NONE;
@@ -449,20 +471,28 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
if (!(cmd->func) (cmd, bsdargc, bsdargs))
{
kernel_type = KOPENBSD;
- return GRUB_ERR_NONE;
+ found = 1;
+ goto free_bsdargs;
}
}
grub_errno = GRUB_ERR_NONE;
}
+
+free_bsdargs:
if (bsdargs != cutargs)
grub_free (bsdargs);
+ if (found)
+ goto out;
}
}
}
while (0);
- return grub_error (GRUB_ERR_BAD_OS, "couldn't load file %s",
- args[0]);
+ err = grub_error (GRUB_ERR_BAD_OS, "couldn't load file %s",
+ args[0]);
+out:
+ grub_free (cutargs);
+ return err;
}
static grub_err_t
@@ -523,15 +553,17 @@ grub_cmd_legacy_initrdnounzip (struct grub_command *mycmd __attribute__ ((unused
char **newargs;
grub_err_t err;
char nounzipbuf[10] = "--nounzip";
+
+ cmd = grub_command_find ("module");
+ if (!cmd)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"),
+ "module");
+
newargs = grub_malloc ((argc + 1) * sizeof (newargs[0]));
if (!newargs)
return grub_errno;
grub_memcpy (newargs + 1, args, argc * sizeof (newargs[0]));
newargs[0] = nounzipbuf;
- cmd = grub_command_find ("module");
- if (!cmd)
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"),
- "module");
err = cmd->func (cmd, argc + 1, newargs);
grub_free (newargs);
@@ -580,7 +612,7 @@ check_password_md5_real (const char *entered,
GRUB_MD_MD5->write (ctx, entered, enteredlen);
digest = GRUB_MD_MD5->read (ctx);
GRUB_MD_MD5->final (ctx);
- memcpy (alt_result, digest, MD5_HASHLEN);
+ grub_memcpy (alt_result, digest, MD5_HASHLEN);
GRUB_MD_MD5->init (ctx);
GRUB_MD_MD5->write (ctx, entered, enteredlen);
@@ -596,7 +628,7 @@ check_password_md5_real (const char *entered,
for (i = 0; i < 1000; i++)
{
- memcpy (alt_result, digest, 16);
+ grub_memcpy (alt_result, digest, 16);
GRUB_MD_MD5->init (ctx);
if ((i & 1) != 0)
diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c
index de6da2616..acd93d123 100644
--- a/grub-core/commands/loadenv.c
+++ b/grub-core/commands/loadenv.c
@@ -263,7 +263,7 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
for (q = p->next; q; q = q->next)
{
grub_disk_addr_t s1, s2;
- grub_disk_addr_t e1, e2, t;
+ grub_disk_addr_t e1, e2;
s1 = p->sector;
e1 = s1 + ((p->length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
@@ -271,16 +271,7 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
s2 = q->sector;
e2 = s2 + ((q->length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
- if (s2 > s1)
- {
- t = s2;
- s2 = s1;
- s1 = t;
- t = e2;
- e2 = e1;
- e1 = t;
- }
- if (e1 > s2)
+ if (s1 < e2 && s2 < e1)
{
/* This might be actually valid, but it is unbelievable that
any filesystem makes such a silly allocation. */
@@ -455,7 +446,7 @@ GRUB_MOD_INIT(loadenv)
{
cmd_load =
grub_register_extcmd ("load_env", grub_cmd_load_env, 0,
- N_("[-f FILE] [-s|--skip-sig] [whitelisted_variable_name] [...]"),
+ N_("[-f FILE] [-s|--skip-sig] [variable_name_to_whitelist] [...]"),
N_("Load variables from environment block file."),
options);
cmd_list =
diff --git a/grub-core/commands/lsmmap.c b/grub-core/commands/lsmmap.c
index 4b504fd28..816ee47d1 100644
--- a/grub-core/commands/lsmmap.c
+++ b/grub-core/commands/lsmmap.c
@@ -37,6 +37,8 @@ static const char *names[] =
is required to save accross hibernations. */
[GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage RAM"),
[GRUB_MEMORY_BADRAM] = N_("faulty RAM (BadRAM)"),
+ [GRUB_MEMORY_PERSISTENT] = N_("persistent RAM"),
+ [GRUB_MEMORY_PERSISTENT_LEGACY] = N_("persistent RAM (legacy)"),
[GRUB_MEMORY_COREBOOT_TABLES] = N_("RAM holding coreboot tables"),
[GRUB_MEMORY_CODE] = N_("RAM holding firmware code")
};
diff --git a/grub-core/commands/macbless.c b/grub-core/commands/macbless.c
index 38ca353a2..18efa1a84 100644
--- a/grub-core/commands/macbless.c
+++ b/grub-core/commands/macbless.c
@@ -37,7 +37,7 @@ struct find_node_context
grub_uint64_t inode_found;
char *dirname;
enum
- { NONE, FILE, DIR } found;
+ { FOUND_NONE, FOUND_FILE, FOUND_DIR } found;
};
static int
@@ -53,13 +53,13 @@ find_inode (const char *filename,
&& grub_strcasecmp (ctx->dirname, filename) == 0)))
{
ctx->inode_found = info->inode;
- ctx->found = info->dir ? DIR : FILE;
+ ctx->found = info->dir ? FOUND_DIR : FOUND_FILE;
}
return 0;
}
grub_err_t
-grub_mac_bless_inode (grub_device_t dev, grub_uint64_t inode, int is_dir,
+grub_mac_bless_inode (grub_device_t dev, grub_uint32_t inode, int is_dir,
int intel)
{
grub_err_t err;
@@ -106,7 +106,7 @@ grub_mac_bless_inode (grub_device_t dev, grub_uint64_t inode, int is_dir,
ablk_size = grub_be_to_cpu32 (volheader.hfs.blksz);
ablk_start = grub_be_to_cpu16 (volheader.hfs.first_block);
embedded_offset = (ablk_start
- + extent_start
+ + ((grub_uint64_t) extent_start)
* (ablk_size >> GRUB_DISK_SECTOR_BITS));
err =
@@ -174,8 +174,8 @@ grub_mac_bless_file (grub_device_t dev, const char *path_in, int intel)
}
grub_free (path);
- return grub_mac_bless_inode (dev, ctx.inode_found, (ctx.found == DIR),
- intel);
+ return grub_mac_bless_inode (dev, (grub_uint32_t) ctx.inode_found,
+ (ctx.found == FOUND_DIR), intel);
}
static grub_err_t
@@ -183,7 +183,7 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args)
{
char *device_name;
char *path = 0;
- grub_device_t dev;
+ grub_device_t dev = 0;
grub_err_t err;
if (argc != 1)
@@ -197,13 +197,12 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args)
else
path = path + 1;
- if (!path || *path == 0 || !device_name)
+ if (!path || *path == 0 || !dev)
{
if (dev)
grub_device_close (dev);
grub_free (device_name);
- grub_free (path);
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
}
diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c
index 33b6b99ea..345f97c4d 100644
--- a/grub-core/commands/nativedisk.c
+++ b/grub-core/commands/nativedisk.c
@@ -57,6 +57,7 @@ get_uuid (const char *name, char **uuid, int getnative)
if (!dev->disk)
{
grub_dprintf ("nativedisk", "Skipping non-disk\n");
+ grub_device_close (dev);
return 0;
}
@@ -90,6 +91,7 @@ get_uuid (const char *name, char **uuid, int getnative)
case GRUB_DISK_DEVICE_MEMDISK_ID:
grub_dprintf ("nativedisk", "Skipping native disk %s\n",
dev->disk->name);
+ grub_device_close (dev);
return 0;
/* FIXME: those probably need special handling. */
@@ -196,7 +198,10 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
return grub_errno;
if (get_uuid (NULL, &uuid_root, 0))
- return grub_errno;
+ {
+ grub_free (mods);
+ return grub_errno;
+ }
prefdev = grub_file_get_device_name (prefix);
if (grub_errno)
@@ -208,6 +213,8 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
if (get_uuid (prefdev, &uuid_prefix, 0))
{
grub_free (uuid_root);
+ grub_free (prefdev);
+ grub_free (mods);
return grub_errno;
}
@@ -287,12 +294,15 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
}
grub_free (uuid_root);
grub_free (uuid_prefix);
+ grub_free (prefdev);
+ grub_free (mods);
return GRUB_ERR_NONE;
fail:
grub_free (uuid_root);
grub_free (uuid_prefix);
+ grub_free (prefdev);
for (i = 0; i < mods_loaded; i++)
if (mods[i])
@@ -300,6 +310,8 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
mods[i]->fini = 0;
grub_dl_unload (mods[i]);
}
+ grub_free (mods);
+
return grub_errno;
}
diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c
index f144c511b..693e2cb42 100644
--- a/grub-core/commands/parttool.c
+++ b/grub-core/commands/parttool.c
@@ -133,7 +133,7 @@ show_help (grub_device_t dev)
}
}
if (! found)
- grub_printf_ (N_("Sorry no parttool is available for %s\n"),
+ grub_printf_ (N_("Sorry, no parttool is available for %s\n"),
dev->disk->partition->partmap->name);
return GRUB_ERR_NONE;
}
@@ -243,11 +243,19 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
}
if (argc == 1)
- return show_help (dev);
+ {
+ err = show_help (dev);
+ grub_device_close (dev);
+ return err;
+ }
for (i = 1; i < argc; i++)
if (grub_strcmp (args[i], "help") == 0)
- return show_help (dev);
+ {
+ err = show_help (dev);
+ grub_device_close (dev);
+ return err;
+ }
parsed = (int *) grub_zalloc (argc * sizeof (int));
@@ -274,8 +282,12 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
break;
}
if (! cur)
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"),
+ {
+ grub_free (parsed);
+ grub_device_close (dev);
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"),
args[i]);
+ }
ptool = cur;
pargs = (struct grub_parttool_args *)
grub_zalloc (ptool->nargs * sizeof (struct grub_parttool_args));
diff --git a/grub-core/commands/password_pbkdf2.c b/grub-core/commands/password_pbkdf2.c
index 0dd1aef3d..da636e621 100644
--- a/grub-core/commands/password_pbkdf2.c
+++ b/grub-core/commands/password_pbkdf2.c
@@ -45,6 +45,7 @@ check_password (const char *user, const char *entered, void *pin)
grub_uint8_t *buf;
struct pbkdf2_password *pass = pin;
gcry_err_code_t err;
+ grub_err_t ret;
buf = grub_malloc (pass->buflen);
if (!buf)
@@ -55,17 +56,17 @@ check_password (const char *user, const char *entered, void *pin)
pass->salt, pass->saltlen, pass->c,
buf, pass->buflen);
if (err)
+ ret = grub_crypto_gcry_error (err);
+ else if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0)
+ ret = GRUB_ACCESS_DENIED;
+ else
{
- grub_free (buf);
- return grub_crypto_gcry_error (err);
+ grub_auth_authenticate (user);
+ ret = GRUB_ERR_NONE;
}
- if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0)
- return GRUB_ACCESS_DENIED;
-
- grub_auth_authenticate (user);
-
- return GRUB_ERR_NONE;
+ grub_free (buf);
+ return ret;
}
static inline int
@@ -104,7 +105,10 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)),
pass->c = grub_strtoul (ptr, &ptr, 0);
if (grub_errno)
- return grub_errno;
+ {
+ grub_free (pass);
+ return grub_errno;
+ }
if (*ptr != '.')
{
grub_free (pass);
diff --git a/grub-core/commands/pcidump.c b/grub-core/commands/pcidump.c
index 223d86a74..f99ad4a21 100644
--- a/grub-core/commands/pcidump.c
+++ b/grub-core/commands/pcidump.c
@@ -166,7 +166,7 @@ GRUB_MOD_INIT(pcidump)
{
cmd = grub_register_extcmd ("pcidump", grub_cmd_pcidump, 0,
N_("[-s POSITION] [-d DEVICE]"),
- N_("Dump PCI configuration space."), options);
+ N_("Show raw dump of the PCI configuration space."), options);
}
GRUB_MOD_FINI(pcidump)
diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c
index 16143a34c..7dd32e445 100644
--- a/grub-core/commands/search.c
+++ b/grub-core/commands/search.c
@@ -64,7 +64,7 @@ iterate_device (const char *name, void *data)
/* Skip floppy drives when requested. */
if (ctx->no_floppy &&
name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9')
- return 0;
+ return 1;
#ifdef DO_SEARCH_FS_UUID
#define compare_fn grub_strcasecmp
@@ -210,10 +210,10 @@ try (struct search_ctx *ctx)
/* Cache entry was outdated. Remove it. */
if (!ctx->count)
{
+ *prev = cache_ent->next;
grub_free (cache_ent->key);
grub_free (cache_ent->value);
grub_free (cache_ent);
- *prev = cache_ent->next;
}
}
diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c
index 3f75fecdf..d7fd26b94 100644
--- a/grub-core/commands/search_wrap.c
+++ b/grub-core/commands/search_wrap.c
@@ -175,7 +175,10 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
var = "root";
}
else
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+ goto out;
+ }
if (state[SEARCH_LABEL].set)
grub_search_label (id, var, state[SEARCH_NO_FLOPPY].set,
@@ -187,8 +190,10 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set,
hints, nhints);
else
- return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
+ grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
+out:
+ grub_free (hints);
return grub_errno;
}
diff --git a/grub-core/commands/syslinuxcfg.c b/grub-core/commands/syslinuxcfg.c
index da753e2cc..7be28fada 100644
--- a/grub-core/commands/syslinuxcfg.c
+++ b/grub-core/commands/syslinuxcfg.c
@@ -47,14 +47,14 @@ syslinux_file_getline (char **line, int cont __attribute__ ((unused)),
static const struct grub_arg_option options[] =
{
{"root", 'r', 0,
- N_("root directory of the syslinux disk (default /)."),
+ N_("root directory of the syslinux disk [default=/]."),
N_("DIR"), ARG_TYPE_STRING},
{"cwd", 'c', 0,
- N_("home directory of the syslinux config (default directory of configfile)."),
+ N_("current directory of syslinux [default is parent directory of input file]."),
N_("DIR"), ARG_TYPE_STRING},
- {"isolinux", 'i', 0, N_("assume isolinux."), 0, 0},
- {"pxelinux", 'p', 0, N_("assume pxelinux."), 0, 0},
- {"syslinux", 's', 0, N_("assume syslinux."), 0, 0},
+ {"isolinux", 'i', 0, N_("assume input is an isolinux configuration file."), 0, 0},
+ {"pxelinux", 'p', 0, N_("assume input is a pxelinux configuration file."), 0, 0},
+ {"syslinux", 's', 0, N_("assume input is a syslinux configuration file."), 0, 0},
{0, 0, 0, 0, 0, 0}
};
@@ -119,7 +119,10 @@ syslinux_file (grub_extcmd_context_t ctxt, const char *filename)
{
menu = grub_zalloc (sizeof (*menu));
if (! menu)
- return grub_errno;
+ {
+ grub_free (result);
+ return grub_errno;
+ }
grub_env_set_menu (menu);
}
@@ -183,25 +186,25 @@ GRUB_MOD_INIT(syslinuxcfg)
N_("FILE"),
/* TRANSLATORS: "syslinux config" means
"config as used by syslinux". */
- N_("Parse syslinux config in same context"),
+ N_("Execute syslinux config in same context"),
options);
cmd_configfile
= grub_register_extcmd ("syslinux_configfile",
grub_cmd_syslinux_source, 0,
N_("FILE"),
- N_("Parse syslinux config in new context"),
+ N_("Execute syslinux config in new context"),
options);
cmd_source_extract
= grub_register_extcmd ("extract_syslinux_entries_source",
grub_cmd_syslinux_source, 0,
N_("FILE"),
- N_("Parse syslinux config in same context taking only menu entries"),
+ N_("Execute syslinux config in same context taking only menu entries"),
options);
cmd_configfile_extract
= grub_register_extcmd ("extract_syslinux_entries_configfile",
grub_cmd_syslinux_source, 0,
N_("FILE"),
- N_("Parse syslinux config in new context taking only menu entries"),
+ N_("Execute syslinux config in new context taking only menu entries"),
options);
}
diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c
index c98c13d8c..5f06642f6 100644
--- a/grub-core/commands/test.c
+++ b/grub-core/commands/test.c
@@ -332,7 +332,7 @@ test_parse (char **args, int *argn, int argc)
get_fileinfo (args[*argn + 1], &ctx);
update_val (ctx.file_exists && ctx.file_info.dir, &ctx);
(*argn) += 2;
- return ctx.or || ctx.and;
+ continue;
}
if (grub_strcmp (args[*argn], "-e") == 0)
@@ -340,7 +340,7 @@ test_parse (char **args, int *argn, int argc)
get_fileinfo (args[*argn + 1], &ctx);
update_val (ctx.file_exists, &ctx);
(*argn) += 2;
- return ctx.or || ctx.and;
+ continue;
}
if (grub_strcmp (args[*argn], "-f") == 0)
@@ -349,7 +349,7 @@ test_parse (char **args, int *argn, int argc)
/* FIXME: check for other types. */
update_val (ctx.file_exists && ! ctx.file_info.dir, &ctx);
(*argn) += 2;
- return ctx.or || ctx.and;
+ continue;
}
if (grub_strcmp (args[*argn], "-s") == 0)
@@ -362,7 +362,7 @@ test_parse (char **args, int *argn, int argc)
grub_file_close (file);
grub_errno = GRUB_ERR_NONE;
(*argn) += 2;
- return ctx.or || ctx.and;
+ continue;
}
/* String tests. */
diff --git a/grub-core/commands/tr.c b/grub-core/commands/tr.c
index 84ad6ff8f..ef72841a2 100644
--- a/grub-core/commands/tr.c
+++ b/grub-core/commands/tr.c
@@ -80,7 +80,7 @@ grub_cmd_tr (grub_extcmd_context_t ctxt, int argc, char **args)
} else if (argc > 3)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many parameters");
- if (argc <= 0 && (!s1 || !s2 || !input))
+ if (!s1 || !s2 || !input)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing parameters");
if (grub_strlen (s1) != grub_strlen (s2))
diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c
index 87c6d4f2c..67cb1c785 100644
--- a/grub-core/commands/verify.c
+++ b/grub-core/commands/verify.c
@@ -33,6 +33,13 @@
GRUB_MOD_LICENSE ("GPLv3+");
+struct grub_verified
+{
+ grub_file_t file;
+ void *buf;
+};
+typedef struct grub_verified *grub_verified_t;
+
enum
{
OPTION_SKIP_SIG = 0
@@ -41,7 +48,7 @@ enum
static const struct grub_arg_option options[] =
{
{"skip-sig", 's', 0,
- N_("Skip signature-checking of the signature file."), 0, ARG_TYPE_NONE},
+ N_("Skip signature-checking of the public key file."), 0, ARG_TYPE_NONE},
{0, 0, 0, 0, 0, 0}
};
@@ -301,7 +308,7 @@ grub_load_public_key (grub_file_t f)
if (!sk)
goto fail;
- grub_memset (fingerprint_context, 0, sizeof (fingerprint_context));
+ grub_memset (fingerprint_context, 0, GRUB_MD_SHA1->contextsize);
GRUB_MD_SHA1->init (fingerprint_context);
GRUB_MD_SHA1->write (fingerprint_context, "\x99", 1);
len_be = grub_cpu_to_be16 (len);
@@ -317,19 +324,19 @@ grub_load_public_key (grub_file_t f)
if (grub_file_read (f, &l, sizeof (l)) != sizeof (l))
{
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
- goto fail;
+ break;
}
lb = (grub_be_to_cpu16 (l) + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT;
if (lb > READBUF_SIZE - sizeof (grub_uint16_t))
{
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
- goto fail;
+ break;
}
if (grub_file_read (f, buffer + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb)
{
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
- goto fail;
+ break;
}
grub_memcpy (buffer, &l, sizeof (l));
@@ -339,10 +346,16 @@ grub_load_public_key (grub_file_t f)
buffer, lb + sizeof (grub_uint16_t), 0))
{
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
- goto fail;
+ break;
}
}
+ if (i < pkalgos[pk].nmpipub)
+ {
+ grub_free (sk);
+ goto fail;
+ }
+
GRUB_MD_SHA1->final (fingerprint_context);
grub_memcpy (sk->fingerprint, GRUB_MD_SHA1->read (fingerprint_context), 20);
@@ -447,7 +460,7 @@ grub_verify_signature_real (char *buf, grub_size_t size,
grub_err_t err;
grub_size_t i;
gcry_mpi_t mpis[10];
- grub_uint8_t type;
+ grub_uint8_t type = 0;
err = read_packet_header (sig, &type, &len);
if (err)
@@ -802,19 +815,39 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
static int sec = 0;
+static void
+verified_free (grub_verified_t verified)
+{
+ if (verified)
+ {
+ grub_free (verified->buf);
+ grub_free (verified);
+ }
+}
+
static grub_ssize_t
verified_read (struct grub_file *file, char *buf, grub_size_t len)
{
- grub_memcpy (buf, (char *) file->data + file->offset, len);
+ grub_verified_t verified = file->data;
+
+ grub_memcpy (buf, (char *) verified->buf + file->offset, len);
return len;
}
static grub_err_t
verified_close (struct grub_file *file)
{
- grub_free (file->data);
+ grub_verified_t verified = file->data;
+
+ grub_file_close (verified->file);
+ verified_free (verified);
file->data = 0;
- return GRUB_ERR_NONE;
+
+ /* device and name are freed by parent */
+ file->device = 0;
+ file->name = 0;
+
+ return grub_errno;
}
struct grub_fs verified_fs =
@@ -832,10 +865,13 @@ grub_pubkey_open (grub_file_t io, const char *filename)
grub_err_t err;
grub_file_filter_t curfilt[GRUB_FILE_FILTER_MAX];
grub_file_t ret;
+ grub_verified_t verified;
if (!sec)
return io;
- if (io->device->disk && io->device->disk->id == GRUB_DISK_DEVICE_MEMDISK_ID)
+ if (io->device->disk &&
+ (io->device->disk->dev->id == GRUB_DISK_DEVICE_MEMDISK_ID
+ || io->device->disk->dev->id == GRUB_DISK_DEVICE_PROCFS_ID))
return io;
fsuf = grub_malloc (grub_strlen (filename) + sizeof (".sig"));
if (!fsuf)
@@ -855,7 +891,10 @@ grub_pubkey_open (grub_file_t io, const char *filename)
ret = grub_malloc (sizeof (*ret));
if (!ret)
- return NULL;
+ {
+ grub_file_close (sig);
+ return NULL;
+ }
*ret = *io;
ret->fs = &verified_fs;
@@ -864,29 +903,46 @@ grub_pubkey_open (grub_file_t io, const char *filename)
{
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"big file signature isn't implemented yet");
+ grub_file_close (sig);
+ grub_free (ret);
return NULL;
}
- ret->data = grub_malloc (ret->size);
- if (!ret->data)
+ verified = grub_malloc (sizeof (*verified));
+ if (!verified)
{
+ grub_file_close (sig);
grub_free (ret);
return NULL;
}
- if (grub_file_read (io, ret->data, ret->size) != (grub_ssize_t) ret->size)
+ verified->buf = grub_malloc (ret->size);
+ if (!verified->buf)
+ {
+ grub_file_close (sig);
+ grub_free (verified);
+ grub_free (ret);
+ return NULL;
+ }
+ if (grub_file_read (io, verified->buf, ret->size) != (grub_ssize_t) ret->size)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
+ grub_file_close (sig);
+ verified_free (verified);
+ grub_free (ret);
return NULL;
}
- err = grub_verify_signature_real (ret->data, ret->size, 0, sig, NULL);
+ err = grub_verify_signature_real (verified->buf, ret->size, 0, sig, NULL);
grub_file_close (sig);
if (err)
- return NULL;
- io->device = 0;
- io->name = 0;
- grub_file_close (io);
+ {
+ verified_free (verified);
+ grub_free (ret);
+ return NULL;
+ }
+ verified->file = io;
+ ret->data = verified;
return ret;
}
@@ -966,14 +1022,14 @@ GRUB_MOD_INIT(verify)
options);
cmd_trust = grub_register_extcmd ("trust", grub_cmd_trust, 0,
N_("[-s|--skip-sig] PUBKEY_FILE"),
- N_("Add PKFILE to trusted keys."),
+ N_("Add PUBKEY_FILE to trusted keys."),
options);
cmd_list = grub_register_command ("list_trusted", grub_cmd_list,
0,
- N_("List trusted keys."));
+ N_("Show the list of trusted keys."));
cmd_distrust = grub_register_command ("distrust", grub_cmd_distrust,
N_("PUBKEY_ID"),
- N_("Remove KEYID from trusted keys."));
+ N_("Remove PUBKEY_ID from trusted keys."));
}
GRUB_MOD_FINI(verify)
diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c
index 2807f806b..9b4e72766 100644
--- a/grub-core/commands/wildcard.c
+++ b/grub-core/commands/wildcard.c
@@ -245,7 +245,10 @@ match_devices_iter (const char *name, void *data)
t = grub_realloc (ctx->devs, sizeof (char*) * (ctx->ndev + 2));
if (! t)
- return 1;
+ {
+ grub_free (buffer);
+ return 1;
+ }
ctx->devs = t;
ctx->devs[ctx->ndev++] = buffer;
@@ -290,7 +293,8 @@ struct match_files_ctx
/* Helper for match_files. */
static int
-match_files_iter (const char *name, const struct grub_dirhook_info *info,
+match_files_iter (const char *name,
+ const struct grub_dirhook_info *info __attribute__((unused)),
void *data)
{
struct match_files_ctx *ctx = data;
diff --git a/grub-core/commands/xen/lsxen.c b/grub-core/commands/xen/lsxen.c
index def8c8b40..97713102c 100644
--- a/grub-core/commands/xen/lsxen.c
+++ b/grub-core/commands/xen/lsxen.c
@@ -78,9 +78,9 @@ static grub_command_t cmd_ls, cmd_cat;
GRUB_MOD_INIT (lsxen)
{
cmd_ls = grub_register_command ("xen_ls", grub_cmd_lsxen, N_("[DIR]"),
- N_("List XEN storage."));
+ N_("List Xen storage."));
cmd_cat = grub_register_command ("xen_cat", grub_cmd_catxen, N_("[DIR]"),
- N_("List XEN storage."));
+ N_("List Xen storage."));
}
GRUB_MOD_FINI (lsxen)
diff --git a/grub-core/disk/AFSplitter.c b/grub-core/disk/AFSplitter.c
index d76a1c447..f5a8ddc61 100644
--- a/grub-core/disk/AFSplitter.c
+++ b/grub-core/disk/AFSplitter.c
@@ -72,13 +72,13 @@ AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst,
grub_size_t i;
grub_uint8_t *bufblock;
+ if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0)
+ return GPG_ERR_INV_ARG;
+
bufblock = grub_zalloc (blocksize);
if (bufblock == NULL)
return GPG_ERR_OUT_OF_MEMORY;
- if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
- return GPG_ERR_INV_ARG;
-
grub_memset (bufblock, 0, blocksize);
for (i = 0; i < blocknumbers - 1; i++)
{
diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c
index 0b13fb8eb..494a1b773 100644
--- a/grub-core/disk/ahci.c
+++ b/grub-core/disk/ahci.c
@@ -32,7 +32,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
struct grub_ahci_cmd_head
{
grub_uint32_t config;
- grub_uint32_t transfered;
+ grub_uint32_t transferred;
grub_uint64_t command_table_base;
grub_uint32_t unused[4];
};
@@ -194,13 +194,11 @@ grub_ahci_pciinit (grub_pci_device_t dev,
return 0;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
- grub_pci_write_word (addr, grub_pci_read_word (addr) |
- GRUB_PCI_COMMAND_IO_ENABLED
- | GRUB_PCI_COMMAND_MEM_ENABLED
- | GRUB_PCI_COMMAND_BUS_MASTER);
+ grub_pci_write_word (addr, grub_pci_read_word (addr)
+ | GRUB_PCI_COMMAND_MEM_ENABLED | GRUB_PCI_COMMAND_BUS_MASTER);
hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK,
- sizeof (hba));
+ sizeof (*hba));
grub_dprintf ("ahci", "dev: %x:%x.%x\n", dev.bus, dev.device, dev.function);
grub_dprintf ("ahci", "tfd[0]: %x\n",
@@ -324,7 +322,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
- nports = (hba->cap & GRUB_AHCI_HBA_CAP_NPORTS_MASK) + 1;
+ nports = (GRUB_AHCI_HBA_CAP_NPORTS_MASK) + 1;
grub_dprintf ("ahci", "%d AHCI ports, PI = 0x%x\n", nports,
hba->ports_implemented);
@@ -357,10 +355,10 @@ grub_ahci_pciinit (grub_pci_device_t dev,
if (adevs[i])
{
adevs[i]->hba->ports[adevs[i]->port].sata_error = adevs[i]->hba->ports[adevs[i]->port].sata_error;
- grub_dprintf ("ahci", "err: %x\n",
+ grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error);
- adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head));
+ adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head) * 32);
if (!adevs[i]->command_list_chunk)
{
adevs[i] = 0;
@@ -378,6 +376,12 @@ grub_ahci_pciinit (grub_pci_device_t dev,
adevs[i]->command_list = grub_dma_get_virt (adevs[i]->command_list_chunk);
adevs[i]->command_table = grub_dma_get_virt (adevs[i]->command_table_chunk);
+
+ grub_memset ((void *) adevs[i]->command_list, 0,
+ sizeof (struct grub_ahci_cmd_table));
+ grub_memset ((void *) adevs[i]->command_table, 0,
+ sizeof (struct grub_ahci_cmd_head) * 32);
+
adevs[i]->command_list->command_table_base
= grub_dma_get_phys (adevs[i]->command_table_chunk);
@@ -436,7 +440,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
adevs[i]->hba->ports[adevs[i]->port].intstatus = ~0;
// adevs[i]->hba->ports[adevs[i]->port].fbs = 0;
- grub_dprintf ("ahci", "err: %x\n",
+ grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->rfis = grub_memalign_dma32 (4096,
@@ -450,6 +454,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
adevs[i]->hba->ports[adevs[i]->port].fis_base = grub_dma_get_phys (adevs[i]->rfis);
adevs[i]->hba->ports[adevs[i]->port].command_list_base
= grub_dma_get_phys (adevs[i]->command_list_chunk);
+ adevs[i]->hba->ports[adevs[i]->port].command_issue = 0;
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_FRE;
}
@@ -475,7 +480,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
for (i = 0; i < nports; i++)
if (adevs[i])
{
- grub_dprintf ("ahci", "err: %x\n",
+ grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error);
fr_running |= (1 << i);
@@ -483,7 +488,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON;
adevs[i]->hba->ports[adevs[i]->port].command |= 1 << 28;
- grub_dprintf ("ahci", "err: %x\n",
+ grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error);
}
@@ -510,26 +515,26 @@ grub_ahci_pciinit (grub_pci_device_t dev,
for (i = 0; i < nports; i++)
if (adevs[i])
{
- grub_dprintf ("ahci", "err: %x\n",
+ grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON;
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_SPIN_UP;
- grub_dprintf ("ahci", "err: %x\n",
+ grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->hba->ports[adevs[i]->port].sata_error = ~0;
- grub_dprintf ("ahci", "err: %x\n",
+ grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error);
- grub_dprintf ("ahci", "offset: %x, tfd:%x, CMD: %x\n",
+ grub_dprintf ("ahci", "port %d, offset: %x, tfd:%x, CMD: %x\n", adevs[i]->port,
(int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data -
(char *) adevs[i]->hba),
adevs[i]->hba->ports[adevs[i]->port].task_file_data,
adevs[i]->hba->ports[adevs[i]->port].command);
- grub_dprintf ("ahci", "err: %x\n",
+ grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error);
}
@@ -537,17 +542,19 @@ grub_ahci_pciinit (grub_pci_device_t dev,
for (i = 0; i < nports; i++)
if (adevs[i])
{
- grub_dprintf ("ahci", "offset: %x, tfd:%x, CMD: %x\n",
+ grub_dprintf ("ahci", "port %d, offset: %x, tfd:%x, CMD: %x\n", adevs[i]->port,
(int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data -
(char *) adevs[i]->hba),
adevs[i]->hba->ports[adevs[i]->port].task_file_data,
adevs[i]->hba->ports[adevs[i]->port].command);
- grub_dprintf ("ahci", "err: %x\n",
+ grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->hba->ports[adevs[i]->port].command
- = (adevs[i]->hba->ports[adevs[i]->port].command & 0x0fffffff) | (1 << 28) | 2 | 4;
+ = (adevs[i]->hba->ports[adevs[i]->port].command & 0x0fffffff) | (1 << 28)
+ | GRUB_AHCI_HBA_PORT_CMD_SPIN_UP
+ | GRUB_AHCI_HBA_PORT_CMD_POWER_ON;
/* struct grub_disk_ata_pass_through_parms parms2;
grub_memset (&parms2, 0, sizeof (parms2));
@@ -560,14 +567,14 @@ grub_ahci_pciinit (grub_pci_device_t dev,
while (grub_get_time_ms () < endtime)
{
for (i = 0; i < nports; i++)
- if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & 0x88))
+ if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ)))
break;
if (i == nports)
break;
}
for (i = 0; i < nports; i++)
- if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & 0x88))
+ if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ)))
{
grub_dprintf ("ahci", "port %d is busy\n", i);
failed_adevs[i] = adevs[i];
@@ -596,6 +603,9 @@ grub_ahci_pciinit (grub_pci_device_t dev,
failed_adevs[i] = adevs[i];
adevs[i] = 0;
}
+
+ grub_dprintf ("ahci", "cleaning up failed devs\n");
+
for (i = 0; i < nports; i++)
if (failed_adevs[i] && (fr_running & (1 << i)))
failed_adevs[i]->hba->ports[failed_adevs[i]->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
@@ -621,6 +631,10 @@ grub_ahci_pciinit (grub_pci_device_t dev,
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].sig >> 16) == 0xeb14)
adevs[i]->atapi = 1;
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write_word (addr, grub_pci_read_word (addr)
+ | GRUB_PCI_COMMAND_BUS_MASTER);
+
for (i = 0; i < nports; i++)
if (adevs[i])
{
@@ -847,6 +861,12 @@ grub_ahci_reset_port (struct grub_ahci_device *dev, int force)
{
struct grub_disk_ata_pass_through_parms parms2;
dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
+ dev->hba->ports[dev->port].command_issue = 0;
+ dev->command_list[0].config = 0;
+ dev->command_table[0].prdt[0].unused = 0;
+ dev->command_table[0].prdt[0].size = 0;
+ dev->command_table[0].prdt[0].data_base = 0;
+
endtime = grub_get_time_ms () + 1000;
while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
if (grub_get_time_ms () > endtime)
@@ -914,7 +934,10 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
if (parms->size > GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH)
return grub_error (GRUB_ERR_BUG, "too big data buffer");
- bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1));
+ if (parms->size)
+ bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1));
+ else
+ bufc = grub_memalign_dma32 (1024, 512);
grub_dprintf ("ahci", "AHCI tfd = %x, CL=%p\n",
dev->hba->ports[dev->port].task_file_data,
@@ -924,14 +947,14 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
= (5 << GRUB_AHCI_CONFIG_CFIS_LENGTH_SHIFT)
// | GRUB_AHCI_CONFIG_CLEAR_R_OK
| (0 << GRUB_AHCI_CONFIG_PMP_SHIFT)
- | (1 << GRUB_AHCI_CONFIG_PRDT_LENGTH_SHIFT)
+ | ((parms->size ? 1 : 0) << GRUB_AHCI_CONFIG_PRDT_LENGTH_SHIFT)
| (parms->cmdsize ? GRUB_AHCI_CONFIG_ATAPI : 0)
| (parms->write ? GRUB_AHCI_CONFIG_WRITE : GRUB_AHCI_CONFIG_READ)
| (parms->taskfile.cmd == 8 ? (1 << 8) : 0);
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
- dev->command_list[0].transfered = 0;
+ dev->command_list[0].transferred = 0;
dev->command_list[0].command_table_base
= grub_dma_get_phys (dev->command_table_chunk);
@@ -981,7 +1004,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
if (parms->write)
grub_memcpy ((char *) grub_dma_get_virt (bufc), parms->buffer, parms->size);
- grub_dprintf ("ahci", "AHCI command schedulded\n");
+ grub_dprintf ("ahci", "AHCI command scheduled\n");
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
grub_dprintf ("ahci", "AHCI inten = %x\n",
@@ -1001,7 +1024,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
- endtime = grub_get_time_ms () + (spinup ? 10000 : 5000);
+ endtime = grub_get_time_ms () + (spinup ? 20000 : 20000);
while ((dev->hba->ports[dev->port].command_issue & 1))
if (grub_get_time_ms () > endtime)
{
@@ -1021,7 +1044,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
dev->hba->ports[dev->port].command_issue,
dev->hba->ports[dev->port].intstatus,
dev->hba->ports[dev->port].task_file_data,
- dev->command_list[0].transfered,
+ dev->command_list[0].transferred,
dev->hba->ports[dev->port].sata_error,
((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x00],
((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x18]);
diff --git a/grub-core/disk/ata.c b/grub-core/disk/ata.c
index 2b988490f..8ba4e5c50 100644
--- a/grub-core/disk/ata.c
+++ b/grub-core/disk/ata.c
@@ -216,6 +216,12 @@ grub_ata_setaddress (struct grub_ata *dev,
unsigned int head;
unsigned int sect;
+ if (dev->sectors_per_track == 0
+ || dev->heads == 0)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ "sector %d cannot be addressed "
+ "using CHS addressing", sector);
+
/* Calculate the sector, cylinder and head to use. */
sect = ((grub_uint32_t) sector % dev->sectors_per_track) + 1;
cylinder = (((grub_uint32_t) sector / dev->sectors_per_track)
diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
index 75c6e1f91..1e03a091c 100644
--- a/grub-core/disk/cryptodisk.c
+++ b/grub-core/disk/cryptodisk.c
@@ -25,6 +25,7 @@
#include <grub/fs.h>
#include <grub/file.h>
#include <grub/procfs.h>
+#include <grub/partition.h>
#ifdef GRUB_UTIL
#include <grub/emu/hostdisk.h>
@@ -110,20 +111,23 @@ grub_crypto_pcbc_decrypt (grub_crypto_cipher_handle_t cipher,
{
grub_uint8_t *inptr, *outptr, *end;
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
- if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
- return GPG_ERR_INV_ARG;
+ grub_size_t blocksize;
if (!cipher->cipher->decrypt)
return GPG_ERR_NOT_SUPPORTED;
- if (size % cipher->cipher->blocksize != 0)
+ blocksize = cipher->cipher->blocksize;
+ if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
+ || ((size & (blocksize - 1)) != 0))
+ return GPG_ERR_INV_ARG;
+ if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
return GPG_ERR_INV_ARG;
end = (grub_uint8_t *) in + size;
for (inptr = in, outptr = out; inptr < end;
- inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize)
+ inptr += blocksize, outptr += blocksize)
{
- grub_memcpy (ivt, inptr, cipher->cipher->blocksize);
+ grub_memcpy (ivt, inptr, blocksize);
cipher->cipher->decrypt (cipher->ctx, outptr, inptr);
- grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize);
- grub_crypto_xor (iv, ivt, outptr, cipher->cipher->blocksize);
+ grub_crypto_xor (outptr, outptr, iv, blocksize);
+ grub_crypto_xor (iv, ivt, outptr, blocksize);
}
return GPG_ERR_NO_ERROR;
}
@@ -135,20 +139,23 @@ grub_crypto_pcbc_encrypt (grub_crypto_cipher_handle_t cipher,
{
grub_uint8_t *inptr, *outptr, *end;
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
- if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
- return GPG_ERR_INV_ARG;
- if (!cipher->cipher->decrypt)
+ grub_size_t blocksize;
+ if (!cipher->cipher->encrypt)
return GPG_ERR_NOT_SUPPORTED;
- if (size % cipher->cipher->blocksize != 0)
+ blocksize = cipher->cipher->blocksize;
+ if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
+ return GPG_ERR_INV_ARG;
+ if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
+ || ((size & (blocksize - 1)) != 0))
return GPG_ERR_INV_ARG;
end = (grub_uint8_t *) in + size;
for (inptr = in, outptr = out; inptr < end;
- inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize)
+ inptr += blocksize, outptr += blocksize)
{
- grub_memcpy (ivt, inptr, cipher->cipher->blocksize);
- grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize);
+ grub_memcpy (ivt, inptr, blocksize);
+ grub_crypto_xor (outptr, outptr, iv, blocksize);
cipher->cipher->encrypt (cipher->ctx, outptr, inptr);
- grub_crypto_xor (iv, ivt, outptr, cipher->cipher->blocksize);
+ grub_crypto_xor (iv, ivt, outptr, blocksize);
}
return GPG_ERR_NO_ERROR;
}
@@ -372,11 +379,13 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
break;
case GRUB_CRYPTODISK_MODE_ECB:
if (do_encrypt)
- grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i,
- (1U << dev->log_sector_size));
+ err = grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i,
+ (1U << dev->log_sector_size));
else
- grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i,
- (1U << dev->log_sector_size));
+ err = grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i,
+ (1U << dev->log_sector_size));
+ if (err)
+ return err;
break;
default:
return GPG_ERR_NOT_IMPLEMENTED;
@@ -710,6 +719,7 @@ grub_cryptodisk_insert (grub_cryptodisk_t newdev, const char *name,
newdev->id = last_cryptodisk_id++;
newdev->source_id = source->id;
newdev->source_dev_id = source->dev->id;
+ newdev->partition_start = grub_partition_get_start (source->partition);
newdev->next = cryptodisk_list;
cryptodisk_list = newdev;
@@ -732,7 +742,9 @@ grub_cryptodisk_get_by_source_disk (grub_disk_t disk)
grub_cryptodisk_t dev;
for (dev = cryptodisk_list; dev != NULL; dev = dev->next)
if (dev->source_id == disk->id && dev->source_dev_id == disk->dev->id)
- return dev;
+ if ((disk->partition && grub_partition_get_start (disk->partition) == dev->partition_start) ||
+ (!disk->partition && dev->partition_start == 0))
+ return dev;
return NULL;
}
@@ -753,6 +765,7 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
newdev->cheat_fd = GRUB_UTIL_FD_INVALID;
newdev->source_id = source->id;
newdev->source_dev_id = source->dev->id;
+ newdev->partition_start = grub_partition_get_start (source->partition);
newdev->id = last_cryptodisk_id++;
newdev->next = cryptodisk_list;
cryptodisk_list = newdev;
@@ -762,25 +775,26 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
void
grub_util_cryptodisk_get_abstraction (grub_disk_t disk,
- void (*cb) (const char *val))
+ void (*cb) (const char *val, void *data),
+ void *data)
{
grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
- cb ("cryptodisk");
- cb (dev->modname);
+ cb ("cryptodisk", data);
+ cb (dev->modname, data);
if (dev->cipher)
- cb (dev->cipher->cipher->modname);
+ cb (dev->cipher->cipher->modname, data);
if (dev->secondary_cipher)
- cb (dev->secondary_cipher->cipher->modname);
+ cb (dev->secondary_cipher->cipher->modname, data);
if (dev->essiv_cipher)
- cb (dev->essiv_cipher->cipher->modname);
+ cb (dev->essiv_cipher->cipher->modname, data);
if (dev->hash)
- cb (dev->hash->modname);
+ cb (dev->hash->modname, data);
if (dev->essiv_hash)
- cb (dev->essiv_hash->modname);
+ cb (dev->essiv_hash->modname, data);
if (dev->iv_hash)
- cb (dev->iv_hash->modname);
+ cb (dev->iv_hash->modname, data);
}
const char *
@@ -955,33 +969,43 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args)
grub_disk_t disk;
grub_cryptodisk_t dev;
char *diskname;
- char *disklast;
+ char *disklast = NULL;
+ grub_size_t len;
search_uuid = NULL;
check_boot = state[2].set;
diskname = args[0];
- if (diskname[0] == '(' && *(disklast = &diskname[grub_strlen (diskname) - 1]) == ')')
+ len = grub_strlen (diskname);
+ if (len && diskname[0] == '(' && diskname[len - 1] == ')')
{
+ disklast = &diskname[len - 1];
*disklast = '\0';
- disk = grub_disk_open (diskname + 1);
- *disklast = ')';
+ diskname++;
}
- else
- disk = grub_disk_open (diskname);
+
+ disk = grub_disk_open (diskname);
if (!disk)
- return grub_errno;
+ {
+ if (disklast)
+ *disklast = ')';
+ return grub_errno;
+ }
dev = grub_cryptodisk_get_by_source_disk (disk);
if (dev)
{
grub_dprintf ("cryptodisk", "already mounted as crypto%lu\n", dev->id);
grub_disk_close (disk);
+ if (disklast)
+ *disklast = ')';
return GRUB_ERR_NONE;
}
- err = grub_cryptodisk_scan_device_real (args[0], disk);
+ err = grub_cryptodisk_scan_device_real (diskname, disk);
grub_disk_close (disk);
+ if (disklast)
+ *disklast = ')';
return err;
}
diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c
index 28b70c666..6f901c0ad 100644
--- a/grub-core/disk/diskfilter.c
+++ b/grub-core/disk/diskfilter.c
@@ -71,10 +71,12 @@ is_lv_readable (struct grub_diskfilter_lv *lv, int easily)
case GRUB_DISKFILTER_RAID6:
if (!easily)
need--;
+ /* Fallthrough. */
case GRUB_DISKFILTER_RAID4:
case GRUB_DISKFILTER_RAID5:
if (!easily)
need--;
+ /* Fallthrough. */
case GRUB_DISKFILTER_STRIPED:
break;
@@ -354,7 +356,8 @@ grub_diskfilter_memberlist (grub_disk_t disk)
void
grub_diskfilter_get_partmap (grub_disk_t disk,
- void (*cb) (const char *pm))
+ void (*cb) (const char *pm, void *data),
+ void *data)
{
struct grub_diskfilter_lv *lv = disk->data;
struct grub_diskfilter_pv *pv;
@@ -376,7 +379,7 @@ grub_diskfilter_get_partmap (grub_disk_t disk,
continue;
}
for (s = 0; pv->partmaps[s]; s++)
- cb (pv->partmaps[s]);
+ cb (pv->partmaps[s], data);
}
}
@@ -482,6 +485,96 @@ grub_diskfilter_read_node (const struct grub_diskfilter_node *node,
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown node '%s'", node->name);
}
+
+static grub_err_t
+validate_segment (struct grub_diskfilter_segment *seg);
+
+static grub_err_t
+validate_lv (struct grub_diskfilter_lv *lv)
+{
+ unsigned int i;
+ if (!lv)
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown volume");
+
+ if (!lv->vg || lv->vg->extent_size == 0)
+ return grub_error (GRUB_ERR_READ_ERROR, "invalid volume");
+
+ for (i = 0; i < lv->segment_count; i++)
+ {
+ grub_err_t err;
+ err = validate_segment (&lv->segments[i]);
+ if (err)
+ return err;
+ }
+ return GRUB_ERR_NONE;
+}
+
+
+static grub_err_t
+validate_node (const struct grub_diskfilter_node *node)
+{
+ /* Check whether we actually know the physical volume we want to
+ read from. */
+ if (node->pv)
+ return GRUB_ERR_NONE;
+ if (node->lv)
+ return validate_lv (node->lv);
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown node '%s'", node->name);
+}
+
+static grub_err_t
+validate_segment (struct grub_diskfilter_segment *seg)
+{
+ grub_err_t err;
+
+ if (seg->stripe_size == 0 || seg->node_count == 0)
+ return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
+
+ switch (seg->type)
+ {
+ case GRUB_DISKFILTER_RAID10:
+ {
+ grub_uint8_t near, far;
+ near = seg->layout & 0xFF;
+ far = (seg->layout >> 8) & 0xFF;
+ if ((seg->layout >> 16) == 0 && far == 0)
+ return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
+ if (near > seg->node_count)
+ return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
+ break;
+ }
+
+ case GRUB_DISKFILTER_STRIPED:
+ case GRUB_DISKFILTER_MIRROR:
+ break;
+
+ case GRUB_DISKFILTER_RAID4:
+ case GRUB_DISKFILTER_RAID5:
+ if (seg->node_count <= 1)
+ return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
+ break;
+
+ case GRUB_DISKFILTER_RAID6:
+ if (seg->node_count <= 2)
+ return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
+ break;
+
+ default:
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unsupported RAID level %d", seg->type);
+ }
+
+ unsigned i;
+ for (i = 0; i < seg->node_count; i++)
+ {
+ err = validate_node (&seg->nodes[i]);
+ if (err)
+ return err;
+ }
+ return GRUB_ERR_NONE;
+
+}
+
static grub_err_t
read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector,
grub_size_t size, char *buf)
@@ -493,6 +586,7 @@ read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector,
if (seg->node_count == 1)
return grub_diskfilter_read_node (&seg->nodes[0],
sector, size, buf);
+ /* Fallthrough. */
case GRUB_DISKFILTER_MIRROR:
case GRUB_DISKFILTER_RAID10:
{
@@ -847,6 +941,23 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
for (lv = vg->lvs; lv; lv = lv->next)
{
+ grub_err_t err;
+
+ /* RAID 1 and single-disk RAID 0 don't use a chunksize but code
+ assumes one so set one. */
+ for (i = 0; i < lv->segment_count; i++)
+ {
+ if (lv->segments[i].type == 1)
+ lv->segments[i].stripe_size = 64;
+ if (lv->segments[i].type == GRUB_DISKFILTER_STRIPED
+ && lv->segments[i].node_count == 1
+ && lv->segments[i].stripe_size == 0)
+ lv->segments[i].stripe_size = 64;
+ }
+
+ err = validate_lv(lv);
+ if (err)
+ return err;
lv->number = lv_num++;
if (lv->fullname)
@@ -887,12 +998,6 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
lv->fullname = tmp;
}
}
- /* RAID 1 doesn't use a chunksize but code assumes one so set
- one. */
- for (i = 0; i < lv->segment_count; i++)
- if (lv->segments[i].type == 1)
- lv->segments[i].stripe_size = 64;
- lv->vg = vg;
}
/* Add our new array to the list. */
vg->next = array_list;
@@ -902,7 +1007,7 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
struct grub_diskfilter_vg *
grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
- char *name, grub_uint64_t disk_size,
+ const char *name, grub_uint64_t disk_size,
grub_uint64_t stripe_size,
int layout, int level)
{
@@ -925,6 +1030,11 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
n = layout & 0xFF;
if (n == 1)
n = (layout >> 8) & 0xFF;
+ if (n == 0)
+ {
+ grub_free (uuid);
+ return NULL;
+ }
totsize = grub_divmod64 (nmemb * disk_size, n, 0);
}
@@ -938,6 +1048,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
break;
default:
+ grub_free (uuid);
return NULL;
}
@@ -951,7 +1062,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
array->lvs->segments->extent_count = totsize;
}
- if (array->lvs->segments
+ if (array->lvs && array->lvs->segments
&& array->lvs->segments->raid_member_size > disk_size)
array->lvs->segments->raid_member_size = disk_size;
@@ -960,7 +1071,10 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
}
array = grub_zalloc (sizeof (*array));
if (!array)
- return NULL;
+ {
+ grub_free (uuid);
+ return NULL;
+ }
array->uuid = uuid;
array->uuid_len = uuidlen;
if (name)
@@ -982,8 +1096,16 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
goto fail;
array->lvs->segment_count = 1;
array->lvs->visible = 1;
- array->lvs->name = array->name;
- array->lvs->fullname = array->name;
+ if (array->name)
+ {
+ array->lvs->name = grub_strdup (array->name);
+ if (!array->lvs->name)
+ goto fail;
+ array->lvs->fullname = grub_strdup (array->name);
+ if (!array->lvs->fullname)
+ goto fail;
+ }
+ array->lvs->vg = array;
array->lvs->idname = grub_malloc (sizeof ("mduuid/") + 2 * uuidlen);
if (!array->lvs->idname)
@@ -1033,13 +1155,26 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
return array;
fail:
- grub_free (array->lvs);
+ if (array->lvs)
+ {
+ grub_free (array->lvs->name);
+ grub_free (array->lvs->fullname);
+ grub_free (array->lvs->idname);
+ if (array->lvs->segments)
+ {
+ grub_free (array->lvs->segments->nodes);
+ grub_free (array->lvs->segments);
+ }
+ grub_free (array->lvs);
+ }
while (array->pvs)
{
pv = array->pvs->next;
grub_free (array->pvs);
array->pvs = pv;
}
+ grub_free (array->name);
+ grub_free (array->uuid);
grub_free (array);
return NULL;
}
@@ -1142,10 +1277,9 @@ free_array (void)
{
unsigned i;
vg->lvs = lv->next;
- if (lv->name != lv->fullname)
- grub_free (lv->fullname);
- if (lv->name != vg->name)
- grub_free (lv->name);
+ grub_free (lv->fullname);
+ grub_free (lv->name);
+ grub_free (lv->idname);
for (i = 0; i < lv->segment_count; i++)
grub_free (lv->segments[i].nodes);
grub_free (lv->segments);
diff --git a/grub-core/disk/dmraid_nvidia.c b/grub-core/disk/dmraid_nvidia.c
index 6e6405529..060279124 100644
--- a/grub-core/disk/dmraid_nvidia.c
+++ b/grub-core/disk/dmraid_nvidia.c
@@ -99,6 +99,8 @@ grub_dmraid_nv_detect (grub_disk_t disk,
struct grub_nv_super sb;
int level;
grub_uint64_t disk_size;
+ grub_uint32_t capacity;
+ grub_uint8_t total_volumes;
char *uuid;
if (disk->partition)
@@ -124,11 +126,17 @@ grub_dmraid_nv_detect (grub_disk_t disk,
return NULL;
}
+ capacity = grub_le_to_cpu32 (sb.capacity);
+ total_volumes = sb.array.total_volumes;
+
switch (sb.array.raid_level)
{
case NV_LEVEL_0:
level = 0;
- disk_size = sb.capacity / sb.array.total_volumes;
+ if (total_volumes == 0)
+ /* Not RAID. */
+ return NULL;
+ disk_size = capacity / total_volumes;
break;
case NV_LEVEL_1:
@@ -138,7 +146,10 @@ grub_dmraid_nv_detect (grub_disk_t disk,
case NV_LEVEL_5:
level = 5;
- disk_size = sb.capacity / (sb.array.total_volumes - 1);
+ if (total_volumes == 0 || total_volumes == 1)
+ /* Not RAID. */
+ return NULL;
+ disk_size = capacity / (total_volumes - 1);
break;
default:
@@ -161,7 +172,7 @@ grub_dmraid_nv_detect (grub_disk_t disk,
return grub_diskfilter_make_raid (sizeof (sb.array.signature),
uuid, sb.array.total_volumes,
- NULL, disk_size,
+ "nv", disk_size,
sb.array.stripe_block_size,
GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC,
level);
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
index e04203fe0..3b79f7bbc 100644
--- a/grub-core/disk/efi/efidisk.c
+++ b/grub-core/disk/efi/efidisk.c
@@ -43,47 +43,6 @@ static struct grub_efidisk_data *fd_devices;
static struct grub_efidisk_data *hd_devices;
static struct grub_efidisk_data *cd_devices;
-/* Duplicate a device path. */
-static grub_efi_device_path_t *
-duplicate_device_path (const grub_efi_device_path_t *dp)
-{
- grub_efi_device_path_t *p;
- grub_size_t total_size = 0;
-
- for (p = (grub_efi_device_path_t *) dp;
- ;
- p = GRUB_EFI_NEXT_DEVICE_PATH (p))
- {
- total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p);
- if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p))
- break;
- }
-
- p = grub_malloc (total_size);
- if (! p)
- return 0;
-
- grub_memcpy (p, dp, total_size);
- return p;
-}
-
-/* Return the device path node right before the end node. */
-static grub_efi_device_path_t *
-find_last_device_path (const grub_efi_device_path_t *dp)
-{
- grub_efi_device_path_t *next, *p;
-
- if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
- return 0;
-
- for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH (p);
- ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next);
- p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next))
- ;
-
- return p;
-}
-
static struct grub_efidisk_data *
make_devices (void)
{
@@ -110,7 +69,7 @@ make_devices (void)
if (! dp)
continue;
- ldp = find_last_device_path (dp);
+ ldp = grub_efi_find_last_device_path (dp);
if (! ldp)
/* This is empty. Why? */
continue;
@@ -126,6 +85,12 @@ make_devices (void)
{
/* Uggh. */
grub_free (handles);
+ while (devices)
+ {
+ d = devices->next;
+ grub_free (devices);
+ devices = d;
+ }
return 0;
}
@@ -150,11 +115,11 @@ find_parent_device (struct grub_efidisk_data *devices,
grub_efi_device_path_t *dp, *ldp;
struct grub_efidisk_data *parent;
- dp = duplicate_device_path (d->device_path);
+ dp = grub_efi_duplicate_device_path (d->device_path);
if (! dp)
return 0;
- ldp = find_last_device_path (dp);
+ ldp = grub_efi_find_last_device_path (dp);
ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
ldp->length = sizeof (*ldp);
@@ -180,11 +145,11 @@ is_child (struct grub_efidisk_data *child,
grub_efi_device_path_t *dp, *ldp;
int ret;
- dp = duplicate_device_path (child->device_path);
+ dp = grub_efi_duplicate_device_path (child->device_path);
if (! dp)
return 0;
- ldp = find_last_device_path (dp);
+ ldp = grub_efi_find_last_device_path (dp);
ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
ldp->length = sizeof (*ldp);
@@ -207,8 +172,8 @@ add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d)
{
int ret;
- ret = grub_efi_compare_device_paths (find_last_device_path ((*p)->device_path),
- find_last_device_path (d->device_path));
+ ret = grub_efi_compare_device_paths (grub_efi_find_last_device_path ((*p)->device_path),
+ grub_efi_find_last_device_path (d->device_path));
if (ret == 0)
ret = grub_efi_compare_device_paths ((*p)->device_path,
d->device_path);
@@ -333,6 +298,21 @@ name_devices (struct grub_efidisk_data *devices)
if (! dp)
continue;
+ /* Ghosts proudly presented by Apple. */
+ if (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
+ && GRUB_EFI_DEVICE_PATH_SUBTYPE (dp)
+ == GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE)
+ {
+ grub_efi_vendor_device_path_t *vendor = (grub_efi_vendor_device_path_t *) dp;
+ const struct grub_efi_guid apple = GRUB_EFI_VENDOR_APPLE_GUID;
+
+ if (vendor->header.length == sizeof (*vendor)
+ && grub_memcmp (&vendor->vendor_guid, &apple,
+ sizeof (vendor->vendor_guid)) == 0
+ && find_parent_device (devices, d))
+ continue;
+ }
+
m = d->block_io->media;
if (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_ACPI_DEVICE_PATH_TYPE
&& GRUB_EFI_DEVICE_PATH_SUBTYPE (dp)
@@ -513,8 +493,15 @@ grub_efidisk_open (const char *name, struct grub_disk *disk)
m = d->block_io->media;
/* FIXME: Probably it is better to store the block size in the disk,
and total sectors should be replaced with total blocks. */
- grub_dprintf ("efidisk", "m = %p, last block = %llx, block size = %x\n",
- m, (unsigned long long) m->last_block, m->block_size);
+ grub_dprintf ("efidisk",
+ "m = %p, last block = %llx, block size = %x, io align = %x\n",
+ m, (unsigned long long) m->last_block, m->block_size,
+ m->io_align);
+
+ /* Ensure required buffer alignment is a power of two (or is zero). */
+ if (m->io_align & (m->io_align - 1))
+ return grub_error (GRUB_ERR_IO, "invalid buffer alignment %d", m->io_align);
+
disk->total_sectors = m->last_block + 1;
/* Don't increase this value due to bug in some EFI. */
disk->max_agglomerate = 0xa0000 >> (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS);
@@ -544,15 +531,42 @@ grub_efidisk_readwrite (struct grub_disk *disk, grub_disk_addr_t sector,
{
struct grub_efidisk_data *d;
grub_efi_block_io_t *bio;
+ grub_efi_status_t status;
+ grub_size_t io_align, num_bytes;
+ char *aligned_buf;
d = disk->data;
bio = d->block_io;
- return efi_call_5 ((wr ? bio->write_blocks : bio->read_blocks), bio,
- bio->media->media_id,
- (grub_efi_uint64_t) sector,
- (grub_efi_uintn_t) size << disk->log_sector_size,
- buf);
+ /* Set alignment to 1 if 0 specified */
+ io_align = bio->media->io_align ? bio->media->io_align : 1;
+ num_bytes = size << disk->log_sector_size;
+
+ if ((grub_addr_t) buf & (io_align - 1))
+ {
+ aligned_buf = grub_memalign (io_align, num_bytes);
+ if (! aligned_buf)
+ return GRUB_EFI_OUT_OF_RESOURCES;
+ if (wr)
+ grub_memcpy (aligned_buf, buf, num_bytes);
+ }
+ else
+ {
+ aligned_buf = buf;
+ }
+
+ status = efi_call_5 ((wr ? bio->write_blocks : bio->read_blocks), bio,
+ bio->media->media_id, (grub_efi_uint64_t) sector,
+ (grub_efi_uintn_t) num_bytes, aligned_buf);
+
+ if ((grub_addr_t) buf & (io_align - 1))
+ {
+ if (!wr)
+ grub_memcpy (buf, aligned_buf, num_bytes);
+ grub_free (aligned_buf);
+ }
+
+ return status;
}
static grub_err_t
@@ -567,7 +581,9 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
status = grub_efidisk_readwrite (disk, sector, size, buf, 0);
- if (status != GRUB_EFI_SUCCESS)
+ if (status == GRUB_EFI_NO_MEDIA)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'"), disk->name);
+ else if (status != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_READ_ERROR,
N_("failure reading sector 0x%llx from `%s'"),
(unsigned long long) sector,
@@ -588,7 +604,9 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,
status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1);
- if (status != GRUB_EFI_SUCCESS)
+ if (status == GRUB_EFI_NO_MEDIA)
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'"), disk->name);
+ else if (status != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_WRITE_ERROR,
N_("failure writing sector 0x%llx to `%s'"),
(unsigned long long) sector, disk->name);
@@ -780,7 +798,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
if (! dp)
return 0;
- ldp = find_last_device_path (dp);
+ ldp = grub_efi_find_last_device_path (dp);
if (! ldp)
return 0;
@@ -788,7 +806,6 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE
|| GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))
{
- int is_cdrom = 0;
struct grub_efidisk_get_device_name_ctx ctx;
char *dev_name;
grub_efi_device_path_t *dup_dp;
@@ -796,22 +813,19 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
/* It is necessary to duplicate the device path so that GRUB
can overwrite it. */
- dup_dp = duplicate_device_path (dp);
+ dup_dp = grub_efi_duplicate_device_path (dp);
if (! dup_dp)
return 0;
while (1)
{
grub_efi_device_path_t *dup_ldp;
- dup_ldp = find_last_device_path (dup_dp);
+ dup_ldp = grub_efi_find_last_device_path (dup_dp);
if (!(GRUB_EFI_DEVICE_PATH_TYPE (dup_ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE
|| GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)))
break;
- if (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE)
- is_cdrom = 1;
-
dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
dup_ldp->length = sizeof (*dup_ldp);
@@ -846,10 +860,13 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
if (! ctx.partition_name)
{
+ /* No partition found. In most cases partition is embed in
+ the root path anyway, so this is not critical.
+ This happens only if partition is on partmap that GRUB
+ doesn't need to access root.
+ */
grub_disk_close (parent);
- if (is_cdrom)
- return grub_strdup (device_name);
- return 0;
+ return grub_strdup (device_name);
}
dev_name = grub_xasprintf ("%s,%s", parent->name,
diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c
index 9025c9d46..e9d23299a 100644
--- a/grub-core/disk/geli.c
+++ b/grub-core/disk/geli.c
@@ -212,7 +212,8 @@ grub_util_get_geli_uuid (const char *dev)
s = grub_util_get_fd_size (fd, dev, &log_secsize);
s >>= log_secsize;
- grub_util_fd_seek (fd, (s << log_secsize) - 512);
+ if (grub_util_fd_seek (fd, (s << log_secsize) - 512) < 0)
+ grub_util_error ("%s", _("couldn't read ELI metadata"));
uuid = xmalloc (GRUB_MD_SHA256->mdlen * 2 + 1);
if (grub_util_fd_read (fd, (void *) &hdr, 512) < 0)
@@ -225,13 +226,16 @@ grub_util_get_geli_uuid (const char *dev)
/* Look for GELI magic sequence. */
if (grub_memcmp (header->magic, GELI_MAGIC, sizeof (GELI_MAGIC))
- || grub_le_to_cpu32 (header->version) > 5
+ || grub_le_to_cpu32 (header->version) > 7
|| grub_le_to_cpu32 (header->version) < 1)
grub_util_error ("%s", _("wrong ELI magic or version"));
err = make_uuid ((void *) &hdr, uuid);
if (err)
- return NULL;
+ {
+ grub_free (uuid);
+ return NULL;
+ }
return uuid;
}
@@ -265,7 +269,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
/* Look for GELI magic sequence. */
if (grub_memcmp (header.magic, GELI_MAGIC, sizeof (GELI_MAGIC))
- || grub_le_to_cpu32 (header.version) > 5
+ || grub_le_to_cpu32 (header.version) > 7
|| grub_le_to_cpu32 (header.version) < 1)
{
grub_dprintf ("geli", "wrong magic %02x\n", header.magic[0]);
@@ -332,19 +336,29 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
{
secondary_cipher = grub_crypto_cipher_open (ciph);
if (!secondary_cipher)
- return NULL;
+ {
+ grub_crypto_cipher_close (cipher);
+ return NULL;
+ }
+
}
if (grub_le_to_cpu16 (header.keylen) > 1024)
{
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid keysize %d",
grub_le_to_cpu16 (header.keylen));
+ grub_crypto_cipher_close (cipher);
+ grub_crypto_cipher_close (secondary_cipher);
return NULL;
}
newdev = grub_zalloc (sizeof (struct grub_cryptodisk));
if (!newdev)
- return NULL;
+ {
+ grub_crypto_cipher_close (cipher);
+ grub_crypto_cipher_close (secondary_cipher);
+ return NULL;
+ }
newdev->cipher = cipher;
newdev->secondary_cipher = secondary_cipher;
newdev->offset = 0;
@@ -391,6 +405,7 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
grub_uint8_t geomkey[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t verify_key[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t zero[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
+ grub_uint8_t geli_cipher_key[64];
char passphrase[MAX_PASSPHRASE] = "";
unsigned i;
gcry_err_code_t gcry_err;
@@ -514,6 +529,19 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
continue;
grub_printf_ (N_("Slot %d opened\n"), i);
+ if (grub_le_to_cpu32 (header.version) >= 7)
+ {
+ /* GELI >=7 uses the cipher_key */
+ grub_memcpy (geli_cipher_key, candidate_key.cipher_key,
+ sizeof (candidate_key.cipher_key));
+ }
+ else
+ {
+ /* GELI <=6 uses the iv_key */
+ grub_memcpy (geli_cipher_key, candidate_key.iv_key,
+ sizeof (candidate_key.iv_key));
+ }
+
/* Set the master key. */
if (!dev->rekey)
{
@@ -530,13 +558,13 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
grub_size_t real_keysize = keysize;
if (grub_le_to_cpu16 (header.alg) == 0x16)
real_keysize *= 2;
- /* For a reason I don't know, the IV key is used in rekeying. */
- grub_memcpy (dev->rekey_key, candidate_key.iv_key,
- sizeof (candidate_key.iv_key));
+
+ grub_memcpy (dev->rekey_key, geli_cipher_key,
+ sizeof (geli_cipher_key));
dev->rekey_derived_size = real_keysize;
dev->last_rekey = -1;
COMPILE_TIME_ASSERT (sizeof (dev->rekey_key)
- >= sizeof (candidate_key.iv_key));
+ >= sizeof (geli_cipher_key));
}
dev->iv_prefix_len = sizeof (candidate_key.iv_key);
diff --git a/grub-core/disk/i386/pc/biosdisk.c b/grub-core/disk/i386/pc/biosdisk.c
index 1689539cd..f0aadd111 100644
--- a/grub-core/disk/i386/pc/biosdisk.c
+++ b/grub-core/disk/i386/pc/biosdisk.c
@@ -382,7 +382,8 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
/* Some buggy BIOSes doesn't return the total sectors
correctly but returns zero. So if it is zero, compute
it by C/H/S returned by the LBA BIOS call. */
- total_sectors = drp->cylinders * drp->heads * drp->sectors;
+ total_sectors = ((grub_uint64_t) drp->cylinders)
+ * drp->heads * drp->sectors;
if (drp->bytes_per_sector
&& !(drp->bytes_per_sector & (drp->bytes_per_sector - 1))
&& drp->bytes_per_sector >= 512
@@ -419,8 +420,14 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
}
}
+ if (data->sectors == 0)
+ data->sectors = 63;
+ if (data->heads == 0)
+ data->heads = 255;
+
if (! total_sectors)
- total_sectors = data->cylinders * data->heads * data->sectors;
+ total_sectors = ((grub_uint64_t) data->cylinders)
+ * data->heads * data->sectors;
}
disk->total_sectors = total_sectors;
@@ -455,6 +462,14 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
{
struct grub_biosdisk_data *data = disk->data;
+ /* VirtualBox fails with sectors above 2T on CDs.
+ Since even BD-ROMS are never that big anyway, return error. */
+ if ((data->flags & GRUB_BIOSDISK_FLAG_CDROM)
+ && (sector >> 32))
+ return grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("attempt to read or write outside of disk `%s'"),
+ disk->name);
+
if (data->flags & GRUB_BIOSDISK_FLAG_LBA)
{
struct grub_biosdisk_dap *dap;
diff --git a/grub-core/disk/ieee1275/nand.c b/grub-core/disk/ieee1275/nand.c
index 576e9ccc4..feffa8c4c 100644
--- a/grub-core/disk/ieee1275/nand.c
+++ b/grub-core/disk/ieee1275/nand.c
@@ -113,6 +113,11 @@ grub_nand_open (const char *name, grub_disk_t disk)
}
data->block_size = (args.size1 >> GRUB_DISK_SECTOR_BITS);
+ if (!data->block_size)
+ {
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "invalid block size");
+ goto fail;
+ }
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
args.method = (grub_ieee1275_cell_t) "size";
diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
index 6870b3958..235c0fe2c 100644
--- a/grub-core/disk/ieee1275/ofdisk.c
+++ b/grub-core/disk/ieee1275/ofdisk.c
@@ -34,7 +34,8 @@ struct ofdisk_hash_ent
char *open_path;
char *grub_devpath;
int is_boot;
- int is_cdrom;
+ int is_removable;
+ int block_size_fails;
/* Pointer to shortest available name on nodes representing canonical names,
otherwise NULL. */
const char *shortest;
@@ -42,6 +43,10 @@ struct ofdisk_hash_ent
struct ofdisk_hash_ent *next;
};
+static grub_err_t
+grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size,
+ struct ofdisk_hash_ent *op);
+
#define OFDISK_HASH_SZ 8
static struct ofdisk_hash_ent *ofdisk_hash[OFDISK_HASH_SZ];
@@ -123,7 +128,7 @@ ofdisk_hash_add_real (char *devpath)
}
static int
-check_string_cdrom (const char *str)
+check_string_removable (const char *str)
{
const char *ptr = grub_strrchr (str, '/');
@@ -131,7 +136,7 @@ check_string_cdrom (const char *str)
ptr++;
else
ptr = str;
- return (grub_strncmp (ptr, "cdrom", 5) == 0);
+ return (grub_strncmp (ptr, "cdrom", 5) == 0 || grub_strncmp (ptr, "fd", 2) == 0);
}
static struct ofdisk_hash_ent *
@@ -147,8 +152,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
{
p->shortest = p->devpath;
p->grub_shortest = p->grub_devpath;
- if (check_string_cdrom (devpath))
- p->is_cdrom = 1;
+ if (check_string_removable (devpath))
+ p->is_removable = 1;
return p;
}
@@ -158,8 +163,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
else
grub_free (curcan);
- if (check_string_cdrom (devpath) || check_string_cdrom (curcan))
- pcan->is_cdrom = 1;
+ if (check_string_removable (devpath) || check_string_removable (curcan))
+ pcan->is_removable = 1;
if (!pcan)
grub_errno = GRUB_ERR_NONE;
@@ -222,7 +227,10 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
if (grub_ieee1275_open (alias->path, &ihandle))
return;
-
+
+ /* This method doesn't need memory allocation for the table. Open
+ firmware takes care of all memory management and the result table
+ stays in memory and is never freed. */
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
args.method = (grub_ieee1275_cell_t) "vscsi-report-luns";
args.ihandle = ihandle;
@@ -255,6 +263,82 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
grub_free (buf);
return;
}
+ else if (grub_strcmp (alias->type, "sas_ioa") == 0)
+ {
+ /* The method returns the number of disks and a table where
+ * each ID is 64-bit long. Example of sas paths:
+ * /pci@80000002000001f/pci1014,034A@0/sas/disk@c05db70800
+ * /pci@80000002000001f/pci1014,034A@0/sas/disk@a05db70800
+ * /pci@80000002000001f/pci1014,034A@0/sas/disk@805db70800 */
+
+ struct sas_children
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t max;
+ grub_ieee1275_cell_t table;
+ grub_ieee1275_cell_t catch_result;
+ grub_ieee1275_cell_t nentries;
+ }
+ args;
+ char *buf, *bufptr;
+ unsigned i;
+ grub_uint64_t *table;
+ grub_uint16_t table_size;
+ grub_ieee1275_ihandle_t ihandle;
+
+ buf = grub_malloc (grub_strlen (alias->path) +
+ sizeof ("/disk@7766554433221100"));
+ if (!buf)
+ return;
+ bufptr = grub_stpcpy (buf, alias->path);
+
+ /* Power machines documentation specify 672 as maximum SAS disks in
+ one system. Using a slightly larger value to be safe. */
+ table_size = 768;
+ table = grub_malloc (table_size * sizeof (grub_uint64_t));
+
+ if (!table)
+ {
+ grub_free (buf);
+ return;
+ }
+
+ if (grub_ieee1275_open (alias->path, &ihandle))
+ {
+ grub_free (buf);
+ grub_free (table);
+ return;
+ }
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 2);
+ args.method = (grub_ieee1275_cell_t) "get-sas-children";
+ args.ihandle = ihandle;
+ args.max = table_size;
+ args.table = (grub_ieee1275_cell_t) table;
+ args.catch_result = 0;
+ args.nentries = 0;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ {
+ grub_ieee1275_close (ihandle);
+ grub_free (table);
+ grub_free (buf);
+ return;
+ }
+
+ for (i = 0; i < args.nentries; i++)
+ {
+ grub_snprintf (bufptr, sizeof ("/disk@7766554433221100"),
+ "/disk@%" PRIxGRUB_UINT64_T, table[i]);
+ dev_iterate_real (buf, buf);
+ }
+
+ grub_ieee1275_close (ihandle);
+ grub_free (table);
+ grub_free (buf);
+ }
if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS)
&& grub_strcmp (alias->type, "block") == 0)
@@ -330,7 +414,7 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
}
}
- if (!ent->is_boot && ent->is_cdrom)
+ if (!ent->is_boot && ent->is_removable)
continue;
if (hook (ent->grub_shortest, hook_data))
@@ -375,6 +459,8 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
/* XXX: This should be large enough for any possible case. */
char prop[64];
grub_ssize_t actual;
+ grub_uint32_t block_size = 0;
+ grub_err_t err;
if (grub_strncmp (name, "ieee1275/", sizeof ("ieee1275/") - 1) != 0)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
@@ -405,14 +491,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a block device");
}
- grub_uint32_t block_size = 0;
- if (grub_ofdisk_get_block_size (devpath, &block_size) == 0)
- {
- for (disk->log_sector_size = 0;
- (1U << disk->log_sector_size) < block_size;
- disk->log_sector_size++);
- }
-
/* XXX: There is no property to read the number of blocks. There
should be a property `#blocks', but it is not there. Perhaps it
is possible to use seek for this. */
@@ -423,14 +501,31 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
op = ofdisk_hash_find (devpath);
if (!op)
op = ofdisk_hash_add (devpath, NULL);
- else
- grub_free (devpath);
if (!op)
- return grub_errno;
+ {
+ grub_free (devpath);
+ return grub_errno;
+ }
disk->id = (unsigned long) op;
disk->data = op->open_path;
+
+ err = grub_ofdisk_get_block_size (devpath, &block_size, op);
+ if (err)
+ {
+ grub_free (devpath);
+ return err;
+ }
+ if (block_size != 0)
+ {
+ for (disk->log_sector_size = 0;
+ (1U << disk->log_sector_size) < block_size;
+ disk->log_sector_size++);
+ }
+ else
+ disk->log_sector_size = 9;
}
+ grub_free (devpath);
return 0;
}
@@ -589,8 +684,9 @@ grub_ofdisk_init (void)
grub_disk_dev_register (&grub_ofdisk_dev);
}
-grub_err_t
-grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size)
+static grub_err_t
+grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size,
+ struct ofdisk_hash_ent *op)
{
struct size_args_ieee1275
{
@@ -612,20 +708,34 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size)
if (! last_ihandle)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
+ *block_size = 0;
+
+ if (op->block_size_fails >= 2)
+ return GRUB_ERR_NONE;
+
INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2);
args_ieee1275.method = (grub_ieee1275_cell_t) "block-size";
args_ieee1275.ihandle = last_ihandle;
args_ieee1275.result = 1;
- *block_size = GRUB_DISK_SECTOR_SIZE;
-
- if ((IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) || (args_ieee1275.result))
- grub_dprintf ("disk", "can't get block size\n");
- else
- if (args_ieee1275.size1
- && !(args_ieee1275.size1 & (args_ieee1275.size1 - 1))
- && args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384)
+ if (IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1)
+ {
+ grub_dprintf ("disk", "can't get block size: failed call-method\n");
+ op->block_size_fails++;
+ }
+ else if (args_ieee1275.result)
+ {
+ grub_dprintf ("disk", "can't get block size: %lld\n",
+ (long long) args_ieee1275.result);
+ op->block_size_fails++;
+ }
+ else if (args_ieee1275.size1
+ && !(args_ieee1275.size1 & (args_ieee1275.size1 - 1))
+ && args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384)
+ {
+ op->block_size_fails = 0;
*block_size = args_ieee1275.size1;
+ }
return 0;
}
diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
index d64d0a89d..0f978ad05 100644
--- a/grub-core/disk/ldm.c
+++ b/grub-core/disk/ldm.c
@@ -963,7 +963,7 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
if (embed_type != GRUB_EMBED_PCBIOS)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
- "LDM curently supports only PC-BIOS embedding");
+ "LDM currently supports only PC-BIOS embedding");
if (disk->partition)
return grub_error (GRUB_ERR_BUG, "disk isn't LDM");
pv = grub_diskfilter_get_pv_from_disk (disk, &vg);
@@ -1012,7 +1012,7 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
usable for bootloaders (called generically
"embedding zone") and this operation is
called "embedding". */
- N_("your LDM embedding Partition is too small;"
+ N_("your LDM Embedding Partition is too small;"
" embedding won't be possible"));
*nsectors = lv->size;
if (*nsectors > max_nsectors)
diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c
index 250202947..86c50c612 100644
--- a/grub-core/disk/luks.c
+++ b/grub-core/disk/luks.c
@@ -143,6 +143,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
{
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid keysize %d",
grub_be_to_cpu32 (header.keyBytes));
+ grub_crypto_cipher_close (cipher);
return NULL;
}
@@ -181,9 +182,10 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
}
if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES)
{
- grub_crypto_cipher_close (cipher);
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported XTS block size: %d",
cipher->cipher->blocksize);
+ grub_crypto_cipher_close (cipher);
+ grub_crypto_cipher_close (secondary_cipher);
return NULL;
}
if (secondary_cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES)
@@ -191,6 +193,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
grub_crypto_cipher_close (cipher);
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported XTS block size: %d",
secondary_cipher->cipher->blocksize);
+ grub_crypto_cipher_close (secondary_cipher);
return NULL;
}
}
@@ -200,9 +203,9 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
cipheriv = ciphermode + sizeof ("lrw-") - 1;
if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES)
{
- grub_crypto_cipher_close (cipher);
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported LRW block size: %d",
cipher->cipher->blocksize);
+ grub_crypto_cipher_close (cipher);
return NULL;
}
}
@@ -225,6 +228,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|| cipher->cipher->blocksize == 0)
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported benbi blocksize: %d",
cipher->cipher->blocksize);
+ /* FIXME should we return an error here? */
for (benbi_log = 0;
(cipher->cipher->blocksize << benbi_log) < GRUB_DISK_SECTOR_SIZE;
benbi_log++);
@@ -243,6 +247,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
if (!essiv_hash)
{
grub_crypto_cipher_close (cipher);
+ grub_crypto_cipher_close (secondary_cipher);
grub_error (GRUB_ERR_FILE_NOT_FOUND,
"Couldn't load %s hash", hash_str);
return NULL;
@@ -251,12 +256,14 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
if (!essiv_cipher)
{
grub_crypto_cipher_close (cipher);
+ grub_crypto_cipher_close (secondary_cipher);
return NULL;
}
}
else
{
grub_crypto_cipher_close (cipher);
+ grub_crypto_cipher_close (secondary_cipher);
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown IV mode: %s",
cipheriv);
return NULL;
@@ -276,7 +283,12 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
newdev = grub_zalloc (sizeof (struct grub_cryptodisk));
if (!newdev)
- return NULL;
+ {
+ grub_crypto_cipher_close (cipher);
+ grub_crypto_cipher_close (essiv_cipher);
+ grub_crypto_cipher_close (secondary_cipher);
+ return NULL;
+ }
newdev->cipher = cipher;
newdev->offset = grub_be_to_cpu32 (header.payloadOffset);
newdev->source_disk = NULL;
@@ -451,6 +463,7 @@ luks_recover_key (grub_disk_t source,
return GRUB_ERR_NONE;
}
+ grub_free (split_key);
return GRUB_ACCESS_DENIED;
}
diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c
index 4025532c4..7b265c780 100644
--- a/grub-core/disk/lvm.c
+++ b/grub-core/disk/lvm.c
@@ -65,7 +65,7 @@ grub_lvm_checkvalue (char **p, char *str, char *tmpl)
static int
grub_lvm_check_flag (char *p, const char *str, const char *flag)
{
- int len_str = grub_strlen (str), len_flag = grub_strlen (flag);
+ grub_size_t len_str = grub_strlen (str), len_flag = grub_strlen (flag);
while (1)
{
char *q;
@@ -111,7 +111,8 @@ grub_lvm_detect (grub_disk_t disk,
struct grub_lvm_disk_locn *dlocn;
struct grub_lvm_mda_header *mdah;
struct grub_lvm_raw_locn *rlocn;
- unsigned int i, j, vgname_len;
+ unsigned int i, j;
+ grub_size_t vgname_len;
struct grub_diskfilter_vg *vg;
struct grub_diskfilter_pv *pv;
@@ -159,7 +160,7 @@ grub_lvm_detect (grub_disk_t disk,
"we don't support multiple LVM data areas");
#ifdef GRUB_UTIL
- grub_util_info ("we don't support multiple LVM data areas\n");
+ grub_util_info ("we don't support multiple LVM data areas");
#endif
goto fail;
}
@@ -188,7 +189,7 @@ grub_lvm_detect (grub_disk_t disk,
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unknown LVM metadata header");
#ifdef GRUB_UTIL
- grub_util_info ("unknown LVM metadata header\n");
+ grub_util_info ("unknown LVM metadata header");
#endif
goto fail2;
}
@@ -212,7 +213,7 @@ grub_lvm_detect (grub_disk_t disk,
if (q == metadatabuf + mda_size)
{
#ifdef GRUB_UTIL
- grub_util_info ("error parsing metadata\n");
+ grub_util_info ("error parsing metadata");
#endif
goto fail2;
}
@@ -229,7 +230,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("couldn't find ID\n");
+ grub_util_info ("couldn't find ID");
#endif
goto fail3;
}
@@ -257,7 +258,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("unknown extent size\n");
+ grub_util_info ("unknown extent size");
#endif
goto fail4;
}
@@ -273,7 +274,7 @@ grub_lvm_detect (grub_disk_t disk,
/* Add all the pvs to the volume group. */
while (1)
{
- int s;
+ grub_ssize_t s;
while (grub_isspace (*p))
p++;
@@ -305,7 +306,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("unknown pe_start\n");
+ grub_util_info ("unknown pe_start");
#endif
goto pvs_fail;
}
@@ -314,7 +315,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("error parsing pe_start\n");
+ grub_util_info ("error parsing pe_start");
#endif
goto pvs_fail;
}
@@ -332,15 +333,15 @@ grub_lvm_detect (grub_disk_t disk,
}
}
- p = grub_strstr (p, "logical_volumes");
+ p = grub_strstr (p, "logical_volumes {");
if (p)
{
- p += sizeof ("logical_volumes = ") - 1;
+ p += sizeof ("logical_volumes {") - 1;
/* And add all the lvs to the volume group. */
while (1)
{
- int s;
+ grub_ssize_t s;
int skip_lv = 0;
struct grub_diskfilter_lv *lv;
struct grub_diskfilter_segment *seg;
@@ -401,7 +402,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("couldn't find ID\n");
+ grub_util_info ("couldn't find ID");
#endif
goto lvs_fail;
}
@@ -421,11 +422,11 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("unknown segment_count\n");
+ grub_util_info ("unknown segment_count");
#endif
goto lvs_fail;
}
- lv->segments = grub_malloc (sizeof (*seg) * lv->segment_count);
+ lv->segments = grub_zalloc (sizeof (*seg) * lv->segment_count);
seg = lv->segments;
for (i = 0; i < lv->segment_count; i++)
@@ -435,7 +436,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("unknown segment\n");
+ grub_util_info ("unknown segment");
#endif
goto lvs_segment_fail;
}
@@ -444,7 +445,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("unknown start_extent\n");
+ grub_util_info ("unknown start_extent");
#endif
goto lvs_segment_fail;
}
@@ -452,7 +453,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("unknown extent_count\n");
+ grub_util_info ("unknown extent_count");
#endif
goto lvs_segment_fail;
}
@@ -474,7 +475,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("unknown stripe_count\n");
+ grub_util_info ("unknown stripe_count");
#endif
goto lvs_segment_fail;
}
@@ -490,7 +491,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("unknown stripes\n");
+ grub_util_info ("unknown stripes");
#endif
goto lvs_segment_fail2;
}
@@ -532,7 +533,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("unknown mirror_count\n");
+ grub_util_info ("unknown mirror_count");
#endif
goto lvs_segment_fail;
}
@@ -544,7 +545,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("unknown mirrors\n");
+ grub_util_info ("unknown mirrors");
#endif
goto lvs_segment_fail2;
}
@@ -576,13 +577,17 @@ grub_lvm_detect (grub_disk_t disk,
if (is_pvmove)
seg->node_count = 1;
}
- else if (grub_memcmp (p, "raid", sizeof ("raid") - 1)
- == 0 && (p[sizeof ("raid") - 1] >= '4'
- && p[sizeof ("raid") - 1] <= '6')
+ else if (grub_memcmp (p, "raid", sizeof ("raid") - 1) == 0
+ && ((p[sizeof ("raid") - 1] >= '4'
+ && p[sizeof ("raid") - 1] <= '6')
+ || p[sizeof ("raid") - 1] == '1')
&& p[sizeof ("raidX") - 1] == '"')
{
switch (p[sizeof ("raid") - 1])
{
+ case '1':
+ seg->type = GRUB_DISKFILTER_MIRROR;
+ break;
case '4':
seg->type = GRUB_DISKFILTER_RAID4;
seg->layout = GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC;
@@ -602,21 +607,23 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("unknown device_count\n");
+ grub_util_info ("unknown device_count");
#endif
goto lvs_segment_fail;
}
- seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
- if (p == NULL)
+ if (seg->type != GRUB_DISKFILTER_MIRROR)
{
+ seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
+ if (p == NULL)
+ {
#ifdef GRUB_UTIL
- grub_util_info ("unknown stripe_size\n");
+ grub_util_info ("unknown stripe_size");
#endif
- goto lvs_segment_fail;
+ goto lvs_segment_fail;
+ }
}
-
seg->nodes = grub_zalloc (sizeof (seg->nodes[0])
* seg->node_count);
@@ -624,7 +631,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
- grub_util_info ("unknown mirrors\n");
+ grub_util_info ("unknown raids");
#endif
goto lvs_segment_fail2;
}
@@ -671,7 +678,7 @@ grub_lvm_detect (grub_disk_t disk,
p2 = grub_strchr (p, '"');
if (p2)
*p2 = 0;
- grub_util_info ("unknown LVM type %s\n", p);
+ grub_util_info ("unknown LVM type %s", p);
if (p2)
*p2 ='"';
#endif
diff --git a/grub-core/disk/mdraid_linux.c b/grub-core/disk/mdraid_linux.c
index 4aa588235..11024ae31 100644
--- a/grub-core/disk/mdraid_linux.c
+++ b/grub-core/disk/mdraid_linux.c
@@ -33,16 +33,16 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define grub_md_to_cpu64 grub_be_to_cpu64
#define grub_md_to_cpu32 grub_be_to_cpu32
#define grub_md_to_cpu16 grub_be_to_cpu16
-#define grub_cpu_to_md64_compile_time grub_cpu_to_be64
-#define grub_cpu_to_md32_compile_time grub_cpu_to_be32
-#define grub_cpu_to_md16_compile_time grub_cpu_to_be16
+#define grub_cpu_to_md64_compile_time grub_cpu_to_be64_compile_time
+#define grub_cpu_to_md32_compile_time grub_cpu_to_be32_compile_time
+#define grub_cpu_to_md16_compile_time grub_cpu_to_be16_compile_time
#else
#define grub_md_to_cpu64 grub_le_to_cpu64
#define grub_md_to_cpu32 grub_le_to_cpu32
#define grub_md_to_cpu16 grub_le_to_cpu16
-#define grub_cpu_to_md64_compile_time grub_cpu_to_le64
-#define grub_cpu_to_md32_compile_time grub_cpu_to_le32
-#define grub_cpu_to_md16_compile_time grub_cpu_to_le16
+#define grub_cpu_to_md64_compile_time grub_cpu_to_le64_compile_time
+#define grub_cpu_to_md32_compile_time grub_cpu_to_le32_compile_time
+#define grub_cpu_to_md16_compile_time grub_cpu_to_le16_compile_time
#endif
#define RESERVED_BYTES (64 * 1024)
diff --git a/grub-core/disk/raid6_recover.c b/grub-core/disk/raid6_recover.c
index 61a8ba666..aa674f6ca 100644
--- a/grub-core/disk/raid6_recover.c
+++ b/grub-core/disk/raid6_recover.c
@@ -34,9 +34,9 @@ static unsigned powx_inv[256];
static const grub_uint8_t poly = 0x1d;
static void
-grub_raid_block_mulx (unsigned mul, char *buf, int size)
+grub_raid_block_mulx (unsigned mul, char *buf, grub_size_t size)
{
- int i;
+ grub_size_t i;
grub_uint8_t *p;
p = (grub_uint8_t *) buf;
@@ -63,6 +63,16 @@ grub_raid6_init_table (void)
}
}
+static unsigned
+mod_255 (unsigned x)
+{
+ while (x > 0xff)
+ x = (x >> 8) + (x & 0xff);
+ if (x == 0xff)
+ return 0;
+ return x;
+}
+
static grub_err_t
grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p,
char *buf, grub_disk_addr_t sector, grub_size_t size)
@@ -162,11 +172,11 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p,
grub_crypto_xor (qbuf, qbuf, buf, size);
- c = ((255 ^ bad1)
- + (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)])) % 255;
+ c = mod_255((255 ^ bad1)
+ + (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)]));
grub_raid_block_mulx (c, qbuf, size);
- c = ((unsigned) bad2 + c) % 255;
+ c = mod_255((unsigned) bad2 + c);
grub_raid_block_mulx (c, pbuf, size);
grub_crypto_xor (pbuf, pbuf, qbuf, size);
diff --git a/grub-core/disk/scsi.c b/grub-core/disk/scsi.c
index b6cb2f421..4c6923f8b 100644
--- a/grub-core/disk/scsi.c
+++ b/grub-core/disk/scsi.c
@@ -201,7 +201,7 @@ grub_scsi_read_capacity16 (grub_scsi_t scsi)
rc.opcode = grub_scsi_cmd_read_capacity16;
rc.lun = (scsi->lun << GRUB_SCSI_LUN_SHIFT) | 0x10;
rc.logical_block_addr = 0;
- rc.alloc_len = grub_cpu_to_be32 (sizeof (rcd));
+ rc.alloc_len = grub_cpu_to_be32_compile_time (sizeof (rcd));
rc.PMI = 0;
rc.control = 0;
@@ -615,9 +615,10 @@ grub_scsi_open (const char *name, grub_disk_t disk)
if (scsi->blocksize & (scsi->blocksize - 1) || !scsi->blocksize)
{
+ grub_error (GRUB_ERR_IO, "invalid sector size %d",
+ scsi->blocksize);
grub_free (scsi);
- return grub_error (GRUB_ERR_IO, "invalid sector size %d",
- scsi->blocksize);
+ return grub_errno;
}
for (disk->log_sector_size = 0;
(1U << disk->log_sector_size) < scsi->blocksize;
diff --git a/grub-core/disk/usbms.c b/grub-core/disk/usbms.c
index 2b769bdd8..380ca4c4c 100644
--- a/grub-core/disk/usbms.c
+++ b/grub-core/disk/usbms.c
@@ -307,7 +307,7 @@ grub_usbms_transfer_bo (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
/* Setup the request. */
grub_memset (&cbw, 0, sizeof (cbw));
- cbw.signature = grub_cpu_to_le32 (0x43425355);
+ cbw.signature = grub_cpu_to_le32_compile_time (0x43425355);
cbw.tag = tag;
cbw.transfer_length = grub_cpu_to_le32 (size);
cbw.flags = (!read_write) << GRUB_USBMS_DIRECTION_BIT;
@@ -414,7 +414,7 @@ CheckCSW:
/* If phase error or not valid signature, do bulk-only reset device. */
if ((status.status == 2) ||
- (status.signature != grub_cpu_to_le32(0x53425355)))
+ (status.signature != grub_cpu_to_le32_compile_time(0x53425355)))
{ /* Bulk-only reset device. */
grub_dprintf ("usb", "Bulk-only reset device - bad status\n");
grub_usbms_reset (dev);
diff --git a/grub-core/disk/xen/xendisk.c b/grub-core/disk/xen/xendisk.c
index 2b11c2a2e..b18a9238d 100644
--- a/grub-core/disk/xen/xendisk.c
+++ b/grub-core/disk/xen/xendisk.c
@@ -40,6 +40,7 @@ struct virtdisk
grub_xen_evtchn_t evtchn;
void *dma_page;
grub_xen_grant_t dma_grant;
+ struct virtdisk *compat_next;
};
#define xen_wmb() mb()
@@ -47,6 +48,7 @@ struct virtdisk
static struct virtdisk *virtdisks;
static grub_size_t vdiskcnt;
+struct virtdisk *compat_head;
static int
grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
@@ -66,20 +68,32 @@ grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
static grub_err_t
grub_virtdisk_open (const char *name, grub_disk_t disk)
{
- grub_size_t i;
+ int i;
grub_uint32_t secsize;
char fdir[200];
char *buf;
+ int num = -1;
+ struct virtdisk *vd;
- for (i = 0; i < vdiskcnt; i++)
- if (grub_strcmp (name, virtdisks[i].fullname) == 0)
+ /* For compatibility with pv-grub legacy menu.lst accept hdX as disk name */
+ if (name[0] == 'h' && name[1] == 'd' && name[2])
+ {
+ num = grub_strtoul (name + 2, 0, 10);
+ if (grub_errno)
+ {
+ grub_errno = 0;
+ num = -1;
+ }
+ }
+ for (i = 0, vd = compat_head; vd; vd = vd->compat_next, i++)
+ if (i == num || grub_strcmp (name, vd->fullname) == 0)
break;
- if (i == vdiskcnt)
+ if (!vd)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a virtdisk");
- disk->data = &virtdisks[i];
- disk->id = i;
+ disk->data = vd;
+ disk->id = vd - virtdisks;
- grub_snprintf (fdir, sizeof (fdir), "%s/sectors", virtdisks[i].backend_dir);
+ grub_snprintf (fdir, sizeof (fdir), "%s/sectors", vd->backend_dir);
buf = grub_xenstore_get_file (fdir, NULL);
if (!buf)
return grub_errno;
@@ -87,8 +101,7 @@ grub_virtdisk_open (const char *name, grub_disk_t disk)
if (grub_errno)
return grub_errno;
- grub_snprintf (fdir, sizeof (fdir), "%s/sector-size",
- virtdisks[i].backend_dir);
+ grub_snprintf (fdir, sizeof (fdir), "%s/sector-size", vd->backend_dir);
buf = grub_xenstore_get_file (fdir, NULL);
if (!buf)
return grub_errno;
@@ -264,6 +277,7 @@ fill (const char *dir, void *data)
grub_err_t err;
void *buf;
struct evtchn_alloc_unbound alloc_unbound;
+ struct virtdisk **prev = &compat_head, *vd = compat_head;
/* Shouldn't happen unles some hotplug happened. */
if (vdiskcnt >= *ctr)
@@ -374,6 +388,19 @@ fill (const char *dir, void *data)
virtdisks[vdiskcnt].frontend_dir = grub_strdup (fdir);
+ /* For compatibility with pv-grub maintain linked list sorted by handle
+ value in increasing order. This allows mapping of (hdX) disk names
+ from legacy menu.lst */
+ while (vd)
+ {
+ if (vd->handle > virtdisks[vdiskcnt].handle)
+ break;
+ prev = &vd->compat_next;
+ vd = vd->compat_next;
+ }
+ virtdisks[vdiskcnt].compat_next = vd;
+ *prev = &virtdisks[vdiskcnt];
+
vdiskcnt++;
return 0;
diff --git a/grub-core/efiemu/loadcore.c b/grub-core/efiemu/loadcore.c
index 6968b3719..44085ef81 100644
--- a/grub-core/efiemu/loadcore.c
+++ b/grub-core/efiemu/loadcore.c
@@ -154,7 +154,10 @@ grub_efiemu_init_segments (grub_efiemu_segment_t *segs, const Elf_Ehdr *e)
s->sh_flags & SHF_EXECINSTR ? GRUB_EFI_RUNTIME_SERVICES_CODE
: GRUB_EFI_RUNTIME_SERVICES_DATA);
if (seg->handle < 0)
- return grub_errno;
+ {
+ grub_free (seg);
+ return grub_errno;
+ }
seg->off = 0;
}
@@ -343,7 +346,7 @@ SUFFIX (grub_efiemu_loadcore_init) (void *core, const char *filename,
return grub_error (GRUB_ERR_BAD_MODULE, N_("this ELF file is not of the right type"));
/* Make sure that every section is within the core. */
- if ((grub_size_t) core_size < e->e_shoff + e->e_shentsize * e->e_shnum)
+ if ((grub_size_t) core_size < e->e_shoff + (grub_uint32_t) e->e_shentsize * e->e_shnum)
return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
filename);
diff --git a/grub-core/efiemu/main.c b/grub-core/efiemu/main.c
index f2140ad29..f6813b1ed 100644
--- a/grub-core/efiemu/main.c
+++ b/grub-core/efiemu/main.c
@@ -196,7 +196,7 @@ grub_efiemu_load_file (const char *filename)
{
grub_file_close (file);
grub_efiemu_unload ();
- return grub_errno;
+ return err;
}
grub_dprintf ("efiemu", "mm initialized\n");
diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c
index d4a4f3aad..e606dbffc 100644
--- a/grub-core/efiemu/mm.c
+++ b/grub-core/efiemu/mm.c
@@ -99,7 +99,8 @@ grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
grub_size_t align_overhead;
struct grub_efiemu_memrequest *ret, *cur, *prev;
/* Check that the request is correct */
- if (type >= GRUB_EFI_MAX_MEMORY_TYPE || type <= GRUB_EFI_LOADER_CODE)
+ if (type <= GRUB_EFI_LOADER_CODE || type == GRUB_EFI_PERSISTENT_MEMORY ||
+ type >= GRUB_EFI_MAX_MEMORY_TYPE)
return -2;
/* Add new size to requested size */
@@ -166,6 +167,13 @@ efiemu_alloc_requests (void)
GRUB_EFI_MEMORY_MAPPED_IO,
GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE,
GRUB_EFI_PAL_CODE
+
+ /*
+ * These are not allocatable:
+ * GRUB_EFI_RESERVED_MEMORY_TYPE
+ * GRUB_EFI_PERSISTENT_MEMORY
+ * >= GRUB_EFI_MAX_MEMORY_TYPE
+ */
};
/* Compute total memory needed */
@@ -402,6 +410,10 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
return grub_efiemu_add_to_mmap (addr, size,
GRUB_EFI_ACPI_MEMORY_NVS);
+ case GRUB_MEMORY_PERSISTENT:
+ case GRUB_MEMORY_PERSISTENT_LEGACY:
+ return grub_efiemu_add_to_mmap (addr, size,
+ GRUB_EFI_PERSISTENT_MEMORY);
default:
grub_dprintf ("efiemu",
"Unknown memory type %d. Assuming unusable\n", type);
@@ -445,7 +457,7 @@ grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
case GRUB_EFI_MEMORY_MAPPED_IO:
case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
case GRUB_EFI_PAL_CODE:
- case GRUB_EFI_MAX_MEMORY_TYPE:
+ default:
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
GRUB_MEMORY_RESERVED, hook_data);
break;
@@ -468,6 +480,12 @@ grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
GRUB_MEMORY_NVS, hook_data);
break;
+
+ case GRUB_EFI_PERSISTENT_MEMORY:
+ hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
+ GRUB_MEMORY_PERSISTENT, hook_data);
+ break;
+
}
return 0;
@@ -503,7 +521,8 @@ grub_efiemu_mmap_sort_and_uniq (void)
[GRUB_EFI_ACPI_MEMORY_NVS] = 3,
[GRUB_EFI_MEMORY_MAPPED_IO] = 4,
[GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE] = 4,
- [GRUB_EFI_PAL_CODE] = 4
+ [GRUB_EFI_PAL_CODE] = 4,
+ [GRUB_EFI_PERSISTENT_MEMORY] = 4
};
int i, j, k, done;
diff --git a/grub-core/efiemu/prepare.c b/grub-core/efiemu/prepare.c
index fb1b25d17..99ddb5abb 100644
--- a/grub-core/efiemu/prepare.c
+++ b/grub-core/efiemu/prepare.c
@@ -21,6 +21,7 @@
#include <grub/err.h>
#include <grub/mm.h>
#include <grub/types.h>
+#include <grub/misc.h>
#include <grub/efiemu/efiemu.h>
#include <grub/crypto.h>
@@ -82,10 +83,16 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks,
((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off);
/* Put pointer to the list of configuration tables in system table */
- grub_efiemu_write_value
- (&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0,
- conftable_handle, 0, 1,
- sizeof (SUFFIX (grub_efiemu_system_table)->configuration_table));
+ err = grub_efiemu_write_value
+ (&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0,
+ conftable_handle, 0, 1,
+ sizeof (SUFFIX (grub_efiemu_system_table)->configuration_table));
+ if (err)
+ {
+ grub_efiemu_unload ();
+ return err;
+ }
+
SUFFIX(grub_efiemu_system_table)->num_table_entries = cntconftables;
/* Fill the list of configuration tables */
diff --git a/grub-core/font/font.c b/grub-core/font/font.c
index 14b93e172..53d76a64d 100644
--- a/grub-core/font/font.c
+++ b/grub-core/font/font.c
@@ -777,6 +777,7 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
if (grub_file_read (font->file, glyph->bitmap, len) != len)
{
remove_font (font);
+ grub_free (glyph);
return 0;
}
}
@@ -1285,7 +1286,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
- grub_font_get_xheight (combining_glyphs[i]->font) - 1;
if (space <= 0)
space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8;
-
+ /* Fallthrough. */
case GRUB_UNICODE_STACK_ATTACHED_ABOVE:
do_blit (combining_glyphs[i], targetx,
-(ctx.bounds.height + ctx.bounds.y + space
@@ -1326,6 +1327,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
+ combining_glyphs[i]->height);
if (space <= 0)
space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8;
+ /* Fallthrough. */
case GRUB_UNICODE_STACK_ATTACHED_BELOW:
do_blit (combining_glyphs[i], targetx, -(ctx.bounds.y - space),
diff --git a/grub-core/fs/archelp.c b/grub-core/fs/archelp.c
index c85cbfac2..0cf544f6f 100644
--- a/grub-core/fs/archelp.c
+++ b/grub-core/fs/archelp.c
@@ -34,12 +34,12 @@ canonicalize (char *name)
iptr++;
if (iptr[0] == '.' && (iptr[1] == '/' || iptr[1] == 0))
{
- iptr += 2;
+ iptr++;
continue;
}
if (iptr[0] == '.' && iptr[1] == '.' && (iptr[2] == '/' || iptr[2] == 0))
{
- iptr += 3;
+ iptr += 2;
if (optr == name)
continue;
for (optr -= 2; optr >= name && *optr != '/'; optr--);
@@ -249,9 +249,10 @@ grub_archelp_open (struct grub_archelp_data *data,
while (1)
{
grub_uint32_t mode;
+ grub_int32_t mtime;
int restart;
- if (arcops->find_file (data, &fn, NULL, &mode))
+ if (arcops->find_file (data, &fn, &mtime, &mode))
goto fail;
if (mode == GRUB_ARCHELP_ATTR_END)
diff --git a/grub-core/fs/bfs.c b/grub-core/fs/bfs.c
index 145e77186..d2b490bce 100644
--- a/grub-core/fs/bfs.c
+++ b/grub-core/fs/bfs.c
@@ -29,6 +29,7 @@
#include <grub/dl.h>
#include <grub/types.h>
#include <grub/i18n.h>
+#include <grub/fshelp.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -561,10 +562,10 @@ iterate_in_b_tree (grub_disk_t disk,
}
static int
-bfs_strcmp (const char *a, const char *b, grub_size_t alen, grub_size_t blen)
+bfs_strcmp (const char *a, const char *b, grub_size_t alen)
{
char ac, bc;
- while (blen && alen)
+ while (*b && alen)
{
if (*a != *b)
break;
@@ -572,11 +573,10 @@ bfs_strcmp (const char *a, const char *b, grub_size_t alen, grub_size_t blen)
a++;
b++;
alen--;
- blen--;
}
ac = alen ? *a : 0;
- bc = blen ? *b : 0;
+ bc = *b;
#ifdef MODE_AFS
return (int) (grub_int8_t) ac - (int) (grub_int8_t) bc;
@@ -589,7 +589,6 @@ static grub_err_t
find_in_b_tree (grub_disk_t disk,
const struct grub_bfs_superblock *sb,
const struct grub_bfs_inode *ino, const char *name,
- grub_size_t name_len,
grub_uint64_t * res)
{
struct grub_bfs_btree_header head;
@@ -637,7 +636,7 @@ find_in_b_tree (grub_disk_t disk,
end = grub_bfs_to_cpu16 (keylen_idx[(i | (1 << j))]);
if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end)
end = grub_bfs_to_cpu_treehead (node->total_key_len);
- cmp = bfs_strcmp (key_data + start, name, end - start, name_len);
+ cmp = bfs_strcmp (key_data + start, name, end - start);
if (cmp == 0 && level == 0)
{
*res = grub_bfs_to_cpu64 (key_values[i | (1 << j)].val);
@@ -658,7 +657,7 @@ find_in_b_tree (grub_disk_t disk,
end = grub_bfs_to_cpu16 (keylen_idx[0]);
if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end)
end = grub_bfs_to_cpu_treehead (node->total_key_len);
- cmp = bfs_strcmp (key_data, name, end, name_len);
+ cmp = bfs_strcmp (key_data, name, end);
if (cmp == 0 && level == 0)
{
*res = grub_bfs_to_cpu64 (key_values[0].val);
@@ -707,127 +706,119 @@ find_in_b_tree (grub_disk_t disk,
}
}
+struct grub_fshelp_node
+{
+ grub_disk_t disk;
+ const struct grub_bfs_superblock *sb;
+ struct grub_bfs_inode ino;
+};
+
static grub_err_t
-hop_level (grub_disk_t disk,
- const struct grub_bfs_superblock *sb,
- struct grub_bfs_inode *ino, const char *name,
- const char *name_end)
+lookup_file (grub_fshelp_node_t dir,
+ const char *name,
+ grub_fshelp_node_t *foundnode,
+ enum grub_fshelp_filetype *foundtype)
{
grub_err_t err;
+ struct grub_bfs_inode *new_ino;
grub_uint64_t res = 0;
- if (((grub_bfs_to_cpu32 (ino->mode) & ATTR_TYPE) != ATTR_DIR))
- return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
-
- err = find_in_b_tree (disk, sb, ino, name, name_end - name, &res);
+ err = find_in_b_tree (dir->disk, dir->sb, &dir->ino, name, &res);
if (err)
return err;
- return grub_disk_read (disk, res
- << (grub_bfs_to_cpu32 (sb->log2_bsize)
- - GRUB_DISK_SECTOR_BITS), 0,
- sizeof (*ino), (char *) ino);
+ *foundnode = grub_malloc (sizeof (struct grub_fshelp_node));
+ if (!*foundnode)
+ return grub_errno;
+
+ (*foundnode)->disk = dir->disk;
+ (*foundnode)->sb = dir->sb;
+ new_ino = &(*foundnode)->ino;
+
+ if (grub_disk_read (dir->disk, res
+ << (grub_bfs_to_cpu32 (dir->sb->log2_bsize)
+ - GRUB_DISK_SECTOR_BITS), 0,
+ sizeof (*new_ino), (char *) new_ino))
+ {
+ grub_free (*foundnode);
+ return grub_errno;
+ }
+ switch (grub_bfs_to_cpu32 (new_ino->mode) & ATTR_TYPE)
+ {
+ default:
+ case ATTR_REG:
+ *foundtype = GRUB_FSHELP_REG;
+ break;
+ case ATTR_DIR:
+ *foundtype = GRUB_FSHELP_DIR;
+ break;
+ case ATTR_LNK:
+ *foundtype = GRUB_FSHELP_SYMLINK;
+ break;
+ }
+ return GRUB_ERR_NONE;
}
-static grub_err_t
-find_file (const char *path, grub_disk_t disk,
- const struct grub_bfs_superblock *sb, struct grub_bfs_inode *ino)
+static char *
+read_symlink (grub_fshelp_node_t node)
{
- const char *ptr, *next = path;
char *alloc = NULL;
- char *wptr;
grub_err_t err;
- struct grub_bfs_inode old_ino;
- unsigned symlinks_max = 32;
- err = read_extent (disk, sb, &sb->root_dir, 0, 0, ino,
- sizeof (*ino));
- if (err)
- return err;
-
- while (1)
+#ifndef MODE_AFS
+ if (!(grub_bfs_to_cpu32 (node->ino.flags) & LONG_SYMLINK))
{
- ptr = next;
- while (*ptr == '/')
- ptr++;
- if (*ptr == 0)
+ alloc = grub_malloc (sizeof (node->ino.inplace_link) + 1);
+ if (!alloc)
{
- grub_free (alloc);
- return GRUB_ERR_NONE;
+ return NULL;
}
- for (next = ptr; *next && *next != '/'; next++);
- grub_memcpy (&old_ino, ino, sizeof (old_ino));
- err = hop_level (disk, sb, ino, ptr, next);
+ grub_memcpy (alloc, node->ino.inplace_link,
+ sizeof (node->ino.inplace_link));
+ alloc[sizeof (node->ino.inplace_link)] = 0;
+ }
+ else
+#endif
+ {
+ grub_size_t symsize = grub_bfs_to_cpu64 (node->ino.size);
+ alloc = grub_malloc (symsize + 1);
+ if (!alloc)
+ return NULL;
+ err = read_bfs_file (node->disk, node->sb, &node->ino, 0, alloc, symsize, 0, 0);
if (err)
- return err;
-
- if (((grub_bfs_to_cpu32 (ino->mode) & ATTR_TYPE) == ATTR_LNK))
{
- char *old_alloc = alloc;
- if (--symlinks_max == 0)
- {
- grub_free (alloc);
- return grub_error (GRUB_ERR_SYMLINK_LOOP,
- N_("too deep nesting of symlinks"));
- }
-
-#ifndef MODE_AFS
- if (grub_bfs_to_cpu32 (ino->flags) & LONG_SYMLINK)
-#endif
- {
- grub_size_t symsize = grub_bfs_to_cpu64 (ino->size);
- alloc = grub_malloc (grub_strlen (next)
- + symsize + 1);
- if (!alloc)
- {
- grub_free (alloc);
- return grub_errno;
- }
- grub_free (old_alloc);
- err = read_bfs_file (disk, sb, ino, 0, alloc, symsize, 0, 0);
- if (err)
- {
- grub_free (alloc);
- return err;
- }
- alloc[symsize] = 0;
- }
-#ifndef MODE_AFS
- else
- {
- alloc = grub_malloc (grub_strlen (next)
- + sizeof (ino->inplace_link) + 1);
- if (!alloc)
- {
- grub_free (alloc);
- return grub_errno;
- }
- grub_free (old_alloc);
- grub_memcpy (alloc, ino->inplace_link,
- sizeof (ino->inplace_link));
- alloc[sizeof (ino->inplace_link)] = 0;
- }
-#endif
- if (alloc[0] == '/')
- {
- err = read_extent (disk, sb, &sb->root_dir, 0, 0, ino,
- sizeof (*ino));
- if (err)
- {
- grub_free (alloc);
- return err;
- }
- }
- else
- grub_memcpy (ino, &old_ino, sizeof (old_ino));
- wptr = alloc + grub_strlen (alloc);
- if (next)
- wptr = grub_stpcpy (wptr, next);
- *wptr = 0;
- next = alloc;
- continue;
+ grub_free (alloc);
+ return NULL;
}
+ alloc[symsize] = 0;
}
+
+ return alloc;
+}
+
+static grub_err_t
+find_file (const char *path, grub_disk_t disk,
+ const struct grub_bfs_superblock *sb, struct grub_bfs_inode *ino,
+ enum grub_fshelp_filetype exptype)
+{
+ grub_err_t err;
+ struct grub_fshelp_node root = {
+ .disk = disk,
+ .sb = sb,
+ };
+ struct grub_fshelp_node *found;
+
+ err = read_extent (disk, sb, &sb->root_dir, 0, 0, &root.ino,
+ sizeof (root.ino));
+ if (err)
+ return err;
+ err = grub_fshelp_find_file_lookup (path, &root, &found, lookup_file, read_symlink, exptype);
+ if (!err)
+ grub_memcpy (ino, &found->ino, sizeof (*ino));
+
+ if (&root != found)
+ grub_free (found);
+ return err;
}
static grub_err_t
@@ -909,11 +900,9 @@ grub_bfs_dir (grub_device_t device, const char *path,
{
struct grub_bfs_inode ino;
- err = find_file (path, device->disk, &ctx.sb, &ino);
+ err = find_file (path, device->disk, &ctx.sb, &ino, GRUB_FSHELP_DIR);
if (err)
return err;
- if (((grub_bfs_to_cpu32 (ino.mode) & ATTR_TYPE) != ATTR_DIR))
- return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
iterate_in_b_tree (device->disk, &ctx.sb, &ino, grub_bfs_dir_iter,
&ctx);
}
@@ -934,11 +923,9 @@ grub_bfs_open (struct grub_file *file, const char *name)
{
struct grub_bfs_inode ino;
struct grub_bfs_data *data;
- err = find_file (name, file->device->disk, &sb, &ino);
+ err = find_file (name, file->device->disk, &sb, &ino, GRUB_FSHELP_REG);
if (err)
return err;
- if (((grub_bfs_to_cpu32 (ino.mode) & ATTR_TYPE) != ATTR_REG))
- return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
data = grub_zalloc (sizeof (struct grub_bfs_data));
if (!data)
@@ -1034,7 +1021,7 @@ read_bfs_attr (grub_disk_t disk,
if (err)
return -1;
- err = find_in_b_tree (disk, sb, ino, name, grub_strlen (name), &res);
+ err = find_in_b_tree (disk, sb, ino, name, &res);
if (err)
return -1;
grub_disk_read (disk, res
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index b15a9d65d..9cffa91fa 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -680,6 +680,8 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
grub_uint64_t stripen;
grub_uint64_t stripe_offset;
grub_uint64_t off = addr - grub_le_to_cpu64 (key->offset);
+ grub_uint64_t chunk_stripe_length;
+ grub_uint16_t nstripes;
unsigned redundancy = 1;
unsigned i, j;
@@ -690,15 +692,17 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
"couldn't find the chunk descriptor");
}
+ nstripes = grub_le_to_cpu16 (chunk->nstripes) ? : 1;
+ chunk_stripe_length = grub_le_to_cpu64 (chunk->stripe_length) ? : 512;
grub_dprintf ("btrfs", "chunk 0x%" PRIxGRUB_UINT64_T
"+0x%" PRIxGRUB_UINT64_T
" (%d stripes (%d substripes) of %"
PRIxGRUB_UINT64_T ")\n",
grub_le_to_cpu64 (key->offset),
grub_le_to_cpu64 (chunk->size),
- grub_le_to_cpu16 (chunk->nstripes),
+ nstripes,
grub_le_to_cpu16 (chunk->nsubstripes),
- grub_le_to_cpu64 (chunk->stripe_length));
+ chunk_stripe_length);
switch (grub_le_to_cpu64 (chunk->type)
& ~GRUB_BTRFS_CHUNK_TYPE_BITS_DONTCARE)
@@ -708,8 +712,10 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
grub_uint64_t stripe_length;
grub_dprintf ("btrfs", "single\n");
stripe_length = grub_divmod64 (grub_le_to_cpu64 (chunk->size),
- grub_le_to_cpu16 (chunk->nstripes),
+ nstripes,
NULL);
+ if (stripe_length == 0)
+ stripe_length = 512;
stripen = grub_divmod64 (off, stripe_length, &stripe_offset);
csize = (stripen + 1) * stripe_length - off;
break;
@@ -730,33 +736,34 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
grub_uint64_t low;
grub_dprintf ("btrfs", "RAID0\n");
middle = grub_divmod64 (off,
- grub_le_to_cpu64 (chunk->stripe_length),
+ chunk_stripe_length,
&low);
- high = grub_divmod64 (middle, grub_le_to_cpu16 (chunk->nstripes),
+ high = grub_divmod64 (middle, nstripes,
&stripen);
stripe_offset =
- low + grub_le_to_cpu64 (chunk->stripe_length) * high;
- csize = grub_le_to_cpu64 (chunk->stripe_length) - low;
+ low + chunk_stripe_length * high;
+ csize = chunk_stripe_length - low;
break;
}
case GRUB_BTRFS_CHUNK_TYPE_RAID10:
{
grub_uint64_t middle, high;
grub_uint64_t low;
+ grub_uint16_t nsubstripes;
+ nsubstripes = grub_le_to_cpu16 (chunk->nsubstripes) ? : 1;
middle = grub_divmod64 (off,
- grub_le_to_cpu64 (chunk->stripe_length),
+ chunk_stripe_length,
&low);
high = grub_divmod64 (middle,
- grub_le_to_cpu16 (chunk->nstripes)
- / grub_le_to_cpu16 (chunk->nsubstripes),
+ nstripes / nsubstripes ? : 1,
&stripen);
- stripen *= grub_le_to_cpu16 (chunk->nsubstripes);
- redundancy = grub_le_to_cpu16 (chunk->nsubstripes);
- stripe_offset = low + grub_le_to_cpu64 (chunk->stripe_length)
+ stripen *= nsubstripes;
+ redundancy = nsubstripes;
+ stripe_offset = low + chunk_stripe_length
* high;
- csize = grub_le_to_cpu64 (chunk->stripe_length) - low;
+ csize = chunk_stripe_length - low;
break;
}
default:
@@ -1051,7 +1058,7 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data,
data->extend = data->extstart + grub_le_to_cpu64 (data->extent->size);
if (data->extent->type == GRUB_BTRFS_EXTENT_REGULAR
- && (char *) &data->extent + elemsize
+ && (char *) data->extent + elemsize
>= (char *) &data->extent->filled + sizeof (data->extent->filled))
data->extend =
data->extstart + grub_le_to_cpu64 (data->extent->filled);
@@ -1104,7 +1111,12 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data,
- (grub_uint8_t *) data->extent),
extoff, buf, csize)
!= (grub_ssize_t) csize)
- return -1;
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "premature end of compressed");
+ return -1;
+ }
}
else if (data->extent->compression == GRUB_BTRFS_COMPRESSION_LZO)
{
@@ -1158,7 +1170,12 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data,
grub_free (tmp);
if (ret != (grub_ssize_t) csize)
- return -1;
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "premature end of compressed");
+ return -1;
+ }
break;
}
@@ -1191,7 +1208,7 @@ get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key,
struct grub_btrfs_key key_out, key_in;
struct grub_btrfs_root_item ri;
- key_in.object_id = GRUB_BTRFS_ROOT_VOL_OBJECTID;
+ key_in.object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_ROOT_VOL_OBJECTID);
key_in.offset = 0;
key_in.type = GRUB_BTRFS_ITEM_TYPE_ROOT_ITEM;
err = lower_bound (data, &key_in, &key_out,
diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c
index 7ad148361..0842701a6 100644
--- a/grub-core/fs/cbfs.c
+++ b/grub-core/fs/cbfs.c
@@ -74,8 +74,7 @@ grub_cbfs_find_file (struct grub_archelp_data *data, char **name,
(void) mtime;
offset = grub_be_to_cpu32 (hd.offset);
- if (mode)
- *mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME;
+ *mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME;
namesize = offset;
if (namesize >= sizeof (hd))
@@ -144,11 +143,14 @@ static struct grub_archelp_data *
grub_cbfs_mount (grub_disk_t disk)
{
struct cbfs_file hd;
- struct grub_archelp_data *data;
+ struct grub_archelp_data *data = NULL;
grub_uint32_t ptr;
grub_off_t header_off;
struct cbfs_header head;
+ if (grub_disk_get_size (disk) == GRUB_DISK_SIZE_UNKNOWN)
+ goto fail;
+
if (grub_disk_read (disk, grub_disk_get_size (disk) - 1,
GRUB_DISK_SECTOR_SIZE - sizeof (ptr),
sizeof (ptr), &ptr))
@@ -193,6 +195,7 @@ grub_cbfs_mount (grub_disk_t disk)
return data;
fail:
+ grub_free (data);
grub_error (GRUB_ERR_BAD_FS, "not a cbfs filesystem");
return 0;
}
@@ -341,8 +344,16 @@ init_cbfsdisk (void)
ptr = *(grub_uint32_t *) 0xfffffffc;
head = (struct cbfs_header *) (grub_addr_t) ptr;
-
- if (!validate_head (head))
+ grub_dprintf ("cbfs", "head=%p\n", head);
+
+ /* coreboot current supports only ROMs <= 16 MiB. Bigger ROMs will
+ have problems as RCBA is 18 MiB below end of 32-bit typically,
+ so either memory map would have to be rearranged or we'd need to support
+ reading ROMs through controller directly.
+ */
+ if (ptr < 0xff000000
+ || 0xffffffff - ptr < (grub_uint32_t) sizeof (*head) + 0xf
+ || !validate_head (head))
return;
cbfsdisk_size = ALIGN_UP (grub_be_to_cpu32 (head->romsize),
diff --git a/grub-core/fs/cpio_common.c b/grub-core/fs/cpio_common.c
index b0ae9f445..50fea47d1 100644
--- a/grub-core/fs/cpio_common.c
+++ b/grub-core/fs/cpio_common.c
@@ -61,8 +61,15 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name,
modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode));
namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize));
- if (mode)
- *mode = modeval;
+ /* Don't allow negative numbers. */
+ if (namesize >= 0x80000000)
+ {
+ /* Probably a corruption, don't attempt to recover. */
+ *mode = GRUB_ARCHELP_ATTR_END;
+ return GRUB_ERR_NONE;
+ }
+
+ *mode = modeval;
*name = grub_malloc (namesize + 1);
if (*name == NULL)
diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c
index ca7342188..841b8707c 100644
--- a/grub-core/fs/ext2.c
+++ b/grub-core/fs/ext2.c
@@ -103,6 +103,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* Extents used */
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
+#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
#define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400 /* EA in inode */
#define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000 /* data in dirent */
@@ -115,6 +116,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define EXT2_DRIVER_SUPPORTED_INCOMPAT ( EXT2_FEATURE_INCOMPAT_FILETYPE \
| EXT4_FEATURE_INCOMPAT_EXTENTS \
| EXT4_FEATURE_INCOMPAT_FLEX_BG \
+ | EXT2_FEATURE_INCOMPAT_META_BG \
| EXT4_FEATURE_INCOMPAT_64BIT \
| EXT4_FEATURE_INCOMPAT_INLINE_DATA)
/* List of rationales for the ignored "incompatible" features:
@@ -123,8 +125,13 @@ GRUB_MOD_LICENSE ("GPLv3+");
* journal because they will ignore the journal, but the next
* ext3 driver to mount the volume will find the journal and
* replay it, potentially corrupting the metadata written by
- * the ext2 drivers. Safe to ignore for this RO driver. */
-#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER )
+ * the ext2 drivers. Safe to ignore for this RO driver.
+ * mmp: Not really back-incompatible - was added as such to
+ * avoid multiple read-write mounts. Safe to ignore for this
+ * RO driver.
+ */
+#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \
+ | EXT4_FEATURE_INCOMPAT_MMP)
#define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U
@@ -368,6 +375,35 @@ static grub_dl_t my_mod;
+/* Check is a = b^x for some x. */
+static inline int
+is_power_of (grub_uint64_t a, grub_uint32_t b)
+{
+ grub_uint64_t c;
+ /* Prevent overflow assuming b < 8. */
+ if (a >= (1LL << 60))
+ return 0;
+ for (c = 1; c <= a; c *= b);
+ return (c == a);
+}
+
+
+static inline int
+group_has_super_block (struct grub_ext2_data *data, grub_uint64_t group)
+{
+ if (!(data->sblock.feature_ro_compat
+ & grub_cpu_to_le32_compile_time(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)))
+ return 1;
+ /* Algorithm looked up in Linux source. */
+ if (group <= 1)
+ return 1;
+ /* Even number is never a power of odd number. */
+ if (!(group & 1))
+ return 0;
+ return (is_power_of(group, 7) || is_power_of(group, 5) ||
+ is_power_of(group, 3));
+}
+
/* Inline data is stored using inline extended attributes. Attributes consist
of entry and value. Entries start after inode proper, following 4 bytes
magic header. Each entry is 4 bytes aligned, end of list is marked with
@@ -431,13 +467,36 @@ grub_ext2_find_inline_data (struct grub_fshelp_node *node, grub_size_t isize,
/* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of
the mounted filesystem DATA. */
inline static grub_err_t
-grub_ext2_blockgroup (struct grub_ext2_data *data, int group,
+grub_ext2_blockgroup (struct grub_ext2_data *data, grub_uint64_t group,
struct grub_ext2_block_group *blkgrp)
{
+ grub_uint64_t full_offset = (group << data->log_group_desc_size);
+ grub_uint64_t block, offset;
+ block = (full_offset >> LOG2_BLOCK_SIZE (data));
+ offset = (full_offset & ((1 << LOG2_BLOCK_SIZE (data)) - 1));
+ if ((data->sblock.feature_incompat
+ & grub_cpu_to_le32_compile_time (EXT2_FEATURE_INCOMPAT_META_BG))
+ && block >= grub_le_to_cpu32(data->sblock.first_meta_bg))
+ {
+ grub_uint64_t first_block_group;
+ /* Find the first block group for which a descriptor
+ is stored in given block. */
+ first_block_group = (block << (LOG2_BLOCK_SIZE (data)
+ - data->log_group_desc_size));
+
+ block = (first_block_group
+ * grub_le_to_cpu32(data->sblock.blocks_per_group));
+
+ if (group_has_super_block (data, first_block_group))
+ block++;
+ }
+ else
+ /* Superblock. */
+ block++;
return grub_disk_read (data->disk,
- ((grub_le_to_cpu32 (data->sblock.first_data_block) + 1)
- << LOG2_EXT2_BLOCK_SIZE (data)),
- group << data->log_group_desc_size,
+ ((grub_le_to_cpu32 (data->sblock.first_data_block)
+ + block)
+ << LOG2_EXT2_BLOCK_SIZE (data)), offset,
sizeof (struct grub_ext2_block_group), blkgrp);
}
@@ -576,11 +635,16 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
shift = 2;
goto indirect;
}
- return grub_error (GRUB_ERR_BAD_FS,
- "ext2fs doesn't support quadruple indirect blocks");
+ grub_error (GRUB_ERR_BAD_FS,
+ "ext2fs doesn't support quadruple indirect blocks");
+ return -1;
indirect:
do {
+ /* If the indirect block is zero, all child blocks are absent
+ (i.e. filled with zeros.) */
+ if (indir == 0)
+ return 0;
if (grub_disk_read (data->disk,
((grub_disk_addr_t) grub_le_to_cpu32 (indir))
<< log2_blksz,
@@ -588,7 +652,7 @@ indirect:
& ((1 << log_perblock) - 1))
* sizeof (indir),
sizeof (indir), &indir))
- return grub_errno;
+ return -1;
} while (shift--);
return grub_le_to_cpu32 (indir);
@@ -737,7 +801,12 @@ grub_ext2_mount (grub_disk_t disk)
/* Make sure this is an ext2 filesystem. */
if (data->sblock.magic != grub_cpu_to_le16_compile_time (EXT2_MAGIC)
- || grub_le_to_cpu32 (data->sblock.log2_block_size) >= 16)
+ || grub_le_to_cpu32 (data->sblock.log2_block_size) >= 16
+ || data->sblock.inodes_per_group == 0
+ /* 20 already means 1GiB blocks. We don't want to deal with blocks overflowing int32. */
+ || grub_le_to_cpu32 (data->sblock.log2_block_size) > 20
+ || EXT2_INODE_SIZE (data) == 0
+ || EXT2_BLOCK_SIZE (data) / EXT2_INODE_SIZE (data) == 0)
{
grub_error (GRUB_ERR_BAD_FS, "not an ext2 filesystem");
goto fail;
diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c
index 79fe864d7..635c2c425 100644
--- a/grub-core/fs/fat.c
+++ b/grub-core/fs/fat.c
@@ -31,6 +31,7 @@
#else
#include <grub/exfat.h>
#endif
+#include <grub/fshelp.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -173,8 +174,6 @@ struct grub_fat_data
#ifndef MODE_EXFAT
grub_uint32_t root_sector;
grub_uint32_t num_root_sectors;
-#else
- int is_contiguous;
#endif
int cluster_bits;
@@ -182,13 +181,22 @@ struct grub_fat_data
grub_uint32_t cluster_sector;
grub_uint32_t num_clusters;
+ grub_uint32_t uuid;
+};
+
+struct grub_fshelp_node {
+ grub_disk_t disk;
+ struct grub_fat_data *data;
+
grub_uint8_t attr;
grub_ssize_t file_size;
grub_uint32_t file_cluster;
grub_uint32_t cur_cluster_num;
grub_uint32_t cur_cluster;
- grub_uint32_t uuid;
+#ifdef MODE_EXFAT
+ int is_contiguous;
+#endif
};
static grub_dl_t my_mod;
@@ -427,13 +435,6 @@ grub_fat_mount (grub_disk_t disk)
(void) magic;
#endif
- /* Start from the root directory. */
- data->file_cluster = data->root_cluster;
- data->cur_cluster_num = ~0U;
- data->attr = GRUB_FAT_ATTR_DIRECTORY;
-#ifdef MODE_EXFAT
- data->is_contiguous = 0;
-#endif
return data;
fail:
@@ -444,7 +445,7 @@ grub_fat_mount (grub_disk_t disk)
}
static grub_ssize_t
-grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
+grub_fat_read_data (grub_disk_t disk, grub_fshelp_node_t node,
grub_disk_read_hook_t read_hook, void *read_hook_data,
grub_off_t offset, grub_size_t len, char *buf)
{
@@ -457,13 +458,13 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
#ifndef MODE_EXFAT
/* This is a special case. FAT12 and FAT16 doesn't have the root directory
in clusters. */
- if (data->file_cluster == ~0U)
+ if (node->file_cluster == ~0U)
{
- size = (data->num_root_sectors << GRUB_DISK_SECTOR_BITS) - offset;
+ size = (node->data->num_root_sectors << GRUB_DISK_SECTOR_BITS) - offset;
if (size > len)
size = len;
- if (grub_disk_read (disk, data->root_sector, offset, size, buf))
+ if (grub_disk_read (disk, node->data->root_sector, offset, size, buf))
return -1;
return size;
@@ -471,12 +472,12 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
#endif
#ifdef MODE_EXFAT
- if (data->is_contiguous)
+ if (node->is_contiguous)
{
/* Read the data here. */
- sector = (data->cluster_sector
- + ((data->file_cluster - 2)
- << data->cluster_bits));
+ sector = (node->data->cluster_sector
+ + ((node->file_cluster - 2)
+ << node->data->cluster_bits));
disk->read_hook = read_hook;
disk->read_hook_data = read_hook_data;
@@ -491,53 +492,53 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
#endif
/* Calculate the logical cluster number and offset. */
- logical_cluster_bits = (data->cluster_bits
+ logical_cluster_bits = (node->data->cluster_bits
+ GRUB_DISK_SECTOR_BITS);
logical_cluster = offset >> logical_cluster_bits;
offset &= (1ULL << logical_cluster_bits) - 1;
- if (logical_cluster < data->cur_cluster_num)
+ if (logical_cluster < node->cur_cluster_num)
{
- data->cur_cluster_num = 0;
- data->cur_cluster = data->file_cluster;
+ node->cur_cluster_num = 0;
+ node->cur_cluster = node->file_cluster;
}
while (len)
{
- while (logical_cluster > data->cur_cluster_num)
+ while (logical_cluster > node->cur_cluster_num)
{
/* Find next cluster. */
grub_uint32_t next_cluster;
grub_uint32_t fat_offset;
- switch (data->fat_size)
+ switch (node->data->fat_size)
{
case 32:
- fat_offset = data->cur_cluster << 2;
+ fat_offset = node->cur_cluster << 2;
break;
case 16:
- fat_offset = data->cur_cluster << 1;
+ fat_offset = node->cur_cluster << 1;
break;
default:
/* case 12: */
- fat_offset = data->cur_cluster + (data->cur_cluster >> 1);
+ fat_offset = node->cur_cluster + (node->cur_cluster >> 1);
break;
}
/* Read the FAT. */
- if (grub_disk_read (disk, data->fat_sector, fat_offset,
- (data->fat_size + 7) >> 3,
+ if (grub_disk_read (disk, node->data->fat_sector, fat_offset,
+ (node->data->fat_size + 7) >> 3,
(char *) &next_cluster))
return -1;
next_cluster = grub_le_to_cpu32 (next_cluster);
- switch (data->fat_size)
+ switch (node->data->fat_size)
{
case 16:
next_cluster &= 0xFFFF;
break;
case 12:
- if (data->cur_cluster & 1)
+ if (node->cur_cluster & 1)
next_cluster >>= 4;
next_cluster &= 0x0FFF;
@@ -545,27 +546,27 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
}
grub_dprintf ("fat", "fat_size=%d, next_cluster=%u\n",
- data->fat_size, next_cluster);
+ node->data->fat_size, next_cluster);
/* Check the end. */
- if (next_cluster >= data->cluster_eof_mark)
+ if (next_cluster >= node->data->cluster_eof_mark)
return ret;
- if (next_cluster < 2 || next_cluster >= data->num_clusters)
+ if (next_cluster < 2 || next_cluster >= node->data->num_clusters)
{
grub_error (GRUB_ERR_BAD_FS, "invalid cluster %u",
next_cluster);
return -1;
}
- data->cur_cluster = next_cluster;
- data->cur_cluster_num++;
+ node->cur_cluster = next_cluster;
+ node->cur_cluster_num++;
}
/* Read the data here. */
- sector = (data->cluster_sector
- + ((data->cur_cluster - 2)
- << data->cluster_bits));
+ sector = (node->data->cluster_sector
+ + ((node->cur_cluster - 2)
+ << node->data->cluster_bits));
size = (1 << logical_cluster_bits) - offset;
if (size > len)
size = len;
@@ -631,7 +632,7 @@ grub_fat_iterate_fini (struct grub_fat_iterate_context *ctxt)
#ifdef MODE_EXFAT
static grub_err_t
-grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
+grub_fat_iterate_dir_next (grub_fshelp_node_t node,
struct grub_fat_iterate_context *ctxt)
{
grub_memset (&ctxt->dir, 0, sizeof (ctxt->dir));
@@ -641,7 +642,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
ctxt->offset += sizeof (dir);
- if (grub_fat_read_data (disk, data, 0, 0, ctxt->offset, sizeof (dir),
+ if (grub_fat_read_data (node->disk, node, 0, 0, ctxt->offset, sizeof (dir),
(char *) &dir)
!= sizeof (dir))
break;
@@ -663,7 +664,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
{
struct grub_fat_dir_entry sec;
ctxt->offset += sizeof (sec);
- if (grub_fat_read_data (disk, data, 0, 0,
+ if (grub_fat_read_data (node->disk, node, 0, 0,
ctxt->offset, sizeof (sec), (char *) &sec)
!= sizeof (sec))
break;
@@ -680,7 +681,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
ctxt->dir.file_size
= grub_cpu_to_le64 (sec.type_specific.stream_extension.file_size);
ctxt->dir.have_stream = 1;
- ctxt->dir.is_contiguous = !!(dir.type_specific.stream_extension.flags
+ ctxt->dir.is_contiguous = !!(sec.type_specific.stream_extension.flags
& grub_cpu_to_le16_compile_time (FLAG_CONTIGUOUS));
break;
case 0xc1:
@@ -727,7 +728,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
#else
static grub_err_t
-grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
+grub_fat_iterate_dir_next (grub_fshelp_node_t node,
struct grub_fat_iterate_context *ctxt)
{
char *filep = 0;
@@ -742,7 +743,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
ctxt->offset += sizeof (ctxt->dir);
/* Read a directory entry. */
- if (grub_fat_read_data (disk, data, 0, 0,
+ if (grub_fat_read_data (node->disk, node, 0, 0,
ctxt->offset, sizeof (ctxt->dir),
(char *) &ctxt->dir)
!= sizeof (ctxt->dir) || ctxt->dir.name[0] == 0)
@@ -829,7 +830,9 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
i--;
}
- *filep++ = '.';
+ /* XXX should we check that dir position is 0 or 1? */
+ if (i > 2 || filep[0] != '.' || (i == 2 && filep[1] != '.'))
+ *filep++ = '.';
for (i = 8; i < 11 && ctxt->dir.name[i]; i++)
*filep++ = grub_tolower (ctxt->dir.name[i]);
@@ -851,62 +854,20 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
#endif
-/* Find the underlying directory or file in PATH and return the
- next path. If there is no next path or an error occurs, return NULL.
- If HOOK is specified, call it with each file name. */
-static char *
-grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
- const char *path, const char *origpath,
- grub_fs_dir_hook_t hook, void *hook_data)
+static grub_err_t lookup_file (grub_fshelp_node_t node,
+ const char *name,
+ grub_fshelp_node_t *foundnode,
+ enum grub_fshelp_filetype *foundtype)
{
- char *dirname, *dirp;
- int call_hook;
- int found = 0;
- struct grub_fat_iterate_context ctxt;
grub_err_t err;
-
- if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
- {
- grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
- return 0;
- }
-
- /* Extract a directory name. */
- while (*path == '/')
- path++;
-
- dirp = grub_strchr (path, '/');
- if (dirp)
- {
- unsigned len = dirp - path;
-
- dirname = grub_malloc (len + 1);
- if (! dirname)
- goto fail;
-
- grub_memcpy (dirname, path, len);
- dirname[len] = '\0';
- }
- else
- /* This is actually a file. */
- dirname = grub_strdup (path);
-
- call_hook = (! dirp && hook);
+ struct grub_fat_iterate_context ctxt;
err = grub_fat_iterate_init (&ctxt);
if (err)
- {
- grub_free (dirname);
- return 0;
- }
+ return err;
- while (!(err = grub_fat_iterate_dir_next (disk, data, &ctxt)))
+ while (!(err = grub_fat_iterate_dir_next (node, &ctxt)))
{
- struct grub_dirhook_info info;
- grub_memset (&info, 0, sizeof (info));
-
- info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY);
- info.case_insensitive = 1;
#ifdef MODE_EXFAT
if (!ctxt.dir.have_stream)
@@ -915,33 +876,33 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID)
continue;
#endif
- if (*dirname == '\0' && call_hook)
- {
- if (hook (ctxt.filename, &info, hook_data))
- break;
- else
- continue;
- }
- if (grub_strcasecmp (dirname, ctxt.filename) == 0)
+ if (grub_strcasecmp (name, ctxt.filename) == 0)
{
- found = 1;
- data->attr = ctxt.dir.attr;
+ *foundnode = grub_malloc (sizeof (struct grub_fshelp_node));
+ if (!*foundnode)
+ return grub_errno;
+ (*foundnode)->attr = ctxt.dir.attr;
#ifdef MODE_EXFAT
- data->file_size = ctxt.dir.file_size;
- data->file_cluster = ctxt.dir.first_cluster;
- data->is_contiguous = ctxt.dir.is_contiguous;
+ (*foundnode)->file_size = ctxt.dir.file_size;
+ (*foundnode)->file_cluster = ctxt.dir.first_cluster;
+ (*foundnode)->is_contiguous = ctxt.dir.is_contiguous;
#else
- data->file_size = grub_le_to_cpu32 (ctxt.dir.file_size);
- data->file_cluster = ((grub_le_to_cpu16 (ctxt.dir.first_cluster_high) << 16)
+ (*foundnode)->file_size = grub_le_to_cpu32 (ctxt.dir.file_size);
+ (*foundnode)->file_cluster = ((grub_le_to_cpu16 (ctxt.dir.first_cluster_high) << 16)
| grub_le_to_cpu16 (ctxt.dir.first_cluster_low));
+ /* If directory points to root, starting cluster is 0 */
+ if (!(*foundnode)->file_cluster)
+ (*foundnode)->file_cluster = node->data->root_cluster;
#endif
- data->cur_cluster_num = ~0U;
+ (*foundnode)->cur_cluster_num = ~0U;
+ (*foundnode)->data = node->data;
+ (*foundnode)->disk = node->disk;
- if (call_hook)
- hook (ctxt.filename, &info, hook_data);
+ *foundtype = ((*foundnode)->attr & GRUB_FAT_ATTR_DIRECTORY) ? GRUB_FSHELP_DIR : GRUB_FSHELP_REG;
- break;
+ grub_fat_iterate_fini (&ctxt);
+ return GRUB_ERR_NONE;
}
}
@@ -949,13 +910,8 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
if (err == GRUB_ERR_EOF)
err = 0;
- if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook)
- grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
+ return err;
- fail:
- grub_free (dirname);
-
- return found ? dirp : 0;
}
static grub_err_t
@@ -964,9 +920,9 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
{
struct grub_fat_data *data = 0;
grub_disk_t disk = device->disk;
- grub_size_t len;
- char *dirname = 0;
- char *p;
+ grub_fshelp_node_t found = NULL;
+ grub_err_t err;
+ struct grub_fat_iterate_context ctxt;
grub_dl_ref (my_mod);
@@ -974,27 +930,53 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
if (! data)
goto fail;
- /* Make sure that DIRNAME terminates with '/'. */
- len = grub_strlen (path);
- dirname = grub_malloc (len + 1 + 1);
- if (! dirname)
+ struct grub_fshelp_node root = {
+ .data = data,
+ .disk = disk,
+ .attr = GRUB_FAT_ATTR_DIRECTORY,
+ .file_size = 0,
+ .file_cluster = data->root_cluster,
+ .cur_cluster_num = ~0U,
+ .cur_cluster = 0,
+#ifdef MODE_EXFAT
+ .is_contiguous = 0,
+#endif
+ };
+
+ err = grub_fshelp_find_file_lookup (path, &root, &found, lookup_file, NULL, GRUB_FSHELP_DIR);
+ if (err)
+ goto fail;
+
+ err = grub_fat_iterate_init (&ctxt);
+ if (err)
goto fail;
- grub_memcpy (dirname, path, len);
- p = dirname + len;
- if (path[len - 1] != '/')
- *p++ = '/';
- *p = '\0';
- p = dirname;
-
- do
+
+ while (!(err = grub_fat_iterate_dir_next (found, &ctxt)))
{
- p = grub_fat_find_dir (disk, data, p, path, hook, hook_data);
+ struct grub_dirhook_info info;
+ grub_memset (&info, 0, sizeof (info));
+
+ info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY);
+ info.case_insensitive = 1;
+#ifdef MODE_EXFAT
+ if (!ctxt.dir.have_stream)
+ continue;
+#else
+ if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID)
+ continue;
+#endif
+
+ if (hook (ctxt.filename, &info, hook_data))
+ break;
}
- while (p && grub_errno == GRUB_ERR_NONE);
+ grub_fat_iterate_fini (&ctxt);
+ if (err == GRUB_ERR_EOF)
+ err = 0;
fail:
+ if (found != &root)
+ grub_free (found);
- grub_free (dirname);
grub_free (data);
grub_dl_unref (my_mod);
@@ -1006,35 +988,43 @@ static grub_err_t
grub_fat_open (grub_file_t file, const char *name)
{
struct grub_fat_data *data = 0;
- char *p = (char *) name;
+ grub_fshelp_node_t found = NULL;
+ grub_err_t err;
+ grub_disk_t disk = file->device->disk;
grub_dl_ref (my_mod);
- data = grub_fat_mount (file->device->disk);
+ data = grub_fat_mount (disk);
if (! data)
goto fail;
- do
- {
- p = grub_fat_find_dir (file->device->disk, data, p, name, 0, 0);
- if (grub_errno != GRUB_ERR_NONE)
- goto fail;
- }
- while (p);
+ struct grub_fshelp_node root = {
+ .data = data,
+ .disk = disk,
+ .attr = GRUB_FAT_ATTR_DIRECTORY,
+ .file_size = 0,
+ .file_cluster = data->root_cluster,
+ .cur_cluster_num = ~0U,
+ .cur_cluster = 0,
+#ifdef MODE_EXFAT
+ .is_contiguous = 0,
+#endif
+ };
- if (data->attr & GRUB_FAT_ATTR_DIRECTORY)
- {
- grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
- goto fail;
- }
+ err = grub_fshelp_find_file_lookup (name, &root, &found, lookup_file, NULL, GRUB_FSHELP_REG);
+ if (err)
+ goto fail;
- file->data = data;
- file->size = data->file_size;
+ file->data = found;
+ file->size = found->file_size;
return GRUB_ERR_NONE;
fail:
+ if (found != &root)
+ grub_free (found);
+
grub_free (data);
grub_dl_unref (my_mod);
@@ -1053,7 +1043,10 @@ grub_fat_read (grub_file_t file, char *buf, grub_size_t len)
static grub_err_t
grub_fat_close (grub_file_t file)
{
- grub_free (file->data);
+ grub_fshelp_node_t node = file->data;
+
+ grub_free (node->data);
+ grub_free (node);
grub_dl_unref (my_mod);
@@ -1066,20 +1059,29 @@ grub_fat_label (grub_device_t device, char **label)
{
struct grub_fat_dir_entry dir;
grub_ssize_t offset = -sizeof(dir);
- struct grub_fat_data *data;
grub_disk_t disk = device->disk;
+ struct grub_fshelp_node root = {
+ .disk = disk,
+ .attr = GRUB_FAT_ATTR_DIRECTORY,
+ .file_size = 0,
+ .cur_cluster_num = ~0U,
+ .cur_cluster = 0,
+ .is_contiguous = 0,
+ };
- data = grub_fat_mount (disk);
- if (! data)
+ root.data = grub_fat_mount (disk);
+ if (! root.data)
return grub_errno;
+ root.file_cluster = root.data->root_cluster;
+
*label = NULL;
while (1)
{
offset += sizeof (dir);
- if (grub_fat_read_data (disk, data, 0, 0,
+ if (grub_fat_read_data (disk, &root, 0, 0,
offset, sizeof (dir), (char *) &dir)
!= sizeof (dir))
break;
@@ -1099,7 +1101,7 @@ grub_fat_label (grub_device_t device, char **label)
* GRUB_MAX_UTF8_PER_UTF16 + 1);
if (!*label)
{
- grub_free (data);
+ grub_free (root.data);
return grub_errno;
}
chc = dir.type_specific.volume_label.character_count;
@@ -1111,7 +1113,7 @@ grub_fat_label (grub_device_t device, char **label)
}
}
- grub_free (data);
+ grub_free (root.data);
return grub_errno;
}
@@ -1120,30 +1122,32 @@ grub_fat_label (grub_device_t device, char **label)
static grub_err_t
grub_fat_label (grub_device_t device, char **label)
{
- struct grub_fat_data *data;
grub_disk_t disk = device->disk;
grub_err_t err;
struct grub_fat_iterate_context ctxt;
+ struct grub_fshelp_node root = {
+ .disk = disk,
+ .attr = GRUB_FAT_ATTR_DIRECTORY,
+ .file_size = 0,
+ .cur_cluster_num = ~0U,
+ .cur_cluster = 0,
+ };
*label = 0;
grub_dl_ref (my_mod);
- data = grub_fat_mount (disk);
- if (! data)
+ root.data = grub_fat_mount (disk);
+ if (! root.data)
goto fail;
- if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
- {
- grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
- return 0;
- }
+ root.file_cluster = root.data->root_cluster;
err = grub_fat_iterate_init (&ctxt);
if (err)
goto fail;
- while (!(err = grub_fat_iterate_dir_next (disk, data, &ctxt)))
+ while (!(err = grub_fat_iterate_dir_next (&root, &ctxt)))
if ((ctxt.dir.attr & ~GRUB_FAT_ATTR_ARCHIVE) == GRUB_FAT_ATTR_VOLUME_ID)
{
*label = grub_strdup (ctxt.filename);
@@ -1156,7 +1160,7 @@ grub_fat_label (grub_device_t device, char **label)
grub_dl_unref (my_mod);
- grub_free (data);
+ grub_free (root.data);
return grub_errno;
}
diff --git a/grub-core/fs/fshelp.c b/grub-core/fs/fshelp.c
index 42bd542bb..4c902adf3 100644
--- a/grub-core/fs/fshelp.c
+++ b/grub-core/fs/fshelp.c
@@ -30,210 +30,320 @@ GRUB_MOD_LICENSE ("GPLv3+");
typedef int (*iterate_dir_func) (grub_fshelp_node_t dir,
grub_fshelp_iterate_dir_hook_t hook,
void *data);
+typedef grub_err_t (*lookup_file_func) (grub_fshelp_node_t dir,
+ const char *name,
+ grub_fshelp_node_t *foundnode,
+ enum grub_fshelp_filetype *foundtype);
typedef char *(*read_symlink_func) (grub_fshelp_node_t node);
+struct stack_element {
+ struct stack_element *parent;
+ grub_fshelp_node_t node;
+ enum grub_fshelp_filetype type;
+};
+
/* Context for grub_fshelp_find_file. */
struct grub_fshelp_find_file_ctx
{
+ /* Inputs. */
const char *path;
- grub_fshelp_node_t rootnode, currroot, currnode, oldnode;
- enum grub_fshelp_filetype foundtype;
+ grub_fshelp_node_t rootnode;
+
+ /* Global options. */
int symlinknest;
- const char *name;
- const char *next;
- enum grub_fshelp_filetype type;
+
+ /* Current file being traversed and its parents. */
+ struct stack_element *currnode;
};
/* Helper for find_file_iter. */
static void
free_node (grub_fshelp_node_t node, struct grub_fshelp_find_file_ctx *ctx)
{
- if (node != ctx->rootnode && node != ctx->currroot)
+ if (node != ctx->rootnode)
grub_free (node);
}
+static void
+pop_element (struct grub_fshelp_find_file_ctx *ctx)
+{
+ struct stack_element *el;
+ el = ctx->currnode;
+ ctx->currnode = el->parent;
+ free_node (el->node, ctx);
+ grub_free (el);
+}
+
+static void
+free_stack (struct grub_fshelp_find_file_ctx *ctx)
+{
+ while (ctx->currnode)
+ pop_element (ctx);
+}
+
+static void
+go_up_a_level (struct grub_fshelp_find_file_ctx *ctx)
+{
+ if (!ctx->currnode->parent)
+ return;
+ pop_element (ctx);
+}
+
+static grub_err_t
+push_node (struct grub_fshelp_find_file_ctx *ctx, grub_fshelp_node_t node, enum grub_fshelp_filetype filetype)
+{
+ struct stack_element *nst;
+ nst = grub_malloc (sizeof (*nst));
+ if (!nst)
+ return grub_errno;
+ nst->node = node;
+ nst->type = filetype & ~GRUB_FSHELP_CASE_INSENSITIVE;
+ nst->parent = ctx->currnode;
+ ctx->currnode = nst;
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+go_to_root (struct grub_fshelp_find_file_ctx *ctx)
+{
+ free_stack (ctx);
+ return push_node (ctx, ctx->rootnode, GRUB_FSHELP_DIR);
+}
+
+struct grub_fshelp_find_file_iter_ctx
+{
+ const char *name;
+ grub_fshelp_node_t *foundnode;
+ enum grub_fshelp_filetype *foundtype;
+};
+
/* Helper for grub_fshelp_find_file. */
static int
find_file_iter (const char *filename, enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node, void *data)
{
- struct grub_fshelp_find_file_ctx *ctx = data;
+ struct grub_fshelp_find_file_iter_ctx *ctx = data;
if (filetype == GRUB_FSHELP_UNKNOWN ||
((filetype & GRUB_FSHELP_CASE_INSENSITIVE)
- ? grub_strncasecmp (ctx->name, filename, ctx->next - ctx->name)
- : grub_strncmp (ctx->name, filename, ctx->next - ctx->name))
- || filename[ctx->next - ctx->name])
+ ? grub_strcasecmp (ctx->name, filename)
+ : grub_strcmp (ctx->name, filename)))
{
grub_free (node);
return 0;
}
/* The node is found, stop iterating over the nodes. */
- ctx->type = filetype & ~GRUB_FSHELP_CASE_INSENSITIVE;
- ctx->oldnode = ctx->currnode;
- ctx->currnode = node;
-
+ *ctx->foundnode = node;
+ *ctx->foundtype = filetype;
return 1;
}
static grub_err_t
-find_file (const char *currpath, grub_fshelp_node_t currroot,
- grub_fshelp_node_t *currfound,
- iterate_dir_func iterate_dir, read_symlink_func read_symlink,
- struct grub_fshelp_find_file_ctx *ctx)
+directory_find_file (grub_fshelp_node_t node, const char *name, grub_fshelp_node_t *foundnode,
+ enum grub_fshelp_filetype *foundtype, iterate_dir_func iterate_dir)
{
- ctx->currroot = currroot;
- ctx->name = currpath;
- ctx->type = GRUB_FSHELP_DIR;
- ctx->currnode = currroot;
- ctx->oldnode = currroot;
+ int found;
+ struct grub_fshelp_find_file_iter_ctx ctx = {
+ .foundnode = foundnode,
+ .foundtype = foundtype,
+ .name = name
+ };
+ found = iterate_dir (node, find_file_iter, &ctx);
+ if (! found)
+ {
+ if (grub_errno)
+ return grub_errno;
+ }
+ return GRUB_ERR_NONE;
+}
- for (;;)
+static grub_err_t
+find_file (char *currpath,
+ iterate_dir_func iterate_dir, lookup_file_func lookup_file,
+ read_symlink_func read_symlink,
+ struct grub_fshelp_find_file_ctx *ctx)
+{
+ char *name, *next;
+ grub_err_t err;
+ for (name = currpath; ; name = next)
{
- int found;
+ char c;
+ grub_fshelp_node_t foundnode = NULL;
+ enum grub_fshelp_filetype foundtype = 0;
/* Remove all leading slashes. */
- while (*ctx->name == '/')
- ctx->name++;
+ while (*name == '/')
+ name++;
/* Found the node! */
- if (! *ctx->name)
- {
- *currfound = ctx->currnode;
- ctx->foundtype = ctx->type;
- return 0;
- }
+ if (! *name)
+ return 0;
/* Extract the actual part from the pathname. */
- for (ctx->next = ctx->name; *ctx->next && *ctx->next != '/'; ctx->next++);
+ for (next = name; *next && *next != '/'; next++);
/* At this point it is expected that the current node is a
directory, check if this is true. */
- if (ctx->type != GRUB_FSHELP_DIR)
+ if (ctx->currnode->type != GRUB_FSHELP_DIR)
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
+
+ /* Don't rely on fs providing actual . in the listing. */
+ if (next - name == 1 && name[0] == '.')
+ continue;
+
+ /* Don't rely on fs providing actual .. in the listing. */
+ if (next - name == 2 && name[0] == '.' && name[1] == '.')
{
- free_node (ctx->currnode, ctx);
- ctx->currnode = 0;
- return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
+ go_up_a_level (ctx);
+ continue;
}
/* Iterate over the directory. */
- found = iterate_dir (ctx->currnode, find_file_iter, ctx);
- if (! found)
- {
- free_node (ctx->currnode, ctx);
- ctx->currnode = 0;
- if (grub_errno)
- return grub_errno;
+ c = *next;
+ *next = '\0';
+ if (lookup_file)
+ err = lookup_file (ctx->currnode->node, name, &foundnode, &foundtype);
+ else
+ err = directory_find_file (ctx->currnode->node, name, &foundnode, &foundtype, iterate_dir);
+ *next = c;
- break;
- }
+ if (err)
+ return err;
+ if (!foundnode)
+ break;
+
+ push_node (ctx, foundnode, foundtype);
+
/* Read in the symlink and follow it. */
- if (ctx->type == GRUB_FSHELP_SYMLINK)
+ if (ctx->currnode->type == GRUB_FSHELP_SYMLINK)
{
char *symlink;
- const char *next;
/* Test if the symlink does not loop. */
if (++ctx->symlinknest == 8)
- {
- free_node (ctx->currnode, ctx);
- free_node (ctx->oldnode, ctx);
- ctx->currnode = 0;
- ctx->oldnode = 0;
- return grub_error (GRUB_ERR_SYMLINK_LOOP,
- N_("too deep nesting of symlinks"));
- }
+ return grub_error (GRUB_ERR_SYMLINK_LOOP,
+ N_("too deep nesting of symlinks"));
- symlink = read_symlink (ctx->currnode);
- free_node (ctx->currnode, ctx);
- ctx->currnode = 0;
+ symlink = read_symlink (ctx->currnode->node);
if (!symlink)
- {
- free_node (ctx->oldnode, ctx);
- ctx->oldnode = 0;
- return grub_errno;
- }
+ return grub_errno;
/* The symlink is an absolute path, go back to the root inode. */
if (symlink[0] == '/')
{
- free_node (ctx->oldnode, ctx);
- ctx->oldnode = ctx->rootnode;
+ err = go_to_root (ctx);
+ if (err)
+ return err;
+ }
+ else
+ {
+ /* Get from symlink to containing directory. */
+ go_up_a_level (ctx);
}
+
/* Lookup the node the symlink points to. */
- next = ctx->next;
- find_file (symlink, ctx->oldnode, &ctx->currnode,
- iterate_dir, read_symlink, ctx);
- ctx->next = next;
- ctx->type = ctx->foundtype;
+ find_file (symlink, iterate_dir, lookup_file, read_symlink, ctx);
grub_free (symlink);
if (grub_errno)
- {
- free_node (ctx->oldnode, ctx);
- ctx->oldnode = 0;
- return grub_errno;
- }
- }
-
- if (ctx->oldnode != ctx->currnode)
- {
- free_node (ctx->oldnode, ctx);
- ctx->oldnode = 0;
+ return grub_errno;
}
-
- ctx->name = ctx->next;
}
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"),
ctx->path);
}
-/* 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. */
-grub_err_t
-grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
- grub_fshelp_node_t *foundnode,
- iterate_dir_func iterate_dir,
- read_symlink_func read_symlink,
- enum grub_fshelp_filetype expecttype)
+static grub_err_t
+grub_fshelp_find_file_real (const char *path, grub_fshelp_node_t rootnode,
+ grub_fshelp_node_t *foundnode,
+ iterate_dir_func iterate_dir,
+ lookup_file_func lookup_file,
+ read_symlink_func read_symlink,
+ enum grub_fshelp_filetype expecttype)
{
struct grub_fshelp_find_file_ctx ctx = {
.path = path,
.rootnode = rootnode,
- .foundtype = GRUB_FSHELP_DIR,
- .symlinknest = 0
+ .symlinknest = 0,
+ .currnode = 0
};
grub_err_t err;
+ enum grub_fshelp_filetype foundtype;
+ char *duppath;
if (!path || path[0] != '/')
{
- grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
- return grub_errno;
+ return grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
}
- err = find_file (path, rootnode, foundnode, iterate_dir, read_symlink, &ctx);
+ err = go_to_root (&ctx);
if (err)
return err;
+ duppath = grub_strdup (path);
+ if (!duppath)
+ return grub_errno;
+ err = find_file (duppath, iterate_dir, lookup_file, read_symlink, &ctx);
+ grub_free (duppath);
+ if (err)
+ {
+ free_stack (&ctx);
+ return err;
+ }
+
+ *foundnode = ctx.currnode->node;
+ foundtype = ctx.currnode->type;
+ /* Avoid the node being freed. */
+ ctx.currnode->node = 0;
+ free_stack (&ctx);
+
/* Check if the node that was found was of the expected type. */
- if (expecttype == GRUB_FSHELP_REG && ctx.foundtype != expecttype)
+ if (expecttype == GRUB_FSHELP_REG && foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
- else if (expecttype == GRUB_FSHELP_DIR && ctx.foundtype != expecttype)
+ else if (expecttype == GRUB_FSHELP_DIR && foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0;
}
+/* 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. */
+grub_err_t
+grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
+ grub_fshelp_node_t *foundnode,
+ iterate_dir_func iterate_dir,
+ read_symlink_func read_symlink,
+ enum grub_fshelp_filetype expecttype)
+{
+ return grub_fshelp_find_file_real (path, rootnode, foundnode,
+ iterate_dir, NULL,
+ read_symlink, expecttype);
+
+}
+
+grub_err_t
+grub_fshelp_find_file_lookup (const char *path, grub_fshelp_node_t rootnode,
+ grub_fshelp_node_t *foundnode,
+ lookup_file_func lookup_file,
+ read_symlink_func read_symlink,
+ enum grub_fshelp_filetype expecttype)
+{
+ return grub_fshelp_find_file_real (path, rootnode, foundnode,
+ NULL, lookup_file,
+ read_symlink, expecttype);
+
+}
+
/* 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. READ_HOOK_DATA is passed through as
@@ -252,6 +362,13 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
grub_disk_addr_t i, blockcnt;
int blocksize = 1 << (log2blocksize + GRUB_DISK_SECTOR_BITS);
+ if (pos > filesize)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("attempt to read past the end of file"));
+ return -1;
+ }
+
/* Adjust LEN so it we can't read past the end of the file. */
if (pos + len > filesize)
len = filesize - pos;
diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c
index 1e593059a..fc3683178 100644
--- a/grub-core/fs/hfs.c
+++ b/grub-core/fs/hfs.c
@@ -29,6 +29,7 @@
#include <grub/types.h>
#include <grub/hfs.h>
#include <grub/i18n.h>
+#include <grub/fshelp.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -330,6 +331,7 @@ grub_hfs_mount (grub_disk_t disk)
/* Check if this is a HFS filesystem. */
if (grub_be_to_cpu16 (data->sblock.magic) != GRUB_HFS_MAGIC
+ || data->sblock.blksz == 0
|| (data->sblock.blksz & grub_cpu_to_be32_compile_time (0xc00001ff)))
{
grub_error (GRUB_ERR_BAD_FS, "not an HFS filesystem");
@@ -367,9 +369,14 @@ grub_hfs_mount (grub_disk_t disk)
data->cat_root = grub_be_to_cpu32 (treehead.head.root_node);
data->cat_size = grub_be_to_cpu16 (treehead.head.node_size);
+ if (data->cat_size == 0
+ || data->blksz < data->cat_size
+ || data->blksz < data->ext_size)
+ goto fail;
+
/* Lookup the root directory node in the catalog tree using the
volume name. */
- key.parent_dir = grub_cpu_to_be32 (1);
+ key.parent_dir = grub_cpu_to_be32_compile_time (1);
key.strlen = data->sblock.volname[0];
grub_strcpy ((char *) key.str, (char *) (data->sblock.volname + 1));
@@ -686,6 +693,7 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
int i;
struct grub_hfs_extent *dat;
int blk;
+ grub_uint16_t reccnt;
dat = (struct grub_hfs_extent *) (type == 0
? (&data->sblock.catalog_recs)
@@ -704,8 +712,12 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
return grub_errno;
}
+ reccnt = grub_be_to_cpu16 (node->node.reccnt);
+ if (reccnt > (nodesize >> 1))
+ reccnt = (nodesize >> 1);
+
/* Iterate over all records in this node. */
- for (i = 0; i < grub_be_to_cpu16 (node->node.reccnt); i++)
+ for (i = 0; i < reccnt; i++)
{
int pos = (nodesize >> 1) - 1 - i;
struct pointer
@@ -713,16 +725,19 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
grub_uint8_t keylen;
grub_uint8_t key;
} GRUB_PACKED *pnt;
- pnt = (struct pointer *) (grub_be_to_cpu16 (node->offsets[pos])
- + node->rawnode);
+ grub_uint16_t off = grub_be_to_cpu16 (node->offsets[pos]);
+ if (off > nodesize - sizeof(*pnt))
+ continue;
+ pnt = (struct pointer *) (off + node->rawnode);
+ if (nodesize < (grub_size_t) off + pnt->keylen + 1)
+ continue;
struct grub_hfs_record rec =
{
&pnt->key,
pnt->keylen,
&pnt->key + pnt->keylen +(pnt->keylen + 1) % 2,
- nodesize - grub_be_to_cpu16 (node->offsets[pos])
- - pnt->keylen - 1
+ nodesize - off - pnt->keylen - 1
};
if (node_hook (&node->node, &rec, hook_arg))
@@ -1111,90 +1126,81 @@ utf8_to_macroman (grub_uint8_t *to, const char *from)
return optr - to;
}
+union grub_hfs_anyrec {
+ struct grub_hfs_filerec frec;
+ struct grub_hfs_dirrec dir;
+};
+
+struct grub_fshelp_node
+{
+ struct grub_hfs_data *data;
+ union grub_hfs_anyrec fdrec;
+ grub_uint32_t inode;
+};
+
+static grub_err_t
+lookup_file (grub_fshelp_node_t dir,
+ const char *name,
+ grub_fshelp_node_t *foundnode,
+ enum grub_fshelp_filetype *foundtype)
+{
+ struct grub_hfs_catalog_key key;
+ grub_ssize_t slen;
+ union grub_hfs_anyrec fdrec;
+
+ key.parent_dir = grub_cpu_to_be32 (dir->inode);
+ slen = utf8_to_macroman (key.str, name);
+ if (slen < 0)
+ /* Not found */
+ return GRUB_ERR_NONE;
+ key.strlen = slen;
+
+ /* Lookup this node. */
+ if (! grub_hfs_find_node (dir->data, (char *) &key, dir->data->cat_root,
+ 0, (char *) &fdrec.frec, sizeof (fdrec.frec)))
+ /* Not found */
+ return GRUB_ERR_NONE;
+
+ *foundnode = grub_malloc (sizeof (struct grub_fshelp_node));
+ if (!*foundnode)
+ return grub_errno;
+
+ (*foundnode)->inode = grub_be_to_cpu32 (fdrec.dir.dirid);
+ (*foundnode)->fdrec = fdrec;
+ (*foundnode)->data = dir->data;
+ *foundtype = (fdrec.frec.type == GRUB_HFS_FILETYPE_DIR) ? GRUB_FSHELP_DIR : GRUB_FSHELP_REG;
+ return GRUB_ERR_NONE;
+}
/* Find a file or directory with the pathname PATH in the filesystem
DATA. Return the file record in RETDATA when it is non-zero.
Return the directory number in RETINODE when it is non-zero. */
static grub_err_t
grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
- struct grub_hfs_filerec *retdata, int *retinode)
+ grub_fshelp_node_t *found,
+ enum grub_fshelp_filetype exptype)
{
- int inode = data->rootdir;
- char *next;
- char *origpath;
- union {
- struct grub_hfs_filerec frec;
- struct grub_hfs_dirrec dir;
- } fdrec;
-
- fdrec.frec.type = GRUB_HFS_FILETYPE_DIR;
-
- if (path[0] != '/')
- {
- grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
- return 0;
+ struct grub_fshelp_node root = {
+ .data = data,
+ .inode = data->rootdir,
+ .fdrec = {
+ .frec = {
+ .type = GRUB_HFS_FILETYPE_DIR
+ }
}
+ };
+ grub_err_t err;
- origpath = grub_strdup (path);
- if (!origpath)
- return grub_errno;
-
- path = origpath;
- while (*path == '/')
- path++;
+ err = grub_fshelp_find_file_lookup (path, &root, found, lookup_file, NULL, exptype);
- while (path && grub_strlen (path))
+ if (&root == *found)
{
- grub_ssize_t slen;
- if (fdrec.frec.type != GRUB_HFS_FILETYPE_DIR)
- {
- grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
- goto fail;
- }
-
- /* Isolate a part of the path. */
- next = grub_strchr (path, '/');
- if (next)
- {
- while (*next == '/')
- *(next++) = '\0';
- }
-
- struct grub_hfs_catalog_key key;
-
- key.parent_dir = grub_cpu_to_be32 (inode);
- slen = utf8_to_macroman (key.str, path);
- if (slen < 0)
- {
- grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
- goto fail;
- }
- key.strlen = slen;
-
- /* Lookup this node. */
- if (! grub_hfs_find_node (data, (char *) &key, data->cat_root,
- 0, (char *) &fdrec.frec, sizeof (fdrec.frec)))
- {
- grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
- goto fail;
- }
-
- if (grub_errno)
- goto fail;
-
- inode = grub_be_to_cpu32 (fdrec.dir.dirid);
- path = next;
+ *found = grub_malloc (sizeof (root));
+ if (!*found)
+ return grub_errno;
+ grub_memcpy (*found, &root, sizeof (root));
}
-
- if (retdata)
- grub_memcpy (retdata, &fdrec.frec, sizeof (fdrec.frec));
-
- if (retinode)
- *retinode = inode;
-
- fail:
- grub_free (origpath);
- return grub_errno;
+ return err;
}
struct grub_hfs_dir_hook_ctx
@@ -1252,16 +1258,14 @@ static grub_err_t
grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
void *hook_data)
{
- int inode;
-
struct grub_hfs_data *data;
- struct grub_hfs_filerec frec;
struct grub_hfs_dir_hook_ctx ctx =
{
.hook = hook,
.hook_data = hook_data
};
-
+ grub_fshelp_node_t found = NULL;
+
grub_dl_ref (my_mod);
data = grub_hfs_mount (device->disk);
@@ -1269,18 +1273,13 @@ grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
goto fail;
/* First the directory ID for the directory. */
- if (grub_hfs_find_dir (data, path, &frec, &inode))
+ if (grub_hfs_find_dir (data, path, &found, GRUB_FSHELP_DIR))
goto fail;
- if (frec.type != GRUB_HFS_FILETYPE_DIR)
- {
- grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
- goto fail;
- }
-
- grub_hfs_iterate_dir (data, data->cat_root, inode, grub_hfs_dir_hook, &ctx);
+ grub_hfs_iterate_dir (data, data->cat_root, found->inode, grub_hfs_dir_hook, &ctx);
fail:
+ grub_free (found);
grub_free (data);
grub_dl_unref (my_mod);
@@ -1294,35 +1293,36 @@ static grub_err_t
grub_hfs_open (struct grub_file *file, const char *name)
{
struct grub_hfs_data *data;
- struct grub_hfs_filerec frec;
-
+ grub_fshelp_node_t found = NULL;
+
grub_dl_ref (my_mod);
data = grub_hfs_mount (file->device->disk);
- if (grub_hfs_find_dir (data, name, &frec, 0))
+ if (!data)
{
- grub_free (data);
grub_dl_unref (my_mod);
return grub_errno;
}
- if (frec.type != GRUB_HFS_FILETYPE_FILE)
+ if (grub_hfs_find_dir (data, name, &found, GRUB_FSHELP_REG))
{
grub_free (data);
- grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
+ grub_free (found);
grub_dl_unref (my_mod);
return grub_errno;
}
- grub_memcpy (data->extents, frec.extents, sizeof (grub_hfs_datarecord_t));
- file->size = grub_be_to_cpu32 (frec.size);
- data->size = grub_be_to_cpu32 (frec.size);
- data->fileid = grub_be_to_cpu32 (frec.fileid);
+ grub_memcpy (data->extents, found->fdrec.frec.extents, sizeof (grub_hfs_datarecord_t));
+ file->size = grub_be_to_cpu32 (found->fdrec.frec.size);
+ data->size = grub_be_to_cpu32 (found->fdrec.frec.size);
+ data->fileid = grub_be_to_cpu32 (found->fdrec.frec.fileid);
file->offset = 0;
file->data = data;
+ grub_free (found);
+
return 0;
}
diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c
index 950d8a1e1..21159e858 100644
--- a/grub-core/fs/hfsplus.c
+++ b/grub-core/fs/hfsplus.c
@@ -336,6 +336,9 @@ grub_hfsplus_mount (grub_disk_t disk)
data->case_sensitive = ((magic == GRUB_HFSPLUSX_MAGIC) &&
(header.key_compare == GRUB_HFSPLUSX_BINARYCOMPARE));
+ if (data->catalog_tree.nodesize < 2)
+ goto fail;
+
if (grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, 0,
sizeof (struct grub_hfsplus_btnode),
sizeof (header), (char *) &header) <= 0)
@@ -350,6 +353,9 @@ grub_hfsplus_mount (grub_disk_t disk)
data->extoverflow_tree.root = grub_be_to_cpu32 (header.root);
data->extoverflow_tree.nodesize = grub_be_to_cpu16 (header.nodesize);
+ if (data->extoverflow_tree.nodesize < 2)
+ goto fail;
+
if (grub_hfsplus_read_file (&data->attr_tree.file, 0, 0,
sizeof (struct grub_hfsplus_btnode),
sizeof (header), (char *) &header) <= 0)
@@ -723,7 +729,10 @@ list_nodes (void *record, void *hook_arg)
/* If the name is obviously invalid, skip this node. */
if (catkey->name[i] == 0)
- return 0;
+ {
+ grub_free (filename);
+ return 0;
+ }
}
*grub_utf16_to_utf8 ((grub_uint8_t *) filename, catkey->name,
@@ -745,7 +754,10 @@ list_nodes (void *record, void *hook_arg)
callback function. */
node = grub_malloc (sizeof (*node));
if (!node)
- return 1;
+ {
+ grub_free (filename);
+ return 1;
+ }
node->data = ctx->dir->data;
node->compressed = 0;
node->cbuf = 0;
@@ -780,8 +792,8 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
};
struct grub_hfsplus_key_internal intern;
- struct grub_hfsplus_btnode *node;
- grub_disk_addr_t ptr;
+ struct grub_hfsplus_btnode *node = NULL;
+ grub_disk_addr_t ptr = 0;
{
struct grub_fshelp_node *fsnode;
@@ -964,8 +976,8 @@ grub_hfsplus_label (grub_device_t device, char **label)
struct grub_hfsplus_catkey *catkey;
int i, label_len;
struct grub_hfsplus_key_internal intern;
- struct grub_hfsplus_btnode *node;
- grub_disk_addr_t ptr;
+ struct grub_hfsplus_btnode *node = NULL;
+ grub_disk_addr_t ptr = 0;
*label = 0;
diff --git a/grub-core/fs/hfspluscomp.c b/grub-core/fs/hfspluscomp.c
index 461b4678f..d76f3f137 100644
--- a/grub-core/fs/hfspluscomp.c
+++ b/grub-core/fs/hfspluscomp.c
@@ -156,8 +156,12 @@ hfsplus_read_compressed_real (struct grub_hfsplus_file *node,
if (ts > node->size - (pos & ~(HFSPLUS_COMPRESS_BLOCK_SIZE)))
ts = node->size - (pos & ~(HFSPLUS_COMPRESS_BLOCK_SIZE));
if (grub_zlib_decompress (tmp_buf, sz, 0,
- node->cbuf, ts) < 0)
+ node->cbuf, ts) != (grub_ssize_t) ts)
{
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "premature end of compressed");
+
grub_free (tmp_buf);
return -1;
}
@@ -288,8 +292,14 @@ hfsplus_open_compressed_real (struct grub_hfsplus_file *node)
if (grub_zlib_decompress ((char *) (cmp_head + 1),
grub_cpu_to_be64 (attr_head->size)
- sizeof (*cmp_head), 0,
- node->cbuf, node->size) < 0)
- return grub_errno;
+ node->cbuf, node->size)
+ != (grub_ssize_t) node->size)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "premature end of compressed");
+ return grub_errno;
+ }
node->compressed = 1;
return 0;
}
diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c
index 6a6677337..c9c8374bf 100644
--- a/grub-core/fs/iso9660.c
+++ b/grub-core/fs/iso9660.c
@@ -750,19 +750,15 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
if (dir->data->joliet && !ctx.filename)
{
- char *oldname, *semicolon;
+ char *semicolon;
- oldname = name;
ctx.filename = grub_iso9660_convert_string
- ((grub_uint8_t *) oldname, dirent.namelen >> 1);
+ ((grub_uint8_t *) name, dirent.namelen >> 1);
semicolon = grub_strrchr (ctx.filename, ';');
if (semicolon)
*semicolon = '\0';
- if (ctx.filename_alloc)
- grub_free (oldname);
-
ctx.filename_alloc = 1;
}
@@ -959,14 +955,15 @@ grub_iso9660_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_iso9660_data *data =
(struct grub_iso9660_data *) file->data;
+ grub_err_t err;
/* XXX: The file is stored in as a single extent. */
data->disk->read_hook = file->read_hook;
data->disk->read_hook_data = file->read_hook_data;
- read_node (data->node, file->offset, len, buf);
+ err = read_node (data->node, file->offset, len, buf);
data->disk->read_hook = NULL;
- if (grub_errno)
+ if (err || grub_errno)
return -1;
return len;
diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c
index 98e1b71ec..d451b3426 100644
--- a/grub-core/fs/minix.c
+++ b/grub-core/fs/minix.c
@@ -65,7 +65,6 @@ typedef grub_uint16_t grub_minix_uintn_t;
#define grub_minix_to_cpu_n grub_minix_to_cpu16
#endif
-#define GRUB_MINIX_INODE_BLKSZ(data) sizeof (grub_minix_uintn_t)
#ifdef MODE_MINIX3
typedef grub_uint32_t grub_minix_ino_t;
#define grub_minix_to_cpu_ino grub_minix_to_cpu32
@@ -83,19 +82,6 @@ typedef grub_uint16_t grub_minix_ino_t;
#define GRUB_MINIX_INODE_DINDIR_ZONE(data) (grub_minix_to_cpu_n \
(data->inode.double_indir_zone))
-#ifndef MODE_MINIX3
-#define GRUB_MINIX_LOG2_ZONESZ (GRUB_MINIX_LOG2_BSIZE \
- + grub_minix_to_cpu16 (data->sblock.log2_zone_size))
-#endif
-#define GRUB_MINIX_ZONESZ ((grub_uint64_t) data->block_size << \
- (GRUB_DISK_SECTOR_BITS + grub_minix_to_cpu16 (data->sblock.log2_zone_size)))
-
-#ifdef MODE_MINIX3
-#define GRUB_MINIX_ZONE2SECT(zone) ((zone) * data->block_size)
-#else
-#define GRUB_MINIX_ZONE2SECT(zone) ((zone) << GRUB_MINIX_LOG2_ZONESZ)
-#endif
-
#ifdef MODE_MINIX3
struct grub_minix_sblock
@@ -172,6 +158,7 @@ struct grub_minix_data
{
struct grub_minix_sblock sblock;
struct grub_minix_inode inode;
+ grub_uint32_t block_per_zone;
grub_minix_ino_t ino;
int linknest;
grub_disk_t disk;
@@ -184,15 +171,32 @@ static grub_dl_t my_mod;
static grub_err_t grub_minix_find_file (struct grub_minix_data *data,
const char *path);
+#ifdef MODE_MINIX3
+static inline grub_disk_addr_t
+grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone)
+{
+ return ((grub_disk_addr_t) zone) * data->block_size;
+}
+#else
+static inline grub_disk_addr_t
+grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone)
+{
+ int log2_zonesz = (GRUB_MINIX_LOG2_BSIZE
+ + grub_minix_to_cpu16 (data->sblock.log2_zone_size));
+ return (((grub_disk_addr_t) zone) << log2_zonesz);
+}
+#endif
+
+
/* Read the block pointer in ZONE, on the offset NUM. */
static grub_minix_uintn_t
-grub_get_indir (struct grub_minix_data *data,
+grub_get_indir (struct grub_minix_data *data,
grub_minix_uintn_t zone,
grub_minix_uintn_t num)
{
grub_minix_uintn_t indirn;
grub_disk_read (data->disk,
- GRUB_MINIX_ZONE2SECT(zone),
+ grub_minix_zone2sect(data, zone),
sizeof (grub_minix_uintn_t) * num,
sizeof (grub_minix_uintn_t), (char *) &indirn);
return grub_minix_to_cpu_n (indirn);
@@ -202,8 +206,6 @@ static grub_minix_uintn_t
grub_minix_get_file_block (struct grub_minix_data *data, unsigned int blk)
{
grub_minix_uintn_t indir;
- const grub_uint32_t block_per_zone = (GRUB_MINIX_ZONESZ
- / GRUB_MINIX_INODE_BLKSZ (data));
/* Direct block. */
if (blk < GRUB_MINIX_INODE_DIR_BLOCKS)
@@ -211,33 +213,33 @@ grub_minix_get_file_block (struct grub_minix_data *data, unsigned int blk)
/* Indirect block. */
blk -= GRUB_MINIX_INODE_DIR_BLOCKS;
- if (blk < block_per_zone)
+ if (blk < data->block_per_zone)
{
indir = grub_get_indir (data, GRUB_MINIX_INODE_INDIR_ZONE (data), blk);
return indir;
}
/* Double indirect block. */
- blk -= block_per_zone;
- if (blk < block_per_zone * block_per_zone)
+ blk -= data->block_per_zone;
+ if (blk < (grub_uint64_t) data->block_per_zone * (grub_uint64_t) data->block_per_zone)
{
indir = grub_get_indir (data, GRUB_MINIX_INODE_DINDIR_ZONE (data),
- blk / block_per_zone);
+ blk / data->block_per_zone);
- indir = grub_get_indir (data, indir, blk % block_per_zone);
+ indir = grub_get_indir (data, indir, blk % data->block_per_zone);
return indir;
}
#if defined (MODE_MINIX3) || defined (MODE_MINIX2)
- blk -= block_per_zone * block_per_zone;
- if (blk < ((grub_uint64_t) block_per_zone * (grub_uint64_t) block_per_zone
- * (grub_uint64_t) block_per_zone))
+ blk -= data->block_per_zone * data->block_per_zone;
+ if (blk < ((grub_uint64_t) data->block_per_zone * (grub_uint64_t) data->block_per_zone
+ * (grub_uint64_t) data->block_per_zone))
{
indir = grub_get_indir (data, grub_minix_to_cpu_n (data->inode.triple_indir_zone),
- (blk / block_per_zone) / block_per_zone);
- indir = grub_get_indir (data, indir, (blk / block_per_zone) % block_per_zone);
- indir = grub_get_indir (data, indir, blk % block_per_zone);
+ (blk / data->block_per_zone) / data->block_per_zone);
+ indir = grub_get_indir (data, indir, (blk / data->block_per_zone) % data->block_per_zone);
+ indir = grub_get_indir (data, indir, blk % data->block_per_zone);
return indir;
}
@@ -262,6 +264,13 @@ grub_minix_read_file (struct grub_minix_data *data,
grub_uint32_t posblock;
grub_uint32_t blockoff;
+ if (pos > GRUB_MINIX_INODE_SIZE (data))
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE,
+ N_("attempt to read past the end of file"));
+ return -1;
+ }
+
/* Adjust len so it we can't read past the end of the file. */
if (len + pos > GRUB_MINIX_INODE_SIZE (data))
len = GRUB_MINIX_INODE_SIZE (data) - pos;
@@ -278,7 +287,7 @@ grub_minix_read_file (struct grub_minix_data *data,
for (i = posblock; i < blockcnt; i++)
{
- grub_disk_addr_t blknr;
+ grub_minix_uintn_t blknr;
grub_uint64_t blockend = data->block_size << GRUB_DISK_SECTOR_BITS;
grub_off_t skipfirst = 0;
@@ -307,7 +316,7 @@ grub_minix_read_file (struct grub_minix_data *data,
data->disk->read_hook = read_hook;
data->disk->read_hook_data = read_hook_data;
grub_disk_read (data->disk,
- GRUB_MINIX_ZONE2SECT(blknr),
+ grub_minix_zone2sect(data, blknr),
skipfirst, blockend, buf);
data->disk->read_hook = 0;
if (grub_errno)
@@ -333,7 +342,8 @@ grub_minix_read_inode (struct grub_minix_data *data, grub_minix_ino_t ino)
/* The first inode in minix is inode 1. */
ino--;
- block = GRUB_MINIX_ZONE2SECT (2 + grub_minix_to_cpu16 (sblock->inode_bmap_size)
+ block = grub_minix_zone2sect (data,
+ 2 + grub_minix_to_cpu16 (sblock->inode_bmap_size)
+ grub_minix_to_cpu16 (sblock->zone_bmap_size));
block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_inode));
int offs = (ino % (GRUB_DISK_SECTOR_SIZE
@@ -508,6 +518,12 @@ grub_minix_mount (grub_disk_t disk)
data->block_size = 2;
#endif
+ data->block_per_zone = (((grub_uint64_t) data->block_size << \
+ (GRUB_DISK_SECTOR_BITS + grub_minix_to_cpu16 (data->sblock.log2_zone_size)))
+ / sizeof (grub_minix_uintn_t));
+ if (!data->block_per_zone)
+ goto fail;
+
return data;
fail:
diff --git a/grub-core/fs/nilfs2.c b/grub-core/fs/nilfs2.c
index 388ee188e..598a2a55b 100644
--- a/grub-core/fs/nilfs2.c
+++ b/grub-core/fs/nilfs2.c
@@ -724,6 +724,10 @@ grub_nilfs2_valid_sb (struct grub_nilfs2_super_block *sbp)
if (grub_le_to_cpu32 (sbp->s_rev_level) != NILFS_SUPORT_REV)
return 0;
+ /* 20 already means 1GiB blocks. We don't want to deal with blocks overflowing int32. */
+ if (grub_le_to_cpu32 (sbp->s_log_block_size) > 20)
+ return 0;
+
return 1;
}
diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c
index d3a91f5d7..6f8468862 100644
--- a/grub-core/fs/ntfs.c
+++ b/grub-core/fs/ntfs.c
@@ -618,7 +618,10 @@ list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos,
ustr = get_utf8 (np, ns);
if (ustr == NULL)
- return 0;
+ {
+ grub_free (fdiro);
+ return 0;
+ }
if (namespace)
type |= GRUB_FSHELP_CASE_INSENSITIVE;
@@ -917,12 +920,16 @@ grub_ntfs_mount (grub_disk_t disk)
if (bpb.clusters_per_mft > 0)
data->mft_size = ((grub_disk_addr_t) bpb.clusters_per_mft) << data->log_spc;
+ else if (-bpb.clusters_per_mft < GRUB_NTFS_BLK_SHR || -bpb.clusters_per_mft >= 31)
+ goto fail;
else
data->mft_size = 1ULL << (-bpb.clusters_per_mft - GRUB_NTFS_BLK_SHR);
if (bpb.clusters_per_index > 0)
data->idx_size = (((grub_disk_addr_t) bpb.clusters_per_index)
<< data->log_spc);
+ else if (-bpb.clusters_per_index < GRUB_NTFS_BLK_SHR || -bpb.clusters_per_index >= 31)
+ goto fail;
else
data->idx_size = 1ULL << (-bpb.clusters_per_index - GRUB_NTFS_BLK_SHR);
diff --git a/grub-core/fs/ntfscomp.c b/grub-core/fs/ntfscomp.c
index 2e1ce51a8..3cd97d337 100644
--- a/grub-core/fs/ntfscomp.c
+++ b/grub-core/fs/ntfscomp.c
@@ -104,7 +104,7 @@ decomp_block (struct grub_ntfs_comp *cc, grub_uint8_t *dest)
if (tag & 1)
{
grub_uint32_t i, len, delta, code, lmask, dshift;
- grub_uint16_t word;
+ grub_uint16_t word = 0;
if (decomp_get16 (cc, &word))
return grub_errno;
diff --git a/grub-core/fs/proc.c b/grub-core/fs/proc.c
index a03469ec6..31f3aa9a4 100644
--- a/grub-core/fs/proc.c
+++ b/grub-core/fs/proc.c
@@ -22,6 +22,7 @@
#include <grub/file.h>
#include <grub/mm.h>
#include <grub/dl.h>
+#include <grub/archelp.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -74,6 +75,44 @@ grub_procdev_write (grub_disk_t disk __attribute ((unused)),
return GRUB_ERR_OUT_OF_RANGE;
}
+struct grub_archelp_data
+{
+ struct grub_procfs_entry *entry, *next_entry;
+};
+
+static void
+grub_procfs_rewind (struct grub_archelp_data *data)
+{
+ data->entry = NULL;
+ data->next_entry = grub_procfs_entries;
+}
+
+static grub_err_t
+grub_procfs_find_file (struct grub_archelp_data *data, char **name,
+ grub_int32_t *mtime,
+ grub_uint32_t *mode)
+{
+ data->entry = data->next_entry;
+ if (!data->entry)
+ {
+ *mode = GRUB_ARCHELP_ATTR_END;
+ return GRUB_ERR_NONE;
+ }
+ data->next_entry = data->entry->next;
+ *mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME;
+ *name = grub_strdup (data->entry->name);
+ *mtime = 0;
+ if (!*name)
+ return grub_errno;
+ return GRUB_ERR_NONE;
+}
+
+static struct grub_archelp_ops arcops =
+ {
+ .find_file = grub_procfs_find_file,
+ .rewind = grub_procfs_rewind
+ };
+
static grub_ssize_t
grub_procfs_read (grub_file_t file, char *buf, grub_size_t len)
{
@@ -99,44 +138,35 @@ static grub_err_t
grub_procfs_dir (grub_device_t device, const char *path,
grub_fs_dir_hook_t hook, void *hook_data)
{
- const char *ptr;
- struct grub_dirhook_info info;
- struct grub_procfs_entry *entry;
-
- grub_memset (&info, 0, sizeof (info));
+ struct grub_archelp_data data;
/* Check if the disk is our dummy disk. */
if (grub_strcmp (device->disk->name, "proc"))
return grub_error (GRUB_ERR_BAD_FS, "not a procfs");
- for (ptr = path; *ptr == '/'; ptr++);
- if (*ptr)
- return 0;
- FOR_LIST_ELEMENTS((entry), (grub_procfs_entries))
- if (hook (entry->name, &info, hook_data))
- return 0;
- return 0;
+
+ grub_procfs_rewind (&data);
+
+ return grub_archelp_dir (&data, &arcops,
+ path, hook, hook_data);
}
static grub_err_t
grub_procfs_open (struct grub_file *file, const char *path)
{
- const char *pathptr;
- struct grub_procfs_entry *entry;
-
- for (pathptr = path; *pathptr == '/'; pathptr++);
-
- FOR_LIST_ELEMENTS((entry), (grub_procfs_entries))
- if (grub_strcmp (pathptr, entry->name) == 0)
- {
- grub_size_t sz;
- file->data = entry->get_contents (&sz);
- if (!file->data)
- return grub_errno;
- file->size = sz;
- return GRUB_ERR_NONE;
- }
-
- return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
+ grub_err_t err;
+ struct grub_archelp_data data;
+ grub_size_t sz;
+
+ grub_procfs_rewind (&data);
+
+ err = grub_archelp_open (&data, &arcops, path);
+ if (err)
+ return err;
+ file->data = data.entry->get_contents (&sz);
+ if (!file->data)
+ return grub_errno;
+ file->size = sz;
+ return GRUB_ERR_NONE;
}
static struct grub_disk_dev grub_procfs_dev = {
diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c
index ac65054d3..39736f63c 100644
--- a/grub-core/fs/reiserfs.c
+++ b/grub-core/fs/reiserfs.c
@@ -365,7 +365,7 @@ grub_reiserfs_set_key_offset (struct grub_reiserfs_key *key,
key->u.v1.offset = grub_cpu_to_le32 (value);
else
key->u.v2.offset_type \
- = ((key->u.v2.offset_type & grub_cpu_to_le64 (15ULL << 60))
+ = ((key->u.v2.offset_type & grub_cpu_to_le64_compile_time (15ULL << 60))
| grub_cpu_to_le64 (value & (~0ULL >> 4)));
}
@@ -412,7 +412,7 @@ grub_reiserfs_set_key_type (struct grub_reiserfs_key *key,
key->u.v1.type = grub_cpu_to_le32 (type);
else
key->u.v2.offset_type
- = ((key->u.v2.offset_type & grub_cpu_to_le64 (~0ULL >> 4))
+ = ((key->u.v2.offset_type & grub_cpu_to_le64_compile_time (~0ULL >> 4))
| grub_cpu_to_le64 ((grub_uint64_t) type << 60));
assert (grub_reiserfs_get_key_type (key) == grub_type);
@@ -783,12 +783,30 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
struct grub_reiserfs_key entry_key;
enum grub_fshelp_filetype entry_type;
char *entry_name;
+ char *entry_name_end = 0;
+ char c;
if (!(entry_state & GRUB_REISERFS_VISIBLE_MASK))
continue;
entry_name = (((char *) directory_headers)
+ grub_le_to_cpu16 (directory_header->location));
+ if (entry_number == 0)
+ {
+ entry_name_end = (char *) block_header
+ + grub_le_to_cpu16 (item_headers[block_position].item_location)
+ + grub_le_to_cpu16 (item_headers[block_position].item_size);
+ }
+ else
+ {
+ entry_name_end = (((char *) directory_headers)
+ + grub_le_to_cpu16 (directory_headers[entry_number - 1].location));
+ }
+ if (entry_name_end < entry_name || entry_name_end > (char *) block_header + block_size)
+ {
+ entry_name_end = (char *) block_header + block_size;
+ }
+
entry_key.directory_id = directory_header->directory_id;
entry_key.object_id = directory_header->object_id;
entry_key.u.v2.offset_type = 0;
@@ -935,7 +953,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
else
{
/* Pseudo file ".." never has stat block. */
- if (grub_strcmp (entry_name, ".."))
+ if (entry_name_end == entry_name + 2 && grub_memcmp (entry_name, "..", 2) != 0)
grub_dprintf ("reiserfs",
"Warning : %s has no stat block !\n",
entry_name);
@@ -943,18 +961,21 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
goto next;
}
}
+
+ c = *entry_name_end;
+ *entry_name_end = 0;
if (hook (entry_name, entry_type, entry_item, hook_data))
{
+ *entry_name_end = c;
grub_dprintf ("reiserfs", "Found : %s, type=%d\n",
entry_name, entry_type);
ret = 1;
goto found;
}
+ *entry_name_end = c;
next:
- *entry_name = 0; /* Make sure next entry name (which is just
- before this one in disk order) stops before
- the current one. */
+ ;
}
if (next_offset == 0)
@@ -997,8 +1018,8 @@ grub_reiserfs_open (struct grub_file *file, const char *name)
data = grub_reiserfs_mount (file->device->disk);
if (! data)
goto fail;
- key.directory_id = grub_cpu_to_le32 (1);
- key.object_id = grub_cpu_to_le32 (2);
+ key.directory_id = grub_cpu_to_le32_compile_time (1);
+ key.object_id = grub_cpu_to_le32_compile_time (2);
key.u.v2.offset_type = 0;
grub_reiserfs_set_key_type (&key, GRUB_REISERFS_DIRECTORY, 2);
grub_reiserfs_set_key_offset (&key, 1);
@@ -1090,7 +1111,7 @@ grub_reiserfs_read_real (struct grub_fshelp_node *node,
switch (found.type)
{
case GRUB_REISERFS_DIRECT:
- block = found.block_number * (block_size >> GRUB_DISK_SECTOR_BITS);
+ block = ((grub_disk_addr_t) found.block_number) * (block_size >> GRUB_DISK_SECTOR_BITS);
grub_dprintf ("reiserfs_blocktype", "D: %u\n", (unsigned) block);
if (initial_position < current_position + item_size)
{
@@ -1289,8 +1310,8 @@ grub_reiserfs_dir (grub_device_t device, const char *path,
data = grub_reiserfs_mount (device->disk);
if (! data)
goto fail;
- root_key.directory_id = grub_cpu_to_le32 (1);
- root_key.object_id = grub_cpu_to_le32 (2);
+ root_key.directory_id = grub_cpu_to_le32_compile_time (1);
+ root_key.object_id = grub_cpu_to_le32_compile_time (2);
root_key.u.v2.offset_type = 0;
grub_reiserfs_set_key_type (&root_key, GRUB_REISERFS_DIRECTORY, 2);
grub_reiserfs_set_key_offset (&root_key, 1);
diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c
index 6c8215048..57b8d8da6 100644
--- a/grub-core/fs/sfs.c
+++ b/grub-core/fs/sfs.c
@@ -173,10 +173,11 @@ grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block,
struct grub_sfs_btree *tree;
int i;
grub_uint32_t next;
+ grub_size_t blocksize = GRUB_DISK_SECTOR_SIZE << data->log_blocksize;
- treeblock = grub_malloc (GRUB_DISK_SECTOR_SIZE << data->log_blocksize);
- if (!block)
- return 0;
+ treeblock = grub_malloc (blocksize);
+ if (!treeblock)
+ return grub_errno;
next = grub_be_to_cpu32 (data->rblock.btree);
tree = (struct grub_sfs_btree *) treeblock;
@@ -184,17 +185,21 @@ grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block,
/* Handle this level in the btree. */
do
{
+ grub_uint16_t nnodes;
grub_disk_read (data->disk,
((grub_disk_addr_t) next) << data->log_blocksize,
- 0, GRUB_DISK_SECTOR_SIZE << data->log_blocksize,
- treeblock);
+ 0, blocksize, treeblock);
if (grub_errno)
{
grub_free (treeblock);
return grub_errno;
}
- for (i = grub_be_to_cpu16 (tree->nodes) - 1; i >= 0; i--)
+ nnodes = grub_be_to_cpu16 (tree->nodes);
+ if (nnodes * (grub_uint32_t) (tree)->nodesize > blocksize)
+ break;
+
+ for (i = (int) nnodes - 1; i >= 0; i--)
{
#define EXTNODE(tree, index) \
diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c
index fd412830c..839bff889 100644
--- a/grub-core/fs/udf.c
+++ b/grub-core/fs/udf.c
@@ -986,6 +986,7 @@ grub_udf_read_symlink (grub_fshelp_node_t node)
case 1:
if (ptr[1])
goto fail;
+ /* Fallthrough. */
case 2:
/* in 4 bytes. out: 1 byte. */
optr = out;
diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c
index 4a2161cc7..293f027aa 100644
--- a/grub-core/fs/ufs.c
+++ b/grub-core/fs/ufs.c
@@ -394,7 +394,7 @@ grub_ufs_read_file (struct grub_ufs_data *data,
return -1;
}
else
- grub_memset (buf, UFS_BLKSZ (sblock) - skipfirst, 0);
+ grub_memset (buf, 0, blockend);
buf += UFS_BLKSZ (sblock) - skipfirst;
}
@@ -465,7 +465,13 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino)
&& INODE_SIZE (data) <= sizeof (data->inode.symlink))
grub_strcpy (symlink, (char *) data->inode.symlink);
else
- grub_ufs_read_file (data, 0, 0, 0, sz, symlink);
+ {
+ if (grub_ufs_read_file (data, 0, 0, 0, sz, symlink) < 0)
+ {
+ grub_free(symlink);
+ return grub_errno;
+ }
+ }
symlink[sz] = '\0';
/* The symlink is an absolute path, go back to the root inode. */
@@ -604,7 +610,8 @@ grub_ufs_mount (grub_disk_t disk)
endiannesses. */
if (data->sblock.magic == grub_cpu_to_ufs32_compile_time (GRUB_UFS_MAGIC)
&& data->sblock.bsize != 0
- && ((data->sblock.bsize & (data->sblock.bsize - 1)) == 0))
+ && ((data->sblock.bsize & (data->sblock.bsize - 1)) == 0)
+ && data->sblock.ino_per_group != 0)
{
for (data->log2_blksz = 0;
(1U << data->log2_blksz) < grub_ufs_to_cpu32 (data->sblock.bsize);
diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c
index 16ffd3f1e..ca9c0c37a 100644
--- a/grub-core/fs/xfs.c
+++ b/grub-core/fs/xfs.c
@@ -34,6 +34,50 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define XFS_INODE_FORMAT_EXT 2
#define XFS_INODE_FORMAT_BTREE 3
+/* Superblock version field flags */
+#define XFS_SB_VERSION_NUMBITS 0x000f
+#define XFS_SB_VERSION_ATTRBIT 0x0010
+#define XFS_SB_VERSION_NLINKBIT 0x0020
+#define XFS_SB_VERSION_QUOTABIT 0x0040
+#define XFS_SB_VERSION_ALIGNBIT 0x0080
+#define XFS_SB_VERSION_DALIGNBIT 0x0100
+#define XFS_SB_VERSION_LOGV2BIT 0x0400
+#define XFS_SB_VERSION_SECTORBIT 0x0800
+#define XFS_SB_VERSION_EXTFLGBIT 0x1000
+#define XFS_SB_VERSION_DIRV2BIT 0x2000
+#define XFS_SB_VERSION_MOREBITSBIT 0x8000
+#define XFS_SB_VERSION_BITS_SUPPORTED \
+ (XFS_SB_VERSION_NUMBITS | \
+ XFS_SB_VERSION_ATTRBIT | \
+ XFS_SB_VERSION_NLINKBIT | \
+ XFS_SB_VERSION_QUOTABIT | \
+ XFS_SB_VERSION_ALIGNBIT | \
+ XFS_SB_VERSION_DALIGNBIT | \
+ XFS_SB_VERSION_LOGV2BIT | \
+ XFS_SB_VERSION_SECTORBIT | \
+ XFS_SB_VERSION_EXTFLGBIT | \
+ XFS_SB_VERSION_DIRV2BIT | \
+ XFS_SB_VERSION_MOREBITSBIT)
+
+/* Recognized xfs format versions */
+#define XFS_SB_VERSION_4 4 /* Good old XFS filesystem */
+#define XFS_SB_VERSION_5 5 /* CRC enabled filesystem */
+
+/* features2 field flags */
+#define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */
+#define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */
+#define XFS_SB_VERSION2_PROJID32BIT 0x00000080 /* 32-bit project ids */
+#define XFS_SB_VERSION2_FTYPE 0x00000200 /* inode type in dir */
+#define XFS_SB_VERSION2_BITS_SUPPORTED \
+ (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \
+ XFS_SB_VERSION2_ATTR2BIT | \
+ XFS_SB_VERSION2_PROJID32BIT | \
+ XFS_SB_VERSION2_FTYPE)
+
+/* incompat feature flags */
+#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */
+#define XFS_SB_FEAT_INCOMPAT_SUPPORTED \
+ (XFS_SB_FEAT_INCOMPAT_FTYPE)
struct grub_xfs_sblock
{
@@ -45,7 +89,9 @@ struct grub_xfs_sblock
grub_uint64_t rootino;
grub_uint8_t unused3[20];
grub_uint32_t agsize;
- grub_uint8_t unused4[20];
+ grub_uint8_t unused4[12];
+ grub_uint16_t version;
+ grub_uint8_t unused5[6];
grub_uint8_t label[12];
grub_uint8_t log2_bsize;
grub_uint8_t log2_sect;
@@ -54,12 +100,19 @@ struct grub_xfs_sblock
grub_uint8_t log2_agblk;
grub_uint8_t unused6[67];
grub_uint8_t log2_dirblk;
+ grub_uint8_t unused7[7];
+ grub_uint32_t features2;
+ grub_uint8_t unused8[4];
+ grub_uint32_t sb_features_compat;
+ grub_uint32_t sb_features_ro_compat;
+ grub_uint32_t sb_features_incompat;
+ grub_uint32_t sb_features_log_incompat;
} GRUB_PACKED;
struct grub_xfs_dir_header
{
grub_uint8_t count;
- grub_uint8_t smallino;
+ grub_uint8_t largeino;
union
{
grub_uint32_t i4;
@@ -67,21 +120,29 @@ struct grub_xfs_dir_header
} GRUB_PACKED parent;
} GRUB_PACKED;
+/* Structure for directory entry inlined in the inode */
struct grub_xfs_dir_entry
{
grub_uint8_t len;
grub_uint16_t offset;
char name[1];
- /* Inode number follows, 32 bits. */
+ /* Inode number follows, 32 / 64 bits. */
} GRUB_PACKED;
+/* Structure for directory entry in a block */
struct grub_xfs_dir2_entry
{
grub_uint64_t inode;
grub_uint8_t len;
} GRUB_PACKED;
-typedef grub_uint32_t grub_xfs_extent[4];
+struct grub_xfs_extent
+{
+ /* This should be a bitfield but bietfields are unportable, so just have
+ a raw array and functions extracting useful info from it.
+ */
+ grub_uint32_t raw[4];
+} GRUB_PACKED;
struct grub_xfs_btree_node
{
@@ -90,21 +151,22 @@ struct grub_xfs_btree_node
grub_uint16_t numrecs;
grub_uint64_t left;
grub_uint64_t right;
- grub_uint64_t keys[1];
-} GRUB_PACKED;
+ /* In V5 here follow crc, uuid, etc. */
+ /* Then follow keys and block pointers */
+} GRUB_PACKED;
struct grub_xfs_btree_root
{
grub_uint16_t level;
grub_uint16_t numrecs;
grub_uint64_t keys[1];
-} GRUB_PACKED;
+} GRUB_PACKED;
struct grub_xfs_time
{
grub_uint32_t sec;
grub_uint32_t nanosec;
-} GRUB_PACKED;
+} GRUB_PACKED;
struct grub_xfs_inode
{
@@ -123,19 +185,11 @@ struct grub_xfs_inode
grub_uint16_t unused3;
grub_uint8_t fork_offset;
grub_uint8_t unused4[17];
- union
- {
- char raw[156];
- struct dir
- {
- struct grub_xfs_dir_header dirhead;
- struct grub_xfs_dir_entry direntry[1];
- } dir;
- grub_xfs_extent extents[XFS_INODE_EXTENTS];
- struct grub_xfs_btree_root btree;
- } GRUB_PACKED data;
} GRUB_PACKED;
+#define XFS_V2_INODE_SIZE sizeof(struct grub_xfs_inode)
+#define XFS_V3_INODE_SIZE (XFS_V2_INODE_SIZE + 76)
+
struct grub_xfs_dirblock_tail
{
grub_uint32_t leaf_count;
@@ -157,6 +211,8 @@ struct grub_xfs_data
int pos;
int bsize;
grub_uint32_t agsize;
+ unsigned int hasftype:1;
+ unsigned int hascrc:1;
struct grub_fshelp_node diropen;
};
@@ -164,6 +220,71 @@ static grub_dl_t my_mod;
+static int grub_xfs_sb_hascrc(struct grub_xfs_data *data)
+{
+ return (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) ==
+ grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5);
+}
+
+static int grub_xfs_sb_hasftype(struct grub_xfs_data *data)
+{
+ if ((data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) ==
+ grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5) &&
+ data->sblock.sb_features_incompat & grub_cpu_to_be32_compile_time(XFS_SB_FEAT_INCOMPAT_FTYPE))
+ return 1;
+ if (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_MOREBITSBIT) &&
+ data->sblock.features2 & grub_cpu_to_be32_compile_time(XFS_SB_VERSION2_FTYPE))
+ return 1;
+ return 0;
+}
+
+static int grub_xfs_sb_valid(struct grub_xfs_data *data)
+{
+ grub_dprintf("xfs", "Validating superblock\n");
+ if (grub_strncmp ((char *) (data->sblock.magic), "XFSB", 4)
+ || data->sblock.log2_bsize < GRUB_DISK_SECTOR_BITS
+ || ((int) data->sblock.log2_bsize
+ + (int) data->sblock.log2_dirblk) >= 27)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "not a XFS filesystem");
+ return 0;
+ }
+ if ((data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) ==
+ grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5))
+ {
+ grub_dprintf("xfs", "XFS v5 superblock detected\n");
+ if (data->sblock.sb_features_incompat &
+ grub_cpu_to_be32_compile_time(~XFS_SB_FEAT_INCOMPAT_SUPPORTED))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "XFS filesystem has unsupported "
+ "incompatible features");
+ return 0;
+ }
+ return 1;
+ }
+ else if ((data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) ==
+ grub_cpu_to_be16_compile_time(XFS_SB_VERSION_4))
+ {
+ grub_dprintf("xfs", "XFS v4 superblock detected\n");
+ if (!(data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_DIRV2BIT)))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "XFS filesystem without V2 directories "
+ "is unsupported");
+ return 0;
+ }
+ if (data->sblock.version & grub_cpu_to_be16_compile_time(~XFS_SB_VERSION_BITS_SUPPORTED) ||
+ (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_MOREBITSBIT) &&
+ data->sblock.features2 & grub_cpu_to_be16_compile_time(~XFS_SB_VERSION2_BITS_SUPPORTED)))
+ {
+ grub_error (GRUB_ERR_BAD_FS, "XFS filesystem has unsupported version "
+ "bits");
+ return 0;
+ }
+ return 1;
+ }
+ return 0;
+}
+
/* Filetype information as used in inodes. */
#define FILETYPE_INO_MASK 0170000
#define FILETYPE_INO_REG 0100000
@@ -180,14 +301,14 @@ static inline grub_uint64_t
GRUB_XFS_INO_INOINAG (struct grub_xfs_data *data,
grub_uint64_t ino)
{
- return (grub_be_to_cpu64 (ino) & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1));
+ return (ino & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1));
}
static inline grub_uint64_t
GRUB_XFS_INO_AG (struct grub_xfs_data *data,
grub_uint64_t ino)
{
- return (grub_be_to_cpu64 (ino) >> GRUB_XFS_INO_AGBITS (data));
+ return (ino >> GRUB_XFS_INO_AGBITS (data));
}
static inline grub_disk_addr_t
@@ -198,37 +319,25 @@ GRUB_XFS_FSB_TO_BLOCK (struct grub_xfs_data *data, grub_disk_addr_t fsb)
}
static inline grub_uint64_t
-GRUB_XFS_EXTENT_OFFSET (grub_xfs_extent *exts, int ex)
+GRUB_XFS_EXTENT_OFFSET (struct grub_xfs_extent *exts, int ex)
{
- return ((grub_be_to_cpu32 (exts[ex][0]) & ~(1 << 31)) << 23
- | grub_be_to_cpu32 (exts[ex][1]) >> 9);
+ return ((grub_be_to_cpu32 (exts[ex].raw[0]) & ~(1 << 31)) << 23
+ | grub_be_to_cpu32 (exts[ex].raw[1]) >> 9);
}
static inline grub_uint64_t
-GRUB_XFS_EXTENT_BLOCK (grub_xfs_extent *exts, int ex)
+GRUB_XFS_EXTENT_BLOCK (struct grub_xfs_extent *exts, int ex)
{
- return ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex][1])
+ return ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex].raw[1])
& (0x1ff)) << 43
- | (grub_uint64_t) grub_be_to_cpu32 (exts[ex][2]) << 11
- | grub_be_to_cpu32 (exts[ex][3]) >> 21);
+ | (grub_uint64_t) grub_be_to_cpu32 (exts[ex].raw[2]) << 11
+ | grub_be_to_cpu32 (exts[ex].raw[3]) >> 21);
}
static inline grub_uint64_t
-GRUB_XFS_EXTENT_SIZE (grub_xfs_extent *exts, int ex)
-{
- return (grub_be_to_cpu32 (exts[ex][3]) & ((1 << 21) - 1));
-}
-
-static inline int
-GRUB_XFS_ROUND_TO_DIRENT (int pos)
+GRUB_XFS_EXTENT_SIZE (struct grub_xfs_extent *exts, int ex)
{
- return ((((pos) + 8 - 1) / 8) * 8);
-}
-
-static inline int
-GRUB_XFS_NEXT_DIRENT (int pos, int len)
-{
- return (pos) + GRUB_XFS_ROUND_TO_DIRENT (8 + 1 + len + 2);
+ return (grub_be_to_cpu32 (exts[ex].raw[3]) & ((1 << 21) - 1));
}
@@ -255,6 +364,109 @@ grub_xfs_inode_offset (struct grub_xfs_data *data,
data->sblock.log2_inode);
}
+static inline grub_size_t
+grub_xfs_inode_size(struct grub_xfs_data *data)
+{
+ return (grub_size_t)1 << data->sblock.log2_inode;
+}
+
+/*
+ * Returns size occupied by XFS inode stored in memory - we store struct
+ * grub_fshelp_node there but on disk inode size may be actually larger than
+ * struct grub_xfs_inode so we need to account for that so that we can read
+ * from disk directly into in-memory structure.
+ */
+static inline grub_size_t
+grub_xfs_fshelp_size(struct grub_xfs_data *data)
+{
+ return sizeof (struct grub_fshelp_node) - sizeof (struct grub_xfs_inode)
+ + grub_xfs_inode_size(data);
+}
+
+/* This should return void * but XFS code is error-prone with alignment, so
+ return char to retain cast-align.
+ */
+static char *
+grub_xfs_inode_data(struct grub_xfs_inode *inode)
+{
+ if (inode->version <= 2)
+ return ((char *)inode) + XFS_V2_INODE_SIZE;
+ return ((char *)inode) + XFS_V3_INODE_SIZE;
+}
+
+static struct grub_xfs_dir_entry *
+grub_xfs_inline_de(struct grub_xfs_dir_header *head)
+{
+ /*
+ With small inode numbers the header is 4 bytes smaller because of
+ smaller parent pointer
+ */
+ return (struct grub_xfs_dir_entry *)
+ (((char *) head) + sizeof(struct grub_xfs_dir_header) -
+ (head->largeino ? 0 : sizeof(grub_uint32_t)));
+}
+
+static grub_uint8_t *
+grub_xfs_inline_de_inopos(struct grub_xfs_data *data,
+ struct grub_xfs_dir_entry *de)
+{
+ return ((grub_uint8_t *)(de + 1)) + de->len - 1 + (data->hasftype ? 1 : 0);
+}
+
+static struct grub_xfs_dir_entry *
+grub_xfs_inline_next_de(struct grub_xfs_data *data,
+ struct grub_xfs_dir_header *head,
+ struct grub_xfs_dir_entry *de)
+{
+ char *p = (char *)de + sizeof(struct grub_xfs_dir_entry) - 1 + de->len;
+
+ p += head->largeino ? sizeof(grub_uint64_t) : sizeof(grub_uint32_t);
+ if (data->hasftype)
+ p++;
+
+ return (struct grub_xfs_dir_entry *)p;
+}
+
+static struct grub_xfs_dirblock_tail *
+grub_xfs_dir_tail(struct grub_xfs_data *data, void *dirblock)
+{
+ int dirblksize = 1 << (data->sblock.log2_bsize + data->sblock.log2_dirblk);
+
+ return (struct grub_xfs_dirblock_tail *)
+ ((char *)dirblock + dirblksize - sizeof (struct grub_xfs_dirblock_tail));
+}
+
+static struct grub_xfs_dir2_entry *
+grub_xfs_first_de(struct grub_xfs_data *data, void *dirblock)
+{
+ if (data->hascrc)
+ return (struct grub_xfs_dir2_entry *)((char *)dirblock + 64);
+ return (struct grub_xfs_dir2_entry *)((char *)dirblock + 16);
+}
+
+static struct grub_xfs_dir2_entry *
+grub_xfs_next_de(struct grub_xfs_data *data, struct grub_xfs_dir2_entry *de)
+{
+ int size = sizeof (struct grub_xfs_dir2_entry) + de->len + 2 /* Tag */;
+
+ if (data->hasftype)
+ size++; /* File type */
+ return (struct grub_xfs_dir2_entry *)(((char *)de) + ALIGN_UP(size, 8));
+}
+
+/* This should return void * but XFS code is error-prone with alignment, so
+ return char to retain cast-align.
+ */
+static char *
+grub_xfs_btree_keys(struct grub_xfs_data *data,
+ struct grub_xfs_btree_node *leaf)
+{
+ char *keys = (char *)(leaf + 1);
+
+ if (data->hascrc)
+ keys += 48; /* skip crc, uuid, ... */
+ return keys;
+}
static grub_err_t
grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino,
@@ -263,9 +475,11 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino,
grub_uint64_t block = grub_xfs_inode_block (data, ino);
int offset = grub_xfs_inode_offset (data, ino);
+ grub_dprintf("xfs", "Reading inode (%"PRIuGRUB_UINT64_T") - %"PRIuGRUB_UINT64_T", %d\n",
+ ino, block, offset);
/* Read the inode. */
- if (grub_disk_read (data->disk, block, offset,
- 1 << data->sblock.log2_inode, inode))
+ if (grub_disk_read (data->disk, block, offset, grub_xfs_inode_size(data),
+ inode))
return grub_errno;
if (grub_strncmp ((char *) inode->magic, "IN", 2))
@@ -274,40 +488,47 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino,
return 0;
}
+static grub_uint64_t
+get_fsb (const void *keys, int idx)
+{
+ const char *p = (const char *) keys + sizeof(grub_uint64_t) * idx;
+ return grub_be_to_cpu64 (grub_get_unaligned64 (p));
+}
static grub_disk_addr_t
grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
{
struct grub_xfs_btree_node *leaf = 0;
int ex, nrec;
- grub_xfs_extent *exts;
+ struct grub_xfs_extent *exts;
grub_uint64_t ret = 0;
if (node->inode.format == XFS_INODE_FORMAT_BTREE)
{
- const grub_uint64_t *keys;
+ struct grub_xfs_btree_root *root;
+ const char *keys;
int recoffset;
leaf = grub_malloc (node->data->bsize);
if (leaf == 0)
return 0;
- nrec = grub_be_to_cpu16 (node->inode.data.btree.numrecs);
- keys = &node->inode.data.btree.keys[0];
+ root = (struct grub_xfs_btree_root *) grub_xfs_inode_data(&node->inode);
+ nrec = grub_be_to_cpu16 (root->numrecs);
+ keys = (char *) &root->keys[0];
if (node->inode.fork_offset)
recoffset = (node->inode.fork_offset - 1) / 2;
else
- recoffset = ((1 << node->data->sblock.log2_inode)
- - ((char *) &node->inode.data.btree.keys
- - (char *) &node->inode))
- / (2 * sizeof (grub_uint64_t));
+ recoffset = (grub_xfs_inode_size(node->data)
+ - ((char *) keys - (char *) &node->inode))
+ / (2 * sizeof (grub_uint64_t));
do
{
int i;
for (i = 0; i < nrec; i++)
{
- if (fileblock < grub_be_to_cpu64 (keys[i]))
+ if (fileblock < get_fsb(keys, i))
break;
}
@@ -317,12 +538,16 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
grub_free (leaf);
return 0;
}
+
if (grub_disk_read (node->data->disk,
- GRUB_XFS_FSB_TO_BLOCK (node->data, grub_be_to_cpu64 (keys[i - 1 + recoffset])) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS),
+ GRUB_XFS_FSB_TO_BLOCK (node->data, get_fsb (keys, i - 1 + recoffset)) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS),
0, node->data->bsize, leaf))
return 0;
- if (grub_strncmp ((char *) leaf->magic, "BMAP", 4))
+ if ((!node->data->hascrc &&
+ grub_strncmp ((char *) leaf->magic, "BMAP", 4)) ||
+ (node->data->hascrc &&
+ grub_strncmp ((char *) leaf->magic, "BMA3", 4)))
{
grub_free (leaf);
grub_error (GRUB_ERR_BAD_FS, "not a correct XFS BMAP node");
@@ -330,18 +555,18 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
}
nrec = grub_be_to_cpu16 (leaf->numrecs);
- keys = &leaf->keys[0];
- recoffset = ((node->data->bsize - ((char *) &leaf->keys
+ keys = grub_xfs_btree_keys(node->data, leaf);
+ recoffset = ((node->data->bsize - ((char *) keys
- (char *) leaf))
/ (2 * sizeof (grub_uint64_t)));
}
while (leaf->level);
- exts = (grub_xfs_extent *) keys;
+ exts = (struct grub_xfs_extent *) keys;
}
else if (node->inode.format == XFS_INODE_FORMAT_EXT)
{
nrec = grub_be_to_cpu32 (node->inode.nextents);
- exts = &node->inode.data.extents[0];
+ exts = (struct grub_xfs_extent *) grub_xfs_inode_data(&node->inode);
}
else
{
@@ -379,13 +604,13 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
POS. Return the amount of read bytes in READ. */
static grub_ssize_t
grub_xfs_read_file (grub_fshelp_node_t node,
- grub_disk_read_hook_t read_hook, void *read_hook_data,
- grub_off_t pos, grub_size_t len, char *buf)
+ grub_disk_read_hook_t read_hook, void *read_hook_data,
+ grub_off_t pos, grub_size_t len, char *buf, grub_uint32_t header_size)
{
return grub_fshelp_read_file (node->data->disk, node,
read_hook, read_hook_data,
pos, len, buf, grub_xfs_read_block,
- grub_be_to_cpu64 (node->inode.size),
+ grub_be_to_cpu64 (node->inode.size) + header_size,
node->data->sblock.log2_bsize
- GRUB_DISK_SECTOR_BITS, 0);
}
@@ -394,23 +619,34 @@ grub_xfs_read_file (grub_fshelp_node_t node,
static char *
grub_xfs_read_symlink (grub_fshelp_node_t node)
{
- int size = grub_be_to_cpu64 (node->inode.size);
+ grub_ssize_t size = grub_be_to_cpu64 (node->inode.size);
+
+ if (size < 0)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "invalid symlink");
+ return 0;
+ }
switch (node->inode.format)
{
case XFS_INODE_FORMAT_INO:
- return grub_strndup (node->inode.data.raw, size);
+ return grub_strndup (grub_xfs_inode_data(&node->inode), size);
case XFS_INODE_FORMAT_EXT:
{
char *symlink;
grub_ssize_t numread;
+ int off = 0;
+
+ if (node->data->hascrc)
+ off = 56;
symlink = grub_malloc (size + 1);
if (!symlink)
return 0;
- numread = grub_xfs_read_file (node, 0, 0, 0, size, symlink);
+ node->inode.size = grub_be_to_cpu64 (size + off);
+ numread = grub_xfs_read_file (node, 0, 0, off, size, symlink, off);
if (numread != size)
{
grub_free (symlink);
@@ -456,9 +692,7 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
struct grub_fshelp_node *fdiro;
grub_err_t err;
- fdiro = grub_malloc (sizeof (struct grub_fshelp_node)
- - sizeof (struct grub_xfs_inode)
- + (1 << ctx->diro->data->sblock.log2_inode) + 1);
+ fdiro = grub_malloc (grub_xfs_fshelp_size(ctx->diro->data) + 1);
if (!fdiro)
{
grub_print_error ();
@@ -496,24 +730,18 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
{
case XFS_INODE_FORMAT_INO:
{
- struct grub_xfs_dir_entry *de = &diro->inode.data.dir.direntry[0];
- int smallino = !diro->inode.data.dir.dirhead.smallino;
+ struct grub_xfs_dir_header *head = (struct grub_xfs_dir_header *) grub_xfs_inode_data(&diro->inode);
+ struct grub_xfs_dir_entry *de = grub_xfs_inline_de(head);
+ int smallino = !head->largeino;
int i;
grub_uint64_t parent;
/* If small inode numbers are used to pack the direntry, the
parent inode number is small too. */
if (smallino)
- {
- parent = grub_be_to_cpu32 (diro->inode.data.dir.dirhead.parent.i4);
- parent = grub_cpu_to_be64 (parent);
- /* The header is a bit smaller than usual. */
- de = (struct grub_xfs_dir_entry *) ((char *) de - 4);
- }
+ parent = grub_be_to_cpu32 (head->parent.i4);
else
- {
- parent = diro->inode.data.dir.dirhead.parent.i8;
- }
+ parent = grub_be_to_cpu64 (head->parent.i8);
/* Synthesize the direntries for `.' and `..'. */
if (iterate_dir_call_hook (diro->ino, ".", &ctx))
@@ -522,12 +750,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
if (iterate_dir_call_hook (parent, "..", &ctx))
return 1;
- for (i = 0; i < diro->inode.data.dir.dirhead.count; i++)
+ for (i = 0; i < head->count; i++)
{
grub_uint64_t ino;
- grub_uint8_t *inopos = (((grub_uint8_t *) de)
- + sizeof (struct grub_xfs_dir_entry)
- + de->len - 1);
+ grub_uint8_t *inopos = grub_xfs_inline_de_inopos(dir->data, de);
grub_uint8_t c;
/* inopos might be unaligned. */
@@ -545,18 +771,17 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
| (((grub_uint64_t) inopos[5]) << 16)
| (((grub_uint64_t) inopos[6]) << 8)
| (((grub_uint64_t) inopos[7]) << 0);
- ino = grub_cpu_to_be64 (ino);
c = de->name[de->len];
de->name[de->len] = '\0';
if (iterate_dir_call_hook (ino, de->name, &ctx))
- return 1;
+ {
+ de->name[de->len] = c;
+ return 1;
+ }
de->name[de->len] = c;
- de = ((struct grub_xfs_dir_entry *)
- (((char *) de)+ sizeof (struct grub_xfs_dir_entry) + de->len
- + ((smallino ? sizeof (grub_uint32_t)
- : sizeof (grub_uint64_t))) - 1));
+ de = grub_xfs_inline_next_de(dir->data, head, de);
}
break;
}
@@ -583,19 +808,15 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
>> dirblk_log2);
blk++)
{
- /* The header is skipped, the first direntry is stored
- from byte 16. */
- int pos = 16;
+ struct grub_xfs_dir2_entry *direntry =
+ grub_xfs_first_de(dir->data, dirblock);
int entries;
- int tail_start = (dirblk_size
- - sizeof (struct grub_xfs_dirblock_tail));
-
- struct grub_xfs_dirblock_tail *tail;
- tail = (struct grub_xfs_dirblock_tail *) &dirblock[tail_start];
+ struct grub_xfs_dirblock_tail *tail =
+ grub_xfs_dir_tail(dir->data, dirblock);
numread = grub_xfs_read_file (dir, 0, 0,
blk << dirblk_log2,
- dirblk_size, dirblock);
+ dirblk_size, dirblock, 0);
if (numread != dirblk_size)
return 0;
@@ -603,14 +824,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
- grub_be_to_cpu32 (tail->leaf_stale));
/* Iterate over all entries within this block. */
- while (pos < (dirblk_size
- - (int) sizeof (struct grub_xfs_dir2_entry)))
+ while ((char *)direntry < (char *)tail)
{
- struct grub_xfs_dir2_entry *direntry;
grub_uint8_t *freetag;
char *filename;
- direntry = (struct grub_xfs_dir2_entry *) &dirblock[pos];
freetag = (grub_uint8_t *) direntry;
if (grub_get_unaligned16 (freetag) == 0XFFFF)
@@ -618,17 +836,20 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
grub_uint8_t *skip = (freetag + sizeof (grub_uint16_t));
/* This entry is not used, go to the next one. */
- pos += grub_be_to_cpu16 (grub_get_unaligned16 (skip));
+ direntry = (struct grub_xfs_dir2_entry *)
+ (((char *)direntry) +
+ grub_be_to_cpu16 (grub_get_unaligned16 (skip)));
continue;
}
- filename = &dirblock[pos + sizeof (*direntry)];
- /* The byte after the filename is for the tag, which
- is not used by GRUB. So it can be overwritten. */
+ filename = (char *)(direntry + 1);
+ /* The byte after the filename is for the filetype, padding, or
+ tag, which is not used by GRUB. So it can be overwritten. */
filename[direntry->len] = '\0';
- if (iterate_dir_call_hook (direntry->inode, filename, &ctx))
+ if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode),
+ filename, &ctx))
{
grub_free (dirblock);
return 1;
@@ -641,8 +862,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
break;
/* Select the next directory entry. */
- pos = GRUB_XFS_NEXT_DIRENT (pos, direntry->len);
- pos = GRUB_XFS_ROUND_TO_DIRENT (pos);
+ direntry = grub_xfs_next_de(dir->data, direntry);
}
}
grub_free (dirblock);
@@ -667,36 +887,35 @@ grub_xfs_mount (grub_disk_t disk)
if (!data)
return 0;
+ grub_dprintf("xfs", "Reading sb\n");
/* Read the superblock. */
if (grub_disk_read (disk, 0, 0,
sizeof (struct grub_xfs_sblock), &data->sblock))
goto fail;
- if (grub_strncmp ((char *) (data->sblock.magic), "XFSB", 4)
- || data->sblock.log2_bsize < GRUB_DISK_SECTOR_BITS
- || ((int) data->sblock.log2_bsize
- + (int) data->sblock.log2_dirblk) >= 27)
- {
- grub_error (GRUB_ERR_BAD_FS, "not a XFS filesystem");
- goto fail;
- }
+ if (!grub_xfs_sb_valid(data))
+ goto fail;
data = grub_realloc (data,
sizeof (struct grub_xfs_data)
- sizeof (struct grub_xfs_inode)
- + (1 << data->sblock.log2_inode) + 1);
+ + grub_xfs_inode_size(data) + 1);
if (! data)
goto fail;
data->diropen.data = data;
- data->diropen.ino = data->sblock.rootino;
+ data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino);
data->diropen.inode_read = 1;
data->bsize = grub_be_to_cpu32 (data->sblock.bsize);
data->agsize = grub_be_to_cpu32 (data->sblock.agsize);
+ data->hasftype = grub_xfs_sb_hasftype(data);
+ data->hascrc = grub_xfs_sb_hascrc(data);
data->disk = disk;
data->pos = 0;
+ grub_dprintf("xfs", "Reading root ino %"PRIuGRUB_UINT64_T"\n",
+ grub_cpu_to_be64(data->sblock.rootino));
grub_xfs_read_inode (data, data->diropen.ino, &data->diropen.inode);
@@ -799,10 +1018,7 @@ grub_xfs_open (struct grub_file *file, const char *name)
if (fdiro != &data->diropen)
{
- grub_memcpy (&data->diropen, fdiro,
- sizeof (struct grub_fshelp_node)
- - sizeof (struct grub_xfs_inode)
- + (1 << data->sblock.log2_inode));
+ grub_memcpy (&data->diropen, fdiro, grub_xfs_fshelp_size(data));
grub_free (fdiro);
}
@@ -832,7 +1048,7 @@ grub_xfs_read (grub_file_t file, char *buf, grub_size_t len)
return grub_xfs_read_file (&data->diropen,
file->read_hook, file->read_hook_data,
- file->offset, len, buf);
+ file->offset, len, buf, 0);
}
diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c
index 4d0bde4ce..6e1fff9e9 100644
--- a/grub-core/fs/zfs/zfs.c
+++ b/grub-core/fs/zfs/zfs.c
@@ -252,7 +252,6 @@ struct grub_zfs_data
uberblock_t current_uberblock;
- int mounted;
grub_uint64_t guid;
};
@@ -281,21 +280,30 @@ grub_crypto_cipher_handle_t (*grub_zfs_load_key) (const struct grub_zfs_key *key
*/
#define MAX_SUPPORTED_FEATURE_STRLEN 50
static const char *spa_feature_names[] = {
- "org.illumos:lz4_compress",NULL
+ "org.illumos:lz4_compress",
+ "com.delphix:hole_birth",
+ "com.delphix:embedded_data",
+ "com.delphix:extensible_dataset",
+ "org.open-zfs:large_blocks",
+ NULL
};
static int
check_feature(const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx);
-static int
+static grub_err_t
check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data );
static grub_err_t
zlib_decompress (void *s, void *d,
grub_size_t slen, grub_size_t dlen)
{
- if (grub_zlib_decompress (s, slen, 0, d, dlen) < 0)
- return grub_errno;
- return GRUB_ERR_NONE;
+ if (grub_zlib_decompress (s, slen, 0, d, dlen) == (grub_ssize_t) dlen)
+ return GRUB_ERR_NONE;
+
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
+ "premature end of compressed");
+ return grub_errno;
}
static grub_err_t
@@ -953,7 +961,7 @@ nvpair_value (const char *nvp,char **val,
static grub_err_t
check_pool_label (struct grub_zfs_data *data,
struct grub_zfs_device_desc *diskdesc,
- int *inserted)
+ int *inserted, int original)
{
grub_uint64_t pool_state, txg = 0;
char *nvlist,*features;
@@ -1077,11 +1085,12 @@ check_pool_label (struct grub_zfs_data *data,
grub_dprintf ("zfs", "check 11 passed\n");
- if (data->mounted && data->guid != poolguid)
- return grub_error (GRUB_ERR_BAD_FS, "another zpool");
- else
+ if (original)
data->guid = poolguid;
+ if (data->guid != poolguid)
+ return grub_error (GRUB_ERR_BAD_FS, "another zpool");
+
{
char *nv;
nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE);
@@ -1182,7 +1191,7 @@ scan_disk (grub_device_t dev, struct grub_zfs_data *data,
}
grub_dprintf ("zfs", "label ok %d\n", label);
- err = check_pool_label (data, &desc, inserted);
+ err = check_pool_label (data, &desc, inserted, original);
if (err || !*inserted)
{
grub_errno = GRUB_ERR_NONE;
@@ -1497,6 +1506,9 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc,
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"raidz%d is not supported", desc->nparity);
+ if (desc->n_children <= desc->nparity || desc->n_children < 1)
+ return grub_error(GRUB_ERR_BAD_FS, "too little devices for given parity");
+
orig_s = (((len + (1 << desc->ashift) - 1) >> desc->ashift)
+ (desc->n_children - desc->nparity) - 1);
s = orig_s;
@@ -1744,7 +1756,7 @@ zio_read_gang (blkptr_t * bp, grub_zfs_endian_t endian, dva_t * dva, void *buf,
for (i = 0; i < SPA_GBH_NBLKPTRS; i++)
{
- if (zio_gb->zg_blkptr[i].blk_birth == 0)
+ if (BP_IS_HOLE(&zio_gb->zg_blkptr[i]))
continue;
err = zio_read_data (&zio_gb->zg_blkptr[i], endian, buf, data);
@@ -1794,6 +1806,39 @@ zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, void *buf,
}
/*
+ * buf must be at least BPE_GET_PSIZE(bp) bytes long (which will never be
+ * more than BPE_PAYLOAD_SIZE bytes).
+ */
+static grub_err_t
+decode_embedded_bp_compressed(const blkptr_t *bp, void *buf)
+{
+ grub_size_t psize, i;
+ grub_uint8_t *buf8 = buf;
+ grub_uint64_t w = 0;
+ const grub_uint64_t *bp64 = (const grub_uint64_t *)bp;
+
+ psize = BPE_GET_PSIZE(bp);
+
+ /*
+ * Decode the words of the block pointer into the byte array.
+ * Low bits of first word are the first byte (little endian).
+ */
+ for (i = 0; i < psize; i++)
+ {
+ if (i % sizeof (w) == 0)
+ {
+ /* beginning of a word */
+ w = *bp64;
+ bp64++;
+ if (!BPE_IS_PAYLOADWORD(bp, bp64))
+ bp64++;
+ }
+ buf8[i] = BF64_GET(w, (i % sizeof (w)) * 8, 8);
+ }
+ return GRUB_ERR_NONE;
+}
+
+/*
* Read in a block of data, verify its checksum, decompress if needed,
* and put the uncompressed data in buf.
*/
@@ -1811,12 +1856,26 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf,
*buf = NULL;
checksum = (grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 40) & 0xff;
- comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0xff;
+ comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0x7f;
encrypted = ((grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 60) & 3);
- lsize = (BP_IS_HOLE(bp) ? 0 :
- (((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) & 0xffff) + 1)
- << SPA_MINBLOCKSHIFT));
- psize = get_psize (bp, endian);
+ if (BP_IS_EMBEDDED(bp))
+ {
+ if (BPE_GET_ETYPE(bp) != BP_EMBEDDED_TYPE_DATA)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ "unsupported embedded BP (type=%u)\n",
+ BPE_GET_ETYPE(bp));
+ lsize = BPE_GET_LSIZE(bp);
+ psize = BF64_GET_SB(grub_zfs_to_cpu64 ((bp)->blk_prop, endian), 25, 7, 0, 1);
+ }
+ else
+ {
+ lsize = (BP_IS_HOLE(bp) ? 0 :
+ (((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) & 0xffff) + 1)
+ << SPA_MINBLOCKSHIFT));
+ psize = get_psize (bp, endian);
+ }
+ grub_dprintf("zfs", "zio_read: E %d: size %" PRIdGRUB_SSIZE "/%"
+ PRIdGRUB_SSIZE "\n", (int)BP_IS_EMBEDDED(bp), lsize, psize);
if (size)
*size = lsize;
@@ -1830,33 +1889,41 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf,
"compression algorithm %s not supported\n", decomp_table[comp].name);
if (comp != ZIO_COMPRESS_OFF)
- {
- /* It's not really necessary to align to 16, just for safety. */
- compbuf = grub_malloc (ALIGN_UP (psize, 16));
- if (! compbuf)
- return grub_errno;
- }
+ /* It's not really necessary to align to 16, just for safety. */
+ compbuf = grub_malloc (ALIGN_UP (psize, 16));
else
compbuf = *buf = grub_malloc (lsize);
+ if (! compbuf)
+ return grub_errno;
grub_dprintf ("zfs", "endian = %d\n", endian);
- err = zio_read_data (bp, endian, compbuf, data);
+ if (BP_IS_EMBEDDED(bp))
+ err = decode_embedded_bp_compressed(bp, compbuf);
+ else
+ {
+ err = zio_read_data (bp, endian, compbuf, data);
+ /* FIXME is it really necessary? */
+ if (comp != ZIO_COMPRESS_OFF)
+ grub_memset (compbuf + psize, 0, ALIGN_UP (psize, 16) - psize);
+ }
if (err)
{
grub_free (compbuf);
*buf = NULL;
return err;
}
- grub_memset (compbuf, 0, ALIGN_UP (psize, 16) - psize);
- err = zio_checksum_verify (zc, checksum, endian,
- compbuf, psize);
- if (err)
+ if (!BP_IS_EMBEDDED(bp))
{
- grub_dprintf ("zfs", "incorrect checksum\n");
- grub_free (compbuf);
- *buf = NULL;
- return err;
+ err = zio_checksum_verify (zc, checksum, endian,
+ compbuf, psize);
+ if (err)
+ {
+ grub_dprintf ("zfs", "incorrect checksum\n");
+ grub_free (compbuf);
+ *buf = NULL;
+ return err;
+ }
}
if (encrypted)
@@ -1968,7 +2035,7 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf,
dn->endian)
<< SPA_MINBLOCKSHIFT;
*buf = grub_malloc (size);
- if (*buf)
+ if (!*buf)
{
err = grub_errno;
break;
@@ -2006,12 +2073,14 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf,
*/
static grub_err_t
mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian,
- int objsize, const char *name, grub_uint64_t * value,
+ grub_uint32_t objsize, const char *name, grub_uint64_t * value,
int case_insensitive)
{
- int i, chunks;
+ grub_uint32_t i, chunks;
mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk;
+ if (objsize < MZAP_ENT_LEN)
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), name);
chunks = objsize / MZAP_ENT_LEN - 1;
for (i = 0; i < chunks; i++)
{
@@ -2419,7 +2488,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val,
struct grub_zfs_data *data, int case_insensitive)
{
grub_uint64_t block_type;
- int size;
+ grub_uint32_t size;
void *zapbuf;
grub_err_t err;
grub_zfs_endian_t endian;
@@ -2427,7 +2496,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val,
grub_dprintf ("zfs", "looking for '%s'\n", name);
/* Read in the first block of the zap object data. */
- size = grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec,
+ size = (grub_uint32_t) grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec,
zap_dnode->endian) << SPA_MINBLOCKSHIFT;
err = dmu_read (zap_dnode, 0, &zapbuf, &endian, data);
if (err)
@@ -2800,6 +2869,9 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
dnode_path->dn.endian)
<< SPA_MINBLOCKSHIFT);
+ if (blksz == 0)
+ return grub_error(GRUB_ERR_BAD_FS, "0-sized block");
+
sym_value = grub_malloc (sym_sz);
if (!sym_value)
return grub_errno;
@@ -2810,7 +2882,10 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
err = dmu_read (&(dnode_path->dn), block, &t, 0, data);
if (err)
- return err;
+ {
+ grub_free (sym_value);
+ return err;
+ }
movesize = sym_sz - block * blksz;
if (movesize > blksz)
@@ -2825,6 +2900,8 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
if (!path_buf)
{
grub_free (oldpathbuf);
+ if (free_symval)
+ grub_free (sym_value);
return grub_errno;
}
grub_memcpy (path, sym_value, sym_sz);
@@ -3008,7 +3085,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname,
grub_dprintf ("zfs", "alive\n");
- err = dnode_get (mosmdn, objnum, DMU_OT_DSL_DIR, mdn, data);
+ err = dnode_get (mosmdn, objnum, 0, mdn, data);
if (err)
return err;
@@ -3041,7 +3118,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname,
if (err)
return err;
- err = dnode_get (mosmdn, objnum, DMU_OT_DSL_DIR, mdn, data);
+ err = dnode_get (mosmdn, objnum, 0, mdn, data);
if (err)
return err;
@@ -3055,7 +3132,7 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data)
{
void *osp;
blkptr_t *bp;
- grub_size_t ospsize;
+ grub_size_t ospsize = 0;
grub_err_t err;
grub_dprintf ("zfs", "endian = %d\n", mdn->endian);
@@ -3196,8 +3273,7 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol,
grub_dprintf ("zfs", "endian = %d\n", subvol->mdn.endian);
- err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &subvol->mdn,
- data);
+ err = dnode_get (&(data->mos), headobj, 0, &subvol->mdn, data);
if (err)
{
grub_free (fsname);
@@ -3593,8 +3669,13 @@ zfs_mount (grub_device_t dev)
if (ub->ub_version >= SPA_VERSION_FEATURES &&
check_mos_features(&((objset_phys_t *) osp)->os_meta_dnode,ub_endian,
data) != 0)
- return NULL;
-
+ {
+ grub_error (GRUB_ERR_BAD_FS, "Unsupported features in pool");
+ grub_free (osp);
+ zfs_unmount (data);
+ return NULL;
+ }
+
/* Got the MOS. Save it at the memory addr MOS. */
grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode,
DNODE_SIZE);
@@ -3602,8 +3683,6 @@ zfs_mount (grub_device_t dev)
ub_endian) >> 63) & 1;
grub_free (osp);
- data->mounted = 1;
-
return data;
}
@@ -3794,6 +3873,12 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
blksz = grub_zfs_to_cpu16 (data->dnode.dn.dn_datablkszsec,
data->dnode.endian) << SPA_MINBLOCKSHIFT;
+ if (blksz == 0)
+ {
+ grub_error (GRUB_ERR_BAD_FS, "0-sized block");
+ return -1;
+ }
+
/*
* Entire Dnode is too big to fit into the space available. We
* will need to read it in chunks. This could be optimized to
@@ -3887,7 +3972,7 @@ fill_fs_info (struct grub_dirhook_info *info,
{
headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&mdn.dn))->dd_head_dataset_obj, mdn.endian);
- err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &mdn, data);
+ err = dnode_get (&(data->mos), headobj, 0, &mdn, data);
if (err)
{
grub_dprintf ("zfs", "failed here\n");
@@ -3965,7 +4050,12 @@ iterate_zap (const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx)
dnode_end_t dn;
grub_memset (&info, 0, sizeof (info));
- dnode_get (&(ctx->data->subvol.mdn), val, 0, &dn, ctx->data);
+ err = dnode_get (&(ctx->data->subvol.mdn), val, 0, &dn, ctx->data);
+ if (err)
+ {
+ grub_print_error ();
+ return 0;
+ }
if (dn.dn.dn_bonustype == DMU_OT_SA)
{
@@ -4186,11 +4276,11 @@ check_feature (const char *name, grub_uint64_t val,
* errnum: Failure.
*/
-static int
+static grub_err_t
check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data )
{
grub_uint64_t objnum;
- grub_uint8_t errnum = 0;
+ grub_err_t errnum = 0;
dnode_end_t dn,mosmdn;
mzap_phys_t* mzp;
grub_zfs_endian_t endianzap;
diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c
index 1212a8986..2f73449f0 100644
--- a/grub-core/fs/zfs/zfs_lz4.c
+++ b/grub-core/fs/zfs/zfs_lz4.c
@@ -184,6 +184,8 @@ LZ4_uncompress_unknownOutputSize(const char *source,
}
}
/* copy literals */
+ if ((grub_addr_t) length > ~(grub_addr_t)op)
+ goto _output_error;
cpy = op + length;
if ((cpy > oend - COPYLENGTH) ||
(ip + length > iend - COPYLENGTH)) {
diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c
index 88dae72ef..87eef621d 100644
--- a/grub-core/fs/zfs/zfscrypt.c
+++ b/grub-core/fs/zfs/zfscrypt.c
@@ -238,7 +238,7 @@ grub_gcm_decrypt (grub_crypto_cipher_handle_t cipher,
grub_crypto_xor (out + 16 * i, in + 16 * i, mul, csize);
}
for (j = 0; j < 8; j++)
- mac[15 - j] ^= ((psize * 8) >> (8 * j));
+ mac[15 - j] ^= ((((grub_uint64_t) psize) * 8) >> (8 * j));
grub_gcm_mul (mac, h);
if (mac_out)
@@ -354,6 +354,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
if (err)
{
grub_errno = GRUB_ERR_NONE;
+ grub_crypto_cipher_close (cipher);
continue;
}
@@ -362,6 +363,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
if (err)
{
grub_errno = GRUB_ERR_NONE;
+ grub_crypto_cipher_close (cipher);
continue;
}
@@ -372,6 +374,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
{
grub_dprintf ("zfs", "key loading failed\n");
grub_errno = GRUB_ERR_NONE;
+ grub_crypto_cipher_close (cipher);
continue;
}
@@ -381,21 +384,25 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
{
grub_dprintf ("zfs", "key loading failed\n");
grub_errno = GRUB_ERR_NONE;
+ grub_crypto_cipher_close (cipher);
continue;
}
ret = grub_crypto_cipher_open (GRUB_CIPHER_AES);
if (!ret)
{
grub_errno = GRUB_ERR_NONE;
+ grub_crypto_cipher_close (cipher);
continue;
}
err = grub_crypto_cipher_set_key (ret, decrypted, keylen);
if (err)
{
- grub_errno = GRUB_ERR_NONE;
- grub_crypto_cipher_close (ret);
- continue;
- }
+ grub_errno = GRUB_ERR_NONE;
+ grub_crypto_cipher_close (ret);
+ grub_crypto_cipher_close (cipher);
+ continue;
+ }
+ grub_crypto_cipher_close (cipher);
return ret;
}
return NULL;
diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c
index c96bf2183..c8a28acf5 100644
--- a/grub-core/fs/zfs/zfsinfo.c
+++ b/grub-core/fs/zfs/zfsinfo.c
@@ -130,10 +130,12 @@ print_vdev_info (char *nvlist, int tab)
grub_free (bootpath);
grub_free (devid);
grub_free (path);
+ grub_free (type);
return GRUB_ERR_NONE;
}
char is_mirror=(grub_strcmp(type,VDEV_TYPE_MIRROR) == 0);
char is_raidz=(grub_strcmp(type,VDEV_TYPE_RAIDZ) == 0);
+ grub_free (type);
if (is_mirror || is_raidz)
{
diff --git a/grub-core/genemuinit.sh b/grub-core/genemuinit.sh
index 45c15ecb9..8c6bb1c18 100644
--- a/grub-core/genemuinit.sh
+++ b/grub-core/genemuinit.sh
@@ -47,7 +47,7 @@ EOF
read mods
for line in $mods; do
if ${nm} --defined-only -P -p ${line} | grep grub_mod_init > /dev/null; then
- echo "grub_${line}_init ();" | sed 's,\.mod,,g;'
+ echo "grub_${line%%.*}_init ();"
fi
done
@@ -63,7 +63,7 @@ EOF
for line in $mods; do
if ${nm} --defined-only -P -p ${line} | grep grub_mod_fini > /dev/null; then
- echo "grub_${line}_fini ();" | sed 's,\.mod,,g;'
+ echo "grub_${line%%.*}_fini ();"
fi
done
diff --git a/grub-core/genemuinitheader.sh b/grub-core/genemuinitheader.sh
index 6b83f5993..a99a15d06 100644
--- a/grub-core/genemuinitheader.sh
+++ b/grub-core/genemuinitheader.sh
@@ -44,9 +44,9 @@ EOF
read mods
for line in $mods; do
if ${nm} --defined-only -P -p ${line} | grep grub_mod_init > /dev/null; then
- echo "void grub_${line}_init (void);" | sed 's,\.mod,,g;'
+ echo "void grub_${line%%.*}_init (void);"
fi
if ${nm} --defined-only -P -p ${line} | grep grub_mod_fini > /dev/null; then
- echo "void grub_${line}_fini (void);" | sed 's,\.mod,,g;'
+ echo "void grub_${line%%.*}_fini (void);"
fi
done
diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in
index 789732b10..045817b15 100644
--- a/grub-core/genmod.sh.in
+++ b/grub-core/genmod.sh.in
@@ -15,12 +15,12 @@ set -e
#
# Example:
#
-# genmod.sh moddep.lst normal.module normal.mod
+# genmod.sh moddep.lst normal.module build-grub-module-verifier normal.mod
#
moddep=$1
infile=$2
-outfile=$3
+outfile=$4
tmpfile=${outfile}.tmp
modname=`echo $infile | sed -e 's@\.module.*$@@'`
@@ -58,7 +58,7 @@ if test x@TARGET_APPLE_LINKER@ != x1; then
-K grub_mod_init -K grub_mod_fini \
-K _grub_mod_init -K _grub_mod_fini \
-R .note.gnu.gold-version -R .note.GNU-stack \
- -R .note -R .comment $tmpfile || exit 1
+ -R .note -R .comment -R .ARM.exidx $tmpfile || exit 1
fi
if ! test -z "${TARGET_OBJ2ELF}"; then
"${TARGET_OBJ2ELF}" $tmpfile || exit 1
@@ -91,6 +91,9 @@ else
-nr:_grub_mod_init:grub_mod_init \
-nr:_grub_mod_fini:grub_mod_fini \
-wd1106 -nu -nd $tmpfile.bin $tmpfile || exit 1
- rm -f $name.bin
+ rm -f $tmpfile.bin
+fi
+if test x@platform@ != xemu; then
+ ./build-grub-module-verifier@BUILD_EXEEXT@ $tmpfile @target_cpu@
fi
mv $tmpfile $outfile
diff --git a/grub-core/genmoddep.awk b/grub-core/genmoddep.awk
index 2f32465c4..bd98d84cd 100644
--- a/grub-core/genmoddep.awk
+++ b/grub-core/genmoddep.awk
@@ -29,7 +29,7 @@ BEGIN {
}
}
else {
- printf "error: %u: unrecognized input format\n", NR;
+ printf "error: %u: unrecognized input format\n", NR >"/dev/stderr";
error++;
}
}
@@ -39,6 +39,8 @@ END {
if (error >= 1)
exit 1;
+ total_depcount = 0
+
for (mod in modtab) {
# Remove duplications.
split(modtab[mod], depmods, " ");
@@ -52,14 +54,42 @@ END {
uniqmods[depmod] = 1;
}
modlist = ""
+ depcount[mod] = 0
for (depmod in uniqmods) {
modlist = modlist " " depmod;
+ inverse_dependencies[depmod] = inverse_dependencies[depmod] " " mod
+ depcount[mod]++
+ total_depcount++
}
if (mod == "all_video") {
continue;
}
printf "%s:%s\n", mod, modlist;
}
+
+ # Check that we have no dependency circles
+ while (total_depcount != 0) {
+ something_done = 0
+ for (mod in depcount) {
+ if (depcount[mod] == 0) {
+ delete depcount[mod]
+ split(inverse_dependencies[mod], inv_depmods, " ");
+ for (ctr in inv_depmods) {
+ depcount[inv_depmods[ctr]]--
+ total_depcount--
+ }
+ delete inverse_dependencies[mod]
+ something_done = 1
+ }
+ }
+ if (something_done == 0) {
+ for (mod in depcount) {
+ circle = circle " " mod
+ }
+ printf "error: modules %s form a dependency circle\n", circle >"/dev/stderr";
+ exit 1
+ }
+ }
modlist = ""
while (getline <"video.lst") {
modlist = modlist " " $1;
diff --git a/grub-core/gfxmenu/font.c b/grub-core/gfxmenu/font.c
index 64d52670b..756c24f20 100644
--- a/grub-core/gfxmenu/font.c
+++ b/grub-core/gfxmenu/font.c
@@ -45,6 +45,7 @@ grub_font_draw_string (const char *str, grub_font_t font,
grub_uint32_t *logical;
grub_ssize_t logical_len, visual_len;
struct grub_unicode_glyph *visual, *ptr;
+ grub_err_t err;
logical_len = grub_utf8_to_ucs4_alloc (str, &logical, 0);
if (logical_len < 0)
@@ -56,24 +57,28 @@ grub_font_draw_string (const char *str, grub_font_t font,
if (visual_len < 0)
return grub_errno;
+ err = GRUB_ERR_NONE;
for (ptr = visual, x = left_x; ptr < visual + visual_len; ptr++)
{
- grub_err_t err;
struct grub_font_glyph *glyph;
glyph = grub_font_construct_glyph (font, ptr);
if (!glyph)
- return grub_errno;
+ {
+ err = grub_errno;
+ goto out;
+ }
err = grub_font_draw_glyph (glyph, color, x, baseline_y);
- x += glyph->device_width;
if (err)
- return err;
+ goto out;
+ x += glyph->device_width;
}
+out:
for (ptr = visual; ptr < visual + visual_len; ptr++)
grub_unicode_destroy_glyph (ptr);
grub_free (visual);
- return GRUB_ERR_NONE;
+ return err;
}
/* Get the width in pixels of the specified UTF-8 string, when rendered in
diff --git a/grub-core/gfxmenu/gfxmenu.c b/grub-core/gfxmenu/gfxmenu.c
index f49fce802..8a17dda2c 100644
--- a/grub-core/gfxmenu/gfxmenu.c
+++ b/grub-core/gfxmenu/gfxmenu.c
@@ -63,14 +63,14 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"),
"theme");
- instance = grub_zalloc (sizeof (*instance));
- if (!instance)
- return grub_errno;
-
err = grub_video_get_info (&mode_info);
if (err)
return err;
+ instance = grub_zalloc (sizeof (*instance));
+ if (!instance)
+ return grub_errno;
+
if (theme_path[0] != '/' && theme_path[0] != '(')
{
const char *prefix;
diff --git a/grub-core/gfxmenu/gui_circular_progress.c b/grub-core/gfxmenu/gui_circular_progress.c
index 04f68b8d3..354dd7b73 100644
--- a/grub-core/gfxmenu/gui_circular_progress.c
+++ b/grub-core/gfxmenu/gui_circular_progress.c
@@ -138,51 +138,53 @@ circprog_paint (void *vself, const grub_video_rect_t *region)
(height - center_height) / 2, 0, 0,
center_width, center_height);
- int radius = grub_min (height, width) / 2 - grub_max (tick_height, tick_width) / 2 - 1;
- unsigned nticks;
- unsigned tick_begin;
- unsigned tick_end;
- if (self->end <= self->start
- || self->value <= self->start)
- nticks = 0;
- else
- nticks = ((unsigned) (self->num_ticks
- * (self->value - self->start)))
- / ((unsigned) (self->end - self->start));
- /* Do ticks appear or disappear as the value approached the end? */
- if (self->ticks_disappear)
+ if (self->num_ticks)
{
- tick_begin = nticks;
- tick_end = self->num_ticks;
- }
- else
- {
- tick_begin = 0;
- tick_end = nticks;
- }
-
- unsigned i;
- for (i = tick_begin; i < tick_end; i++)
- {
- int x;
- int y;
- int angle;
-
- /* Calculate the location of the tick. */
- angle = self->start_angle
- + i * GRUB_TRIG_ANGLE_MAX / self->num_ticks;
- x = width / 2 + (grub_cos (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
- y = height / 2 + (grub_sin (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
-
- /* Adjust (x,y) so the tick is centered. */
- x -= tick_width / 2;
- y -= tick_height / 2;
-
- /* Draw the tick. */
- grub_video_blit_bitmap (self->tick_bitmap, GRUB_VIDEO_BLIT_BLEND,
- x, y, 0, 0, tick_width, tick_height);
+ int radius = grub_min (height, width) / 2 - grub_max (tick_height, tick_width) / 2 - 1;
+ unsigned nticks;
+ unsigned tick_begin;
+ unsigned tick_end;
+ if (self->end <= self->start
+ || self->value <= self->start)
+ nticks = 0;
+ else
+ nticks = ((unsigned) (self->num_ticks
+ * (self->value - self->start)))
+ / ((unsigned) (self->end - self->start));
+ /* Do ticks appear or disappear as the value approached the end? */
+ if (self->ticks_disappear)
+ {
+ tick_begin = nticks;
+ tick_end = self->num_ticks;
+ }
+ else
+ {
+ tick_begin = 0;
+ tick_end = nticks;
+ }
+
+ unsigned i;
+ for (i = tick_begin; i < tick_end; i++)
+ {
+ int x;
+ int y;
+ int angle;
+
+ /* Calculate the location of the tick. */
+ angle = self->start_angle
+ + i * GRUB_TRIG_ANGLE_MAX / self->num_ticks;
+ x = width / 2 + (grub_cos (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
+ y = height / 2 + (grub_sin (angle) * radius / GRUB_TRIG_FRACTION_SCALE);
+
+ /* Adjust (x,y) so the tick is centered. */
+ x -= tick_width / 2;
+ y -= tick_height / 2;
+
+ /* Draw the tick. */
+ grub_video_blit_bitmap (self->tick_bitmap, GRUB_VIDEO_BLIT_BLEND,
+ x, y, 0, 0, tick_width, tick_height);
+ }
}
-
grub_gui_restore_viewport (&vpsave);
}
diff --git a/grub-core/gfxmenu/gui_label.c b/grub-core/gfxmenu/gui_label.c
index 507c01014..a4c817891 100644
--- a/grub-core/gfxmenu/gui_label.c
+++ b/grub-core/gfxmenu/gui_label.c
@@ -154,6 +154,8 @@ label_get_minimal_size (void *vself, unsigned *width, unsigned *height)
+ grub_font_get_descent (self->font));
}
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static void
label_set_state (void *vself, int visible, int start __attribute__ ((unused)),
int current, int end __attribute__ ((unused)))
@@ -235,6 +237,8 @@ label_set_property (void *vself, const char *name, const char *value)
return GRUB_ERR_NONE;
}
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
static struct grub_gui_component_ops label_ops =
{
.destroy = label_destroy,
diff --git a/grub-core/gfxmenu/gui_list.c b/grub-core/gfxmenu/gui_list.c
index 5d26811f9..01477cdf2 100644
--- a/grub-core/gfxmenu/gui_list.c
+++ b/grub-core/gfxmenu/gui_list.c
@@ -131,6 +131,9 @@ get_num_shown_items (list_impl_t self)
int max_top_pad = grub_max (item_top_pad, sel_top_pad);
int max_bottom_pad = grub_max (item_bottom_pad, sel_bottom_pad);
+ if (item_height + item_vspace <= 0)
+ return 1;
+
return (self->bounds.height + item_vspace - 2 * boxpad
- max_top_pad - max_bottom_pad
- box_top_pad - box_bottom_pad) / (item_height + item_vspace);
diff --git a/grub-core/gfxmenu/gui_progress_bar.c b/grub-core/gfxmenu/gui_progress_bar.c
index 605c10997..b128f0866 100644
--- a/grub-core/gfxmenu/gui_progress_bar.c
+++ b/grub-core/gfxmenu/gui_progress_bar.c
@@ -118,9 +118,15 @@ draw_filled_rect_bar (grub_gui_progress_bar_t self)
f.width + 2, f.height + 2);
/* Bar background. */
- int barwidth = (f.width
- * (self->value - self->start)
- / (self->end - self->start));
+ unsigned barwidth;
+
+ if (self->end <= self->start
+ || self->value <= self->start)
+ barwidth = 0;
+ else
+ barwidth = (f.width
+ * (self->value - self->start)
+ / (self->end - self->start));
grub_video_fill_rect (grub_video_map_rgba_color (self->bg_color),
f.x + barwidth, f.y,
f.width - barwidth, f.height);
@@ -183,6 +189,8 @@ draw_pixmap_bar (grub_gui_progress_bar_t self)
}
}
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static void
draw_text (grub_gui_progress_bar_t self)
{
@@ -212,6 +220,8 @@ draw_text (grub_gui_progress_bar_t self)
}
}
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
static void
progress_bar_paint (void *vself, const grub_video_rect_t *region)
{
diff --git a/grub-core/gfxmenu/icon_manager.c b/grub-core/gfxmenu/icon_manager.c
index ff49ab0e0..1894682ef 100644
--- a/grub-core/gfxmenu/icon_manager.c
+++ b/grub-core/gfxmenu/icon_manager.c
@@ -106,8 +106,10 @@ grub_gfxmenu_icon_manager_set_theme_path (grub_gfxmenu_icon_manager_t mgr,
const char *path)
{
/* Clear the cache if the theme path has changed. */
- if (((mgr->theme_path == 0) != (path == 0))
- || (grub_strcmp (mgr->theme_path, path) != 0))
+ if (mgr->theme_path == 0 && path == 0)
+ return;
+ if (mgr->theme_path == 0 || path == 0
+ || grub_strcmp (mgr->theme_path, path) != 0)
grub_gfxmenu_icon_manager_clear_cache (mgr);
grub_free (mgr->theme_path);
diff --git a/grub-core/gfxmenu/theme_loader.c b/grub-core/gfxmenu/theme_loader.c
index 8a7945816..02978392c 100644
--- a/grub-core/gfxmenu/theme_loader.c
+++ b/grub-core/gfxmenu/theme_loader.c
@@ -255,7 +255,7 @@ theme_set_string (grub_gfxmenu_view_t view,
{
unsigned int tmp;
int err = theme_get_unsigned_int_from_proportional (value,
- view->screen.width,
+ view->screen.height,
&tmp);
if (err != GRUB_ERR_NONE)
return err;
@@ -275,7 +275,7 @@ theme_set_string (grub_gfxmenu_view_t view,
{
unsigned int tmp;
int err = theme_get_unsigned_int_from_proportional (value,
- view->screen.width,
+ view->screen.height,
&tmp);
if (err != GRUB_ERR_NONE)
return err;
@@ -774,6 +774,8 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
view->canvas->component.ops->destroy (view->canvas);
view->canvas = grub_gui_canvas_new ();
+ if (!view->canvas)
+ goto fail;
((grub_gui_component_t) view->canvas)
->ops->set_bounds ((grub_gui_component_t) view->canvas,
&view->screen);
diff --git a/grub-core/gmodule.pl.in b/grub-core/gmodule.pl.in
index 6739a6f1c..78aa1e64e 100644
--- a/grub-core/gmodule.pl.in
+++ b/grub-core/gmodule.pl.in
@@ -23,7 +23,7 @@ while (<>) {
}
print " -s $2 $sections{$1}"
- if ($sections{$1} ne '0x0');
+ if ($sections{$1} ne '0x0' and $sections{$1} ne '');
};
close (READELF);
print "\n";
diff --git a/grub-core/gnulib/argp-help.c b/grub-core/gnulib/argp-help.c
index 2914f4723..b9be63f40 100644
--- a/grub-core/gnulib/argp-help.c
+++ b/grub-core/gnulib/argp-help.c
@@ -1,5 +1,5 @@
/* Hierarchical argument parsing help output
- Copyright (C) 1995-2005, 2007, 2009-2013 Free Software Foundation, Inc.
+ Copyright (C) 1995-2005, 2007, 2009-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -650,7 +650,7 @@ hol_find_entry (struct hol *hol, const char *name)
return 0;
}
-/* If an entry with the long option NAME occurs in HOL, set it's special
+/* If an entry with the long option NAME occurs in HOL, set its special
sort position to GROUP. */
static void
hol_set_group (struct hol *hol, const char *name, int group)
@@ -1507,11 +1507,15 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
if (vt)
{
if (post)
- inp_text = vt + 1;
+ {
+ inp_text = vt + 1;
+ if (! *inp_text)
+ inp_text = 0;
+ }
else
{
inp_text_len = vt - argp->doc;
- inp_text = __strndup (argp->doc, inp_text_len);
+ inp_text = inp_text_len ? __strndup (argp->doc, inp_text_len) : 0;
}
}
else
diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c
index aec798f59..0f2ea6bd8 100644
--- a/grub-core/io/gzio.c
+++ b/grub-core/io/gzio.c
@@ -1161,6 +1161,19 @@ grub_gzio_open (grub_file_t io, const char *name __attribute__ ((unused)))
return file;
}
+static grub_uint8_t
+mod_31 (grub_uint16_t v)
+{
+ /* At most 2 iterations for any number that
+ we can get here.
+ In any case faster than real division. */
+ while (v > 0x1f)
+ v = (v & 0x1f) + (v >> 5);
+ if (v == 0x1f)
+ return 0;
+ return v;
+}
+
static int
test_zlib_header (grub_gzio_t gzio)
{
@@ -1178,7 +1191,10 @@ test_zlib_header (grub_gzio_t gzio)
return 0;
}
- if ((cmf * 256U + flg) % 31U)
+ /* Usually it would be: (cmf * 256 + flg) % 31 != 0. */
+ /* But 256 == 8 (31). */
+ /* By multiplying by 4 and using 32 == 1 (31). We get our formula. */
+ if (mod_31 (cmf + flg * 4) != 0)
{
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, N_("unsupported gzip format"));
return 0;
@@ -1303,12 +1319,6 @@ grub_zlib_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
ret = grub_gzio_read_real (gzio, off, outbuf, outsize);
grub_free (gzio);
- if (!grub_errno && ret != (grub_ssize_t) outsize)
- {
- grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, "premature end of compressed");
- ret = -1;
- }
-
/* FIXME: Check Adler. */
return ret;
}
diff --git a/grub-core/io/lzopio.c b/grub-core/io/lzopio.c
index de2ea6778..7559c6c9c 100644
--- a/grub-core/io/lzopio.c
+++ b/grub-core/io/lzopio.c
@@ -403,8 +403,6 @@ test_header (grub_file_t file)
return 1;
CORRUPTED:
- grub_free(name);
-
return 0;
}
diff --git a/grub-core/kern/acpi.c b/grub-core/kern/acpi.c
new file mode 100644
index 000000000..5746ac00c
--- /dev/null
+++ b/grub-core/kern/acpi.c
@@ -0,0 +1,119 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2012 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/types.h>
+#include <grub/time.h>
+#include <grub/misc.h>
+#include <grub/acpi.h>
+
+/* Simple checksum by summing all bytes. Used by ACPI and SMBIOS. */
+grub_uint8_t
+grub_byte_checksum (void *base, grub_size_t size)
+{
+ grub_uint8_t *ptr;
+ grub_uint8_t ret = 0;
+ for (ptr = (grub_uint8_t *) base; ptr < ((grub_uint8_t *) base) + size;
+ ptr++)
+ ret += *ptr;
+ return ret;
+}
+
+static void *
+grub_acpi_rsdt_find_table (struct grub_acpi_table_header *rsdt, const char *sig)
+{
+ grub_size_t s;
+ grub_unaligned_uint32_t *ptr;
+
+ if (!rsdt)
+ return 0;
+
+ if (grub_memcmp (rsdt->signature, "RSDT", 4) != 0)
+ return 0;
+
+ ptr = (grub_unaligned_uint32_t *) (rsdt + 1);
+ s = (rsdt->length - sizeof (*rsdt)) / sizeof (grub_uint32_t);
+ for (; s; s--, ptr++)
+ {
+ struct grub_acpi_table_header *tbl;
+ tbl = (struct grub_acpi_table_header *) (grub_addr_t) ptr->val;
+ if (grub_memcmp (tbl->signature, sig, 4) == 0)
+ return tbl;
+ }
+ return 0;
+}
+
+static void *
+grub_acpi_xsdt_find_table (struct grub_acpi_table_header *xsdt, const char *sig)
+{
+ grub_size_t s;
+ grub_unaligned_uint64_t *ptr;
+
+ if (!xsdt)
+ return 0;
+
+ if (grub_memcmp (xsdt->signature, "XSDT", 4) != 0)
+ return 0;
+
+ ptr = (grub_unaligned_uint64_t *) (xsdt + 1);
+ s = (xsdt->length - sizeof (*xsdt)) / sizeof (grub_uint32_t);
+ for (; s; s--, ptr++)
+ {
+ struct grub_acpi_table_header *tbl;
+#if GRUB_CPU_SIZEOF_VOID_P != 8
+ if (ptr->val >> 32)
+ continue;
+#endif
+ tbl = (struct grub_acpi_table_header *) (grub_addr_t) ptr->val;
+ if (grub_memcmp (tbl->signature, sig, 4) == 0)
+ return tbl;
+ }
+ return 0;
+}
+
+struct grub_acpi_fadt *
+grub_acpi_find_fadt (void)
+{
+ struct grub_acpi_fadt *fadt = 0;
+ struct grub_acpi_rsdp_v10 *rsdpv1;
+ struct grub_acpi_rsdp_v20 *rsdpv2;
+ rsdpv1 = grub_machine_acpi_get_rsdpv1 ();
+ if (rsdpv1)
+ fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *)
+ (grub_addr_t) rsdpv1->rsdt_addr,
+ GRUB_ACPI_FADT_SIGNATURE);
+ if (fadt)
+ return fadt;
+ rsdpv2 = grub_machine_acpi_get_rsdpv2 ();
+ if (rsdpv2)
+ fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *)
+ (grub_addr_t) rsdpv2->rsdpv1.rsdt_addr,
+ GRUB_ACPI_FADT_SIGNATURE);
+ if (fadt)
+ return fadt;
+ if (rsdpv2
+#if GRUB_CPU_SIZEOF_VOID_P != 8
+ && !(rsdpv2->xsdt_addr >> 32)
+#endif
+ )
+ fadt = grub_acpi_xsdt_find_table ((struct grub_acpi_table_header *)
+ (grub_addr_t) rsdpv2->xsdt_addr,
+ GRUB_ACPI_FADT_SIGNATURE);
+ if (fadt)
+ return fadt;
+ return 0;
+}
diff --git a/grub-core/kern/arm/cache.S b/grub-core/kern/arm/cache.S
index 3763b7800..354a069fe 100644
--- a/grub-core/kern/arm/cache.S
+++ b/grub-core/kern/arm/cache.S
@@ -37,20 +37,16 @@
* Simple cache maintenance functions
*/
-dlinesz_addr:
- .long EXT_C(grub_arch_cache_dlinesz)
-ilinesz_addr:
- .long EXT_C(grub_arch_cache_ilinesz)
-
@ r0 - *beg (inclusive)
@ r1 - *end (exclusive)
-clean_dcache_range:
+@void grub_arm_clean_dcache_range (grub_addr_t start, grub_addr_t end, grub_addr_t dlinesz)
+#ifdef ARMV6
+FUNCTION(grub_arm_clean_dcache_range_armv6)
+#else
+FUNCTION(grub_arm_clean_dcache_range_armv7)
+#endif
+ DSB
@ Clean data cache for range to point-of-unification
- ldr r2, dlinesz_addr
- ldr r2, [r2]
- sub r3, r2, #1 @ align "beg" to start of line
- mvn r3, r3
- and r0, r0, r3
1: cmp r0, r1
bge 2f
#ifdef ARMV6
@@ -65,13 +61,12 @@ clean_dcache_range:
@ r0 - *beg (inclusive)
@ r1 - *end (exclusive)
-invalidate_icache_range:
+#ifdef ARMV6
+FUNCTION(grub_arm_invalidate_icache_range_armv6)
+#else
+FUNCTION(grub_arm_invalidate_icache_range_armv7)
+#endif
@ Invalidate instruction cache for range to point-of-unification
- ldr r2, ilinesz_addr
- ldr r2, [r2]
- sub r3, r2, #1 @ align "beg" to start of line
- mvn r3, r3
- and r0, r0, r3
1: cmp r0, r1
bge 2f
mcr p15, 0, r0, c7, c5, 1 @ ICIMVAU
@@ -83,21 +78,6 @@ invalidate_icache_range:
ISB
bx lr
-@void grub_arch_sync_caches (void *address, grub_size_t len)
-#ifdef ARMV6
-FUNCTION(grub_arch_sync_caches_armv6)
-#else
-FUNCTION(grub_arch_sync_caches_armv7)
-#endif
- DSB
- add r1, r0, r1
- push {r0-r2, lr}
- bl clean_dcache_range
- pop {r0, r1}
- bl invalidate_icache_range
- pop {r2, lr}
- bx lr
-
#ifdef ARMV6
FUNCTION(grub_arm_disable_caches_mmu_armv6)
#else
diff --git a/grub-core/kern/arm/cache.c b/grub-core/kern/arm/cache.c
index f78d070a2..34154ccdb 100644
--- a/grub-core/kern/arm/cache.c
+++ b/grub-core/kern/arm/cache.c
@@ -1,6 +1,11 @@
#include <grub/dl.h>
#include <grub/cache.h>
#include <grub/arm/system.h>
+#ifdef GRUB_MACHINE_UBOOT
+#include <grub/uboot/uboot.h>
+#include <grub/uboot/api_public.h>
+#include <grub/mm.h>
+#endif
/* This is only about cache architecture. It doesn't imply
the CPU architecture. */
@@ -13,12 +18,21 @@ static enum
ARCH_ARMV7
} type = ARCH_UNKNOWN;
-grub_uint32_t grub_arch_cache_dlinesz;
-grub_uint32_t grub_arch_cache_ilinesz;
+static int is_v6_mmu;
+
+static grub_uint32_t grub_arch_cache_dlinesz;
+static grub_uint32_t grub_arch_cache_ilinesz;
+static grub_uint32_t grub_arch_cache_max_linesz;
/* Prototypes for asm functions. */
-void grub_arch_sync_caches_armv6 (void *address, grub_size_t len);
-void grub_arch_sync_caches_armv7 (void *address, grub_size_t len);
+void grub_arm_clean_dcache_range_armv6 (grub_addr_t start, grub_addr_t end,
+ grub_addr_t dlinesz);
+void grub_arm_clean_dcache_range_armv7 (grub_addr_t start, grub_addr_t end,
+ grub_addr_t dlinesz);
+void grub_arm_invalidate_icache_range_armv6 (grub_addr_t start, grub_addr_t end,
+ grub_addr_t dlinesz);
+void grub_arm_invalidate_icache_range_armv7 (grub_addr_t start, grub_addr_t end,
+ grub_addr_t dlinesz);
void grub_arm_disable_caches_mmu_armv6 (void);
void grub_arm_disable_caches_mmu_armv7 (void);
grub_uint32_t grub_arm_main_id (void);
@@ -38,8 +52,11 @@ probe_caches (void)
case 0x4:
case 0x5:
case 0x6:
+ is_v6_mmu = 0;
+ break;
case 0x7:
case 0xf:
+ is_v6_mmu = 1;
break;
default:
grub_fatal ("Unsupported ARM ID 0x%x", main_id);
@@ -82,20 +99,148 @@ probe_caches (void)
default:
grub_fatal ("Unsupported cache type 0x%x", cache_type);
}
+ if (grub_arch_cache_dlinesz > grub_arch_cache_ilinesz)
+ grub_arch_cache_max_linesz = grub_arch_cache_dlinesz;
+ else
+ grub_arch_cache_max_linesz = grub_arch_cache_ilinesz;
+}
+
+#ifdef GRUB_MACHINE_UBOOT
+
+static void subdivide (grub_uint32_t *table, grub_uint32_t *subtable,
+ grub_uint32_t addr)
+{
+ grub_uint32_t j;
+ addr = addr >> 20 << 20;
+ table[addr >> 20] = (grub_addr_t) subtable | 1;
+ for (j = 0; j < 256; j++)
+ subtable[j] = addr | (j << 12)
+ | (3 << 4) | (3 << 6) | (3 << 8) | (3 << 10)
+ | (0 << 3) | (1 << 2) | 2;
+}
+
+void
+grub_arm_enable_caches_mmu (void)
+{
+ grub_uint32_t *table;
+ grub_uint32_t i;
+ grub_uint32_t border_crossing = 0;
+ grub_uint32_t *subtable;
+ struct sys_info *si = grub_uboot_get_sys_info ();
+
+ if (!si || (si->mr_no == 0))
+ {
+ grub_printf ("couldn't get memory map, not enabling caches");
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ if (type == ARCH_UNKNOWN)
+ probe_caches ();
+
+ for (i = 0; (signed) i < si->mr_no; i++)
+ {
+ if (si->mr[i].start & ((1 << 20) - 1))
+ border_crossing++;
+ if ((si->mr[i].start + si->mr[i].size) & ((1 << 20) - 1))
+ border_crossing++;
+ }
+
+ grub_printf ("%d crossers\n", border_crossing);
+
+ table = grub_memalign (1 << 14, (1 << 14) + (border_crossing << 10));
+ if (!table)
+ {
+ grub_printf ("couldn't allocate place for MMU table, not enabling caches");
+ grub_errno = GRUB_ERR_NONE;
+ return;
+ }
+
+ subtable = table + (1 << 12);
+ /* Map all unknown as device. */
+ for (i = 0; i < (1 << 12); i++)
+ table[i] = (i << 20) | (3 << 10) | (0 << 3) | (1 << 2) | 2;
+ /*
+ Device: TEX= 0, C=0, B=1
+ normal: TEX= 0, C=1, B=1
+ AP = 3
+ IMP = 0
+ Domain = 0
+*/
+
+ for (i = 0; (signed) i < si->mr_no; i++)
+ {
+ if (si->mr[i].start & ((1 << 20) - 1))
+ {
+ subdivide (table, subtable, si->mr[i].start);
+ subtable += (1 << 8);
+ }
+ if ((si->mr[i].start + si->mr[i].size) & ((1 << 20) - 1))
+ {
+ subdivide (table, subtable, si->mr[i].start + si->mr[i].size);
+ subtable += (1 << 8);
+ }
+ }
+
+ for (i = 0; (signed) i < si->mr_no; i++)
+ if ((si->mr[i].flags & MR_ATTR_MASK) == MR_ATTR_DRAM
+ || (si->mr[i].flags & MR_ATTR_MASK) == MR_ATTR_SRAM
+ || (si->mr[i].flags & MR_ATTR_MASK) == MR_ATTR_FLASH)
+ {
+ grub_uint32_t cur, end;
+ cur = si->mr[i].start;
+ end = si->mr[i].start + si->mr[i].size;
+ while (cur < end)
+ {
+ grub_uint32_t *st;
+ if ((table[cur >> 20] & 3) == 2)
+ {
+ cur = cur >> 20 << 20;
+ table[cur >> 20] = cur | (3 << 10) | (1 << 3) | (1 << 2) | 2;
+ cur += (1 << 20);
+ continue;
+ }
+ cur = cur >> 12 << 12;
+ st = (grub_uint32_t *) (table[cur >> 20] & ~0x3ff);
+ st[(cur >> 12) & 0xff] = cur | (3 << 4) | (3 << 6)
+ | (3 << 8) | (3 << 10)
+ | (1 << 3) | (1 << 2) | 2;
+ cur += (1 << 12);
+ }
+ }
+
+ grub_printf ("MMU tables generated\n");
+ if (is_v6_mmu)
+ grub_arm_clear_mmu_v6 ();
+
+ grub_printf ("enabling MMU\n");
+ grub_arm_enable_mmu (table);
+ grub_printf ("MMU enabled\n");
}
+#endif
+
void
grub_arch_sync_caches (void *address, grub_size_t len)
{
+ grub_addr_t start = (grub_addr_t) address;
+ grub_addr_t end = start + len;
+
if (type == ARCH_UNKNOWN)
probe_caches ();
+ start = ALIGN_DOWN (start, grub_arch_cache_max_linesz);
+ end = ALIGN_UP (end, grub_arch_cache_max_linesz);
switch (type)
{
case ARCH_ARMV6:
- grub_arch_sync_caches_armv6 (address, len);
+ grub_arm_clean_dcache_range_armv6 (start, end, grub_arch_cache_dlinesz);
+ grub_arm_invalidate_icache_range_armv6 (start, end,
+ grub_arch_cache_ilinesz);
break;
case ARCH_ARMV7:
- grub_arch_sync_caches_armv7 (address, len);
+ grub_arm_clean_dcache_range_armv7 (start, end, grub_arch_cache_dlinesz);
+ grub_arm_invalidate_icache_range_armv7 (start, end,
+ grub_arch_cache_ilinesz);
break;
/* Nothing to do. */
case ARCH_ARMV5_WRITE_THROUGH:
@@ -114,6 +259,7 @@ grub_arm_disable_caches_mmu (void)
probe_caches ();
switch (type)
{
+ case ARCH_ARMV5_WRITE_THROUGH:
case ARCH_ARMV6_UNIFIED:
case ARCH_ARMV6:
grub_arm_disable_caches_mmu_armv6 ();
@@ -121,9 +267,6 @@ grub_arm_disable_caches_mmu (void)
case ARCH_ARMV7:
grub_arm_disable_caches_mmu_armv7 ();
break;
- /* Nothing to do. */
- case ARCH_ARMV5_WRITE_THROUGH:
- break;
/* Pacify GCC. */
case ARCH_UNKNOWN:
break;
diff --git a/grub-core/kern/arm/cache_armv6.S b/grub-core/kern/arm/cache_armv6.S
index c8f94abcf..dfaded0eb 100644
--- a/grub-core/kern/arm/cache_armv6.S
+++ b/grub-core/kern/arm/cache_armv6.S
@@ -22,7 +22,6 @@
.text
.syntax unified
.arm
- .arch armv6
# define DMB mcr p15, 0, r0, c7, c10, 5
# define DSB mcr p15, 0, r0, c7, c10, 4
@@ -41,4 +40,33 @@ FUNCTION(grub_arm_main_id)
FUNCTION(grub_arm_cache_type)
mrc p15, 0, r0, c0, c0, 1
- bx lr \ No newline at end of file
+ bx lr
+
+FUNCTION(grub_arm_clear_mmu_v6)
+ mov r0, #0
+ mcr p15, 0, r0, c2, c0, 2
+ bx lr
+
+FUNCTION(grub_arm_enable_mmu)
+ mcr p15, 0, r0, c2, c0, 0
+
+ mvn r0, #0
+ mcr p15, 0, r0, c3, c0, 0
+
+ mrc p15, 0, r0, c1, c0, 0
+ bic r0, r0, #(1 << 23)
+ mcr p15, 0, r0, c1, c0, 0
+
+ mrc p15, 0, r0, c1, c0, 0
+ orr r0, r0, #(1 << 0)
+ mcr p15, 0, r0, c1, c0, 0
+
+ mrc p15, 0, r0, c1, c0, 0
+ orr r0, r0, #(1 << 2)
+ mcr p15, 0, r0, c1, c0, 0
+
+ mrc p15, 0, r0, c1, c0, 0
+ orr r0, r0, #(1 << 12)
+ mcr p15, 0, r0, c1, c0, 0
+
+ bx lr
diff --git a/grub-core/kern/arm/misc.S b/grub-core/kern/arm/compiler-rt.S
index 8943cc302..645b42f50 100644
--- a/grub-core/kern/arm/misc.S
+++ b/grub-core/kern/arm/compiler-rt.S
@@ -58,25 +58,22 @@ FUNCTION(__aeabi_lmul)
ldmfd sp!, {r4, fp}
bx lr
- .macro division parent
+ .macro division32 parent
- stmfd sp!, {lr}
- sub sp, sp, #12
- mov r2, r1
- add r1, sp, #4
- str r1, [sp, #0]
- mov r1, #0
- mov r3, #0
+ sub sp, sp, #8 @ Allocate naturally aligned 64-bit space
+ stmfd sp!, {r3,lr} @ Dummy r3 to maintain stack alignment
+ add r2, sp, #8 @ Set r2 to address of 64-bit space
bl \parent
- ldr r1, [sp, #4]
- add sp, sp, #12
- ldmfd sp!, {lr}
+ ldr r1, [sp, #8] @ Extract remainder
+ ldmfd sp!, {r3,lr} @ Pop into an unused arg/scratch register
+ add sp, sp, #8
bx lr
.endm
FUNCTION(__aeabi_uidivmod)
- division grub_divmod64
-
+ division32 grub_divmod32
+FUNCTION(__aeabi_idivmod)
+ division32 grub_divmod32s
/*
* Null divide-by-zero handler
diff --git a/grub-core/kern/arm/dl.c b/grub-core/kern/arm/dl.c
index 57cac2e75..24364e189 100644
--- a/grub-core/kern/arm/dl.c
+++ b/grub-core/kern/arm/dl.c
@@ -78,9 +78,9 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
const Elf_Rel *rel, *max;
for (rel = (const Elf_Rel *) ((grub_addr_t) e + s->sh_offset),
- max = rel + s->sh_size / s->sh_entsize;
- rel < max;
- rel++)
+ max = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_size);
+ rel + 1 <= max;
+ rel = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_entsize))
switch (ELF_R_TYPE (rel->r_info))
{
case R_ARM_CALL:
@@ -205,6 +205,21 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
*/
case R_ARM_V4BX:
break;
+ case R_ARM_THM_MOVW_ABS_NC:
+ case R_ARM_THM_MOVT_ABS:
+ {
+ grub_uint32_t offset;
+ offset = grub_arm_thm_movw_movt_get_value((grub_uint16_t *) target);
+ offset += sym_addr;
+
+ if (ELF_R_TYPE (rel->r_info) == R_ARM_THM_MOVT_ABS)
+ offset >>= 16;
+ else
+ offset &= 0xffff;
+
+ grub_arm_thm_movw_movt_set_value((grub_uint16_t *) target, offset);
+ }
+ break;
case R_ARM_THM_JUMP19:
{
/* Thumb instructions can be 16-bit aligned */
diff --git a/grub-core/kern/arm/dl_helper.c b/grub-core/kern/arm/dl_helper.c
index 5721939c1..21d77f763 100644
--- a/grub-core/kern/arm/dl_helper.c
+++ b/grub-core/kern/arm/dl_helper.c
@@ -25,6 +25,20 @@
#include <grub/i18n.h>
#include <grub/arm/reloc.h>
+static inline grub_uint32_t
+thumb_get_instruction_word (grub_uint16_t *target)
+{
+ /* Extract instruction word in alignment-safe manner */
+ return grub_le_to_cpu16 ((*target)) << 16 | grub_le_to_cpu16 (*(target + 1));
+}
+
+static inline void
+thumb_set_instruction_word (grub_uint16_t *target, grub_uint32_t insword)
+{
+ *target = grub_cpu_to_le16 (insword >> 16);
+ *(target + 1) = grub_cpu_to_le16 (insword & 0xffff);
+}
+
/*
* R_ARM_ABS32
*
@@ -56,9 +70,7 @@ grub_arm_thm_call_get_offset (grub_uint16_t *target)
grub_uint32_t insword;
grub_int32_t offset;
- /* Extract instruction word in alignment-safe manner */
- insword = (grub_le_to_cpu16 (*target) << 16)
- | (grub_le_to_cpu16(*(target + 1)));
+ insword = thumb_get_instruction_word (target);
/* Extract bitfields from instruction words */
sign = (insword >> 26) & 1;
@@ -83,9 +95,7 @@ grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset)
grub_uint32_t insword;
int is_blx;
- /* Extract instruction word in alignment-safe manner */
- insword = (grub_le_to_cpu16 (*target) << 16)
- | (grub_le_to_cpu16(*(target + 1)));
+ insword = thumb_get_instruction_word (target);
if (((insword >> 12) & 0xd) == 0xc)
is_blx = 1;
@@ -108,9 +118,7 @@ grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset)
(((offset >> 12) & 0x03ff) << 16) |
(j1 << 13) | (j2 << 11) | ((offset >> 1) & 0x07ff);
- /* Write instruction word back in alignment-safe manner */
- *target = grub_cpu_to_le16 ((insword >> 16) & 0xffff);
- *(target + 1) = grub_cpu_to_le16 (insword & 0xffff);
+ thumb_set_instruction_word (target, insword);
grub_dprintf ("dl", " *insword = 0x%08x", insword);
@@ -123,9 +131,7 @@ grub_arm_thm_jump19_get_offset (grub_uint16_t *target)
grub_int32_t offset;
grub_uint32_t insword;
- /* Extract instruction word in alignment-safe manner */
- insword = (grub_le_to_cpu16 (*target) << 16)
- | (grub_le_to_cpu16(*(target + 1)));
+ insword = thumb_get_instruction_word (target);
/* Extract and sign extend offset */
offset = ((insword >> 26) & 1) << 19
@@ -149,9 +155,7 @@ grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset)
offset >>= 1;
offset &= 0xfffff;
- /* Extract instruction word in alignment-safe manner */
- insword = grub_le_to_cpu16 ((*target)) << 16
- | grub_le_to_cpu16 (*(target + 1));
+ insword = thumb_get_instruction_word (target);
/* Reassemble instruction word and write back */
insword &= insmask;
@@ -160,8 +164,7 @@ grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset)
| ((offset >> 17) & 1) << 13
| ((offset >> 11) & 0x3f) << 16
| (offset & 0x7ff);
- *target = grub_cpu_to_le16 (insword >> 16);
- *(target + 1) = grub_cpu_to_le16 (insword & 0xffff);
+ thumb_set_instruction_word (target, insword);
}
int
@@ -172,6 +175,32 @@ grub_arm_thm_jump19_check_offset (grub_int32_t offset)
return 1;
}
+grub_uint16_t
+grub_arm_thm_movw_movt_get_value (grub_uint16_t *target)
+{
+ grub_uint32_t insword;
+
+ insword = thumb_get_instruction_word (target);
+
+ return ((insword & 0xf0000) >> 4) | ((insword & 0x04000000) >> 15) | \
+ ((insword & 0x7000) >> 4) | (insword & 0xff);
+}
+
+void
+grub_arm_thm_movw_movt_set_value (grub_uint16_t *target, grub_uint16_t value)
+{
+ grub_uint32_t insword;
+ const grub_uint32_t insmask = 0xfbf08f00;
+
+ insword = thumb_get_instruction_word (target);
+ insword &= insmask;
+
+ insword |= ((value & 0xf000) << 4) | ((value & 0x0800) << 15) | \
+ ((value & 0x0700) << 4) | (value & 0xff);
+
+ thumb_set_instruction_word (target, insword);
+}
+
/***********************************************************
* ARM (A32) relocations: *
diff --git a/grub-core/kern/arm/efi/init.c b/grub-core/kern/arm/efi/init.c
index a6ae03475..06df60e2f 100644
--- a/grub-core/kern/arm/efi/init.c
+++ b/grub-core/kern/arm/efi/init.c
@@ -38,7 +38,7 @@ static void
increment_timer (grub_efi_event_t event __attribute__ ((unused)),
void *context __attribute__ ((unused)))
{
- tmr++;
+ tmr += 10;
}
void
@@ -52,7 +52,7 @@ grub_machine_init (void)
efi_call_5 (b->create_event, GRUB_EFI_EVT_TIMER | GRUB_EFI_EVT_NOTIFY_SIGNAL,
GRUB_EFI_TPL_CALLBACK, increment_timer, NULL, &tmr_evt);
- efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 10000);
+ efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 100000);
grub_install_get_time_ms (grub_efi_get_time_ms);
}
@@ -67,7 +67,7 @@ grub_machine_fini (int flags)
b = grub_efi_system_table->boot_services;
- efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 0);
+ efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_CANCEL, 0);
efi_call_1 (b->close_event, tmr_evt);
grub_efi_fini ();
diff --git a/grub-core/kern/arm/efi/misc.c b/grub-core/kern/arm/efi/misc.c
index efec98061..7cd41842a 100644
--- a/grub-core/kern/arm/efi/misc.c
+++ b/grub-core/kern/arm/efi/misc.c
@@ -198,6 +198,5 @@ grub_efi_prepare_platform (void)
if (err != GRUB_ERR_NONE)
return err;
- grub_arm_disable_caches_mmu();
return GRUB_ERR_NONE;
}
diff --git a/grub-core/kern/arm/uboot/startup.S b/grub-core/kern/arm/uboot/startup.S
index 0c4a5f670..5efaae16e 100644
--- a/grub-core/kern/arm/uboot/startup.S
+++ b/grub-core/kern/arm/uboot/startup.S
@@ -55,10 +55,6 @@ FUNCTION(_start)
VARIABLE(grub_total_module_size)
.long 0
-VARIABLE(grub_uboot_machine_type)
- .long 0
-VARIABLE(grub_uboot_boot_data)
- .long 0
VARIABLE(grub_modbase)
.long 0
bss_start_ptr:
@@ -66,29 +62,66 @@ bss_start_ptr:
end_ptr:
.long EXT_C(_end)
+ @ Memory map at start:
+ @ * text+data
+ @ * list relocations
+ @ * modules
+ @ Before we enter C, we need to apply the relocations
+ @ and get following map:
+ @ * text+data
+ @ * BSS (cleared)
+ @ * stack
+ @ * modules
+ @
+ @ To make things easier we ensure
+ @ that BSS+stack is larger than list of relocations
+ @ by increasing stack if necessarry.
+ @ This allows us to always unconditionally copy backwards
+ @ Currently list of relocations is ~5K and stack is set
+ @ to be at least 256K
+
FUNCTION(codestart)
@ Store context: Machine ID, atags/dtb, ...
@ U-Boot API signature is stored on the U-Boot heap
@ Stack pointer used as start address for signature probing
mov r12, sp
adr sp, entry_state
- push {r4-r12,lr} @ store U-Boot context (sp in r12)
+ push {r1-r12,lr} @ store U-Boot context (sp in r12)
- str r1, EXT_C(grub_uboot_machine_type)
- str r2, EXT_C(grub_uboot_boot_data)
+ adr r1, _start
+ ldr r0, bss_start_ptr @ src
+ add r0, r0, r1
- @ Modules have been stored as a blob in BSS,
+ add r0, r0, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
+ mvn r2, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
+ and r0, r0, r2
+1:
+ ldr r3, [r0], #4 @load next offset
+ @ both -2 and -1 are treated the same as we have only one type of relocs
+ @ -2 means "end of this type of relocs" and -1 means "end of all relocs"
+ add r2, r3, #2
+ cmp r2, #1
+ bls reloc_done
+ @ Adjust next offset
+ ldr r2, [r3, r1]
+ add r2, r2, r1
+ str r2, [r3, r1]
+ b 1b
+
+reloc_done:
+
+ @ Modules have been stored as a blob
@ they need to be manually relocated to _end
- ldr r0, bss_start_ptr @ src
add r0, r0, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
mvn r1, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
- and r0, r0, r1
+ and r0, r0, r1 @ src = aligned end of relocations
ldr r1, end_ptr @ dst = End of BSS
ldr r2, grub_total_module_size @ blob size
add r1, r1, #GRUB_KERNEL_MACHINE_STACK_SIZE
and r1, r1, #~0x7 @ Ensure 8-byte alignment
+
sub sp, r1, #8
add r1, r1, #1024
@@ -157,6 +190,11 @@ FUNCTION(grub_uboot_return)
.align 3
@ U-boot context stack space
entry_state_end:
+VARIABLE(grub_uboot_machine_type)
+ .long 0 @ r1
+VARIABLE(grub_uboot_boot_data)
+ .long 0 @ r2
+ .long 0 @ r3
.long 0 @ r4
.long 0 @ r5
.long 0 @ r6
diff --git a/grub-core/kern/arm64/dl.c b/grub-core/kern/arm64/dl.c
index e19ba6a0d..cf50d7250 100644
--- a/grub-core/kern/arm64/dl.c
+++ b/grub-core/kern/arm64/dl.c
@@ -132,6 +132,12 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
*abs_place = (grub_uint64_t) sym_addr;
}
break;
+ case R_AARCH64_ADD_ABS_LO12_NC:
+ grub_arm64_set_abs_lo12 (place, sym_addr);
+ break;
+ case R_AARCH64_LDST64_ABS_LO12_NC:
+ grub_arm64_set_abs_lo12_ldst64 (place, sym_addr);
+ break;
case R_AARCH64_CALL26:
case R_AARCH64_JUMP26:
{
@@ -154,6 +160,18 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
grub_arm64_set_xxxx26_offset (place, offset);
}
break;
+ case R_AARCH64_ADR_PREL_PG_HI21:
+ {
+ grub_int64_t offset = (sym_addr & ~0xfffULL) - (((grub_uint64_t) place) & ~0xfffULL);
+
+ if (!grub_arm64_check_hi21_signed (offset))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "HI21 out of range");
+
+ grub_arm64_set_hi21 (place, offset);
+ }
+ break;
+
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"),
diff --git a/grub-core/kern/arm64/dl_helper.c b/grub-core/kern/arm64/dl_helper.c
index d213ab93e..f031b1ae9 100644
--- a/grub-core/kern/arm64/dl_helper.c
+++ b/grub-core/kern/arm64/dl_helper.c
@@ -53,3 +53,43 @@ grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset)
*place &= insmask;
*place |= grub_cpu_to_le32 (offset >> 2) & ~insmask;
}
+
+int
+grub_arm64_check_hi21_signed (grub_int64_t offset)
+{
+ if (offset != (grub_int64_t)(grub_int32_t)offset)
+ return 0;
+ return 1;
+}
+
+void
+grub_arm64_set_hi21 (grub_uint32_t *place, grub_int64_t offset)
+{
+ const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0x9f00001f);
+ grub_uint32_t val;
+
+ offset >>= 12;
+
+ val = ((offset & 3) << 29) | (((offset >> 2) & 0x7ffff) << 5);
+
+ *place &= insmask;
+ *place |= grub_cpu_to_le32 (val) & ~insmask;
+}
+
+void
+grub_arm64_set_abs_lo12 (grub_uint32_t *place, grub_int64_t target)
+{
+ const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xffc003ff);
+
+ *place &= insmask;
+ *place |= grub_cpu_to_le32 (target << 10) & ~insmask;
+}
+
+void
+grub_arm64_set_abs_lo12_ldst64 (grub_uint32_t *place, grub_int64_t target)
+{
+ const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xfff803ff);
+
+ *place &= insmask;
+ *place |= grub_cpu_to_le32 (target << 7) & ~insmask;
+}
diff --git a/grub-core/kern/arm64/efi/init.c b/grub-core/kern/arm64/efi/init.c
new file mode 100644
index 000000000..6224999ec
--- /dev/null
+++ b/grub-core/kern/arm64/efi/init.c
@@ -0,0 +1,60 @@
+/* init.c - initialize an arm-based EFI system */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2013 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/env.h>
+#include <grub/kernel.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/time.h>
+#include <grub/efi/efi.h>
+#include <grub/loader.h>
+
+static grub_uint64_t timer_frequency_in_khz;
+
+static grub_uint64_t
+grub_efi_get_time_ms (void)
+{
+ grub_uint64_t tmr;
+ asm volatile("mrs %0, cntvct_el0" : "=r" (tmr));
+
+ return tmr / timer_frequency_in_khz;
+}
+
+
+void
+grub_machine_init (void)
+{
+ grub_uint64_t timer_frequency;
+
+ grub_efi_init ();
+
+ asm volatile("mrs %0, cntfrq_el0" : "=r" (timer_frequency));
+ timer_frequency_in_khz = timer_frequency / 1000;
+
+ grub_install_get_time_ms (grub_efi_get_time_ms);
+}
+
+void
+grub_machine_fini (int flags)
+{
+ if (!(flags & GRUB_LOADER_FLAG_NORETURN))
+ return;
+
+ grub_efi_fini ();
+}
diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c
new file mode 100644
index 000000000..5cfcb3907
--- /dev/null
+++ b/grub-core/kern/compiler-rt.c
@@ -0,0 +1,419 @@
+/* compiler-rt.c - compiler helpers. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010-2014 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/misc.h>
+#include <grub/compiler-rt.h>
+
+#ifndef GRUB_EMBED_DECOMPRESSOR
+void * GRUB_BUILTIN_ATTR
+memcpy (void *dest, const void *src, grub_size_t n)
+{
+ return grub_memmove (dest, src, n);
+}
+void * GRUB_BUILTIN_ATTR
+memmove (void *dest, const void *src, grub_size_t n)
+{
+ return grub_memmove (dest, src, n);
+}
+int GRUB_BUILTIN_ATTR
+memcmp (const void *s1, const void *s2, grub_size_t n)
+{
+ return grub_memcmp (s1, s2, n);
+}
+void * GRUB_BUILTIN_ATTR
+memset (void *s, int c, grub_size_t n)
+{
+ return grub_memset (s, c, n);
+}
+
+#ifdef __APPLE__
+
+void GRUB_BUILTIN_ATTR
+__bzero (void *s, grub_size_t n)
+{
+ grub_memset (s, 0, n);
+}
+
+#endif
+
+#if GRUB_DIVISION_IN_SOFTWARE
+
+grub_uint32_t
+__udivsi3 (grub_uint32_t a, grub_uint32_t b)
+{
+ return grub_divmod64 (a, b, 0);
+}
+
+grub_int32_t
+__divsi3 (grub_int32_t a, grub_int32_t b)
+{
+ return grub_divmod64s (a, b, 0);
+}
+
+grub_uint32_t
+__umodsi3 (grub_uint32_t a, grub_uint32_t b)
+{
+ grub_uint64_t ret;
+ grub_divmod64 (a, b, &ret);
+ return ret;
+}
+
+grub_int32_t
+__modsi3 (grub_int32_t a, grub_int32_t b)
+{
+ grub_int64_t ret;
+ grub_divmod64s (a, b, &ret);
+ return ret;
+}
+
+grub_uint64_t
+__udivdi3 (grub_uint64_t a, grub_uint64_t b)
+{
+ return grub_divmod64 (a, b, 0);
+}
+
+grub_uint64_t
+__umoddi3 (grub_uint64_t a, grub_uint64_t b)
+{
+ grub_uint64_t ret;
+ grub_divmod64 (a, b, &ret);
+ return ret;
+}
+
+grub_int64_t
+__divdi3 (grub_int64_t a, grub_int64_t b)
+{
+ return grub_divmod64s (a, b, 0);
+}
+
+grub_int64_t
+__moddi3 (grub_int64_t a, grub_int64_t b)
+{
+ grub_int64_t ret;
+ grub_divmod64s (a, b, &ret);
+ return ret;
+}
+
+#endif
+
+#endif
+
+#ifdef NEED_CTZDI2
+
+unsigned
+__ctzdi2 (grub_uint64_t x)
+{
+ unsigned ret = 0;
+ if (!x)
+ return 64;
+ if (!(x & 0xffffffff))
+ {
+ x >>= 32;
+ ret |= 32;
+ }
+ if (!(x & 0xffff))
+ {
+ x >>= 16;
+ ret |= 16;
+ }
+ if (!(x & 0xff))
+ {
+ x >>= 8;
+ ret |= 8;
+ }
+ if (!(x & 0xf))
+ {
+ x >>= 4;
+ ret |= 4;
+ }
+ if (!(x & 0x3))
+ {
+ x >>= 2;
+ ret |= 2;
+ }
+ if (!(x & 0x1))
+ {
+ x >>= 1;
+ ret |= 1;
+ }
+ return ret;
+}
+#endif
+
+#ifdef NEED_CTZSI2
+unsigned
+__ctzsi2 (grub_uint32_t x)
+{
+ unsigned ret = 0;
+ if (!x)
+ return 32;
+
+ if (!(x & 0xffff))
+ {
+ x >>= 16;
+ ret |= 16;
+ }
+ if (!(x & 0xff))
+ {
+ x >>= 8;
+ ret |= 8;
+ }
+ if (!(x & 0xf))
+ {
+ x >>= 4;
+ ret |= 4;
+ }
+ if (!(x & 0x3))
+ {
+ x >>= 2;
+ ret |= 2;
+ }
+ if (!(x & 0x1))
+ {
+ x >>= 1;
+ ret |= 1;
+ }
+ return ret;
+}
+
+#endif
+
+
+#if defined (__clang__) && !defined(GRUB_EMBED_DECOMPRESSOR)
+/* clang emits references to abort(). */
+void __attribute__ ((noreturn))
+abort (void)
+{
+ grub_fatal ("compiler abort");
+}
+#endif
+
+#if (defined (__MINGW32__) || defined (__CYGWIN__))
+void __register_frame_info (void)
+{
+}
+
+void __deregister_frame_info (void)
+{
+}
+
+void ___chkstk_ms (void)
+{
+}
+
+void __chkstk_ms (void)
+{
+}
+#endif
+
+union component64
+{
+ grub_uint64_t full;
+ struct
+ {
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ grub_uint32_t high;
+ grub_uint32_t low;
+#else
+ grub_uint32_t low;
+ grub_uint32_t high;
+#endif
+ };
+};
+
+#if defined (__powerpc__) || defined (__arm__) || defined(__mips__)
+
+/* Based on libgcc2.c from gcc suite. */
+grub_uint64_t
+__lshrdi3 (grub_uint64_t u, int b)
+{
+ if (b == 0)
+ return u;
+
+ const union component64 uu = {.full = u};
+ const int bm = 32 - b;
+ union component64 w;
+
+ if (bm <= 0)
+ {
+ w.high = 0;
+ w.low = (grub_uint32_t) uu.high >> -bm;
+ }
+ else
+ {
+ const grub_uint32_t carries = (grub_uint32_t) uu.high << bm;
+
+ w.high = (grub_uint32_t) uu.high >> b;
+ w.low = ((grub_uint32_t) uu.low >> b) | carries;
+ }
+
+ return w.full;
+}
+
+/* Based on libgcc2.c from gcc suite. */
+grub_uint64_t
+__ashrdi3 (grub_uint64_t u, int b)
+{
+ if (b == 0)
+ return u;
+
+ const union component64 uu = {.full = u};
+ const int bm = 32 - b;
+ union component64 w;
+
+ if (bm <= 0)
+ {
+ /* w.high = 1..1 or 0..0 */
+ w.high = ((grub_int32_t) uu.high) >> (32 - 1);
+ w.low = ((grub_int32_t) uu.high) >> -bm;
+ }
+ else
+ {
+ const grub_uint32_t carries = ((grub_uint32_t) uu.high) << bm;
+
+ w.high = ((grub_int32_t) uu.high) >> b;
+ w.low = ((grub_uint32_t) uu.low >> b) | carries;
+ }
+
+ return w.full;
+}
+
+/* Based on libgcc2.c from gcc suite. */
+grub_uint64_t
+__ashldi3 (grub_uint64_t u, int b)
+{
+ if (b == 0)
+ return u;
+
+ const union component64 uu = {.full = u};
+ const int bm = 32 - b;
+ union component64 w;
+
+ if (bm <= 0)
+ {
+ w.low = 0;
+ w.high = (grub_uint32_t) uu.low << -bm;
+ }
+ else
+ {
+ const grub_uint32_t carries = (grub_uint32_t) uu.low >> bm;
+
+ w.low = (grub_uint32_t) uu.low << b;
+ w.high = ((grub_uint32_t) uu.high << b) | carries;
+ }
+
+ return w.full;
+}
+
+/* Based on libgcc2.c from gcc suite. */
+int
+__ucmpdi2 (grub_uint64_t a, grub_uint64_t b)
+{
+ union component64 ac, bc;
+ ac.full = a;
+ bc.full = b;
+
+ if (ac.high < bc.high)
+ return 0;
+ else if (ac.high > bc.high)
+ return 2;
+
+ if (ac.low < bc.low)
+ return 0;
+ else if (ac.low > bc.low)
+ return 2;
+ return 1;
+}
+
+#endif
+
+#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || defined(__arm__)
+
+/* Based on libgcc2.c from gcc suite. */
+grub_uint32_t
+__bswapsi2 (grub_uint32_t u)
+{
+ return ((((u) & 0xff000000) >> 24)
+ | (((u) & 0x00ff0000) >> 8)
+ | (((u) & 0x0000ff00) << 8)
+ | (((u) & 0x000000ff) << 24));
+}
+
+/* Based on libgcc2.c from gcc suite. */
+grub_uint64_t
+__bswapdi2 (grub_uint64_t u)
+{
+ return ((((u) & 0xff00000000000000ull) >> 56)
+ | (((u) & 0x00ff000000000000ull) >> 40)
+ | (((u) & 0x0000ff0000000000ull) >> 24)
+ | (((u) & 0x000000ff00000000ull) >> 8)
+ | (((u) & 0x00000000ff000000ull) << 8)
+ | (((u) & 0x0000000000ff0000ull) << 24)
+ | (((u) & 0x000000000000ff00ull) << 40)
+ | (((u) & 0x00000000000000ffull) << 56));
+}
+
+
+#endif
+
+#ifdef __arm__
+grub_uint32_t
+__aeabi_uidiv (grub_uint32_t a, grub_uint32_t b)
+ __attribute__ ((alias ("__udivsi3")));
+grub_int32_t
+__aeabi_idiv (grub_int32_t a, grub_int32_t b)
+ __attribute__ ((alias ("__divsi3")));
+void *__aeabi_memcpy (void *dest, const void *src, grub_size_t n)
+ __attribute__ ((alias ("grub_memcpy")));
+void *__aeabi_memcpy4 (void *dest, const void *src, grub_size_t n)
+ __attribute__ ((alias ("grub_memcpy")));
+void *__aeabi_memcpy8 (void *dest, const void *src, grub_size_t n)
+ __attribute__ ((alias ("grub_memcpy")));
+void *__aeabi_memset (void *s, int c, grub_size_t n)
+ __attribute__ ((alias ("memset")));
+
+void
+__aeabi_memclr (void *s, grub_size_t n)
+{
+ grub_memset (s, 0, n);
+}
+
+void __aeabi_memclr4 (void *s, grub_size_t n)
+ __attribute__ ((alias ("__aeabi_memclr")));
+void __aeabi_memclr8 (void *s, grub_size_t n)
+ __attribute__ ((alias ("__aeabi_memclr")));
+
+int
+__aeabi_ulcmp (grub_uint64_t a, grub_uint64_t b)
+{
+ return __ucmpdi2 (a, b) - 1;
+}
+
+grub_uint64_t
+__aeabi_lasr (grub_uint64_t u, int b)
+ __attribute__ ((alias ("__ashrdi3")));
+grub_uint64_t
+__aeabi_llsr (grub_uint64_t u, int b)
+ __attribute__ ((alias ("__lshrdi3")));
+
+grub_uint64_t
+__aeabi_llsl (grub_uint64_t u, int b)
+ __attribute__ ((alias ("__ashldi3")));
+
+#endif
diff --git a/grub-core/kern/disk.c b/grub-core/kern/disk.c
index 2a44f65af..789f8c052 100644
--- a/grub-core/kern/disk.c
+++ b/grub-core/kern/disk.c
@@ -342,9 +342,9 @@ grub_disk_read_small_real (grub_disk_t disk, grub_disk_addr_t sector,
{
grub_err_t err;
err = (disk->dev->read) (disk, transform_sector (disk, sector),
- 1 << (GRUB_DISK_CACHE_BITS
- + GRUB_DISK_SECTOR_BITS
- - disk->log_sector_size), tmp_buf);
+ 1U << (GRUB_DISK_CACHE_BITS
+ + GRUB_DISK_SECTOR_BITS
+ - disk->log_sector_size), tmp_buf);
if (!err)
{
/* Copy it and store it in the disk cache. */
@@ -366,11 +366,11 @@ grub_disk_read_small_real (grub_disk_t disk, grub_disk_addr_t sector,
sector += (offset >> GRUB_DISK_SECTOR_BITS);
offset &= ((1 << GRUB_DISK_SECTOR_BITS) - 1);
- aligned_sector = (sector & ~((1 << (disk->log_sector_size
- - GRUB_DISK_SECTOR_BITS))
+ aligned_sector = (sector & ~((1ULL << (disk->log_sector_size
+ - GRUB_DISK_SECTOR_BITS))
- 1));
offset += ((sector - aligned_sector) << GRUB_DISK_SECTOR_BITS);
- num = ((size + offset + (1 << (disk->log_sector_size))
+ num = ((size + offset + (1ULL << (disk->log_sector_size))
- 1) >> (disk->log_sector_size));
tmp_buf = grub_malloc (num << disk->log_sector_size);
@@ -431,7 +431,7 @@ grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_err_t err;
grub_size_t len;
- start_sector = sector & ~(GRUB_DISK_CACHE_SIZE - 1);
+ start_sector = sector & ~((grub_disk_addr_t) GRUB_DISK_CACHE_SIZE - 1);
pos = (sector - start_sector) << GRUB_DISK_SECTOR_BITS;
len = ((GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS)
- pos - offset);
diff --git a/grub-core/kern/disk_common.c b/grub-core/kern/disk_common.c
index fb19778ae..2ca12b5f8 100644
--- a/grub-core/kern/disk_common.c
+++ b/grub-core/kern/disk_common.c
@@ -7,6 +7,8 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
grub_off_t *offset, grub_size_t size)
{
grub_partition_t part;
+ grub_disk_addr_t total_sectors;
+
*sector += *offset >> GRUB_DISK_SECTOR_BITS;
*offset &= GRUB_DISK_SECTOR_SIZE - 1;
@@ -27,12 +29,20 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
*sector += start;
}
- if (disk->total_sectors != GRUB_DISK_SIZE_UNKNOWN
- && ((disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)) <= *sector
- || ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
- >> GRUB_DISK_SECTOR_BITS) > (disk->total_sectors
- << (disk->log_sector_size
- - GRUB_DISK_SECTOR_BITS)) - *sector))
+ /* Transform total_sectors to number of 512B blocks. */
+ total_sectors = disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
+
+ /* Some drivers have problems with disks above reasonable.
+ Treat unknown as 1EiB disk. While on it, clamp the size to 1EiB.
+ Just one condition is enough since GRUB_DISK_UNKNOWN_SIZE << ls is always
+ above 9EiB.
+ */
+ if (total_sectors > (1ULL << 51))
+ total_sectors = (1ULL << 51);
+
+ if ((total_sectors <= *sector
+ || ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
+ >> GRUB_DISK_SECTOR_BITS) > total_sectors - *sector))
return grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("attempt to read or write outside of disk `%s'"), disk->name);
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
index 98f858a38..e394cd96f 100644
--- a/grub-core/kern/dl.c
+++ b/grub-core/kern/dl.c
@@ -223,7 +223,7 @@ static grub_err_t
grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
{
unsigned i;
- Elf_Shdr *s;
+ const Elf_Shdr *s;
grub_size_t tsize = 0, talign = 1;
#if !defined (__i386__) && !defined (__x86_64__)
grub_size_t tramp;
@@ -232,9 +232,9 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
#endif
char *ptr;
- for (i = 0, s = (Elf_Shdr *)((char *) e + e->e_shoff);
+ for (i = 0, s = (const Elf_Shdr *)((const char *) e + e->e_shoff);
i < e->e_shnum;
- i++, s = (Elf_Shdr *)((char *) s + e->e_shentsize))
+ i++, s = (const Elf_Shdr *)((const char *) s + e->e_shentsize))
{
tsize = ALIGN_UP (tsize, s->sh_addralign) + s->sh_size;
if (talign < s->sh_addralign)
@@ -333,14 +333,17 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
if (s->sh_type == SHT_SYMTAB)
break;
+ /* Module without symbol table may still be used to pull in dependencies.
+ We verify at build time that such modules do not contain any relocations
+ that may reference symbol table. */
if (i == e->e_shnum)
- return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
+ return GRUB_ERR_NONE;
#ifdef GRUB_MODULES_MACHINE_READONLY
mod->symtab = grub_malloc (s->sh_size);
if (!mod->symtab)
return grub_errno;
- memcpy (mod->symtab, (char *) e + s->sh_offset, s->sh_size);
+ grub_memcpy (mod->symtab, (char *) e + s->sh_offset, s->sh_size);
#else
mod->symtab = (Elf_Sym *) ((char *) e + s->sh_offset);
#endif
@@ -576,6 +579,9 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
if (seg)
{
+ if (!mod->symtab)
+ return grub_error (GRUB_ERR_BAD_MODULE, "relocation without symbol table");
+
err = grub_arch_dl_relocate_symbols (mod, ehdr, s, seg);
if (err)
return err;
@@ -605,7 +611,7 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size)
}
/* Make sure that every section is within the core. */
- if (size < e->e_shoff + e->e_shentsize * e->e_shnum)
+ if (size < e->e_shoff + (grub_uint32_t) e->e_shentsize * e->e_shnum)
{
grub_error (GRUB_ERR_BAD_OS, "ELF sections outside core");
return 0;
@@ -657,6 +663,8 @@ grub_dl_load_core (void *addr, grub_size_t size)
{
grub_dl_t mod;
+ grub_boot_time ("Parsing module");
+
mod = grub_dl_load_core_noinit (addr, size);
if (!mod)
@@ -678,6 +686,8 @@ grub_dl_load_file (const char *filename)
void *core = 0;
grub_dl_t mod = 0;
+ grub_boot_time ("Loading module %s", filename);
+
file = grub_file_open (filename);
if (! file)
return 0;
diff --git a/grub-core/commands/efi/acpi.c b/grub-core/kern/efi/acpi.c
index 74f8cd1a9..74f8cd1a9 100644
--- a/grub-core/commands/efi/acpi.c
+++ b/grub-core/kern/efi/acpi.c
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index c2a5c32ff..caf9bcc41 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -27,6 +27,7 @@
#include <grub/term.h>
#include <grub/kernel.h>
#include <grub/mm.h>
+#include <grub/loader.h>
/* The handle of GRUB itself. Filled in by the startup code. */
grub_efi_handle_t grub_efi_image_handle;
@@ -156,7 +157,7 @@ grub_efi_get_loaded_image (grub_efi_handle_t image_handle)
void
grub_exit (void)
{
- grub_efi_fini ();
+ grub_machine_fini (GRUB_LOADER_FLAG_NORETURN);
efi_call_4 (grub_efi_system_table->boot_services->exit,
grub_efi_image_handle, GRUB_EFI_SUCCESS, 0, 0);
for (;;) ;
@@ -205,6 +206,7 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid,
| GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS
| GRUB_EFI_VARIABLE_RUNTIME_ACCESS),
datasize, data);
+ grub_free (var16);
if (status == GRUB_EFI_SUCCESS)
return GRUB_ERR_NONE;
@@ -236,8 +238,11 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, NULL);
- if (!datasize)
- return NULL;
+ if (status != GRUB_EFI_BUFFER_TOO_SMALL || !datasize)
+ {
+ grub_free (var16);
+ return NULL;
+ }
data = grub_malloc (datasize);
if (!data)
@@ -309,7 +314,7 @@ grub_efi_modules_addr (void)
char *
grub_efi_get_filename (grub_efi_device_path_t *dp0)
{
- char *name = 0, *p;
+ char *name = 0, *p, *pi;
grub_size_t filesize = 0;
grub_efi_device_path_t *dp;
@@ -328,7 +333,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0)
grub_efi_uint16_t len;
len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4)
/ sizeof (grub_efi_char16_t));
- filesize += GRUB_MAX_UTF8_PER_UTF16 * len + 1;
+ filesize += GRUB_MAX_UTF8_PER_UTF16 * len + 2;
}
dp = GRUB_EFI_NEXT_DEVICE_PATH (dp);
@@ -356,12 +361,12 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0)
grub_efi_file_path_device_path_t *fp;
grub_efi_uint16_t len;
- if (p != name)
- *p++ = '/';
+ *p++ = '/';
len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4)
/ sizeof (grub_efi_char16_t));
fp = (grub_efi_file_path_device_path_t *) dp;
+
p = (char *) grub_utf16_to_utf8 ((unsigned char *) p, fp->path_name, len);
}
@@ -370,10 +375,19 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0)
*p = '\0';
- /* EFI breaks paths with backslashes. */
- for (p = name; *p; p++)
- if (*p == '\\')
- *p = '/';
+ for (pi = name, p = name; *pi;)
+ {
+ /* EFI breaks paths with backslashes. */
+ if (*pi == '\\' || *pi == '/')
+ {
+ *p++ = '/';
+ while (*pi == '\\' || *pi == '/')
+ pi++;
+ continue;
+ }
+ *p++ = *pi++;
+ }
+ *p = '\0';
return name;
}
@@ -385,6 +399,75 @@ grub_efi_get_device_path (grub_efi_handle_t handle)
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
}
+/* Return the device path node right before the end node. */
+grub_efi_device_path_t *
+grub_efi_find_last_device_path (const grub_efi_device_path_t *dp)
+{
+ grub_efi_device_path_t *next, *p;
+
+ if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
+ return 0;
+
+ for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH (p);
+ ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next);
+ p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next))
+ ;
+
+ return p;
+}
+
+/* Duplicate a device path. */
+grub_efi_device_path_t *
+grub_efi_duplicate_device_path (const grub_efi_device_path_t *dp)
+{
+ grub_efi_device_path_t *p;
+ grub_size_t total_size = 0;
+
+ for (p = (grub_efi_device_path_t *) dp;
+ ;
+ p = GRUB_EFI_NEXT_DEVICE_PATH (p))
+ {
+ total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p);
+ if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p))
+ break;
+ }
+
+ p = grub_malloc (total_size);
+ if (! p)
+ return 0;
+
+ grub_memcpy (p, dp, total_size);
+ return p;
+}
+
+static void
+dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor)
+{
+ grub_uint32_t vendor_data_len = vendor->header.length - sizeof (*vendor);
+ grub_printf ("/%sVendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)[%x: ",
+ type,
+ (unsigned) vendor->vendor_guid.data1,
+ (unsigned) vendor->vendor_guid.data2,
+ (unsigned) vendor->vendor_guid.data3,
+ (unsigned) vendor->vendor_guid.data4[0],
+ (unsigned) vendor->vendor_guid.data4[1],
+ (unsigned) vendor->vendor_guid.data4[2],
+ (unsigned) vendor->vendor_guid.data4[3],
+ (unsigned) vendor->vendor_guid.data4[4],
+ (unsigned) vendor->vendor_guid.data4[5],
+ (unsigned) vendor->vendor_guid.data4[6],
+ (unsigned) vendor->vendor_guid.data4[7],
+ vendor_data_len);
+ if (vendor->header.length > sizeof (*vendor))
+ {
+ grub_uint32_t i;
+ for (i = 0; i < vendor_data_len; i++)
+ grub_printf ("%02x ", vendor->vendor_defined_data[i]);
+ }
+ grub_printf ("]");
+}
+
+
/* Print the chain of Device Path nodes. This is mainly for debugging. */
void
grub_efi_print_device_path (grub_efi_device_path_t *dp)
@@ -419,53 +502,40 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
{
case GRUB_EFI_PCI_DEVICE_PATH_SUBTYPE:
{
- grub_efi_pci_device_path_t pci;
- grub_memcpy (&pci, dp, len);
+ grub_efi_pci_device_path_t *pci
+ = (grub_efi_pci_device_path_t *) dp;
grub_printf ("/PCI(%x,%x)",
- (unsigned) pci.function, (unsigned) pci.device);
+ (unsigned) pci->function, (unsigned) pci->device);
}
break;
case GRUB_EFI_PCCARD_DEVICE_PATH_SUBTYPE:
{
- grub_efi_pccard_device_path_t pccard;
- grub_memcpy (&pccard, dp, len);
+ grub_efi_pccard_device_path_t *pccard
+ = (grub_efi_pccard_device_path_t *) dp;
grub_printf ("/PCCARD(%x)",
- (unsigned) pccard.function);
+ (unsigned) pccard->function);
}
break;
case GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE:
{
- grub_efi_memory_mapped_device_path_t mmapped;
- grub_memcpy (&mmapped, dp, len);
+ grub_efi_memory_mapped_device_path_t *mmapped
+ = (grub_efi_memory_mapped_device_path_t *) dp;
grub_printf ("/MMap(%x,%llx,%llx)",
- (unsigned) mmapped.memory_type,
- (unsigned long long) mmapped.start_address,
- (unsigned long long) mmapped.end_address);
+ (unsigned) mmapped->memory_type,
+ (unsigned long long) mmapped->start_address,
+ (unsigned long long) mmapped->end_address);
}
break;
case GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE:
- {
- grub_efi_vendor_device_path_t *vendor = (grub_efi_vendor_device_path_t *) dp;
- grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
- (unsigned) vendor->vendor_guid.data1,
- (unsigned) vendor->vendor_guid.data2,
- (unsigned) vendor->vendor_guid.data3,
- (unsigned) vendor->vendor_guid.data4[0],
- (unsigned) vendor->vendor_guid.data4[1],
- (unsigned) vendor->vendor_guid.data4[2],
- (unsigned) vendor->vendor_guid.data4[3],
- (unsigned) vendor->vendor_guid.data4[4],
- (unsigned) vendor->vendor_guid.data4[5],
- (unsigned) vendor->vendor_guid.data4[6],
- (unsigned) vendor->vendor_guid.data4[7]);
- }
+ dump_vendor_path ("Hardware",
+ (grub_efi_vendor_device_path_t *) dp);
break;
case GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE:
{
- grub_efi_controller_device_path_t controller;
- grub_memcpy (&controller, dp, len);
+ grub_efi_controller_device_path_t *controller
+ = (grub_efi_controller_device_path_t *) dp;
grub_printf ("/Ctrl(%x)",
- (unsigned) controller.controller_number);
+ (unsigned) controller->controller_number);
}
break;
default:
@@ -479,31 +549,31 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
{
case GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE:
{
- grub_efi_acpi_device_path_t acpi;
- grub_memcpy (&acpi, dp, len);
+ grub_efi_acpi_device_path_t *acpi
+ = (grub_efi_acpi_device_path_t *) dp;
grub_printf ("/ACPI(%x,%x)",
- (unsigned) acpi.hid,
- (unsigned) acpi.uid);
+ (unsigned) acpi->hid,
+ (unsigned) acpi->uid);
}
break;
case GRUB_EFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE:
{
- grub_efi_expanded_acpi_device_path_t eacpi;
- grub_memcpy (&eacpi, dp, sizeof (eacpi));
+ grub_efi_expanded_acpi_device_path_t *eacpi
+ = (grub_efi_expanded_acpi_device_path_t *) dp;
grub_printf ("/ACPI(");
if (GRUB_EFI_EXPANDED_ACPI_HIDSTR (dp)[0] == '\0')
- grub_printf ("%x,", (unsigned) eacpi.hid);
+ grub_printf ("%x,", (unsigned) eacpi->hid);
else
grub_printf ("%s,", GRUB_EFI_EXPANDED_ACPI_HIDSTR (dp));
if (GRUB_EFI_EXPANDED_ACPI_UIDSTR (dp)[0] == '\0')
- grub_printf ("%x,", (unsigned) eacpi.uid);
+ grub_printf ("%x,", (unsigned) eacpi->uid);
else
grub_printf ("%s,", GRUB_EFI_EXPANDED_ACPI_UIDSTR (dp));
if (GRUB_EFI_EXPANDED_ACPI_CIDSTR (dp)[0] == '\0')
- grub_printf ("%x)", (unsigned) eacpi.cid);
+ grub_printf ("%x)", (unsigned) eacpi->cid);
else
grub_printf ("%s)", GRUB_EFI_EXPANDED_ACPI_CIDSTR (dp));
}
@@ -519,167 +589,165 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
{
case GRUB_EFI_ATAPI_DEVICE_PATH_SUBTYPE:
{
- grub_efi_atapi_device_path_t atapi;
- grub_memcpy (&atapi, dp, len);
+ grub_efi_atapi_device_path_t *atapi
+ = (grub_efi_atapi_device_path_t *) dp;
grub_printf ("/ATAPI(%x,%x,%x)",
- (unsigned) atapi.primary_secondary,
- (unsigned) atapi.slave_master,
- (unsigned) atapi.lun);
+ (unsigned) atapi->primary_secondary,
+ (unsigned) atapi->slave_master,
+ (unsigned) atapi->lun);
}
break;
case GRUB_EFI_SCSI_DEVICE_PATH_SUBTYPE:
{
- grub_efi_scsi_device_path_t scsi;
- grub_memcpy (&scsi, dp, len);
+ grub_efi_scsi_device_path_t *scsi
+ = (grub_efi_scsi_device_path_t *) dp;
grub_printf ("/SCSI(%x,%x)",
- (unsigned) scsi.pun,
- (unsigned) scsi.lun);
+ (unsigned) scsi->pun,
+ (unsigned) scsi->lun);
}
break;
case GRUB_EFI_FIBRE_CHANNEL_DEVICE_PATH_SUBTYPE:
{
- grub_efi_fibre_channel_device_path_t fc;
- grub_memcpy (&fc, dp, len);
+ grub_efi_fibre_channel_device_path_t *fc
+ = (grub_efi_fibre_channel_device_path_t *) dp;
grub_printf ("/FibreChannel(%llx,%llx)",
- (unsigned long long) fc.wwn,
- (unsigned long long) fc.lun);
+ (unsigned long long) fc->wwn,
+ (unsigned long long) fc->lun);
}
break;
case GRUB_EFI_1394_DEVICE_PATH_SUBTYPE:
{
- grub_efi_1394_device_path_t firewire;
- grub_memcpy (&firewire, dp, len);
- grub_printf ("/1394(%llx)", (unsigned long long) firewire.guid);
+ grub_efi_1394_device_path_t *firewire
+ = (grub_efi_1394_device_path_t *) dp;
+ grub_printf ("/1394(%llx)",
+ (unsigned long long) firewire->guid);
}
break;
case GRUB_EFI_USB_DEVICE_PATH_SUBTYPE:
{
- grub_efi_usb_device_path_t usb;
- grub_memcpy (&usb, dp, len);
+ grub_efi_usb_device_path_t *usb
+ = (grub_efi_usb_device_path_t *) dp;
grub_printf ("/USB(%x,%x)",
- (unsigned) usb.parent_port_number,
- (unsigned) usb.usb_interface);
+ (unsigned) usb->parent_port_number,
+ (unsigned) usb->usb_interface);
}
break;
case GRUB_EFI_USB_CLASS_DEVICE_PATH_SUBTYPE:
{
- grub_efi_usb_class_device_path_t usb_class;
- grub_memcpy (&usb_class, dp, len);
+ grub_efi_usb_class_device_path_t *usb_class
+ = (grub_efi_usb_class_device_path_t *) dp;
grub_printf ("/USBClass(%x,%x,%x,%x,%x)",
- (unsigned) usb_class.vendor_id,
- (unsigned) usb_class.product_id,
- (unsigned) usb_class.device_class,
- (unsigned) usb_class.device_subclass,
- (unsigned) usb_class.device_protocol);
+ (unsigned) usb_class->vendor_id,
+ (unsigned) usb_class->product_id,
+ (unsigned) usb_class->device_class,
+ (unsigned) usb_class->device_subclass,
+ (unsigned) usb_class->device_protocol);
}
break;
case GRUB_EFI_I2O_DEVICE_PATH_SUBTYPE:
{
- grub_efi_i2o_device_path_t i2o;
- grub_memcpy (&i2o, dp, len);
- grub_printf ("/I2O(%x)", (unsigned) i2o.tid);
+ grub_efi_i2o_device_path_t *i2o
+ = (grub_efi_i2o_device_path_t *) dp;
+ grub_printf ("/I2O(%x)", (unsigned) i2o->tid);
}
break;
case GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE:
{
- grub_efi_mac_address_device_path_t mac;
- grub_memcpy (&mac, dp, len);
+ grub_efi_mac_address_device_path_t *mac
+ = (grub_efi_mac_address_device_path_t *) dp;
grub_printf ("/MacAddr(%02x:%02x:%02x:%02x:%02x:%02x,%x)",
- (unsigned) mac.mac_address[0],
- (unsigned) mac.mac_address[1],
- (unsigned) mac.mac_address[2],
- (unsigned) mac.mac_address[3],
- (unsigned) mac.mac_address[4],
- (unsigned) mac.mac_address[5],
- (unsigned) mac.if_type);
+ (unsigned) mac->mac_address[0],
+ (unsigned) mac->mac_address[1],
+ (unsigned) mac->mac_address[2],
+ (unsigned) mac->mac_address[3],
+ (unsigned) mac->mac_address[4],
+ (unsigned) mac->mac_address[5],
+ (unsigned) mac->if_type);
}
break;
case GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE:
{
- grub_efi_ipv4_device_path_t ipv4;
- grub_memcpy (&ipv4, dp, len);
+ grub_efi_ipv4_device_path_t *ipv4
+ = (grub_efi_ipv4_device_path_t *) dp;
grub_printf ("/IPv4(%u.%u.%u.%u,%u.%u.%u.%u,%u,%u,%x,%x)",
- (unsigned) ipv4.local_ip_address[0],
- (unsigned) ipv4.local_ip_address[1],
- (unsigned) ipv4.local_ip_address[2],
- (unsigned) ipv4.local_ip_address[3],
- (unsigned) ipv4.remote_ip_address[0],
- (unsigned) ipv4.remote_ip_address[1],
- (unsigned) ipv4.remote_ip_address[2],
- (unsigned) ipv4.remote_ip_address[3],
- (unsigned) ipv4.local_port,
- (unsigned) ipv4.remote_port,
- (unsigned) ipv4.protocol,
- (unsigned) ipv4.static_ip_address);
+ (unsigned) ipv4->local_ip_address[0],
+ (unsigned) ipv4->local_ip_address[1],
+ (unsigned) ipv4->local_ip_address[2],
+ (unsigned) ipv4->local_ip_address[3],
+ (unsigned) ipv4->remote_ip_address[0],
+ (unsigned) ipv4->remote_ip_address[1],
+ (unsigned) ipv4->remote_ip_address[2],
+ (unsigned) ipv4->remote_ip_address[3],
+ (unsigned) ipv4->local_port,
+ (unsigned) ipv4->remote_port,
+ (unsigned) ipv4->protocol,
+ (unsigned) ipv4->static_ip_address);
}
break;
case GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE:
{
- grub_efi_ipv6_device_path_t ipv6;
- grub_memcpy (&ipv6, dp, len);
+ grub_efi_ipv6_device_path_t *ipv6
+ = (grub_efi_ipv6_device_path_t *) dp;
grub_printf ("/IPv6(%x:%x:%x:%x:%x:%x:%x:%x,%x:%x:%x:%x:%x:%x:%x:%x,%u,%u,%x,%x)",
- (unsigned) ipv6.local_ip_address[0],
- (unsigned) ipv6.local_ip_address[1],
- (unsigned) ipv6.local_ip_address[2],
- (unsigned) ipv6.local_ip_address[3],
- (unsigned) ipv6.local_ip_address[4],
- (unsigned) ipv6.local_ip_address[5],
- (unsigned) ipv6.local_ip_address[6],
- (unsigned) ipv6.local_ip_address[7],
- (unsigned) ipv6.remote_ip_address[0],
- (unsigned) ipv6.remote_ip_address[1],
- (unsigned) ipv6.remote_ip_address[2],
- (unsigned) ipv6.remote_ip_address[3],
- (unsigned) ipv6.remote_ip_address[4],
- (unsigned) ipv6.remote_ip_address[5],
- (unsigned) ipv6.remote_ip_address[6],
- (unsigned) ipv6.remote_ip_address[7],
- (unsigned) ipv6.local_port,
- (unsigned) ipv6.remote_port,
- (unsigned) ipv6.protocol,
- (unsigned) ipv6.static_ip_address);
+ (unsigned) ipv6->local_ip_address[0],
+ (unsigned) ipv6->local_ip_address[1],
+ (unsigned) ipv6->local_ip_address[2],
+ (unsigned) ipv6->local_ip_address[3],
+ (unsigned) ipv6->local_ip_address[4],
+ (unsigned) ipv6->local_ip_address[5],
+ (unsigned) ipv6->local_ip_address[6],
+ (unsigned) ipv6->local_ip_address[7],
+ (unsigned) ipv6->remote_ip_address[0],
+ (unsigned) ipv6->remote_ip_address[1],
+ (unsigned) ipv6->remote_ip_address[2],
+ (unsigned) ipv6->remote_ip_address[3],
+ (unsigned) ipv6->remote_ip_address[4],
+ (unsigned) ipv6->remote_ip_address[5],
+ (unsigned) ipv6->remote_ip_address[6],
+ (unsigned) ipv6->remote_ip_address[7],
+ (unsigned) ipv6->local_port,
+ (unsigned) ipv6->remote_port,
+ (unsigned) ipv6->protocol,
+ (unsigned) ipv6->static_ip_address);
}
break;
case GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE:
{
- grub_efi_infiniband_device_path_t ib;
- grub_memcpy (&ib, dp, len);
+ grub_efi_infiniband_device_path_t *ib
+ = (grub_efi_infiniband_device_path_t *) dp;
grub_printf ("/InfiniBand(%x,%llx,%llx,%llx)",
- (unsigned) ib.port_gid[0], /* XXX */
- (unsigned long long) ib.remote_id,
- (unsigned long long) ib.target_port_id,
- (unsigned long long) ib.device_id);
+ (unsigned) ib->port_gid[0], /* XXX */
+ (unsigned long long) ib->remote_id,
+ (unsigned long long) ib->target_port_id,
+ (unsigned long long) ib->device_id);
}
break;
case GRUB_EFI_UART_DEVICE_PATH_SUBTYPE:
{
- grub_efi_uart_device_path_t uart;
- grub_memcpy (&uart, dp, len);
+ grub_efi_uart_device_path_t *uart
+ = (grub_efi_uart_device_path_t *) dp;
grub_printf ("/UART(%llu,%u,%x,%x)",
- (unsigned long long) uart.baud_rate,
- uart.data_bits,
- uart.parity,
- uart.stop_bits);
+ (unsigned long long) uart->baud_rate,
+ uart->data_bits,
+ uart->parity,
+ uart->stop_bits);
}
break;
- case GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE:
+ case GRUB_EFI_SATA_DEVICE_PATH_SUBTYPE:
{
- grub_efi_vendor_messaging_device_path_t *vendor
- = (grub_efi_vendor_messaging_device_path_t *) dp;
- grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
- (unsigned) vendor->vendor_guid.data1,
- (unsigned) vendor->vendor_guid.data2,
- (unsigned) vendor->vendor_guid.data3,
- (unsigned) vendor->vendor_guid.data4[0],
- (unsigned) vendor->vendor_guid.data4[1],
- (unsigned) vendor->vendor_guid.data4[2],
- (unsigned) vendor->vendor_guid.data4[3],
- (unsigned) vendor->vendor_guid.data4[4],
- (unsigned) vendor->vendor_guid.data4[5],
- (unsigned) vendor->vendor_guid.data4[6],
- (unsigned) vendor->vendor_guid.data4[7]);
+ grub_efi_sata_device_path_t *sata;
+ sata = (grub_efi_sata_device_path_t *) dp;
+ grub_printf ("/Sata(%x,%x,%x)",
+ sata->hba_port,
+ sata->multiplier_port,
+ sata->lun);
}
break;
+
+ case GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE:
+ dump_vendor_path ("Messaging",
+ (grub_efi_vendor_device_path_t *) dp);
+ break;
default:
grub_printf ("/UnknownMessaging(%x)", (unsigned) subtype);
break;
@@ -710,31 +778,17 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
break;
case GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE:
{
- grub_efi_cdrom_device_path_t cd;
- grub_memcpy (&cd, dp, len);
+ grub_efi_cdrom_device_path_t *cd
+ = (grub_efi_cdrom_device_path_t *) dp;
grub_printf ("/CD(%u,%llx,%llx)",
- cd.boot_entry,
- (unsigned long long) cd.partition_start,
- (unsigned long long) cd.partition_size);
+ cd->boot_entry,
+ (unsigned long long) cd->partition_start,
+ (unsigned long long) cd->partition_size);
}
break;
case GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE:
- {
- grub_efi_vendor_device_path_t *vendor = (grub_efi_vendor_device_path_t *) dp;
-
- grub_printf ("/Vendor(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
- (unsigned) vendor->vendor_guid.data1,
- (unsigned) vendor->vendor_guid.data2,
- (unsigned) vendor->vendor_guid.data3,
- (unsigned) vendor->vendor_guid.data4[0],
- (unsigned) vendor->vendor_guid.data4[1],
- (unsigned) vendor->vendor_guid.data4[2],
- (unsigned) vendor->vendor_guid.data4[3],
- (unsigned) vendor->vendor_guid.data4[4],
- (unsigned) vendor->vendor_guid.data4[5],
- (unsigned) vendor->vendor_guid.data4[6],
- (unsigned) vendor->vendor_guid.data4[7]);
- }
+ dump_vendor_path ("Media",
+ (grub_efi_vendor_device_path_t *) dp);
break;
case GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE:
{
@@ -754,20 +808,20 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
break;
case GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE:
{
- grub_efi_protocol_device_path_t proto;
- grub_memcpy (&proto, dp, sizeof (proto));
+ grub_efi_protocol_device_path_t *proto
+ = (grub_efi_protocol_device_path_t *) dp;
grub_printf ("/Protocol(%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x)",
- (unsigned) proto.guid.data1,
- (unsigned) proto.guid.data2,
- (unsigned) proto.guid.data3,
- (unsigned) proto.guid.data4[0],
- (unsigned) proto.guid.data4[1],
- (unsigned) proto.guid.data4[2],
- (unsigned) proto.guid.data4[3],
- (unsigned) proto.guid.data4[4],
- (unsigned) proto.guid.data4[5],
- (unsigned) proto.guid.data4[6],
- (unsigned) proto.guid.data4[7]);
+ (unsigned) proto->guid.data1,
+ (unsigned) proto->guid.data2,
+ (unsigned) proto->guid.data3,
+ (unsigned) proto->guid.data4[0],
+ (unsigned) proto->guid.data4[1],
+ (unsigned) proto->guid.data4[2],
+ (unsigned) proto->guid.data4[3],
+ (unsigned) proto->guid.data4[4],
+ (unsigned) proto->guid.data4[5],
+ (unsigned) proto->guid.data4[6],
+ (unsigned) proto->guid.data4[7]);
}
break;
default:
@@ -781,11 +835,11 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
{
case GRUB_EFI_BIOS_DEVICE_PATH_SUBTYPE:
{
- grub_efi_bios_device_path_t bios;
- grub_memcpy (&bios, dp, sizeof (bios));
+ grub_efi_bios_device_path_t *bios
+ = (grub_efi_bios_device_path_t *) dp;
grub_printf ("/BIOS(%x,%x,%s)",
- (unsigned) bios.device_type,
- (unsigned) bios.status_flags,
+ (unsigned) bios->device_type,
+ (unsigned) bios->status_flags,
(char *) (dp + 1));
}
break;
diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c
index 942ab0256..e9c85de12 100644
--- a/grub-core/kern/efi/init.c
+++ b/grub-core/kern/efi/init.c
@@ -63,10 +63,13 @@ grub_machine_get_bootlocation (char **device, char **path)
if (!*device && grub_efi_net_config)
grub_efi_net_config (image->device_handle, device, path);
- /* Get the directory. */
- p = grub_strrchr (*path, '/');
- if (p)
- *p = '\0';
+ if (*path)
+ {
+ /* Get the directory. */
+ p = grub_strrchr (*path, '/');
+ if (p)
+ *p = '\0';
+ }
}
void
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index be37afd9d..20a47aaf5 100644
--- a/grub-core/kern/efi/mm.c
+++ b/grub-core/kern/efi/mm.c
@@ -230,6 +230,7 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size,
grub_efi_boot_services_t *b;
grub_efi_uintn_t key;
grub_efi_uint32_t version;
+ grub_efi_uintn_t size;
if (grub_efi_is_finished)
{
@@ -259,10 +260,14 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size,
map_key = &key;
if (! descriptor_version)
descriptor_version = &version;
+ if (! descriptor_size)
+ descriptor_size = &size;
b = grub_efi_system_table->boot_services;
status = efi_call_5 (b->get_memory_map, memory_map_size, memory_map, map_key,
descriptor_size, descriptor_version);
+ if (*descriptor_size == 0)
+ *descriptor_size = sizeof (grub_efi_memory_descriptor_t);
if (status == GRUB_EFI_SUCCESS)
return 1;
else if (status == GRUB_EFI_BUFFER_TOO_SMALL)
diff --git a/grub-core/kern/elf.c b/grub-core/kern/elf.c
index 5f99c43cc..4f282c9cf 100644
--- a/grub-core/kern/elf.c
+++ b/grub-core/kern/elf.c
@@ -28,6 +28,25 @@
GRUB_MOD_LICENSE ("GPLv3+");
+#pragma GCC diagnostic ignored "-Wcast-align"
+
+#if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275)
+#define GRUB_ELF_ENABLE_BI_ENDIAN 1
+#else
+#define GRUB_ELF_ENABLE_BI_ENDIAN 0
+#endif
+
+#if defined(GRUB_CPU_WORDS_BIGENDIAN)
+#define GRUB_ELF_NATIVE_ENDIANNESS ELFDATA2MSB
+#define GRUB_ELF_OPPOSITE_ENDIANNESS ELFDATA2LSB
+#else
+#define GRUB_ELF_NATIVE_ENDIANNESS ELFDATA2LSB
+#define GRUB_ELF_OPPOSITE_ENDIANNESS ELFDATA2MSB
+#endif
+
+static int grub_elf32_check_endianess_and_bswap_ehdr (grub_elf_t elf);
+static int grub_elf64_check_endianess_and_bswap_ehdr (grub_elf_t elf);
+
/* Check if EHDR is a valid ELF header. */
static grub_err_t
grub_elf_check_header (grub_elf_t elf)
@@ -38,8 +57,25 @@ grub_elf_check_header (grub_elf_t elf)
|| e->e_ident[EI_MAG1] != ELFMAG1
|| e->e_ident[EI_MAG2] != ELFMAG2
|| e->e_ident[EI_MAG3] != ELFMAG3
- || e->e_ident[EI_VERSION] != EV_CURRENT
- || e->e_version != EV_CURRENT)
+ || e->e_ident[EI_VERSION] != EV_CURRENT)
+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF magic"));
+
+ if (grub_elf_is_elf32 (elf))
+ {
+ if (!grub_elf32_check_endianess_and_bswap_ehdr (elf)) {
+ return grub_error (GRUB_ERR_BAD_OS, "invalid ELF endianness magic");
+ }
+ }
+ else if (grub_elf_is_elf64 (elf))
+ {
+ if (!grub_elf64_check_endianess_and_bswap_ehdr (elf)) {
+ return grub_error (GRUB_ERR_BAD_OS, "invalid ELF endianness magic");
+ }
+ }
+ else
+ return grub_error (GRUB_ERR_BAD_OS, "unknown ELF class");
+
+ if (e->e_version != EV_CURRENT)
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF magic"));
return GRUB_ERR_NONE;
@@ -117,6 +153,9 @@ grub_elf_open (const char *name)
}
+#define grub_swap_bytes_halfXX grub_swap_bytes16
+#define grub_swap_bytes_wordXX grub_swap_bytes32
+
/* 32-bit */
#define ehdrXX ehdr32
#define ELFCLASSXX ELFCLASS32
@@ -127,7 +166,12 @@ grub_elf_open (const char *name)
#define grub_elf_is_elfXX grub_elf_is_elf32
#define grub_elfXX_load_phdrs grub_elf32_load_phdrs
#define ElfXX_Phdr Elf32_Phdr
+#define ElfXX_Ehdr Elf32_Ehdr
#define grub_uintXX_t grub_uint32_t
+#define grub_swap_bytes_addrXX grub_swap_bytes32
+#define grub_swap_bytes_offXX grub_swap_bytes32
+#define grub_swap_bytes_XwordXX grub_swap_bytes32
+#define grub_elfXX_check_endianess_and_bswap_ehdr grub_elf32_check_endianess_and_bswap_ehdr
#include "elfXX.c"
@@ -140,7 +184,12 @@ grub_elf_open (const char *name)
#undef grub_elf_is_elfXX
#undef grub_elfXX_load_phdrs
#undef ElfXX_Phdr
+#undef ElfXX_Ehdr
#undef grub_uintXX_t
+#undef grub_swap_bytes_addrXX
+#undef grub_swap_bytes_offXX
+#undef grub_swap_bytes_XwordXX
+#undef grub_elfXX_check_endianess_and_bswap_ehdr
/* 64-bit */
@@ -153,6 +202,11 @@ grub_elf_open (const char *name)
#define grub_elf_is_elfXX grub_elf_is_elf64
#define grub_elfXX_load_phdrs grub_elf64_load_phdrs
#define ElfXX_Phdr Elf64_Phdr
+#define ElfXX_Ehdr Elf64_Ehdr
#define grub_uintXX_t grub_uint64_t
+#define grub_swap_bytes_addrXX grub_swap_bytes64
+#define grub_swap_bytes_offXX grub_swap_bytes64
+#define grub_swap_bytes_XwordXX grub_swap_bytes64
+#define grub_elfXX_check_endianess_and_bswap_ehdr grub_elf64_check_endianess_and_bswap_ehdr
#include "elfXX.c"
diff --git a/grub-core/kern/elfXX.c b/grub-core/kern/elfXX.c
index 1d0997186..1859d1880 100644
--- a/grub-core/kern/elfXX.c
+++ b/grub-core/kern/elfXX.c
@@ -12,7 +12,7 @@ grub_elfXX_load_phdrs (grub_elf_t elf)
if (elf->phdrs)
return GRUB_ERR_NONE;
- phdrs_size = elf->ehdr.ehdrXX.e_phnum * elf->ehdr.ehdrXX.e_phentsize;
+ phdrs_size = (grub_uint32_t) elf->ehdr.ehdrXX.e_phnum * elf->ehdr.ehdrXX.e_phentsize;
grub_dprintf ("elf", "Loading program headers at 0x%llx, size 0x%lx.\n",
(unsigned long long) elf->ehdr.ehdrXX.e_phoff,
@@ -31,6 +31,25 @@ grub_elfXX_load_phdrs (grub_elf_t elf)
return grub_errno;
}
+#if GRUB_ELF_ENABLE_BI_ENDIAN
+ if (elf->ehdr.ehdrXX.e_ident[EI_DATA] == GRUB_ELF_OPPOSITE_ENDIANNESS)
+ {
+ ElfXX_Phdr *phdr;
+ for (phdr = elf->phdrs; (char *) phdr < (char *) elf->phdrs + phdrs_size;
+ phdr = (ElfXX_Phdr *) ((char *) phdr + elf->ehdr.ehdrXX.e_phentsize))
+ {
+ phdr->p_type = grub_swap_bytes_wordXX (phdr->p_type);
+ phdr->p_flags = grub_swap_bytes_wordXX (phdr->p_flags);
+ phdr->p_offset = grub_swap_bytes_offXX (phdr->p_offset);
+ phdr->p_vaddr = grub_swap_bytes_addrXX (phdr->p_vaddr);
+ phdr->p_paddr = grub_swap_bytes_addrXX (phdr->p_paddr);
+ phdr->p_filesz = grub_swap_bytes_XwordXX (phdr->p_filesz);
+ phdr->p_memsz = grub_swap_bytes_XwordXX (phdr->p_memsz);
+ phdr->p_align = grub_swap_bytes_XwordXX (phdr->p_align);
+ }
+ }
+#endif /* GRUB_ELF_ENABLE_BI_ENDIAN */
+
return GRUB_ERR_NONE;
}
@@ -154,3 +173,35 @@ grub_elfXX_load (grub_elf_t elf, const char *filename,
return grub_errno;
}
+
+static int
+grub_elfXX_check_endianess_and_bswap_ehdr (grub_elf_t elf)
+{
+ ElfXX_Ehdr *e = &(elf->ehdr.ehdrXX);
+ if (e->e_ident[EI_DATA] == GRUB_ELF_NATIVE_ENDIANNESS)
+ {
+ return 1;
+ }
+
+#if GRUB_ELF_ENABLE_BI_ENDIAN
+ if (e->e_ident[EI_DATA] == GRUB_ELF_OPPOSITE_ENDIANNESS)
+ {
+ e->e_type = grub_swap_bytes_halfXX (e->e_type);
+ e->e_machine = grub_swap_bytes_halfXX (e->e_machine);
+ e->e_version = grub_swap_bytes_wordXX (e->e_version);
+ e->e_entry = grub_swap_bytes_addrXX (e->e_entry);
+ e->e_phoff = grub_swap_bytes_offXX (e->e_phoff);
+ e->e_shoff = grub_swap_bytes_offXX (e->e_shoff);
+ e->e_flags = grub_swap_bytes_wordXX (e->e_flags);
+ e->e_ehsize = grub_swap_bytes_halfXX (e->e_ehsize);
+ e->e_phentsize = grub_swap_bytes_halfXX (e->e_phentsize);
+ e->e_phnum = grub_swap_bytes_halfXX (e->e_phnum);
+ e->e_shentsize = grub_swap_bytes_halfXX (e->e_shentsize);
+ e->e_shnum = grub_swap_bytes_halfXX (e->e_shnum);
+ e->e_shstrndx = grub_swap_bytes_halfXX (e->e_shstrndx);
+ return 1;
+ }
+#endif /* GRUB_ELF_ENABLE_BI_ENDIAN */
+
+ return 0;
+}
diff --git a/grub-core/kern/emu/argp_common.c b/grub-core/kern/emu/argp_common.c
index 4aca01550..166885870 100644
--- a/grub-core/kern/emu/argp_common.c
+++ b/grub-core/kern/emu/argp_common.c
@@ -21,6 +21,7 @@
#include <config-util.h>
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define _GNU_SOURCE 1
#include <stdlib.h>
diff --git a/grub-core/kern/emu/cache.c b/grub-core/kern/emu/cache.c
index 07be6756f..6f89e871a 100644
--- a/grub-core/kern/emu/cache.c
+++ b/grub-core/kern/emu/cache.c
@@ -8,7 +8,7 @@
#include "../ia64/cache.c"
#elif defined (__arm__) || defined (__aarch64__)
-void __clear_cache (char *beg, char *end);
+void __clear_cache (void *beg, void *end);
void
grub_arch_sync_caches (void *address, grub_size_t len)
diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c
index 44b0fcbb1..87e3e2512 100644
--- a/grub-core/kern/emu/hostdisk.c
+++ b/grub-core/kern/emu/hostdisk.c
@@ -99,7 +99,7 @@ find_free_slot (void)
{
unsigned int i;
- for (i = 0; i < sizeof (map) / sizeof (map[0]); i++)
+ for (i = 0; i < ARRAY_SIZE (map); i++)
if (! map[i].drive)
return i;
@@ -115,7 +115,7 @@ grub_util_biosdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
if (pull != GRUB_DISK_PULL_NONE)
return 0;
- for (i = 0; i < sizeof (map) / sizeof (map[0]); i++)
+ for (i = 0; i < ARRAY_SIZE (map); i++)
if (map[i].drive && hook (map[i].drive, hook_data))
return 1;
@@ -161,9 +161,9 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
{
struct stat st;
# if GRUB_DISK_DEVS_ARE_CHAR
- if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode))
+ if (fstat (fd, &st) >= 0 && S_ISCHR (st.st_mode))
# else
- if (fstat (fd, &st) < 0 || ! S_ISBLK (st.st_mode))
+ if (fstat (fd, &st) >= 0 && S_ISBLK (st.st_mode))
# endif
data->is_disk = 1;
}
@@ -184,7 +184,7 @@ grub_hostdisk_os_dev_to_grub_drive (const char *os_disk, int add)
unsigned int i;
char *canon;
- canon = canonicalize_file_name (os_disk);
+ canon = grub_canonicalize_file_name (os_disk);
if (!canon)
canon = xstrdup (os_disk);
@@ -422,7 +422,7 @@ read_device_map (const char *dev_map)
char buf[1024]; /* XXX */
int lineno = 0;
- if (dev_map[0] == '\0')
+ if (!dev_map || dev_map[0] == '\0')
{
grub_util_info ("no device.map");
return;
@@ -535,7 +535,7 @@ read_device_map (const char *dev_map)
/* On Linux, the devfs uses symbolic links horribly, and that
confuses the interface very much, so use realpath to expand
symbolic links. */
- map[drive].device = canonicalize_file_name (p);
+ map[drive].device = grub_canonicalize_file_name (p);
if (! map[drive].device)
map[drive].device = xstrdup (p);
@@ -581,7 +581,7 @@ grub_util_biosdisk_fini (void)
{
unsigned i;
- for (i = 0; i < sizeof (map) / sizeof (map[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(map); i++)
{
if (map[i].drive)
free (map[i].drive);
diff --git a/grub-core/kern/emu/hostfs.c b/grub-core/kern/emu/hostfs.c
index 7e725f65f..7b28c001f 100644
--- a/grub-core/kern/emu/hostfs.c
+++ b/grub-core/kern/emu/hostfs.c
@@ -19,7 +19,6 @@
#include <config-util.h>
-#define _BSD_SOURCE
#include <grub/fs.h>
#include <grub/file.h>
#include <grub/disk.h>
diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c
index eddb192f9..f91280f68 100644
--- a/grub-core/kern/emu/main.c
+++ b/grub-core/kern/emu/main.c
@@ -66,6 +66,12 @@ grub_reboot (void)
}
void
+grub_exit (void)
+{
+ grub_reboot ();
+}
+
+void
grub_machine_init (void)
{
}
@@ -86,11 +92,16 @@ grub_machine_fini (int flags)
+#define OPT_MEMDISK 257
+
static struct argp_option options[] = {
{"root", 'r', N_("DEVICE_NAME"), 0, N_("Set root device."), 2},
{"device-map", 'm', N_("FILE"), 0,
/* TRANSLATORS: There are many devices in device map. */
N_("use FILE as the device map [default=%s]"), 0},
+ {"memdisk", OPT_MEMDISK, N_("FILE"), 0,
+ /* TRANSLATORS: There are many devices in device map. */
+ N_("use FILE as memdisk"), 0},
{"directory", 'd', N_("DIR"), 0,
N_("use GRUB files in the directory DIR [default=%s]"), 0},
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
@@ -98,6 +109,8 @@ static struct argp_option options[] = {
{ 0, 0, 0, 0, 0, 0 }
};
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static char *
help_filter (int key, const char *text, void *input __attribute__ ((unused)))
{
@@ -112,9 +125,12 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
}
}
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
struct arguments
{
const char *dev_map;
+ const char *mem_disk;
int hold;
};
@@ -127,6 +143,9 @@ argp_parser (int key, char *arg, struct argp_state *state)
switch (key)
{
+ case OPT_MEMDISK:
+ arguments->mem_disk = arg;
+ break;
case 'r':
free (root_dev);
root_dev = xstrdup (arg);
@@ -176,9 +195,13 @@ main (int argc, char *argv[])
struct arguments arguments =
{
.dev_map = DEFAULT_DEVICE_MAP,
- .hold = 0
+ .hold = 0,
+ .mem_disk = 0,
};
volatile int hold = 0;
+ size_t total_module_size = sizeof (struct grub_module_info), memdisk_size = 0;
+ struct grub_module_info *modinfo;
+ void *mods;
grub_util_host_init (&argc, &argv);
@@ -190,6 +213,33 @@ main (int argc, char *argv[])
exit(1);
}
+ if (arguments.mem_disk)
+ {
+ memdisk_size = ALIGN_UP(grub_util_get_image_size (arguments.mem_disk), 512);
+ total_module_size += memdisk_size + sizeof (struct grub_module_header);
+ }
+
+ mods = xmalloc (total_module_size);
+ modinfo = grub_memset (mods, 0, total_module_size);
+ mods = (char *) (modinfo + 1);
+
+ modinfo->magic = GRUB_MODULE_MAGIC;
+ modinfo->offset = sizeof (struct grub_module_info);
+ modinfo->size = total_module_size;
+
+ if (arguments.mem_disk)
+ {
+ struct grub_module_header *header = (struct grub_module_header *) mods;
+ header->type = OBJ_TYPE_MEMDISK;
+ header->size = memdisk_size + sizeof (*header);
+ mods = header + 1;
+
+ grub_util_load_image (arguments.mem_disk, mods);
+ mods = (char *) mods + memdisk_size;
+ }
+
+ grub_modbase = (grub_addr_t) modinfo;
+
hold = arguments.hold;
/* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */
if (hold && verbosity > 0)
diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c
index 43471b4ef..d361feb00 100644
--- a/grub-core/kern/emu/misc.c
+++ b/grub-core/kern/emu/misc.c
@@ -20,7 +20,6 @@
#include <config.h>
#include <errno.h>
-#include <error.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -135,11 +134,13 @@ xasprintf (const char *fmt, ...)
}
#endif
+#if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL)
void
grub_exit (void)
{
exit (1);
}
+#endif
grub_uint64_t
grub_get_time_ms (void)
@@ -150,3 +151,51 @@ grub_get_time_ms (void)
return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
}
+
+size_t
+grub_util_get_image_size (const char *path)
+{
+ FILE *f;
+ size_t ret;
+ off_t sz;
+
+ f = grub_util_fopen (path, "rb");
+
+ if (!f)
+ grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
+
+ fseeko (f, 0, SEEK_END);
+
+ sz = ftello (f);
+ if (sz < 0)
+ grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
+ if (sz != (size_t) sz)
+ grub_util_error (_("file `%s' is too big"), path);
+ ret = (size_t) sz;
+
+ fclose (f);
+
+ return ret;
+}
+
+void
+grub_util_load_image (const char *path, char *buf)
+{
+ FILE *fp;
+ size_t size;
+
+ grub_util_info ("reading %s", path);
+
+ size = grub_util_get_image_size (path);
+
+ fp = grub_util_fopen (path, "rb");
+ if (! fp)
+ grub_util_error (_("cannot open `%s': %s"), path,
+ strerror (errno));
+
+ if (fread (buf, 1, size, fp) != size)
+ grub_util_error (_("cannot read `%s': %s"), path,
+ strerror (errno));
+
+ fclose (fp);
+}
diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c
index 24da12bb9..668f8930b 100644
--- a/grub-core/kern/file.c
+++ b/grub-core/kern/file.c
@@ -89,7 +89,16 @@ grub_file_open (const char *name)
file->device = device;
- if (device->disk && file_name[0] != '/')
+ /* In case of relative pathnames and non-Unix systems (like Windows)
+ * name of host files may not start with `/'. Blocklists for host files
+ * are meaningless as well (for a start, host disk does not allow any direct
+ * access - it is just a marker). So skip host disk in this case.
+ */
+ if (device->disk && file_name[0] != '/'
+#if defined(GRUB_UTIL) || defined(GRUB_MACHINE_EMU)
+ && grub_strcmp (device->disk->name, "host")
+#endif
+ )
/* This is a block list. */
file->fs = &grub_fs_blocklist;
else
diff --git a/grub-core/kern/generic/rtc_get_time_ms.c b/grub-core/kern/generic/rtc_get_time_ms.c
index 49f2acac9..3e39c8fe1 100644
--- a/grub-core/kern/generic/rtc_get_time_ms.c
+++ b/grub-core/kern/generic/rtc_get_time_ms.c
@@ -34,5 +34,5 @@ grub_rtc_get_time_ms (void)
1 s 1 T rtc ticks
*/
grub_uint64_t ticks_ms_per_sec = ((grub_uint64_t) 1000) * grub_get_rtc ();
- return grub_divmod64 (ticks_ms_per_sec, GRUB_TICKS_PER_SECOND, 0);
+ return grub_divmod64 (ticks_ms_per_sec, GRUB_TICKS_PER_SECOND ? : 1000, 0);
}
diff --git a/grub-core/kern/i386/coreboot/cbtable.c b/grub-core/kern/i386/coreboot/cbtable.c
index e3bb7b2e0..1669bc0ca 100644
--- a/grub-core/kern/i386/coreboot/cbtable.c
+++ b/grub-core/kern/i386/coreboot/cbtable.c
@@ -55,7 +55,7 @@ grub_linuxbios_table_iterate (int (*hook) (grub_linuxbios_table_item_t,
if (check_signature (table_header))
goto signature_found;
- grub_fatal ("Could not find coreboot table\n");
+ return 0;
signature_found:
diff --git a/grub-core/kern/i386/coreboot/init.c b/grub-core/kern/i386/coreboot/init.c
index 6b150b47d..3314f027f 100644
--- a/grub-core/kern/i386/coreboot/init.c
+++ b/grub-core/kern/i386/coreboot/init.c
@@ -51,6 +51,7 @@ grub_exit (void)
grub_addr_t grub_modbase = GRUB_KERNEL_I386_COREBOOT_MODULES_ADDR;
static grub_uint64_t modend;
+static int have_memory = 0;
/* Helper for grub_machine_init. */
static int
@@ -82,6 +83,8 @@ heap_init (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - begin));
+ have_memory = 1;
+
return 0;
}
@@ -97,6 +100,8 @@ grub_machine_init (void)
grub_vga_text_init ();
grub_machine_mmap_iterate (heap_init, NULL);
+ if (!have_memory)
+ grub_fatal ("No memory found");
grub_video_coreboot_fb_late_init ();
diff --git a/grub-core/kern/i386/coreboot/mmap.c b/grub-core/kern/i386/coreboot/mmap.c
index 119797551..4d29f6b7d 100644
--- a/grub-core/kern/i386/coreboot/mmap.c
+++ b/grub-core/kern/i386/coreboot/mmap.c
@@ -44,18 +44,44 @@ iterate_linuxbios_table (grub_linuxbios_table_item_t table_item, void *data)
mem_region =
(mem_region_t) ((long) table_item +
sizeof (struct grub_linuxbios_table_item));
- while ((long) mem_region < (long) table_item + (long) table_item->size)
+ for (; (long) mem_region < (long) table_item + (long) table_item->size;
+ mem_region++)
{
- if (ctx->hook (mem_region->addr, mem_region->size,
+ grub_uint64_t start = mem_region->addr;
+ grub_uint64_t end = mem_region->addr + mem_region->size;
+ /* Mark region 0xa0000 - 0x100000 as reserved. */
+ if (start < 0x100000 && end >= 0xa0000
+ && mem_region->type == GRUB_MACHINE_MEMORY_AVAILABLE)
+ {
+ if (start < 0xa0000
+ && ctx->hook (start, 0xa0000 - start,
+ /* Multiboot mmaps match with the coreboot mmap
+ definition. Therefore, we can just pass type
+ through. */
+ mem_region->type,
+ ctx->hook_data))
+ return 1;
+ if (start < 0xa0000)
+ start = 0xa0000;
+ if (start >= end)
+ continue;
+
+ if (ctx->hook (start, (end > 0x100000 ? 0x100000 : end) - start,
+ GRUB_MEMORY_RESERVED,
+ ctx->hook_data))
+ return 1;
+ start = 0x100000;
+
+ if (end <= start)
+ continue;
+ }
+ if (ctx->hook (start, end - start,
/* Multiboot mmaps match with the coreboot mmap
definition. Therefore, we can just pass type
through. */
- (((mem_region->type <= GRUB_MACHINE_MEMORY_BADRAM) && (mem_region->type >= GRUB_MACHINE_MEMORY_AVAILABLE))
- || mem_region->type == GRUB_MEMORY_COREBOOT_TABLES) ? mem_region->type : GRUB_MEMORY_RESERVED,
+ mem_region->type,
ctx->hook_data))
return 1;
-
- mem_region++;
}
return 0;
diff --git a/grub-core/kern/i386/coreboot/startup.S b/grub-core/kern/i386/coreboot/startup.S
index 8c3283846..c8486548d 100644
--- a/grub-core/kern/i386/coreboot/startup.S
+++ b/grub-core/kern/i386/coreboot/startup.S
@@ -61,8 +61,3 @@ multiboot_header:
/* checksum */
.long -0x1BADB002 - MULTIBOOT_MEMORY_INFO
-/*
- * prot_to_real and associated structures (but NOT real_to_prot, that is
- * only needed for BIOS gates).
- */
-#include "../realmode.S"
diff --git a/grub-core/kern/i386/efi/tsc.c b/grub-core/kern/i386/efi/tsc.c
new file mode 100644
index 000000000..4b93ba8e1
--- /dev/null
+++ b/grub-core/kern/i386/efi/tsc.c
@@ -0,0 +1,40 @@
+/* kern/i386/tsc.c - x86 TSC time source implementation
+ * Requires Pentium or better x86 CPU that supports the RDTSC instruction.
+ * This module uses the PIT to calibrate the TSC to
+ * real time.
+ *
+ * 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/types.h>
+#include <grub/time.h>
+#include <grub/misc.h>
+#include <grub/i386/tsc.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/api.h>
+
+int
+grub_tsc_calibrate_from_efi (void)
+{
+ grub_uint64_t start_tsc, end_tsc;
+ /* Use EFI Time Service to calibrate TSC */
+ start_tsc = grub_get_tsc ();
+ efi_call_1 (grub_efi_system_table->boot_services->stall, 1000);
+ end_tsc = grub_get_tsc ();
+ grub_tsc_rate = grub_divmod64 ((1ULL << 32), end_tsc - start_tsc, 0);
+ return 1;
+}
diff --git a/grub-core/kern/i386/int.S b/grub-core/kern/i386/int.S
index 7edace404..862a54202 100644
--- a/grub-core/kern/i386/int.S
+++ b/grub-core/kern/i386/int.S
@@ -44,6 +44,13 @@ FUNCTION(grub_bios_interrupt)
movl 24(%edx), %esi
movl 28(%edx), %edx
+ /*
+ Via C3 CPUs have cache coherence problems, so we need to call
+ wbinvd at these 2 points. As wbinvd slows down boot, don't do
+ it on non-VIA. 9090 is nop nop. */
+VARIABLE(grub_bios_via_workaround1)
+ .byte 0x90, 0x90
+
PROT_TO_REAL
.code16
pushf
@@ -92,6 +99,10 @@ intno:
movw %ax, LOCAL(bios_register_es)
popf
+
+VARIABLE(grub_bios_via_workaround2)
+ .byte 0x90, 0x90
+
REAL_TO_PROT
.code32
diff --git a/grub-core/commands/i386/pc/acpi.c b/grub-core/kern/i386/pc/acpi.c
index d415d2305..297f5d05f 100644
--- a/grub-core/commands/i386/pc/acpi.c
+++ b/grub-core/kern/i386/pc/acpi.c
@@ -29,14 +29,15 @@ grub_machine_acpi_get_rsdpv1 (void)
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4);
ebda_len = * (grub_uint16_t *) ebda;
- if (! ebda_len)
- return 0;
+ if (! ebda_len) /* FIXME do we really need this check? */
+ goto scan_bios;
for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0)
return (struct grub_acpi_rsdp_v10 *) ptr;
+scan_bios:
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
ptr += 16)
@@ -56,8 +57,8 @@ grub_machine_acpi_get_rsdpv2 (void)
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4);
ebda_len = * (grub_uint16_t *) ebda;
- if (! ebda_len)
- return 0;
+ if (! ebda_len) /* FIXME do we really need this check? */
+ goto scan_bios;
for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
@@ -67,6 +68,7 @@ grub_machine_acpi_get_rsdpv2 (void)
== 0)
return (struct grub_acpi_rsdp_v20 *) ptr;
+scan_bios:
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
ptr += 16)
diff --git a/grub-core/kern/i386/pc/init.c b/grub-core/kern/i386/pc/init.c
index 3c8160aab..27bc68b8a 100644
--- a/grub-core/kern/i386/pc/init.c
+++ b/grub-core/kern/i386/pc/init.c
@@ -32,6 +32,7 @@
#include <grub/env.h>
#include <grub/cache.h>
#include <grub/time.h>
+#include <grub/cpu/cpuid.h>
#include <grub/cpu/tsc.h>
#include <grub/machine/time.h>
@@ -184,6 +185,26 @@ mmap_iterate_hook (grub_uint64_t addr, grub_uint64_t size,
return 0;
}
+extern grub_uint16_t grub_bios_via_workaround1, grub_bios_via_workaround2;
+
+/* Via needs additional wbinvd. */
+static void
+grub_via_workaround_init (void)
+{
+ grub_uint32_t manufacturer[3], max_cpuid;
+ if (! grub_cpu_is_cpuid_supported ())
+ return;
+
+ grub_cpuid (0, max_cpuid, manufacturer[0], manufacturer[2], manufacturer[1]);
+
+ if (grub_memcmp (manufacturer, "CentaurHauls", 12) != 0)
+ return;
+
+ grub_bios_via_workaround1 = 0x090f;
+ grub_bios_via_workaround2 = 0x090f;
+ asm volatile ("wbinvd");
+}
+
void
grub_machine_init (void)
{
@@ -193,6 +214,9 @@ grub_machine_init (void)
#endif
grub_addr_t modend;
+ /* This has to happen before any BIOS calls. */
+ grub_via_workaround_init ();
+
grub_modbase = GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR + (_edata - _start);
/* Initialize the console as early as possible. */
diff --git a/grub-core/kern/i386/pc/mmap.c b/grub-core/kern/i386/pc/mmap.c
index 8009e833c..c0c3c3585 100644
--- a/grub-core/kern/i386/pc/mmap.c
+++ b/grub-core/kern/i386/pc/mmap.c
@@ -141,33 +141,35 @@ grub_get_mmap_entry (struct grub_machine_mmap_entry *entry,
grub_err_t
grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
{
- grub_uint32_t cont;
+ grub_uint32_t cont = 0;
struct grub_machine_mmap_entry *entry
= (struct grub_machine_mmap_entry *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+ int e820_works = 0;
- grub_memset (entry, 0, sizeof (entry));
+ while (1)
+ {
+ grub_memset (entry, 0, sizeof (*entry));
- /* Check if grub_get_mmap_entry works. */
- cont = grub_get_mmap_entry (entry, 0);
+ cont = grub_get_mmap_entry (entry, cont);
- if (entry->size)
- do
- {
- if (hook (entry->addr, entry->len,
- /* GRUB mmaps have been defined to match with the E820 definition.
- Therefore, we can just pass type through. */
- entry->type, hook_data))
- break;
+ if (!entry->size)
+ break;
- if (! cont)
- break;
+ if (entry->len)
+ e820_works = 1;
+ if (entry->len
+ && hook (entry->addr, entry->len,
+ /* GRUB mmaps have been defined to match with
+ the E820 definition.
+ Therefore, we can just pass type through. */
+ entry->type, hook_data))
+ break;
- grub_memset (entry, 0, sizeof (entry));
+ if (! cont)
+ break;
+ }
- cont = grub_get_mmap_entry (entry, cont);
- }
- while (entry->size);
- else
+ if (!e820_works)
{
grub_uint32_t eisa_mmap = grub_get_eisa_mmap ();
diff --git a/grub-core/kern/i386/pc/startup.S b/grub-core/kern/i386/pc/startup.S
index 6bb36c603..b8a9b33b4 100644
--- a/grub-core/kern/i386/pc/startup.S
+++ b/grub-core/kern/i386/pc/startup.S
@@ -135,7 +135,7 @@ LOCAL(prot_to_real_addr):
.macro REAL_TO_PROT
movl LOCAL(real_to_prot_addr), %eax
- DATA32 call *%ax
+ calll *%eax
.endm
/*
diff --git a/grub-core/kern/i386/qemu/startup.S b/grub-core/kern/i386/qemu/startup.S
index 3d47d1e4f..0d89858d9 100644
--- a/grub-core/kern/i386/qemu/startup.S
+++ b/grub-core/kern/i386/qemu/startup.S
@@ -28,7 +28,7 @@
_start:
jmp codestart
- . = _start + GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR
+ .org GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR
VARIABLE(grub_core_entry_addr)
.long 0
@@ -73,5 +73,3 @@ codestart:
1:
hlt
jmp 1b
-
-#include "../realmode.S"
diff --git a/grub-core/kern/i386/realmode.S b/grub-core/kern/i386/realmode.S
index 541cedc87..998fdc756 100644
--- a/grub-core/kern/i386/realmode.S
+++ b/grub-core/kern/i386/realmode.S
@@ -54,7 +54,7 @@ protstack:
.endm
.macro REAL_TO_PROT
- DATA32 call real_to_prot
+ calll real_to_prot
.endm
/*
@@ -137,7 +137,22 @@ real_to_prot:
/* load the GDT register */
xorw %ax, %ax
movw %ax, %ds
- DATA32 ADDR32 lgdt gdtdesc
+#ifdef GRUB_MACHINE_QEMU
+ /*
+ qemu is special: gdtdesc is in ROM.
+ %cs = 0xf000
+ _start + GRUB_BOOT_MACHINE_SIZE = 0x100000
+ So
+ _start + GRUB_BOOT_MACHINE_SIZE - 0x10000 points to the same point
+ as %cs.
+ gdtdesc - (_start + GRUB_BOOT_MACHINE_SIZE - 0x10000)
+ = gdtdesc - _start - GRUB_BOOT_MACHINE_SIZE + 0x10000
+ but the later can be computed by assembly.
+ */
+ lgdtl %cs:(gdtdesc - _start - GRUB_BOOT_MACHINE_SIZE + 0x10000)
+#else
+ lgdtl gdtdesc
+#endif
/* turn on protected mode */
movl %cr0, %eax
@@ -145,7 +160,7 @@ real_to_prot:
movl %eax, %cr0
/* jump to relocation, flush prefetch queue, and reload %cs */
- DATA32 ljmp $GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $protcseg
+ ljmpl $GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $protcseg
.code32
protcseg:
@@ -178,6 +193,9 @@ protcseg:
/* return on the old (or initialized) stack! */
ret
+ /* prot_to_real assumes that this code is under 64K which is not
+ true for qemu. */
+#ifndef GRUB_MACHINE_QEMU
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2009,2010 Free Software Foundation, Inc.
@@ -237,7 +255,7 @@ tmpcseg:
movl %eax, %cr0
/* flush prefetch queue, reload %cs */
- DATA32 ljmp $0, $realcseg
+ ljmpl $0, $realcseg
realcseg:
/* we are in real mode now
@@ -258,6 +276,6 @@ realcseg:
#endif
/* return on new stack! */
- DATA32 ret
-
+ retl
+#endif
.code32
diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
index 3a4cae601..2e85289d8 100644
--- a/grub-core/kern/i386/tsc.c
+++ b/grub-core/kern/i386/tsc.c
@@ -1,7 +1,6 @@
/* kern/i386/tsc.c - x86 TSC time source implementation
* Requires Pentium or better x86 CPU that supports the RDTSC instruction.
- * This module uses the RTC (via grub_get_rtc()) to calibrate the TSC to
- * real time.
+ * This module calibrates the TSC to real time.
*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
@@ -25,12 +24,6 @@
#include <grub/misc.h>
#include <grub/i386/tsc.h>
#include <grub/i386/cpuid.h>
-#ifdef GRUB_MACHINE_XEN
-#include <grub/xen.h>
-#else
-#include <grub/i386/pit.h>
-#endif
-#include <grub/cpu/io.h>
/* This defines the value TSC had at the epoch (that is, when we calibrated it). */
static grub_uint64_t tsc_boot_time;
@@ -40,66 +33,6 @@ static grub_uint64_t tsc_boot_time;
in 32-bit. */
grub_uint32_t grub_tsc_rate;
-/* 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;
- grub_uint32_t a,b,c,d;
-
- /* The CPUID instruction is a 'serializing' instruction, and
- avoids out-of-order execution of the RDTSC instruction. */
- grub_cpuid (0,a,b,c,d);
- /* 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;
-}
-
-static __inline int
-grub_cpu_is_tsc_supported (void)
-{
- grub_uint32_t a,b,c,d;
- if (! grub_cpu_is_cpuid_supported ())
- return 0;
-
- grub_cpuid(1,a,b,c,d);
-
- return (d & (1 << 4)) != 0;
-}
-
-#ifndef GRUB_MACHINE_XEN
-
-static void
-grub_pit_wait (grub_uint16_t tics)
-{
- /* Disable timer2 gate and speaker. */
- grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
- & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
- GRUB_PIT_SPEAKER_PORT);
-
- /* Set tics. */
- grub_outb (GRUB_PIT_CTRL_SELECT_2 | GRUB_PIT_CTRL_READLOAD_WORD,
- GRUB_PIT_CTRL);
- grub_outb (tics & 0xff, GRUB_PIT_COUNTER_2);
- grub_outb (tics >> 8, GRUB_PIT_COUNTER_2);
-
- /* Enable timer2 gate, keep speaker disabled. */
- grub_outb ((grub_inb (GRUB_PIT_SPEAKER_PORT) & ~ GRUB_PIT_SPK_DATA)
- | GRUB_PIT_SPK_TMR2,
- GRUB_PIT_SPEAKER_PORT);
-
- /* Wait. */
- while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00);
-
- /* Disable timer2 gate and speaker. */
- grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
- & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
- GRUB_PIT_SPEAKER_PORT);
-}
-#endif
-
static grub_uint64_t
grub_tsc_get_time_ms (void)
{
@@ -110,48 +43,36 @@ grub_tsc_get_time_ms (void)
return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate;
}
-#ifndef GRUB_MACHINE_XEN
-/* Calibrate the TSC based on the RTC. */
-static void
-calibrate_tsc (void)
+static int
+calibrate_tsc_hardcode (void)
{
- /* First calibrate the TSC rate (relative, not absolute time). */
- grub_uint64_t end_tsc;
-
- tsc_boot_time = grub_get_tsc ();
- grub_pit_wait (0xffff);
- end_tsc = grub_get_tsc ();
-
- grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0);
+ grub_tsc_rate = 5368;/* 800 MHz */
+ return 1;
}
-#endif
void
grub_tsc_init (void)
{
-#ifdef GRUB_MACHINE_XEN
- grub_uint64_t t;
- tsc_boot_time = grub_get_tsc ();
- t = grub_xen_shared_info->vcpu_info[0].time.tsc_to_system_mul;
- if (grub_xen_shared_info->vcpu_info[0].time.tsc_shift > 0)
- t <<= grub_xen_shared_info->vcpu_info[0].time.tsc_shift;
- else
- t >>= -grub_xen_shared_info->vcpu_info[0].time.tsc_shift;
- grub_tsc_rate = grub_divmod64 (t, 1000000, 0);
- grub_install_get_time_ms (grub_tsc_get_time_ms);
-#else
- if (grub_cpu_is_tsc_supported ())
- {
- calibrate_tsc ();
- grub_install_get_time_ms (grub_tsc_get_time_ms);
- }
- else
+ if (!grub_cpu_is_tsc_supported ())
{
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_IEEE1275)
grub_install_get_time_ms (grub_rtc_get_time_ms);
#else
grub_fatal ("no TSC found");
#endif
+ return;
}
+
+ tsc_boot_time = grub_get_tsc ();
+
+#ifdef GRUB_MACHINE_XEN
+ (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode());
+#elif defined (GRUB_MACHINE_EFI)
+ (void) (grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode());
+#elif defined (GRUB_MACHINE_COREBOOT)
+ (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
+#else
+ (void) (grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
#endif
+ grub_install_get_time_ms (grub_tsc_get_time_ms);
}
diff --git a/grub-core/kern/i386/tsc_pit.c b/grub-core/kern/i386/tsc_pit.c
new file mode 100644
index 000000000..67990bfa6
--- /dev/null
+++ b/grub-core/kern/i386/tsc_pit.c
@@ -0,0 +1,84 @@
+/* kern/i386/tsc.c - x86 TSC time source implementation
+ * Requires Pentium or better x86 CPU that supports the RDTSC instruction.
+ * This module uses the PIT to calibrate the TSC to
+ * real time.
+ *
+ * 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/types.h>
+#include <grub/time.h>
+#include <grub/misc.h>
+#include <grub/i386/tsc.h>
+#include <grub/i386/pit.h>
+#include <grub/cpu/io.h>
+
+static int
+grub_pit_wait (void)
+{
+ int ret = 0;
+
+ /* Disable timer2 gate and speaker. */
+ grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
+ & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
+ GRUB_PIT_SPEAKER_PORT);
+
+ /* Set tics. */
+ grub_outb (GRUB_PIT_CTRL_SELECT_2 | GRUB_PIT_CTRL_READLOAD_WORD,
+ GRUB_PIT_CTRL);
+ /* 0xffff ticks: 55ms. */
+ grub_outb (0xff, GRUB_PIT_COUNTER_2);
+ grub_outb (0xff, GRUB_PIT_COUNTER_2);
+
+ /* Enable timer2 gate, keep speaker disabled. */
+ grub_outb ((grub_inb (GRUB_PIT_SPEAKER_PORT) & ~ GRUB_PIT_SPK_DATA)
+ | GRUB_PIT_SPK_TMR2,
+ GRUB_PIT_SPEAKER_PORT);
+
+ if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00) {
+ ret = 1;
+ /* Wait. */
+ while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00);
+ }
+
+ /* Disable timer2 gate and speaker. */
+ grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
+ & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
+ GRUB_PIT_SPEAKER_PORT);
+
+ return ret;
+}
+
+/* Calibrate the TSC based on the RTC. */
+int
+grub_tsc_calibrate_from_pit (void)
+{
+ /* First calibrate the TSC rate (relative, not absolute time). */
+ grub_uint64_t start_tsc, end_tsc;
+
+ start_tsc = grub_get_tsc ();
+ if (!grub_pit_wait ())
+ return 0;
+ end_tsc = grub_get_tsc ();
+
+ grub_tsc_rate = 0;
+ if (end_tsc > start_tsc)
+ grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - start_tsc, 0);
+ if (grub_tsc_rate == 0)
+ return 0;
+ return 1;
+}
diff --git a/grub-core/kern/i386/tsc_pmtimer.c b/grub-core/kern/i386/tsc_pmtimer.c
new file mode 100644
index 000000000..c9c361699
--- /dev/null
+++ b/grub-core/kern/i386/tsc_pmtimer.c
@@ -0,0 +1,88 @@
+/* kern/i386/tsc.c - x86 TSC time source implementation
+ * Requires Pentium or better x86 CPU that supports the RDTSC instruction.
+ * This module uses the PIT to calibrate the TSC to
+ * real time.
+ *
+ * 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/types.h>
+#include <grub/time.h>
+#include <grub/misc.h>
+#include <grub/i386/tsc.h>
+#include <grub/i386/pmtimer.h>
+#include <grub/acpi.h>
+#include <grub/cpu/io.h>
+
+grub_uint64_t
+grub_pmtimer_wait_count_tsc (grub_port_t pmtimer,
+ grub_uint16_t num_pm_ticks)
+{
+ grub_uint32_t start;
+ grub_uint32_t last;
+ grub_uint32_t cur, end;
+ grub_uint64_t start_tsc;
+ grub_uint64_t end_tsc;
+ int num_iter = 0;
+
+ start = grub_inl (pmtimer) & 0xffffff;
+ last = start;
+ end = start + num_pm_ticks;
+ start_tsc = grub_get_tsc ();
+ while (1)
+ {
+ cur = grub_inl (pmtimer) & 0xffffff;
+ if (cur < last)
+ cur |= 0x1000000;
+ num_iter++;
+ if (cur >= end)
+ {
+ end_tsc = grub_get_tsc ();
+ return end_tsc - start_tsc;
+ }
+ /* Check for broken PM timer.
+ 50000000 TSCs is between 5 ms (10GHz) and 200 ms (250 MHz)
+ if after this time we still don't have 1 ms on pmtimer, then
+ pmtimer is broken.
+ */
+ if ((num_iter & 0xffffff) == 0 && grub_get_tsc () - start_tsc > 5000000) {
+ return 0;
+ }
+ }
+}
+
+int
+grub_tsc_calibrate_from_pmtimer (void)
+{
+ struct grub_acpi_fadt *fadt;
+ grub_port_t pmtimer;
+ grub_uint64_t tsc_diff;
+
+ fadt = grub_acpi_find_fadt ();
+ if (!fadt)
+ return 0;
+ pmtimer = fadt->pmtimer;
+ if (!pmtimer)
+ return 0;
+
+ /* It's 3.579545 MHz clock. Wait 1 ms. */
+ tsc_diff = grub_pmtimer_wait_count_tsc (pmtimer, 3580);
+ if (tsc_diff == 0)
+ return 0;
+ grub_tsc_rate = grub_divmod64 ((1ULL << 32), tsc_diff, 0);
+ return 1;
+}
diff --git a/grub-core/kern/i386/xen/tsc.c b/grub-core/kern/i386/xen/tsc.c
new file mode 100644
index 000000000..8792b308d
--- /dev/null
+++ b/grub-core/kern/i386/xen/tsc.c
@@ -0,0 +1,40 @@
+/* kern/i386/tsc.c - x86 TSC time source implementation
+ * Requires Pentium or better x86 CPU that supports the RDTSC instruction.
+ * This module uses the PIT to calibrate the TSC to
+ * real time.
+ *
+ * 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/types.h>
+#include <grub/time.h>
+#include <grub/misc.h>
+#include <grub/i386/tsc.h>
+#include <grub/xen.h>
+
+int
+grub_tsc_calibrate_from_xen (void)
+{
+ grub_uint64_t t;
+ t = grub_xen_shared_info->vcpu_info[0].time.tsc_to_system_mul;
+ if (grub_xen_shared_info->vcpu_info[0].time.tsc_shift > 0)
+ t <<= grub_xen_shared_info->vcpu_info[0].time.tsc_shift;
+ else
+ t >>= -grub_xen_shared_info->vcpu_info[0].time.tsc_shift;
+ grub_tsc_rate = grub_divmod64 (t, 1000000, 0);
+ return 1;
+}
diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c
index d92ae14f5..3e12e6b24 100644
--- a/grub-core/kern/ieee1275/cmain.c
+++ b/grub-core/kern/ieee1275/cmain.c
@@ -84,8 +84,10 @@ grub_ieee1275_find_options (void)
rc = grub_ieee1275_get_property (root, "model",
tmp, sizeof (tmp), 0);
- if (rc >= 0 && !grub_strcmp (tmp, "Emulated PC"))
+ if (rc >= 0 && (!grub_strcmp (tmp, "Emulated PC")
+ || !grub_strcmp (tmp, "IBM pSeries (emulated by qemu)"))) {
is_qemu = 1;
+ }
if (rc >= 0 && grub_strncmp (tmp, "IBM", 3) == 0)
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS);
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
index 89b2822e1..12590225e 100644
--- a/grub-core/kern/ieee1275/init.c
+++ b/grub-core/kern/ieee1275/init.c
@@ -46,11 +46,19 @@
#define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024)
/* The maximum heap size we're going to claim */
+#ifdef __i386__
+#define HEAP_MAX_SIZE (unsigned long) (64 * 1024 * 1024)
+#else
#define HEAP_MAX_SIZE (unsigned long) (32 * 1024 * 1024)
+#endif
/* If possible, we will avoid claiming heap above this address, because it
seems to cause relocation problems with OSes that link at 4 MiB */
+#ifdef __i386__
+#define HEAP_MAX_ADDR (unsigned long) (64 * 1024 * 1024)
+#else
#define HEAP_MAX_ADDR (unsigned long) (32 * 1024 * 1024)
+#endif
extern char _start[];
extern char _end[];
@@ -80,9 +88,8 @@ grub_translate_ieee1275_path (char *filepath)
}
}
-void (*grub_ieee1275_net_config) (const char *dev,
- char **device,
- char **path);
+void (*grub_ieee1275_net_config) (const char *dev, char **device, char **path,
+ char *bootpath);
void
grub_machine_get_bootlocation (char **device, char **path)
{
@@ -126,7 +133,7 @@ grub_machine_get_bootlocation (char **device, char **path)
*ptr = 0;
if (grub_ieee1275_net_config)
- grub_ieee1275_net_config (canon, device, path);
+ grub_ieee1275_net_config (canon, device, path, bootpath);
grub_free (dev);
grub_free (canon);
}
@@ -167,7 +174,7 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type,
{
unsigned long *total = data;
- if (type != 1)
+ if (type != GRUB_MEMORY_AVAILABLE)
return 0;
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM))
diff --git a/grub-core/kern/ieee1275/mmap.c b/grub-core/kern/ieee1275/mmap.c
index 911bb0011..bf325eadf 100644
--- a/grub-core/kern/ieee1275/mmap.c
+++ b/grub-core/kern/ieee1275/mmap.c
@@ -25,7 +25,7 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
{
grub_ieee1275_phandle_t root;
grub_ieee1275_phandle_t memory;
- grub_uint32_t available[32];
+ grub_uint32_t available[128];
grub_ssize_t available_size;
grub_uint32_t address_cells = 1;
grub_uint32_t size_cells = 1;
@@ -49,6 +49,9 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
sizeof available, &available_size))
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"couldn't examine /memory/available property");
+ if (available_size < 0 || (grub_size_t) available_size > sizeof (available))
+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
+ "/memory response buffer exceeded");
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS))
{
diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c
index 07c90f7cb..ddb778340 100644
--- a/grub-core/kern/ieee1275/openfw.c
+++ b/grub-core/kern/ieee1275/openfw.c
@@ -271,7 +271,7 @@ grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
grub_ieee1275_cell_t mode;
grub_ieee1275_cell_t size;
grub_ieee1275_cell_t virt;
-#ifdef GRUB_MACHINE_SPARC64
+#ifdef __sparc__
grub_ieee1275_cell_t phys_high;
#endif
grub_ieee1275_cell_t phys_low;
@@ -279,7 +279,7 @@ grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
} args;
INIT_IEEE1275_COMMON (&args.common, "call-method",
-#ifdef GRUB_MACHINE_SPARC64
+#ifdef __sparc__
7,
#else
6,
@@ -287,7 +287,7 @@ grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
1);
args.method = (grub_ieee1275_cell_t) "map";
args.ihandle = grub_ieee1275_mmu;
-#ifdef GRUB_MACHINE_SPARC64
+#ifdef __sparc__
args.phys_high = 0;
#endif
args.phys_low = phys;
diff --git a/grub-core/kern/mips/arc/init.c b/grub-core/kern/mips/arc/init.c
index b4f50e496..3834a1490 100644
--- a/grub-core/kern/mips/arc/init.c
+++ b/grub-core/kern/mips/arc/init.c
@@ -360,7 +360,7 @@ grub_machine_get_bootlocation (char **device, char **path)
char *loaddev = boot_location;
char *pptr, *partptr;
char *dname;
- grub_disk_addr_t poff = -1, pend;
+ grub_disk_addr_t poff = -1, pend = -1;
struct get_device_name_ctx ctx;
grub_disk_t parent = 0;
unsigned i;
diff --git a/grub-core/kern/mips/cache.S b/grub-core/kern/mips/cache.S
index 78e40bcea..fa6897e14 100644
--- a/grub-core/kern/mips/cache.S
+++ b/grub-core/kern/mips/cache.S
@@ -65,4 +65,4 @@ FUNCTION (grub_arch_sync_dma_caches)
#endif
sync_op
- jr $ra \ No newline at end of file
+ jr $ra
diff --git a/grub-core/kern/mips/dl.c b/grub-core/kern/mips/dl.c
index 8c057e01d..e320a4ee7 100644
--- a/grub-core/kern/mips/dl.c
+++ b/grub-core/kern/mips/dl.c
@@ -138,6 +138,10 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
sym = (Elf_Sym *) ((char *) mod->symtab
+ mod->symsize * ELF_R_SYM (rel->r_info));
sym_value = sym->st_value;
+ if (s->sh_type == SHT_RELA)
+ {
+ sym_value += ((Elf_Rela *) rel)->r_addend;
+ }
if (sym_value == (grub_addr_t) &__gnu_local_gp_dummy)
sym_value = (grub_addr_t) mod->got;
else if (sym_value == (grub_addr_t) &_gp_disp_dummy)
diff --git a/grub-core/kern/mips/startup.S b/grub-core/kern/mips/startup.S
index 709a91afa..1fdb58aca 100644
--- a/grub-core/kern/mips/startup.S
+++ b/grub-core/kern/mips/startup.S
@@ -22,6 +22,7 @@
#include <grub/machine/memory.h>
#include <grub/machine/kernel.h>
#include <grub/offsets.h>
+#include <grub/mips/asm.h>
#define BASE_ADDR 8
@@ -36,7 +37,7 @@ start:
bal cont
nop
- . = _start + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
+ .org GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
VARIABLE(grub_total_modules_size)
.long 0
@@ -95,8 +96,8 @@ cont:
modulesmovcont:
beq $t3, $0, modulesmovdone
nop
- lb $t4, 0($t2)
- sb $t4, 0($t1)
+ lb GRUB_ASM_T4, 0($t2)
+ sb GRUB_ASM_T4, 0($t1)
addiu $t2, $t2, -1
addiu $t1, $t1, -1
b modulesmovcont
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index 54db2e125..d1a54df6c 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -95,25 +95,6 @@ grub_memmove (void *dest, const void *src, grub_size_t n)
return dest;
}
-#ifndef __APPLE__
-void *memmove (void *dest, const void *src, grub_size_t n)
- __attribute__ ((alias ("grub_memmove")));
-/* GCC emits references to memcpy() for struct copies etc. */
-void *memcpy (void *dest, const void *src, grub_size_t n)
- __attribute__ ((alias ("grub_memmove")));
-#else
-void * GRUB_BUILTIN_ATTR
-memcpy (void *dest, const void *src, grub_size_t n)
-{
- return grub_memmove (dest, src, n);
-}
-void * GRUB_BUILTIN_ATTR
-memmove (void *dest, const void *src, grub_size_t n)
-{
- return grub_memmove (dest, src, n);
-}
-#endif
-
char *
grub_strcpy (char *dest, const char *src)
{
@@ -253,16 +234,6 @@ grub_memcmp (const void *s1, const void *s2, grub_size_t n)
return 0;
}
-#ifndef __APPLE__
-int memcmp (const void *s1, const void *s2, grub_size_t n)
- __attribute__ ((alias ("grub_memcmp")));
-#else
-int GRUB_BUILTIN_ATTR
-memcmp (const void *s1, const void *s2, grub_size_t n)
-{
- return grub_memcmp (s1, s2, n);
-}
-#endif
int
grub_strcmp (const char *s1, const char *s2)
@@ -532,23 +503,6 @@ grub_memset (void *s, int c, grub_size_t len)
return s;
}
-#ifndef __APPLE__
-void *memset (void *s, int c, grub_size_t n)
- __attribute__ ((alias ("grub_memset")));
-#else
-void * GRUB_BUILTIN_ATTR
-memset (void *s, int c, grub_size_t n)
-{
- return grub_memset (s, c, n);
-}
-
-void GRUB_BUILTIN_ATTR
-__bzero (void *s, grub_size_t n)
-{
- grub_memset (s, 0, n);
-}
-
-#endif
grub_size_t
grub_strlen (const char *s)
@@ -591,10 +545,10 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)
grub_uint64_t m = 0;
/* ARM and IA64 don't have a fast 32-bit division.
- Using that code would just make us use libgcc routines, calling
- them twice (once for modulo and once for quotient.
+ Using that code would just make us use software division routines, calling
+ ourselves indirectly and hence getting infinite recursion.
*/
-#if !defined (__arm__) && !defined (__ia64__)
+#if !GRUB_DIVISION_IN_SOFTWARE
/* Skip the slow computation if 32-bit arithmetic is possible. */
if (n < 0xffffffff && d < 0xffffffff)
{
@@ -628,132 +582,6 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)
return q;
}
-#if !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
-
-#if defined (__arm__)
-
-grub_uint32_t
-__udivsi3 (grub_uint32_t a, grub_uint32_t b)
-{
- return grub_divmod64 (a, b, 0);
-}
-
-grub_uint32_t
-__umodsi3 (grub_uint32_t a, grub_uint32_t b)
-{
- grub_uint64_t ret;
- grub_divmod64 (a, b, &ret);
- return ret;
-}
-
-#endif
-
-#ifdef NEED_CTZDI2
-
-unsigned
-__ctzdi2 (grub_uint64_t x)
-{
- unsigned ret = 0;
- if (!x)
- return 64;
- if (!(x & 0xffffffff))
- {
- x >>= 32;
- ret |= 32;
- }
- if (!(x & 0xffff))
- {
- x >>= 16;
- ret |= 16;
- }
- if (!(x & 0xff))
- {
- x >>= 8;
- ret |= 8;
- }
- if (!(x & 0xf))
- {
- x >>= 4;
- ret |= 4;
- }
- if (!(x & 0x3))
- {
- x >>= 2;
- ret |= 2;
- }
- if (!(x & 0x1))
- {
- x >>= 1;
- ret |= 1;
- }
- return ret;
-}
-#endif
-
-#ifdef NEED_CTZSI2
-unsigned
-__ctzsi2 (grub_uint32_t x)
-{
- unsigned ret = 0;
- if (!x)
- return 32;
-
- if (!(x & 0xffff))
- {
- x >>= 16;
- ret |= 16;
- }
- if (!(x & 0xff))
- {
- x >>= 8;
- ret |= 8;
- }
- if (!(x & 0xf))
- {
- x >>= 4;
- ret |= 4;
- }
- if (!(x & 0x3))
- {
- x >>= 2;
- ret |= 2;
- }
- if (!(x & 0x1))
- {
- x >>= 1;
- ret |= 1;
- }
- return ret;
-}
-
-#endif
-
-#ifdef __arm__
-grub_uint32_t
-__aeabi_uidiv (grub_uint32_t a, grub_uint32_t b)
- __attribute__ ((alias ("__udivsi3")));
-#endif
-
-#if defined (__ia64__)
-
-grub_uint64_t
-__udivdi3 (grub_uint64_t a, grub_uint64_t b)
-{
- return grub_divmod64 (a, b, 0);
-}
-
-grub_uint64_t
-__umoddi3 (grub_uint64_t a, grub_uint64_t b)
-{
- grub_uint64_t ret;
- grub_divmod64 (a, b, &ret);
- return ret;
-}
-
-#endif
-
-#endif /* GRUB_UTIL */
-
/* Convert a long long value to a string. This function avoids 64-bit
modular arithmetic or divisions. */
static inline char *
@@ -912,6 +740,12 @@ parse_printf_args (const char *fmt0, struct printf_args *args,
fmt++;
c = *fmt++;
+ if (c == '%')
+ {
+ n--;
+ continue;
+ }
+
if (c == 'l')
{
c = *fmt++;
@@ -1048,6 +882,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
if (c == '%')
{
write_char (str, &count, max_len,c);
+ n--;
continue;
}
@@ -1262,15 +1097,6 @@ grub_abort (void)
grub_exit ();
}
-#if defined (__clang__) && !defined (GRUB_UTIL)
-/* clang emits references to abort(). */
-void __attribute__ ((noreturn))
-abort (void)
-{
- grub_abort ();
-}
-#endif
-
void
grub_fatal (const char *fmt, ...)
{
@@ -1280,25 +1106,10 @@ grub_fatal (const char *fmt, ...)
grub_vprintf (_(fmt), ap);
va_end (ap);
- grub_abort ();
-}
-
-#if (defined (__MINGW32__) || defined (__CYGWIN__)) && !defined(GRUB_UTIL)
-void __register_frame_info (void)
-{
-}
-
-void __deregister_frame_info (void)
-{
-}
-void ___chkstk_ms (void)
-{
-}
+ grub_refresh ();
-void __chkstk_ms (void)
-{
+ grub_abort ();
}
-#endif
#if BOOT_TIME_STATS
diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c
index 1c3d02388..ee88ff611 100644
--- a/grub-core/kern/mm.c
+++ b/grub-core/kern/mm.c
@@ -325,6 +325,15 @@ grub_memalign (grub_size_t align, grub_size_t size)
if (!grub_mm_base)
goto fail;
+ if (size > ~(grub_size_t) align)
+ goto fail;
+
+ /* We currently assume at least a 32-bit grub_size_t,
+ so limiting allocations to <adress space size> - 1MiB
+ in name of sanity is beneficial. */
+ if ((size + align) > ~(grub_size_t) 0x100000)
+ goto fail;
+
align = (align >> GRUB_MM_ALIGN_LOG2);
if (align == 0)
align = 1;
diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c
index b9bd12352..78175aac2 100644
--- a/grub-core/kern/parser.c
+++ b/grub-core/kern/parser.c
@@ -268,6 +268,7 @@ grub_parser_execute (char *source)
grub_parser_execute_getline (&line, 0, &source);
grub_rescue_parse_line (line, grub_parser_execute_getline, &source);
grub_free (line);
+ grub_print_error ();
}
return grub_errno;
diff --git a/grub-core/kern/powerpc/compiler-rt.S b/grub-core/kern/powerpc/compiler-rt.S
new file mode 100644
index 000000000..b3b912db6
--- /dev/null
+++ b/grub-core/kern/powerpc/compiler-rt.S
@@ -0,0 +1,130 @@
+/*
+ * Special support for eabi and SVR4
+ *
+ * Copyright (C) 1995-2014 Free Software Foundation, Inc.
+ * Written By Michael Meissner
+ * 64-bit support written by David Edelsohn
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 3, or (at your option) any
+ * later version.
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * Under Section 7 of GPL version 3, you are granted additional
+ * permissions described in the GCC Runtime Library Exception, version
+ * 3.1, as published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License and
+ * a copy of the GCC Runtime Library Exception along with this program;
+ * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+/* Do any initializations needed for the eabi environment */
+
+#include <grub/symbol.h>
+#include <grub/dl.h>
+
+ .section ".text"
+
+#define CFI_RESTORE(reg) .cfi_restore reg
+#define CFI_OFFSET(reg, off) .cfi_offset reg, off
+#define CFI_DEF_CFA_REGISTER(reg) .cfi_def_cfa_register reg
+#define CFI_STARTPROC .cfi_startproc
+#define CFI_ENDPROC .cfi_endproc
+
+/* Routines for restoring integer registers, called by the compiler. */
+/* Called with r11 pointing to the stack header word of the caller of the */
+/* function, just beyond the end of the integer restore area. */
+
+CFI_STARTPROC
+CFI_DEF_CFA_REGISTER (11)
+CFI_OFFSET (65, 4)
+CFI_OFFSET (14, -72)
+CFI_OFFSET (15, -68)
+CFI_OFFSET (16, -64)
+CFI_OFFSET (17, -60)
+CFI_OFFSET (18, -56)
+CFI_OFFSET (19, -52)
+CFI_OFFSET (20, -48)
+CFI_OFFSET (21, -44)
+CFI_OFFSET (22, -40)
+CFI_OFFSET (23, -36)
+CFI_OFFSET (24, -32)
+CFI_OFFSET (25, -28)
+CFI_OFFSET (26, -24)
+CFI_OFFSET (27, -20)
+CFI_OFFSET (28, -16)
+CFI_OFFSET (29, -12)
+CFI_OFFSET (30, -8)
+CFI_OFFSET (31, -4)
+FUNCTION(_restgpr_14_x) lwz 14,-72(11) /* restore gp registers */
+CFI_RESTORE (14)
+FUNCTION(_restgpr_15_x) lwz 15,-68(11)
+CFI_RESTORE (15)
+FUNCTION(_restgpr_16_x) lwz 16,-64(11)
+CFI_RESTORE (16)
+FUNCTION(_restgpr_17_x) lwz 17,-60(11)
+CFI_RESTORE (17)
+FUNCTION(_restgpr_18_x) lwz 18,-56(11)
+CFI_RESTORE (18)
+FUNCTION(_restgpr_19_x) lwz 19,-52(11)
+CFI_RESTORE (19)
+FUNCTION(_restgpr_20_x) lwz 20,-48(11)
+CFI_RESTORE (20)
+FUNCTION(_restgpr_21_x) lwz 21,-44(11)
+CFI_RESTORE (21)
+FUNCTION(_restgpr_22_x) lwz 22,-40(11)
+CFI_RESTORE (22)
+FUNCTION(_restgpr_23_x) lwz 23,-36(11)
+CFI_RESTORE (23)
+FUNCTION(_restgpr_24_x) lwz 24,-32(11)
+CFI_RESTORE (24)
+FUNCTION(_restgpr_25_x) lwz 25,-28(11)
+CFI_RESTORE (25)
+FUNCTION(_restgpr_26_x) lwz 26,-24(11)
+CFI_RESTORE (26)
+FUNCTION(_restgpr_27_x) lwz 27,-20(11)
+CFI_RESTORE (27)
+FUNCTION(_restgpr_28_x) lwz 28,-16(11)
+CFI_RESTORE (28)
+FUNCTION(_restgpr_29_x) lwz 29,-12(11)
+CFI_RESTORE (29)
+FUNCTION(_restgpr_30_x) lwz 30,-8(11)
+CFI_RESTORE (30)
+FUNCTION(_restgpr_31_x) lwz 0,4(11)
+ lwz 31,-4(11)
+CFI_RESTORE (31)
+ mtlr 0
+CFI_RESTORE (65)
+ mr 1,11
+CFI_DEF_CFA_REGISTER (1)
+ blr
+CFI_ENDPROC
+
+CFI_STARTPROC
+FUNCTION(_savegpr_14) stw 14,-72(11) /* save gp registers */
+FUNCTION(_savegpr_15) stw 15,-68(11)
+FUNCTION(_savegpr_16) stw 16,-64(11)
+FUNCTION(_savegpr_17) stw 17,-60(11)
+FUNCTION(_savegpr_18) stw 18,-56(11)
+FUNCTION(_savegpr_19) stw 19,-52(11)
+FUNCTION(_savegpr_20) stw 20,-48(11)
+FUNCTION(_savegpr_21) stw 21,-44(11)
+FUNCTION(_savegpr_22) stw 22,-40(11)
+FUNCTION(_savegpr_23) stw 23,-36(11)
+FUNCTION(_savegpr_24) stw 24,-32(11)
+FUNCTION(_savegpr_25) stw 25,-28(11)
+FUNCTION(_savegpr_26) stw 26,-24(11)
+FUNCTION(_savegpr_27) stw 27,-20(11)
+FUNCTION(_savegpr_28) stw 28,-16(11)
+FUNCTION(_savegpr_29) stw 29,-12(11)
+FUNCTION(_savegpr_30) stw 30,-8(11)
+FUNCTION(_savegpr_31) stw 31,-4(11)
+ blr
+CFI_ENDPROC
diff --git a/grub-core/kern/rescue_parser.c b/grub-core/kern/rescue_parser.c
index ab3d04160..633836699 100644
--- a/grub-core/kern/rescue_parser.c
+++ b/grub-core/kern/rescue_parser.c
@@ -43,13 +43,17 @@ grub_rescue_parse_line (char *line,
/* In case of an assignment set the environment accordingly
instead of calling a function. */
- if (n == 1 && grub_strchr (line, '='))
+ if (n == 1)
{
char *val = grub_strchr (args[0], '=');
- val[0] = 0;
- grub_env_set (args[0], val + 1);
- val[0] = '=';
- goto quit;
+
+ if (val)
+ {
+ val[0] = 0;
+ grub_env_set (args[0], val + 1);
+ val[0] = '=';
+ goto quit;
+ }
}
/* Get the command name. */
@@ -72,6 +76,7 @@ grub_rescue_parse_line (char *line,
}
quit:
+ /* Arguments are returned in single memory chunk separated by zeroes */
grub_free (args[0]);
grub_free (args);
diff --git a/grub-core/kern/sparc64/ieee1275/crt0.S b/grub-core/kern/sparc64/ieee1275/crt0.S
index 79b6bb325..03b916f05 100644
--- a/grub-core/kern/sparc64/ieee1275/crt0.S
+++ b/grub-core/kern/sparc64/ieee1275/crt0.S
@@ -27,7 +27,7 @@ _start:
ba codestart
mov %o4, %o0
- . = EXT_C(_start) + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
+ .org GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE
VARIABLE(grub_total_module_size)
.word 0
diff --git a/grub-core/kern/uboot/init.c b/grub-core/kern/uboot/init.c
index 71bc21b8f..5dcc106ed 100644
--- a/grub-core/kern/uboot/init.c
+++ b/grub-core/kern/uboot/init.c
@@ -30,6 +30,8 @@
#include <grub/uboot/disk.h>
#include <grub/uboot/uboot.h>
#include <grub/uboot/api_public.h>
+#include <grub/cpu/system.h>
+#include <grub/cache.h>
extern char __bss_start[];
extern char _end[];
@@ -69,6 +71,19 @@ uboot_timer_ms (void)
return (((grub_uint64_t) high) << 32) | cur;
}
+#ifdef __arm__
+static grub_uint64_t
+rpi_timer_ms (void)
+{
+ static grub_uint32_t last = 0, high = 0;
+ grub_uint32_t cur = *(volatile grub_uint32_t *) 0x20003004;
+ if (cur < last)
+ high++;
+ last = cur;
+ return grub_divmod64 ((((grub_uint64_t) high) << 32) | cur, 1000, 0);
+}
+#endif
+
void
grub_machine_init (void)
{
@@ -93,6 +108,11 @@ grub_machine_init (void)
/* Enumerate memory and initialize the memory management system. */
grub_uboot_mm_init ();
+ /* Should be earlier but it needs memalign. */
+#ifdef __arm__
+ grub_arm_enable_caches_mmu ();
+#endif
+
grub_dprintf ("init", "__bss_start: %p\n", __bss_start);
grub_dprintf ("init", "_end: %p\n", _end);
grub_dprintf ("init", "grub_modbase: %p\n", (void *) grub_modbase);
@@ -106,8 +126,17 @@ grub_machine_init (void)
grub_uboot_probe_hardware ();
/* Initialise timer */
- timer_start = grub_uboot_get_timer (0);
- grub_install_get_time_ms (uboot_timer_ms);
+#ifdef __arm__
+ if (grub_uboot_get_machine_type () == GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI)
+ {
+ grub_install_get_time_ms (rpi_timer_ms);
+ }
+ else
+#endif
+ {
+ timer_start = grub_uboot_get_timer (0);
+ grub_install_get_time_ms (uboot_timer_ms);
+ }
/* Initialize */
grub_ubootdisk_init ();
diff --git a/grub-core/kern/x86_64/dl.c b/grub-core/kern/x86_64/dl.c
index 6cb88bfcc..440690673 100644
--- a/grub-core/kern/x86_64/dl.c
+++ b/grub-core/kern/x86_64/dl.c
@@ -73,7 +73,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
{
grub_int64_t value;
value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value -
- (Elf64_Xword) seg->addr - rel->r_offset;
+ (Elf64_Xword) (grub_addr_t) seg->addr - rel->r_offset;
if (value != (grub_int32_t) value)
return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range");
*addr32 = value;
@@ -83,7 +83,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
case R_X86_64_PC64:
{
*addr64 += rel->r_addend + sym->st_value -
- (Elf64_Xword) seg->addr - rel->r_offset;
+ (Elf64_Xword) (grub_addr_t) seg->addr - rel->r_offset;
}
break;
diff --git a/grub-core/lib/arg.c b/grub-core/lib/arg.c
index 47db94979..fd7744a6f 100644
--- a/grub-core/lib/arg.c
+++ b/grub-core/lib/arg.c
@@ -35,22 +35,22 @@ static const struct grub_arg_option help_options[] =
};
/* Helper for find_short. */
-static struct grub_arg_option *
+static const struct grub_arg_option *
fnd_short (const struct grub_arg_option *opt, char c)
{
while (opt->doc)
{
if (opt->shortarg == c)
- return (struct grub_arg_option *) opt;
+ return opt;
opt++;
}
return 0;
}
-static struct grub_arg_option *
+static const struct grub_arg_option *
find_short (const struct grub_arg_option *options, char c)
{
- struct grub_arg_option *found = 0;
+ const struct grub_arg_option *found = 0;
if (options)
found = fnd_short (options, c);
@@ -60,11 +60,11 @@ find_short (const struct grub_arg_option *options, char c)
switch (c)
{
case 'h':
- found = (struct grub_arg_option *) help_options;
+ found = help_options;
break;
case 'u':
- found = (struct grub_arg_option *) (help_options + 1);
+ found = (help_options + 1);
break;
default:
@@ -76,23 +76,23 @@ find_short (const struct grub_arg_option *options, char c)
}
/* Helper for find_long. */
-static struct grub_arg_option *
+static const struct grub_arg_option *
fnd_long (const struct grub_arg_option *opt, const char *s, int len)
{
while (opt->doc)
{
if (opt->longarg && ! grub_strncmp (opt->longarg, s, len) &&
opt->longarg[len] == '\0')
- return (struct grub_arg_option *) opt;
+ return opt;
opt++;
}
return 0;
}
-static struct grub_arg_option *
+static const struct grub_arg_option *
find_long (const struct grub_arg_option *options, const char *s, int len)
{
- struct grub_arg_option *found = 0;
+ const struct grub_arg_option *found = 0;
if (options)
found = fnd_long (options, s, len);
@@ -240,7 +240,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv,
for (curarg = 0; curarg < argc; curarg++)
{
char *arg = argv[curarg];
- struct grub_arg_option *opt;
+ const struct grub_arg_option *opt;
char *option = 0;
/* No option is used. */
diff --git a/grub-core/lib/arm64/setjmp.S b/grub-core/lib/arm64/setjmp.S
index adaafe40f..ffcabf6e4 100644
--- a/grub-core/lib/arm64/setjmp.S
+++ b/grub-core/lib/arm64/setjmp.S
@@ -17,8 +17,10 @@
*/
#include <grub/symbol.h>
+#include <grub/dl.h>
.file "setjmp.S"
+GRUB_MOD_LICENSE "GPLv3+"
.text
/*
@@ -48,6 +50,7 @@ FUNCTION(grub_longjmp)
ldp x29, x30, [x0], #16
ldr x2, [x0]
mov sp, x2
+ mov x0, #1
cmp x1, #0
csel x0, x1, x0, ne
ret
diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c
index b7c997499..683a8aaa7 100644
--- a/grub-core/lib/crypto.c
+++ b/grub-core/lib/crypto.c
@@ -203,15 +203,18 @@ gcry_err_code_t
grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher,
void *out, const void *in, grub_size_t size)
{
- const grub_uint8_t *inptr;
- grub_uint8_t *outptr, *end;
+ const grub_uint8_t *inptr, *end;
+ grub_uint8_t *outptr;
+ grub_size_t blocksize;
if (!cipher->cipher->decrypt)
return GPG_ERR_NOT_SUPPORTED;
- if (size % cipher->cipher->blocksize != 0)
+ blocksize = cipher->cipher->blocksize;
+ if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
+ || ((size & (blocksize - 1)) != 0))
return GPG_ERR_INV_ARG;
- end = (grub_uint8_t *) in + size;
+ end = (const grub_uint8_t *) in + size;
for (inptr = in, outptr = out; inptr < end;
- inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize)
+ inptr += blocksize, outptr += blocksize)
cipher->cipher->decrypt (cipher->ctx, outptr, inptr);
return GPG_ERR_NO_ERROR;
}
@@ -220,40 +223,47 @@ gcry_err_code_t
grub_crypto_ecb_encrypt (grub_crypto_cipher_handle_t cipher,
void *out, const void *in, grub_size_t size)
{
- const grub_uint8_t *inptr;
- grub_uint8_t *outptr, *end;
+ const grub_uint8_t *inptr, *end;
+ grub_uint8_t *outptr;
+ grub_size_t blocksize;
if (!cipher->cipher->encrypt)
return GPG_ERR_NOT_SUPPORTED;
- if (size % cipher->cipher->blocksize != 0)
+ blocksize = cipher->cipher->blocksize;
+ if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
+ || ((size & (blocksize - 1)) != 0))
return GPG_ERR_INV_ARG;
- end = (grub_uint8_t *) in + size;
+ end = (const grub_uint8_t *) in + size;
for (inptr = in, outptr = out; inptr < end;
- inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize)
+ inptr += blocksize, outptr += blocksize)
cipher->cipher->encrypt (cipher->ctx, outptr, inptr);
return GPG_ERR_NO_ERROR;
}
gcry_err_code_t
grub_crypto_cbc_encrypt (grub_crypto_cipher_handle_t cipher,
- void *out, void *in, grub_size_t size,
+ void *out, const void *in, grub_size_t size,
void *iv_in)
{
- grub_uint8_t *inptr, *outptr, *end;
+ grub_uint8_t *outptr;
+ const grub_uint8_t *inptr, *end;
void *iv;
- if (!cipher->cipher->decrypt)
+ grub_size_t blocksize;
+ if (!cipher->cipher->encrypt)
return GPG_ERR_NOT_SUPPORTED;
- if (size % cipher->cipher->blocksize != 0)
+ blocksize = cipher->cipher->blocksize;
+ if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
+ || ((size & (blocksize - 1)) != 0))
return GPG_ERR_INV_ARG;
- end = (grub_uint8_t *) in + size;
+ end = (const grub_uint8_t *) in + size;
iv = iv_in;
for (inptr = in, outptr = out; inptr < end;
- inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize)
+ inptr += blocksize, outptr += blocksize)
{
- grub_crypto_xor (outptr, inptr, iv, cipher->cipher->blocksize);
+ grub_crypto_xor (outptr, inptr, iv, blocksize);
cipher->cipher->encrypt (cipher->ctx, outptr, outptr);
iv = outptr;
}
- grub_memcpy (iv_in, iv, cipher->cipher->blocksize);
+ grub_memcpy (iv_in, iv, blocksize);
return GPG_ERR_NO_ERROR;
}
@@ -262,23 +272,26 @@ grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher,
void *out, const void *in, grub_size_t size,
void *iv)
{
- const grub_uint8_t *inptr;
- grub_uint8_t *outptr, *end;
+ const grub_uint8_t *inptr, *end;
+ grub_uint8_t *outptr;
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
+ grub_size_t blocksize;
if (!cipher->cipher->decrypt)
return GPG_ERR_NOT_SUPPORTED;
- if (size % cipher->cipher->blocksize != 0)
+ blocksize = cipher->cipher->blocksize;
+ if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
+ || ((size & (blocksize - 1)) != 0))
return GPG_ERR_INV_ARG;
- if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
+ if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
return GPG_ERR_INV_ARG;
- end = (grub_uint8_t *) in + size;
+ end = (const grub_uint8_t *) in + size;
for (inptr = in, outptr = out; inptr < end;
- inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize)
+ inptr += blocksize, outptr += blocksize)
{
- grub_memcpy (ivt, inptr, cipher->cipher->blocksize);
+ grub_memcpy (ivt, inptr, blocksize);
cipher->cipher->decrypt (cipher->ctx, outptr, inptr);
- grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize);
- grub_memcpy (iv, ivt, cipher->cipher->blocksize);
+ grub_crypto_xor (outptr, outptr, iv, blocksize);
+ grub_memcpy (iv, ivt, blocksize);
}
return GPG_ERR_NO_ERROR;
}
@@ -457,7 +470,8 @@ grub_password_get (char buf[], unsigned buf_size)
if (key == '\b')
{
- cur_len--;
+ if (cur_len)
+ cur_len--;
continue;
}
diff --git a/grub-core/lib/disk.c b/grub-core/lib/disk.c
index c7ba68007..0f186883a 100644
--- a/grub-core/lib/disk.c
+++ b/grub-core/lib/disk.c
@@ -37,7 +37,7 @@ grub_disk_cache_invalidate (unsigned long dev_id, unsigned long disk_id,
unsigned cache_index;
struct grub_disk_cache *cache;
- sector &= ~(GRUB_DISK_CACHE_SIZE - 1);
+ sector &= ~((grub_disk_addr_t) GRUB_DISK_CACHE_SIZE - 1);
cache_index = grub_disk_cache_get_index (dev_id, disk_id, sector);
cache = grub_disk_cache_table + cache_index;
@@ -63,8 +63,8 @@ grub_disk_write (grub_disk_t disk, grub_disk_addr_t sector,
if (grub_disk_adjust_range (disk, &sector, &offset, size) != GRUB_ERR_NONE)
return -1;
- aligned_sector = (sector & ~((1 << (disk->log_sector_size
- - GRUB_DISK_SECTOR_BITS)) - 1));
+ aligned_sector = (sector & ~((1ULL << (disk->log_sector_size
+ - GRUB_DISK_SECTOR_BITS)) - 1));
real_offset = offset + ((sector - aligned_sector) << GRUB_DISK_SECTOR_BITS);
sector = aligned_sector;
@@ -77,14 +77,14 @@ grub_disk_write (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t len;
grub_partition_t part;
- tmp_buf = grub_malloc (1 << disk->log_sector_size);
+ tmp_buf = grub_malloc (1U << disk->log_sector_size);
if (!tmp_buf)
return grub_errno;
part = disk->partition;
disk->partition = 0;
if (grub_disk_read (disk, sector,
- 0, (1 << disk->log_sector_size), tmp_buf)
+ 0, (1U << disk->log_sector_size), tmp_buf)
!= GRUB_ERR_NONE)
{
disk->partition = part;
@@ -93,7 +93,7 @@ grub_disk_write (grub_disk_t disk, grub_disk_addr_t sector,
}
disk->partition = part;
- len = (1 << disk->log_sector_size) - real_offset;
+ len = (1U << disk->log_sector_size) - real_offset;
if (len > size)
len = size;
@@ -110,7 +110,7 @@ grub_disk_write (grub_disk_t disk, grub_disk_addr_t sector,
grub_free (tmp_buf);
- sector += (1 << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
+ sector += (1U << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
buf = (const char *) buf + len;
size -= len;
real_offset = 0;
@@ -120,7 +120,7 @@ grub_disk_write (grub_disk_t disk, grub_disk_addr_t sector,
grub_size_t len;
grub_size_t n;
- len = size & ~((1 << disk->log_sector_size) - 1);
+ len = size & ~((1ULL << disk->log_sector_size) - 1);
n = size >> disk->log_sector_size;
if (n > (disk->max_agglomerate
@@ -137,7 +137,7 @@ grub_disk_write (grub_disk_t disk, grub_disk_addr_t sector,
while (n--)
{
grub_disk_cache_invalidate (disk->dev->id, disk->id, sector);
- sector += (1 << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
+ sector += (1U << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
}
buf = (const char *) buf + len;
diff --git a/grub-core/lib/division.c b/grub-core/lib/division.c
new file mode 100644
index 000000000..35606fea7
--- /dev/null
+++ b/grub-core/lib/division.c
@@ -0,0 +1,74 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2015 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/misc.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_uint64_t
+abs64(grub_int64_t a)
+{
+ return a > 0 ? a : -a;
+}
+
+grub_int64_t
+grub_divmod64s (grub_int64_t n,
+ grub_int64_t d,
+ grub_int64_t *ro)
+{
+ grub_uint64_t ru;
+ grub_int64_t q, r;
+ q = grub_divmod64 (abs64(n), abs64(d), &ru);
+ r = ru;
+ /* Now: |n| = |d| * q + r */
+ if (n < 0)
+ {
+ /* -|n| = |d| * (-q) + (-r) */
+ q = -q;
+ r = -r;
+ }
+ /* Now: n = |d| * q + r */
+ if (d < 0)
+ {
+ /* n = (-|d|) * (-q) + r */
+ q = -q;
+ }
+ /* Now: n = d * q + r */
+ if (ro)
+ *ro = r;
+ return q;
+}
+
+grub_uint32_t
+grub_divmod32 (grub_uint32_t n, grub_uint32_t d, grub_uint32_t *ro)
+{
+ grub_uint64_t q, r;
+ q = grub_divmod64 (n, d, &r);
+ *ro = r;
+ return q;
+}
+
+grub_int32_t
+grub_divmod32s (grub_int32_t n, grub_int32_t d, grub_int32_t *ro)
+{
+ grub_int64_t q, r;
+ q = grub_divmod64s (n, d, &r);
+ *ro = r;
+ return q;
+}
diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c
index 9f34dc77b..b5d520f20 100644
--- a/grub-core/lib/fdt.c
+++ b/grub-core/lib/fdt.c
@@ -19,6 +19,9 @@
#include <grub/fdt.h>
#include <grub/misc.h>
#include <grub/mm.h>
+#include <grub/dl.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
#define FDT_SUPPORTED_VERSION 17
@@ -164,10 +167,10 @@ static int add_subnode (void *fdt, int parentoffset, const char *name)
insert:
grub_memmove (token + entry_size / sizeof(*token), token,
(grub_addr_t) end - (grub_addr_t) token);
- *token = grub_cpu_to_be32(FDT_BEGIN_NODE);
+ *token = grub_cpu_to_be32_compile_time(FDT_BEGIN_NODE);
token[entry_size / sizeof(*token) - 2] = 0; /* padding bytes */
grub_strcpy((char *) (token + 1), name);
- token[entry_size / sizeof(*token) - 1] = grub_cpu_to_be32(FDT_END_NODE);
+ token[entry_size / sizeof(*token) - 1] = grub_cpu_to_be32_compile_time(FDT_END_NODE);
grub_fdt_set_size_dt_struct (fdt, struct_size + entry_size);
return ((grub_addr_t) token - (grub_addr_t) fdt
- grub_fdt_get_off_dt_struct(fdt));
@@ -265,10 +268,9 @@ static grub_uint32_t *find_prop (void *fdt, unsigned int nodeoffset,
the size allocated for the FDT; if this function is called before the other
functions in this file and returns success, the other functions are
guaranteed not to access memory locations outside the allocated memory. */
-int grub_fdt_check_header (void *fdt, unsigned int size)
+int grub_fdt_check_header_nosize (void *fdt)
{
if (((grub_addr_t) fdt & 0x7) || (grub_fdt_get_magic (fdt) != FDT_MAGIC)
- || (grub_fdt_get_totalsize (fdt) > size)
|| (grub_fdt_get_version (fdt) < FDT_SUPPORTED_VERSION)
|| (grub_fdt_get_last_comp_version (fdt) > FDT_SUPPORTED_VERSION)
|| (grub_fdt_get_off_dt_struct (fdt) & 0x00000003)
@@ -284,6 +286,15 @@ int grub_fdt_check_header (void *fdt, unsigned int size)
return 0;
}
+int grub_fdt_check_header (void *fdt, unsigned int size)
+{
+ if (size < sizeof (grub_fdt_header_t)
+ || (grub_fdt_get_totalsize (fdt) > size)
+ || grub_fdt_check_header_nosize (fdt) == -1)
+ return -1;
+ return 0;
+}
+
/* Find a direct sub-node of a given parent node. */
int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset,
const char *name)
@@ -369,7 +380,7 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
prop_name_present = 1;
for (i = 0; i < prop_len / sizeof(grub_uint32_t); i++)
- *(prop + 3 + i) = grub_cpu_to_be32 (FDT_NOP);
+ *(prop + 3 + i) = grub_cpu_to_be32_compile_time (FDT_NOP);
if (len > ALIGN_UP(prop_len, sizeof(grub_uint32_t)))
{
/* Length of new property value is greater than the space allocated
@@ -377,7 +388,7 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
nameoff field of the current entry and replace the current entry
with NOP tokens. */
nameoff = grub_be_to_cpu32 (*(prop + 2));
- *prop = *(prop + 1) = *(prop + 2) = grub_cpu_to_be32 (FDT_NOP);
+ *prop = *(prop + 1) = *(prop + 2) = grub_cpu_to_be32_compile_time (FDT_NOP);
prop = NULL;
}
}
@@ -411,7 +422,7 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
struct_end(fdt) - (grub_addr_t) prop);
grub_fdt_set_size_dt_struct (fdt, grub_fdt_get_size_dt_struct (fdt)
+ prop_entry_size(len));
- *prop = grub_cpu_to_be32 (FDT_PROP);
+ *prop = grub_cpu_to_be32_compile_time (FDT_PROP);
*(prop + 2) = grub_cpu_to_be32 (nameoff);
}
*(prop + 1) = grub_cpu_to_be32 (len);
@@ -423,3 +434,32 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
grub_memcpy (prop + 3, val, len);
return 0;
}
+
+int
+grub_fdt_create_empty_tree (void *fdt, unsigned int size)
+{
+ struct grub_fdt_empty_tree *et;
+
+ if (size < GRUB_FDT_EMPTY_TREE_SZ)
+ return -1;
+
+ grub_memset (fdt, 0, size);
+ et = fdt;
+
+ et->empty_node.tree_end = grub_cpu_to_be32_compile_time (FDT_END);
+ et->empty_node.node_end = grub_cpu_to_be32_compile_time (FDT_END_NODE);
+ et->empty_node.node_start = grub_cpu_to_be32_compile_time (FDT_BEGIN_NODE);
+ ((struct grub_fdt_empty_tree *) fdt)->header.off_mem_rsvmap =
+ grub_cpu_to_be32_compile_time (ALIGN_UP (sizeof (grub_fdt_header_t), 8));
+
+ grub_fdt_set_off_dt_strings (fdt, sizeof (*et));
+ grub_fdt_set_off_dt_struct (fdt,
+ sizeof (et->header) + sizeof (et->empty_rsvmap));
+ grub_fdt_set_version (fdt, FDT_SUPPORTED_VERSION);
+ grub_fdt_set_last_comp_version (fdt, FDT_SUPPORTED_VERSION);
+ grub_fdt_set_size_dt_struct (fdt, sizeof (et->empty_node));
+ grub_fdt_set_totalsize (fdt, size);
+ grub_fdt_set_magic (fdt, FDT_MAGIC);
+
+ return 0;
+}
diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c
index 7a7796a12..c3e03c727 100644
--- a/grub-core/lib/i386/backtrace.c
+++ b/grub-core/lib/i386/backtrace.c
@@ -56,11 +56,11 @@ void
grub_backtrace (void)
{
#ifdef __x86_64__
- asm volatile ("movq %rbp, %rdi\n"
- "call " EXT_C("grub_backtrace_pointer"));
+ asm volatile ("movq %%rbp, %%rdi\n"
+ "callq *%%rax": :"a"(grub_backtrace_pointer));
#else
- asm volatile ("movl %ebp, %eax\n"
- "call " EXT_C("grub_backtrace_pointer"));
+ asm volatile ("movl %%ebp, %%eax\n"
+ "calll *%%ecx": :"c"(grub_backtrace_pointer));
#endif
}
diff --git a/grub-core/lib/i386/random.c b/grub-core/lib/i386/random.c
new file mode 100644
index 000000000..cd83d2f8f
--- /dev/null
+++ b/grub-core/lib/i386/random.c
@@ -0,0 +1,103 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2016 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/random.h>
+#include <grub/i386/io.h>
+#include <grub/i386/tsc.h>
+#include <grub/i386/pmtimer.h>
+#include <grub/acpi.h>
+
+static int have_tsc = -1, have_pmtimer = -1;
+static grub_port_t pmtimer_port;
+
+static int
+detect_pmtimer (void)
+{
+ struct grub_acpi_fadt *fadt;
+ fadt = grub_acpi_find_fadt ();
+ if (!fadt)
+ return 0;
+ pmtimer_port = fadt->pmtimer;
+ if (!pmtimer_port)
+ return 0;
+ return 1;
+}
+
+static int
+pmtimer_tsc_get_random_bit (void)
+{
+ /* It's hard to come up with figures about pmtimer and tsc jitter but
+ 50 ppm seems to be typical. So we need 10^6/50 tsc cycles to get drift
+ of one tsc cycle. With TSC at least of 800 MHz it means 1/(50*800)
+ = 1/40000 s or about 3579545 / 40000 = 90 pmtimer ticks.
+ This gives us rate of 40000 bit/s or 5 kB/s.
+ */
+ grub_uint64_t tsc_diff;
+ tsc_diff = grub_pmtimer_wait_count_tsc (pmtimer_port, 90);
+ if (tsc_diff == 0)
+ {
+ have_pmtimer = 0;
+ return -1;
+ }
+ return tsc_diff & 1;
+}
+
+static int
+pmtimer_tsc_get_random_byte (void)
+{
+ grub_uint8_t ret = 0;
+ int i, c;
+ for (i = 0; i < 8; i++)
+ {
+ c = pmtimer_tsc_get_random_bit ();
+ if (c < 0)
+ return -1;
+ ret |= c << i;
+ }
+ return ret;
+}
+
+static int
+pmtimer_fill_buffer (void *buffer, grub_size_t sz)
+{
+ grub_uint8_t *p = buffer;
+ int c;
+ while (sz)
+ {
+ c = pmtimer_tsc_get_random_byte ();
+ if (c < 0)
+ return 0;
+ *p++ = c;
+ sz--;
+ }
+ return 1;
+}
+
+int
+grub_crypto_arch_get_random (void *buffer, grub_size_t sz)
+{
+ if (have_tsc == -1)
+ have_tsc = grub_cpu_is_tsc_supported ();
+ if (!have_tsc)
+ return 0;
+ if (have_pmtimer == -1)
+ have_pmtimer = detect_pmtimer ();
+ if (!have_pmtimer)
+ return 0;
+ return pmtimer_fill_buffer (buffer, sz);
+}
diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c
index d2a1b27ae..71dd4f0ab 100644
--- a/grub-core/lib/i386/relocator.c
+++ b/grub-core/lib/i386/relocator.c
@@ -64,7 +64,6 @@ extern grub_uint64_t grub_relocator64_rbx;
extern grub_uint64_t grub_relocator64_rcx;
extern grub_uint64_t grub_relocator64_rdx;
extern grub_uint64_t grub_relocator64_rip;
-extern grub_uint64_t grub_relocator64_rip_addr;
extern grub_uint64_t grub_relocator64_rsp;
extern grub_uint64_t grub_relocator64_rsi;
extern grub_addr_t grub_relocator64_cr3;
@@ -81,10 +80,13 @@ grub_relocator32_boot (struct grub_relocator *rel,
void *relst;
grub_relocator_chunk_t ch;
- err = grub_relocator_alloc_chunk_align (rel, &ch, 0,
- (0xffffffff - RELOCATOR_SIZEOF (32))
- + 1, RELOCATOR_SIZEOF (32), 16,
- GRUB_RELOCATOR_PREFERENCE_NONE,
+ /* Specific memory range due to Global Descriptor Table for use by payload
+ that we will store in returned chunk. The address range and preference
+ are based on "THE LINUX/x86 BOOT PROTOCOL" specification. */
+ err = grub_relocator_alloc_chunk_align (rel, &ch, 0x1000,
+ 0x9a000 - RELOCATOR_SIZEOF (32),
+ RELOCATOR_SIZEOF (32), 16,
+ GRUB_RELOCATOR_PREFERENCE_LOW,
avoid_efi_bootservices);
if (err)
return err;
diff --git a/grub-core/lib/ieee1275/datetime.c b/grub-core/lib/ieee1275/datetime.c
index 74578f15a..b81fba2ed 100644
--- a/grub-core/lib/ieee1275/datetime.c
+++ b/grub-core/lib/ieee1275/datetime.c
@@ -95,7 +95,7 @@ grub_get_datetime (struct grub_datetime *datetime)
datetime->year = args.year;
datetime->month = args.month;
- datetime->day = args.day;
+ datetime->day = args.day + 1;
datetime->hour = args.hour;
datetime->minute = args.minute;
datetime->second = args.second;
@@ -140,7 +140,7 @@ grub_set_datetime (struct grub_datetime *datetime)
args.year = datetime->year;
args.month = datetime->month;
- args.day = datetime->day;
+ args.day = datetime->day - 1;
args.hour = datetime->hour;
args.minute = datetime->minute;
args.second = datetime->second;
diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c
index 300d8b961..ef56150ac 100644
--- a/grub-core/lib/legacy_parse.c
+++ b/grub-core/lib/legacy_parse.c
@@ -24,6 +24,8 @@
#include <grub/i386/pc/vesa_modes_table.h>
#include <grub/i18n.h>
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
struct legacy_command
{
const char *name;
@@ -662,6 +664,7 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
{
case TYPE_FILE_NO_CONSUME:
hold_arg = 1;
+ /* Fallthrough. */
case TYPE_PARTITION:
case TYPE_FILE:
args[i] = adjust_file (curarg, curarglen);
diff --git a/grub-core/lib/libgcrypt/cipher/rijndael.c b/grub-core/lib/libgcrypt/cipher/rijndael.c
index 4e8eb3abe..559550b50 100644
--- a/grub-core/lib/libgcrypt/cipher/rijndael.c
+++ b/grub-core/lib/libgcrypt/cipher/rijndael.c
@@ -357,7 +357,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
for (j = KC-1; j >= 0; j--)
{
- *((u32*)tk[j]) = *((u32*)k[j]);
+ *((u32_a_t*)tk[j]) = *((u32_a_t*)k[j]);
}
r = 0;
t = 0;
@@ -366,7 +366,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
{
for (; (j < KC) && (t < 4); j++, t++)
{
- *((u32*)W[r][t]) = *((u32*)tk[j]);
+ *((u32_a_t*)W[r][t]) = *((u32_a_t*)tk[j]);
}
if (t == 4)
{
@@ -389,14 +389,14 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
{
for (j = 1; j < KC; j++)
{
- *((u32*)tk[j]) ^= *((u32*)tk[j-1]);
+ *((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
}
}
else
{
for (j = 1; j < KC/2; j++)
{
- *((u32*)tk[j]) ^= *((u32*)tk[j-1]);
+ *((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
}
tk[KC/2][0] ^= S[tk[KC/2 - 1][0]];
tk[KC/2][1] ^= S[tk[KC/2 - 1][1]];
@@ -404,7 +404,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
tk[KC/2][3] ^= S[tk[KC/2 - 1][3]];
for (j = KC/2 + 1; j < KC; j++)
{
- *((u32*)tk[j]) ^= *((u32*)tk[j-1]);
+ *((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
}
}
@@ -413,7 +413,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
{
for (; (j < KC) && (t < 4); j++, t++)
{
- *((u32*)W[r][t]) = *((u32*)tk[j]);
+ *((u32_a_t*)W[r][t]) = *((u32_a_t*)tk[j]);
}
if (t == 4)
{
@@ -483,29 +483,29 @@ prepare_decryption( RIJNDAEL_context *ctx )
for (r=0; r < MAXROUNDS+1; r++ )
{
- *((u32*)ctx->keyschdec[r][0]) = *((u32*)ctx->keyschenc[r][0]);
- *((u32*)ctx->keyschdec[r][1]) = *((u32*)ctx->keyschenc[r][1]);
- *((u32*)ctx->keyschdec[r][2]) = *((u32*)ctx->keyschenc[r][2]);
- *((u32*)ctx->keyschdec[r][3]) = *((u32*)ctx->keyschenc[r][3]);
+ *((u32_a_t*)ctx->keyschdec[r][0]) = *((u32_a_t*)ctx->keyschenc[r][0]);
+ *((u32_a_t*)ctx->keyschdec[r][1]) = *((u32_a_t*)ctx->keyschenc[r][1]);
+ *((u32_a_t*)ctx->keyschdec[r][2]) = *((u32_a_t*)ctx->keyschenc[r][2]);
+ *((u32_a_t*)ctx->keyschdec[r][3]) = *((u32_a_t*)ctx->keyschenc[r][3]);
}
#define W (ctx->keyschdec)
for (r = 1; r < ctx->rounds; r++)
{
w = W[r][0];
- *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
- ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
+ *((u32_a_t*)w) = *((u32_a_t*)U1[w[0]]) ^ *((u32_a_t*)U2[w[1]])
+ ^ *((u32_a_t*)U3[w[2]]) ^ *((u32_a_t*)U4[w[3]]);
w = W[r][1];
- *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
- ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
+ *((u32_a_t*)w) = *((u32_a_t*)U1[w[0]]) ^ *((u32_a_t*)U2[w[1]])
+ ^ *((u32_a_t*)U3[w[2]]) ^ *((u32_a_t*)U4[w[3]]);
w = W[r][2];
- *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
- ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
+ *((u32_a_t*)w) = *((u32_a_t*)U1[w[0]]) ^ *((u32_a_t*)U2[w[1]])
+ ^ *((u32_a_t*)U3[w[2]]) ^ *((u32_a_t*)U4[w[3]]);
w = W[r][3];
- *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
- ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
+ *((u32_a_t*)w) = *((u32_a_t*)U1[w[0]]) ^ *((u32_a_t*)U2[w[1]])
+ ^ *((u32_a_t*)U3[w[2]]) ^ *((u32_a_t*)U4[w[3]]);
}
#undef W
#undef w
diff --git a/grub-core/lib/mips/setjmp.S b/grub-core/lib/mips/setjmp.S
index f01294518..895235b78 100644
--- a/grub-core/lib/mips/setjmp.S
+++ b/grub-core/lib/mips/setjmp.S
@@ -18,6 +18,7 @@
#include <grub/symbol.h>
#include <grub/dl.h>
+#include <grub/mips/asm.h>
.file "setjmp.S"
@@ -29,40 +30,42 @@ GRUB_MOD_LICENSE "GPLv3+"
* int grub_setjmp (grub_jmp_buf env)
*/
FUNCTION(grub_setjmp)
- sw $s0, 0($a0)
- sw $s1, 4($a0)
- sw $s2, 8($a0)
- sw $s3, 12($a0)
- sw $s4, 16($a0)
- sw $s5, 20($a0)
- sw $s6, 24($a0)
- sw $s7, 28($a0)
- sw $s8, 32($a0)
- sw $gp, 36($a0)
- sw $sp, 40($a0)
- sw $ra, 44($a0)
+ GRUB_ASM_REG_S $s0, 0($a0)
+ GRUB_ASM_REG_S $s1, 8($a0)
+ GRUB_ASM_REG_S $s2, 16($a0)
+ GRUB_ASM_REG_S $s3, 24($a0)
+ GRUB_ASM_REG_S $s4, 32($a0)
+ GRUB_ASM_REG_S $s5, 40($a0)
+ GRUB_ASM_REG_S $s6, 48($a0)
+ GRUB_ASM_REG_S $s7, 56($a0)
+ GRUB_ASM_REG_S $s8, 64($a0)
+ GRUB_ASM_REG_S $gp, 72($a0)
+ GRUB_ASM_REG_S $sp, 80($a0)
+ GRUB_ASM_REG_S $ra, 88($a0)
move $v0, $zero
move $v1, $zero
jr $ra
+ nop
/*
* int grub_longjmp (grub_jmp_buf env, int val)
*/
FUNCTION(grub_longjmp)
- lw $s0, 0($a0)
- lw $s1, 4($a0)
- lw $s2, 8($a0)
- lw $s3, 12($a0)
- lw $s4, 16($a0)
- lw $s5, 20($a0)
- lw $s6, 24($a0)
- lw $s7, 28($a0)
- lw $s8, 32($a0)
- lw $gp, 36($a0)
- lw $sp, 40($a0)
- lw $ra, 44($a0)
+ GRUB_ASM_REG_L $s0, 0($a0)
+ GRUB_ASM_REG_L $s1, 8($a0)
+ GRUB_ASM_REG_L $s2, 16($a0)
+ GRUB_ASM_REG_L $s3, 24($a0)
+ GRUB_ASM_REG_L $s4, 32($a0)
+ GRUB_ASM_REG_L $s5, 40($a0)
+ GRUB_ASM_REG_L $s6, 48($a0)
+ GRUB_ASM_REG_L $s7, 56($a0)
+ GRUB_ASM_REG_L $s8, 64($a0)
+ GRUB_ASM_REG_L $gp, 72($a0)
+ GRUB_ASM_REG_L $sp, 80($a0)
+ GRUB_ASM_REG_L $ra, 88($a0)
move $v0, $a1
bne $v0, $zero, 1f
addiu $v0, $v0, 1
1:
move $v1, $zero
jr $ra
+ nop
diff --git a/grub-core/lib/pbkdf2.c b/grub-core/lib/pbkdf2.c
index 2fbaa95e8..28aa96c46 100644
--- a/grub-core/lib/pbkdf2.c
+++ b/grub-core/lib/pbkdf2.c
@@ -31,7 +31,6 @@ GRUB_MOD_LICENSE ("GPLv2+");
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. */
-#pragma GCC diagnostic ignored "-Wunreachable-code"
gcry_err_code_t
grub_crypto_pbkdf2 (const struct gcry_md_spec *md,
@@ -52,7 +51,7 @@ grub_crypto_pbkdf2 (const struct gcry_md_spec *md,
grub_uint8_t *tmp;
grub_size_t tmplen = Slen + 4;
- if (md->mdlen > GRUB_CRYPTO_MAX_MDLEN)
+ if (md->mdlen > GRUB_CRYPTO_MAX_MDLEN || md->mdlen == 0)
return GPG_ERR_INV_ARG;
if (c == 0)
diff --git a/grub-core/lib/posix_wrap/string.h b/grub-core/lib/posix_wrap/string.h
index c4b9bf089..7ae6eee97 100644
--- a/grub-core/lib/posix_wrap/string.h
+++ b/grub-core/lib/posix_wrap/string.h
@@ -42,21 +42,6 @@ strcasecmp (const char *s1, const char *s2)
return grub_strcasecmp (s1, s2);
}
-#ifdef GRUB_UTIL
-static inline void *
-memcpy (void *dest, const void *src, grub_size_t n)
-{
- return grub_memcpy (dest, src, n);
-}
-
-static inline int
-memcmp (const void *s1, const void *s2, grub_size_t n)
-{
- return grub_memcmp (s1, s2, n);
-}
-
-#endif
-
static inline void
bcopy (const void *src, void *dest, grub_size_t n)
{
@@ -99,4 +84,9 @@ memchr (const void *s, int c, grub_size_t n)
return grub_memchr (s, c, n);
}
+#define memcmp grub_memcmp
+#define memcpy grub_memcpy
+#define memmove grub_memmove
+#define memset grub_memset
+
#endif
diff --git a/grub-core/lib/progress.c b/grub-core/lib/progress.c
index 63a0767d6..4b7cbbca6 100644
--- a/grub-core/lib/progress.c
+++ b/grub-core/lib/progress.c
@@ -23,6 +23,7 @@
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/normal.h>
+#include <grub/net.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -37,11 +38,17 @@ grub_file_progress_hook_real (grub_disk_addr_t sector __attribute__ ((unused)),
grub_uint64_t now;
static grub_uint64_t last_progress_update_time;
grub_file_t file = data;
+ const char *e;
file->progress_offset += length;
if (call_depth)
return;
+ e = grub_env_get ("enable_progress_indicator");
+ if (e && e[0] == '0') {
+ return;
+ }
+
call_depth = 1;
now = grub_get_time_ms ();
@@ -70,7 +77,15 @@ grub_file_progress_hook_real (grub_disk_addr_t sector __attribute__ ((unused)),
percent = grub_divmod64 (100 * file->progress_offset,
file->size, 0);
- partial_file_name = grub_strrchr (file->name, '/');
+ /* grub_net_fs_open() saves off partial file structure before name is initialized.
+ It already saves passed file name in net structure so just use it in this case.
+ */
+ if (file->device->net)
+ partial_file_name = grub_strrchr (file->device->net->name, '/');
+ else if (file->name) /* grub_file_open() may leave it as NULL */
+ partial_file_name = grub_strrchr (file->name, '/');
+ else
+ partial_file_name = NULL;
if (partial_file_name)
partial_file_name++;
else
diff --git a/grub-core/lib/random.c b/grub-core/lib/random.c
new file mode 100644
index 000000000..43b966438
--- /dev/null
+++ b/grub-core/lib/random.c
@@ -0,0 +1,120 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2016 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/random.h>
+#include <grub/dl.h>
+#include <grub/lib/hexdump.h>
+#include <grub/command.h>
+#include <grub/mm.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+grub_err_t
+grub_crypto_get_random (void *buffer, grub_size_t sz)
+{
+ /* This is an arbitrer between different methods.
+ TODO: Add more methods in the future. */
+ /* TODO: Add some PRNG smartness to reduce damage from bad entropy. */
+ if (grub_crypto_arch_get_random (buffer, sz))
+ return GRUB_ERR_NONE;
+ return grub_error (GRUB_ERR_IO, "no random sources found");
+}
+
+static int
+get_num_digits (int val)
+{
+ int ret = 0;
+ while (val != 0)
+ {
+ ret++;
+ val /= 10;
+ }
+ if (ret == 0)
+ return 1;
+ return ret;
+}
+
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
+static grub_err_t
+grub_cmd_hexdump_random (grub_command_t cmd __attribute__ ((unused)), int argc, char **args)
+{
+ grub_size_t length = 64;
+ grub_err_t err;
+ void *buffer;
+ grub_uint8_t *ptr;
+ int stats[256];
+ int i, digits = 2;
+ char template[10];
+
+ if (argc >= 1)
+ length = grub_strtoull (args[0], 0, 0);
+
+ if (length == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "length pust be positive");
+
+ buffer = grub_malloc (length);
+ if (!buffer)
+ return grub_errno;
+
+ err = grub_crypto_get_random (buffer, length);
+ if (err)
+ {
+ grub_free (buffer);
+ return err;
+ }
+
+ hexdump (0, buffer, length);
+ grub_memset(stats, 0, sizeof(stats));
+ for (ptr = buffer; ptr < (grub_uint8_t *) buffer + length; ptr++)
+ stats[*ptr]++;
+ grub_printf ("Statistics:\n");
+ for (i = 0; i < 256; i++)
+ {
+ int z = get_num_digits (stats[i]);
+ if (z > digits)
+ digits = z;
+ }
+
+ grub_snprintf (template, sizeof (template), "%%0%dd ", digits);
+
+ for (i = 0; i < 256; i++)
+ {
+ grub_printf ("%s", template);//, stats[i]);
+ if ((i & 0xf) == 0xf)
+ grub_printf ("\n");
+ }
+
+ grub_free (buffer);
+
+ return 0;
+}
+
+static grub_command_t cmd;
+
+GRUB_MOD_INIT (random)
+{
+ cmd = grub_register_command ("hexdump_random", grub_cmd_hexdump_random,
+ N_("[LENGTH]"),
+ N_("Hexdump random data."));
+}
+
+GRUB_MOD_FINI (random)
+{
+ grub_unregister_command (cmd);
+}
diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c
index 7263cbc04..ee9fa7b4f 100644
--- a/grub-core/lib/reed_solomon.c
+++ b/grub-core/lib/reed_solomon.c
@@ -362,7 +362,7 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size,
/* Nothing to do. */
if (!rs)
- return;
+ goto exit;
init_powx ();
@@ -388,6 +388,7 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size,
#ifndef TEST
assert (grub_memcmp (tmp, buffer, data_size) == 0);
#endif
+exit:
free (tmp);
}
#endif
diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c
index 9f9770bc4..ea3ebc719 100644
--- a/grub-core/lib/relocator.c
+++ b/grub-core/lib/relocator.c
@@ -652,7 +652,7 @@ malloc_in_range (struct grub_relocator *rel,
for (i = 0; i < (BITS_IN_BYTE * sizeof (grub_addr_t) / DIGITSORT_BITS);
i++)
{
- memset (counter, 0, (1 + (1 << DIGITSORT_BITS)) * sizeof (counter[0]));
+ grub_memset (counter, 0, (1 + (1 << DIGITSORT_BITS)) * sizeof (counter[0]));
for (j = 0; j < N; j++)
counter[((events[j].pos >> (DIGITSORT_BITS * i))
& DIGITSORT_MASK) + 1]++;
@@ -736,26 +736,36 @@ malloc_in_range (struct grub_relocator *rel,
}
isinsideafter = (!ncollisions && (nstarted || ((nlefto || nstartedfw)
&& !nblockfw)));
- if (!isinsidebefore && isinsideafter)
- starta = from_low_priv ? ALIGN_UP (events[j].pos, align)
- : ALIGN_DOWN (events[j].pos - size, align) + size;
- if (isinsidebefore && !isinsideafter && from_low_priv)
- {
- target = starta;
- if (target < start)
- target = start;
- if (target + size <= end && target + size <= events[j].pos)
- /* Found an usable address. */
- goto found;
- }
- if (isinsidebefore && !isinsideafter && !from_low_priv)
- {
- target = starta - size;
- if (target > end - size)
- target = end - size;
- if (target >= start && target >= events[j].pos)
- goto found;
- }
+ if (from_low_priv) {
+ if (!isinsidebefore && isinsideafter)
+ starta = ALIGN_UP (events[j].pos, align);
+
+ if (isinsidebefore && !isinsideafter)
+ {
+ target = starta;
+ if (target < start)
+ target = start;
+ if (target + size <= end && target + size <= events[j].pos)
+ /* Found an usable address. */
+ goto found;
+ }
+ } else {
+ if (!isinsidebefore && isinsideafter)
+ {
+ if (events[j].pos >= size)
+ starta = ALIGN_DOWN (events[j].pos - size, align) + size;
+ else
+ starta = 0;
+ }
+ if (isinsidebefore && !isinsideafter && starta >= size)
+ {
+ target = starta - size;
+ if (target > end - size)
+ target = end - size;
+ if (target >= start && target >= events[j].pos)
+ goto found;
+ }
+ }
}
}
@@ -865,6 +875,8 @@ malloc_in_range (struct grub_relocator *rel,
% GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT;
struct grub_relocator_fw_leftover *lo
= events[last_lo].leftover;
+ if (offend == 0 && alloc_end != alloc_start)
+ offend = GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT;
lo->freebytes[offstart / 8]
&= ((1 << (8 - (start % 8))) - 1);
grub_memset (lo->freebytes + (offstart + 7) / 8, 0,
diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c
index 21fa17504..28ba3aef0 100644
--- a/grub-core/lib/syslinux_parse.c
+++ b/grub-core/lib/syslinux_parse.c
@@ -649,6 +649,8 @@ helptext (const char *line, grub_file_t file, struct syslinux_menu *menu)
grub_size_t helplen, alloclen = 0;
help = grub_strdup (line);
+ if (!help)
+ return grub_errno;
helplen = grub_strlen (line);
while ((grub_free (buf), buf = grub_file_getline (file)))
{
@@ -682,6 +684,7 @@ helptext (const char *line, grub_file_t file, struct syslinux_menu *menu)
}
grub_free (buf);
+ grub_free (help);
return grub_errno;
}
@@ -717,7 +720,7 @@ syslinux_parse_real (struct syslinux_menu *menu)
for (ptr3 = ptr2; grub_isspace (*ptr3) && *ptr3; ptr3++);
for (ptr4 = ptr3; !grub_isspace (*ptr4) && *ptr4; ptr4++);
for (ptr5 = ptr4; grub_isspace (*ptr5) && *ptr5; ptr5++);
- for (i = 0; i < sizeof (commands) / sizeof (commands[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(commands); i++)
if (grub_strlen (commands[i].name1) == (grub_size_t) (ptr2 - ptr1)
&& grub_strncasecmp (commands[i].name1, ptr1, ptr2 - ptr1) == 0
&& (commands[i].name2 == NULL
@@ -726,7 +729,7 @@ syslinux_parse_real (struct syslinux_menu *menu)
&& grub_strncasecmp (commands[i].name2, ptr3, ptr4 - ptr3)
== 0)))
break;
- if (i == sizeof (commands) / sizeof (commands[0]))
+ if (i == ARRAY_SIZE(commands))
{
if (sizeof ("text") - 1 == ptr2 - ptr1
&& grub_strncasecmp ("text", ptr1, ptr2 - ptr1) == 0
@@ -769,7 +772,7 @@ print_escaped (struct output_buffer *outbuf,
if (err)
return err;
outbuf->buf[outbuf->ptr++] = '\'';
- for (ptr = from; *ptr; ptr++)
+ for (ptr = from; *ptr && ptr < to; ptr++)
{
if (*ptr == '\'')
{
@@ -837,13 +840,96 @@ simplify_filename (char *str)
}
static grub_err_t
+print_config (struct output_buffer *outbuf,
+ struct syslinux_menu *menu,
+ const char *filename, const char *basedir)
+{
+ struct syslinux_menu *menuptr;
+ grub_err_t err = GRUB_ERR_NONE;
+ char *new_cwd = NULL;
+ char *new_target_cwd = NULL;
+ char *newname = NULL;
+ int depth = 0;
+
+ new_cwd = get_read_filename (menu, basedir);
+ if (!new_cwd)
+ {
+ err = grub_errno;
+ goto out;
+ }
+ new_target_cwd = get_target_filename (menu, basedir);
+ if (!new_target_cwd)
+ {
+ err = grub_errno;
+ goto out;
+ }
+ newname = get_read_filename (menu, filename);
+ if (!newname)
+ {
+ err = grub_errno;
+ goto out;
+ }
+ simplify_filename (newname);
+
+ print_string ("#");
+ print_file (outbuf, menu, filename, NULL);
+ print_string (" ");
+ err = print (outbuf, newname, grub_strlen (newname));
+ if (err)
+ return err;
+ print_string (":\n");
+
+ for (menuptr = menu; menuptr; menuptr = menuptr->parent, depth++)
+ if (grub_strcmp (menuptr->filename, newname) == 0
+ || depth > 20)
+ break;
+ if (menuptr)
+ {
+ print_string (" syslinux_configfile -r ");
+ print_file (outbuf, menu, "/", NULL);
+ print_string (" -c ");
+ print_file (outbuf, menu, basedir, NULL);
+ print_string (" ");
+ print_file (outbuf, menu, filename, NULL);
+ print_string ("\n");
+ }
+ else
+ {
+ err = config_file (outbuf, menu->root_read_directory,
+ menu->root_target_directory, new_cwd, new_target_cwd,
+ newname, menu, menu->flavour);
+ if (err == GRUB_ERR_FILE_NOT_FOUND
+ || err == GRUB_ERR_BAD_FILENAME)
+ {
+ grub_errno = err = GRUB_ERR_NONE;
+ print_string ("# File ");
+ err = print (outbuf, newname, grub_strlen (newname));
+ if (err)
+ goto out;
+ print_string (" not found\n");
+ }
+ }
+
+ out:
+ grub_free (newname);
+ grub_free (new_cwd);
+ grub_free (new_target_cwd);
+ return err;
+}
+
+static grub_err_t
write_entry (struct output_buffer *outbuf,
struct syslinux_menu *menu,
struct syslinux_menuentry *curentry)
{
grub_err_t err;
if (curentry->comments)
- print (outbuf, curentry->comments, grub_strlen (curentry->comments));
+ {
+ err = print (outbuf, curentry->comments,
+ grub_strlen (curentry->comments));
+ if (err)
+ return err;
+ }
{
struct syslinux_say *say;
for (say = curentry->say; say && say->next; say = say->next);
@@ -860,9 +946,8 @@ write_entry (struct output_buffer *outbuf,
{
case KERNEL_LINUX:
{
- char *ptr;
- char *cmdline;
- char *initrd = NULL;
+ const char *ptr;
+ const char *initrd = NULL, *initrde= NULL;
for (ptr = curentry->append; ptr && *ptr; ptr++)
if ((ptr == curentry->append || grub_isspace (ptr[-1]))
&& grub_strncasecmp (ptr, "initrd=", sizeof ("initrd=") - 1)
@@ -870,32 +955,20 @@ write_entry (struct output_buffer *outbuf,
break;
if (ptr && *ptr)
{
- char *ptr2;
- grub_size_t totlen = grub_strlen (curentry->append);
initrd = ptr + sizeof ("initrd=") - 1;
- for (ptr2 = ptr; *ptr2 && !grub_isspace (*ptr2); ptr2++);
- if (*ptr2)
- {
- *ptr2 = 0;
- ptr2++;
- }
- cmdline = grub_malloc (totlen + 1 - (ptr2 - ptr));
- if (!cmdline)
- return grub_errno;
- grub_memcpy (cmdline, curentry->append, ptr - curentry->append);
- grub_memcpy (cmdline + (ptr - curentry->append),
- ptr2, totlen - (ptr2 - curentry->append));
- *(cmdline + totlen - (ptr2 - ptr)) = 0;
+ for (initrde = initrd; *initrde && !grub_isspace (*initrde); initrde++);
}
- else
- cmdline = curentry->append;
print_string (" if test x$grub_platform = xpc; then "
"linux_suffix=16; else linux_suffix= ; fi\n");
print_string (" linux$linux_suffix ");
print_file (outbuf, menu, curentry->kernel_file, NULL);
print_string (" ");
- if (cmdline)
- print (outbuf, cmdline, grub_strlen (cmdline));
+ if (curentry->append)
+ {
+ err = print (outbuf, curentry->append, grub_strlen (curentry->append));
+ if (err)
+ return err;
+ }
print_string ("\n");
if (initrd || curentry->initrds)
{
@@ -903,7 +976,7 @@ write_entry (struct output_buffer *outbuf,
print_string (" initrd$linux_suffix ");
if (initrd)
{
- print_file (outbuf, menu, initrd, NULL);
+ print_file (outbuf, menu, initrd, initrde);
print_string (" ");
}
for (lst = curentry->initrds; lst; lst = lst->next)
@@ -949,6 +1022,7 @@ write_entry (struct output_buffer *outbuf,
break;
}
print_string (" # UNSUPPORTED localboot type ");
+ print_string ("\ntrue;\n");
if (print_num (outbuf, n))
return grub_errno;
print_string ("\n");
@@ -1124,8 +1198,7 @@ write_entry (struct output_buffer *outbuf,
ptr++;
i386e = ptr;
}
- if (lme)
- *lme = '\0';
+ *lme = '\0';
if (paee)
*paee = '\0';
if (i386e)
@@ -1230,6 +1303,36 @@ write_entry (struct output_buffer *outbuf,
break;
}
+ if (grub_strcasecmp (basename, "menu.c32") == 0 ||
+ grub_strcasecmp (basename, "vesamenu.c32") == 0)
+ {
+ char *ptr;
+ char *end;
+
+ ptr = curentry->append;
+ if (!ptr)
+ return grub_errno;
+
+ while (*ptr)
+ {
+ end = ptr;
+ for (end = ptr; *end && !grub_isspace (*end); end++);
+ if (*end)
+ *end++ = '\0';
+
+ /* "~" is supposed to be current file, so let's skip it */
+ if (grub_strcmp (ptr, "~") != 0)
+ {
+ err = print_config (outbuf, menu, ptr, "");
+ if (err != GRUB_ERR_NONE)
+ break;
+ }
+ for (ptr = end; *ptr && grub_isspace (*ptr); ptr++);
+ }
+ err = GRUB_ERR_NONE;
+ break;
+ }
+
/* FIXME: gdb, GFXBoot, Hdt, Ifcpu, Ifplop, Kbdmap,
FIXME: Linux, Lua, Meminfo, rosh, Sanbboot */
@@ -1242,70 +1345,13 @@ write_entry (struct output_buffer *outbuf,
}
case KERNEL_CONFIG:
{
- char *new_cwd, *new_target_cwd;
const char *ap;
ap = curentry->append;
if (!ap)
ap = curentry->argument;
if (!ap)
ap = "";
- new_cwd = get_read_filename (menu, ap);
- if (!new_cwd)
- return grub_errno;
- new_target_cwd = get_target_filename (menu, ap);
- if (!new_target_cwd)
- return grub_errno;
-
- struct syslinux_menu *menuptr;
- char *newname;
- int depth = 0;
-
- newname = get_read_filename (menu, curentry->kernel_file);
- if (!newname)
- return grub_errno;
- simplify_filename (newname);
-
- print_string ("#");
- print_file (outbuf, menu, curentry->kernel_file, NULL);
- print_string (" ");
- print (outbuf, newname, grub_strlen (newname));
- print_string (":\n");
-
- for (menuptr = menu; menuptr; menuptr = menuptr->parent, depth++)
- if (grub_strcmp (menuptr->filename, newname) == 0
- || depth > 20)
- break;
- if (menuptr)
- {
- print_string (" syslinux_configfile -r ");
- print_file (outbuf, menu, "/", NULL);
- print_string (" -c ");
- print_file (outbuf, menu, ap, NULL);
- print_string (" ");
- print_file (outbuf, menu, curentry->kernel_file, NULL);
- print_string ("\n");
- }
- else
- {
- err = config_file (outbuf, menu->root_read_directory,
- menu->root_target_directory, new_cwd, new_target_cwd,
- newname, menu, menu->flavour);
- if (err == GRUB_ERR_FILE_NOT_FOUND
- || err == GRUB_ERR_BAD_FILENAME)
- {
- grub_errno = err = GRUB_ERR_NONE;
- print_string ("# File ");
- err = print (outbuf, newname, grub_strlen (newname));
- if (err)
- return err;
- print_string (" not found\n");
- }
- if (err)
- return err;
- }
- grub_free (newname);
- grub_free (new_cwd);
- grub_free (new_target_cwd);
+ print_config (outbuf, menu, curentry->kernel_file, ap);
}
break;
case KERNEL_NO_KERNEL:
@@ -1351,7 +1397,6 @@ free_menu (struct syslinux_menu *menu)
for (say = menu->say; say ; say = nsay)
{
nsay = say->next;
- grub_free (say->msg);
grub_free (say);
}
@@ -1421,6 +1466,13 @@ config_file (struct output_buffer *outbuf,
print_string ("\n");
}
+ if (menu.comments)
+ {
+ err = print (outbuf, menu.comments, grub_strlen (menu.comments));
+ if (err)
+ return err;
+ }
+
if (menu.timeout == 0 && menu.entries && menu.def)
{
err = print_entry (outbuf, &menu, menu.def);
@@ -1432,17 +1484,11 @@ config_file (struct output_buffer *outbuf,
for (curentry = menu.entries; curentry->next; curentry = curentry->next);
lentry = curentry;
- print_string ("set timeout='");
+ print_string ("set timeout=");
err = print_num (outbuf, (menu.timeout + 9) / 10);
if (err)
return err;
print_string ("\n");
- if (menu.comments)
- {
- err = print (outbuf, menu.comments, grub_strlen (menu.comments));
- if (err)
- return err;
- }
if (menu.def)
{
diff --git a/grub-core/lib/x86_64/xen/relocator.S b/grub-core/lib/x86_64/xen/relocator.S
index 78c123350..92e9e72a9 100644
--- a/grub-core/lib/x86_64/xen/relocator.S
+++ b/grub-core/lib/x86_64/xen/relocator.S
@@ -89,7 +89,7 @@ VARIABLE(grub_relocator_xen_mfn_list)
loop 1b
- leaq EXT_C(grub_relocator_xen_mmu_op) (%rip), %rdi
+ leaq LOCAL(mmu_op) (%rip), %rdi
movq $3, %rsi
movq $0, %rdx
movq $0x7FF0, %r10
@@ -104,6 +104,7 @@ VARIABLE(grub_relocator_xen_remap_continue)
jmp *%rax
+LOCAL(mmu_op):
VARIABLE(grub_relocator_xen_mmu_op)
.space 256
diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
index 14a34bfbf..5b39f02bb 100644
--- a/grub-core/loader/arm/linux.c
+++ b/grub-core/loader/arm/linux.c
@@ -44,15 +44,112 @@ static char *linux_args;
static grub_uint32_t machine_type;
static void *fdt_addr;
+typedef void (*kernel_entry_t) (int, unsigned long, void *);
+
#define LINUX_ZIMAGE_OFFSET 0x24
#define LINUX_ZIMAGE_MAGIC 0x016f2818
-#define ARM_FDT_MACHINE_TYPE 0xFFFFFFFF
-
#define LINUX_PHYS_OFFSET (0x00008000)
#define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000)
#define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000)
+static grub_size_t
+get_atag_size (grub_uint32_t *atag)
+{
+ grub_uint32_t *atag0 = atag;
+ while (atag[0] && atag[1])
+ atag += atag[0];
+ return atag - atag0;
+}
+
+/*
+ * linux_prepare_fdt():
+ * Prepares a loaded FDT for being passed to Linux.
+ * Merges in command line parameters and sets up initrd addresses.
+ */
+static grub_err_t
+linux_prepare_atag (void)
+{
+ grub_uint32_t *atag_orig = (grub_uint32_t *) fdt_addr;
+ grub_uint32_t *tmp_atag, *from, *to;
+ grub_size_t tmp_size;
+ grub_size_t arg_size = grub_strlen (linux_args);
+ char *cmdline_orig = NULL;
+ grub_size_t cmdline_orig_len = 0;
+
+ /* some place for cmdline, initrd and terminator. */
+ tmp_size = get_atag_size (atag_orig) + 20 + (arg_size) / 4;
+ tmp_atag = grub_malloc (tmp_size * sizeof (grub_uint32_t));
+ if (!tmp_atag)
+ return grub_errno;
+
+ for (from = atag_orig, to = tmp_atag; from[0] && from[1];
+ from += from[0])
+ switch (from[1])
+ {
+ case 0x54410004:
+ case 0x54410005:
+ case 0x54420005:
+ break;
+ case 0x54410009:
+ if (*(char *) (from + 2))
+ {
+ cmdline_orig = (char *) (from + 2);
+ cmdline_orig_len = grub_strlen (cmdline_orig) + 1;
+ }
+ break;
+ default:
+ grub_memcpy (to, from, sizeof (grub_uint32_t) * from[0]);
+ to += from[0];
+ break;
+ }
+
+ grub_dprintf ("linux", "linux inherited args: '%s'\n",
+ cmdline_orig ? : "");
+ grub_dprintf ("linux", "linux_args: '%s'\n", linux_args);
+
+ /* Generate and set command line */
+ to[0] = 3 + (arg_size + cmdline_orig_len) / 4;
+ to[1] = 0x54410009;
+ if (cmdline_orig)
+ {
+ grub_memcpy ((char *) to + 8, cmdline_orig, cmdline_orig_len - 1);
+ *((char *) to + 8 + cmdline_orig_len - 1) = ' ';
+ }
+ grub_memcpy ((char *) to + 8 + cmdline_orig_len, linux_args, arg_size);
+ grub_memset ((char *) to + 8 + cmdline_orig_len + arg_size, 0,
+ 4 - ((arg_size + cmdline_orig_len) & 3));
+ to += to[0];
+
+ if (initrd_start && initrd_end)
+ {
+ /*
+ * We're using physical addresses, so even if we have LPAE, we're
+ * restricted to a 32-bit address space.
+ */
+ grub_dprintf ("loader", "Initrd @ 0x%08x-0x%08x\n",
+ initrd_start, initrd_end);
+
+ to[0] = 4;
+ to[1] = 0x54420005;
+ to[2] = initrd_start;
+ to[3] = initrd_end - initrd_start;
+ to += 4;
+ }
+
+ to[0] = 0;
+ to[1] = 0;
+ to += 2;
+
+ /* Copy updated FDT to its launch location */
+ grub_memcpy (atag_orig, tmp_atag, sizeof (grub_uint32_t) * (to - tmp_atag));
+ grub_free (tmp_atag);
+
+ grub_dprintf ("loader", "ATAG updated for Linux boot\n");
+
+ return GRUB_ERR_NONE;
+}
+
/*
* linux_prepare_fdt():
* Prepares a loaded FDT for being passed to Linux.
@@ -128,20 +225,44 @@ static grub_err_t
linux_boot (void)
{
kernel_entry_t linuxmain;
- grub_err_t err;
-
- if (!fdt_addr && machine_type == ARM_FDT_MACHINE_TYPE)
+ int fdt_valid, atag_valid;
+
+ fdt_valid = (fdt_addr && grub_fdt_check_header_nosize (fdt_addr) == 0);
+ atag_valid = ((((grub_uint16_t *) fdt_addr)[3] & ~3) == 0x5440
+ && *((grub_uint32_t *) fdt_addr));
+ grub_dprintf ("loader", "atag: %p, %x, %x, %s, %s\n",
+ fdt_addr,
+ ((grub_uint16_t *) fdt_addr)[3],
+ *((grub_uint32_t *) fdt_addr),
+ (char *) fdt_addr,
+ (char *) fdt_addr + 1);
+
+ if (!fdt_valid && machine_type == GRUB_ARM_MACHINE_TYPE_FDT)
return grub_error (GRUB_ERR_FILE_NOT_FOUND,
- N_("device tree must be supplied"));
+ N_("device tree must be supplied (see `devicetree' command)"));
grub_arch_sync_caches ((void *) linux_addr, linux_size);
grub_dprintf ("loader", "Kernel at: 0x%x\n", linux_addr);
- err = linux_prepare_fdt ();
- if (err)
- return err;
- grub_dprintf ("loader", "FDT @ 0x%p\n", fdt_addr);
+ if (fdt_valid)
+ {
+ grub_err_t err;
+
+ err = linux_prepare_fdt ();
+ if (err)
+ return err;
+ grub_dprintf ("loader", "FDT @ 0x%p\n", fdt_addr);
+ }
+ else if (atag_valid)
+ {
+ grub_err_t err;
+
+ err = linux_prepare_atag ();
+ if (err)
+ return err;
+ grub_dprintf ("loader", "ATAG @ 0x%p\n", fdt_addr);
+ }
grub_dprintf ("loader", "Jumping to Linux...\n");
@@ -154,14 +275,19 @@ linux_boot (void)
linuxmain = (kernel_entry_t) linux_addr;
#ifdef GRUB_MACHINE_EFI
- err = grub_efi_prepare_platform();
- if (err != GRUB_ERR_NONE)
- return err;
+ {
+ grub_err_t err;
+ err = grub_efi_prepare_platform();
+ if (err != GRUB_ERR_NONE)
+ return err;
+ }
#endif
+ grub_arm_disable_caches_mmu ();
+
linuxmain (0, machine_type, fdt_addr);
- return err;
+ return grub_error (GRUB_ERR_BAD_OS, "Linux call returned");
}
/*
@@ -173,8 +299,6 @@ linux_load (const char *filename, grub_file_t file)
int size;
size = grub_file_size (file);
- if (size == 0)
- return grub_error (GRUB_ERR_BAD_OS, "empty kernel");
#ifdef GRUB_MACHINE_EFI
linux_addr = (grub_addr_t) grub_efi_allocate_loader_memory (LINUX_PHYS_OFFSET, size);
@@ -194,11 +318,16 @@ linux_load (const char *filename, grub_file_t file)
return grub_errno;
}
- if (*(grub_uint32_t *) (linux_addr + LINUX_ZIMAGE_OFFSET)
- != LINUX_ZIMAGE_MAGIC)
- {
- return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("invalid zImage"));
- }
+ if (size > LINUX_ZIMAGE_OFFSET + 4
+ && *(grub_uint32_t *) (linux_addr + LINUX_ZIMAGE_OFFSET)
+ == LINUX_ZIMAGE_MAGIC)
+ ;
+ else if (size > 0x8000 && *(grub_uint32_t *) (linux_addr) == 0xea000006
+ && machine_type == GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI)
+ grub_memmove ((void *) linux_addr, (void *) (linux_addr + 0x8000),
+ size - 0x8000);
+ else
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("invalid zImage"));
linux_size = size;
@@ -267,7 +396,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
{
grub_file_t file;
grub_size_t size = 0;
- struct grub_linux_initrd_context initrd_ctx;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
@@ -281,14 +410,15 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
size = grub_get_initrd_size (&initrd_ctx);
- if (initrd_start)
- grub_free ((void *) initrd_start);
#ifdef GRUB_MACHINE_EFI
+ if (initrd_start)
+ grub_efi_free_pages (initrd_start,
+ (initrd_end - initrd_start + 0xfff) >> 12);
initrd_start = (grub_addr_t) grub_efi_allocate_loader_memory (LINUX_INITRD_PHYS_OFFSET, size);
if (!initrd_start)
{
- grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("memory allocation failed"));
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
goto fail;
}
#else
@@ -347,7 +477,7 @@ grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)),
fdt_addr = grub_efi_allocate_loader_memory (LINUX_FDT_PHYS_OFFSET, size);
if (!fdt_addr)
{
- grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("memory allocation failed"));
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
goto out;
}
#else
@@ -367,7 +497,7 @@ grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)),
* We've successfully loaded an FDT, so any machine type passed
* from firmware is now obsolete.
*/
- machine_type = ARM_FDT_MACHINE_TYPE;
+ machine_type = GRUB_ARM_MACHINE_TYPE_FDT;
out:
grub_file_close (dtb);
@@ -384,10 +514,11 @@ GRUB_MOD_INIT (linux)
cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd,
0, N_("Load initrd."));
cmd_devicetree = grub_register_command ("devicetree", grub_cmd_devicetree,
+ /* TRANSLATORS: DTB stands for device tree blob. */
0, N_("Load DTB file."));
my_mod = mod;
- fdt_addr = (void *) firmware_get_boot_data ();
- machine_type = firmware_get_machine_type ();
+ fdt_addr = (void *) grub_arm_firmware_get_boot_data ();
+ machine_type = grub_arm_firmware_get_machine_type ();
}
GRUB_MOD_FINI (linux)
diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c
new file mode 100644
index 000000000..5202c14e0
--- /dev/null
+++ b/grub-core/loader/arm64/fdt.c
@@ -0,0 +1,185 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/fdt.h>
+#include <grub/mm.h>
+#include <grub/cpu/fdtload.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/command.h>
+#include <grub/file.h>
+#include <grub/efi/efi.h>
+
+static void *loaded_fdt;
+static void *fdt;
+
+static void *
+get_firmware_fdt (void)
+{
+ grub_efi_configuration_table_t *tables;
+ grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
+ void *firmware_fdt = NULL;
+ unsigned int i;
+
+ /* Look for FDT in UEFI config tables. */
+ tables = grub_efi_system_table->configuration_table;
+
+ for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
+ if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0)
+ {
+ firmware_fdt = tables[i].vendor_table;
+ grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt);
+ break;
+ }
+
+ return firmware_fdt;
+}
+
+void *
+grub_fdt_load (grub_size_t additional_size)
+{
+ void *raw_fdt;
+ grub_size_t size;
+
+ if (fdt)
+ {
+ size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt));
+ grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size);
+ }
+
+ if (loaded_fdt)
+ raw_fdt = loaded_fdt;
+ else
+ raw_fdt = get_firmware_fdt();
+
+ size =
+ raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ;
+ size += additional_size;
+
+ grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size);
+ fdt = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (size));
+ if (!fdt)
+ return NULL;
+
+ if (raw_fdt)
+ {
+ grub_memmove (fdt, raw_fdt, size);
+ grub_fdt_set_totalsize (fdt, size);
+ }
+ else
+ {
+ grub_fdt_create_empty_tree (fdt, size);
+ }
+ return fdt;
+}
+
+grub_err_t
+grub_fdt_install (void)
+{
+ grub_efi_boot_services_t *b;
+ grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
+ grub_efi_status_t status;
+
+ b = grub_efi_system_table->boot_services;
+ status = b->install_configuration_table (&fdt_guid, fdt);
+ if (status != GRUB_EFI_SUCCESS)
+ return grub_error (GRUB_ERR_IO, "failed to install FDT");
+
+ grub_dprintf ("fdt", "Installed/updated FDT configuration table @ %p\n",
+ fdt);
+ return GRUB_ERR_NONE;
+}
+
+void
+grub_fdt_unload (void) {
+ if (!fdt) {
+ return;
+ }
+ grub_efi_free_pages ((grub_efi_physical_address_t) fdt,
+ GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)));
+ fdt = NULL;
+}
+
+static grub_err_t
+grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t dtb;
+ void *blob = NULL;
+ int size;
+
+ if (loaded_fdt)
+ grub_free (loaded_fdt);
+ loaded_fdt = NULL;
+
+ /* No arguments means "use firmware FDT". */
+ if (argc == 0)
+ {
+ return GRUB_ERR_NONE;
+ }
+
+ dtb = grub_file_open (argv[0]);
+ if (!dtb)
+ goto out;
+
+ size = grub_file_size (dtb);
+ blob = grub_malloc (size);
+ if (!blob)
+ goto out;
+
+ if (grub_file_read (dtb, blob, size) < size)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]);
+ goto out;
+ }
+
+ if (grub_fdt_check_header (blob, size) != 0)
+ {
+ grub_error (GRUB_ERR_BAD_OS, N_("invalid device tree"));
+ goto out;
+ }
+
+out:
+ if (dtb)
+ grub_file_close (dtb);
+
+ if (blob)
+ {
+ if (grub_errno == GRUB_ERR_NONE)
+ loaded_fdt = blob;
+ else
+ grub_free (blob);
+ }
+
+ return grub_errno;
+}
+
+static grub_command_t cmd_devicetree;
+
+GRUB_MOD_INIT (fdt)
+{
+ cmd_devicetree =
+ grub_register_command ("devicetree", grub_cmd_devicetree, 0,
+ N_("Load DTB file."));
+}
+
+GRUB_MOD_FINI (fdt)
+{
+ grub_unregister_command (cmd_devicetree);
+}
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
new file mode 100644
index 000000000..9519d2e4d
--- /dev/null
+++ b/grub-core/loader/arm64/linux.c
@@ -0,0 +1,354 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2013 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/charset.h>
+#include <grub/command.h>
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/fdt.h>
+#include <grub/linux.h>
+#include <grub/loader.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/cpu/linux.h>
+#include <grub/cpu/fdtload.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/pe32.h>
+#include <grub/i18n.h>
+#include <grub/lib/cmdline.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_dl_t my_mod;
+static int loaded;
+
+static void *kernel_addr;
+static grub_uint64_t kernel_size;
+
+static char *linux_args;
+static grub_uint32_t cmdline_size;
+
+static grub_addr_t initrd_start;
+static grub_addr_t initrd_end;
+
+grub_err_t
+grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh)
+{
+ if (lh->magic != GRUB_ARM64_LINUX_MAGIC)
+ return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
+
+ if ((lh->code0 & 0xffff) != GRUB_EFI_PE_MAGIC)
+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+ N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled"));
+
+ grub_dprintf ("linux", "UEFI stub kernel:\n");
+ grub_dprintf ("linux", "text_offset = 0x%012llx\n",
+ (long long unsigned) lh->text_offset);
+ grub_dprintf ("linux", "PE/COFF header @ %08x\n", lh->hdr_offset);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+finalize_params_linux (void)
+{
+ int node, retval;
+
+ void *fdt;
+
+ fdt = grub_fdt_load (0x400);
+
+ if (!fdt)
+ goto failure;
+
+ node = grub_fdt_find_subnode (fdt, 0, "chosen");
+ if (node < 0)
+ node = grub_fdt_add_subnode (fdt, 0, "chosen");
+
+ if (node < 1)
+ goto failure;
+
+ /* Set initrd info */
+ if (initrd_start && initrd_end > initrd_start)
+ {
+ grub_dprintf ("linux", "Initrd @ 0x%012lx-0x%012lx\n",
+ initrd_start, initrd_end);
+
+ retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-start",
+ initrd_start);
+ if (retval)
+ goto failure;
+ retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-end",
+ initrd_end);
+ if (retval)
+ goto failure;
+ }
+
+ if (grub_fdt_install() != GRUB_ERR_NONE)
+ goto failure;
+
+ return GRUB_ERR_NONE;
+
+failure:
+ grub_fdt_unload();
+ return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT");
+}
+
+grub_err_t
+grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args)
+{
+ grub_efi_memory_mapped_device_path_t *mempath;
+ grub_efi_handle_t image_handle;
+ grub_efi_boot_services_t *b;
+ grub_efi_status_t status;
+ grub_efi_loaded_image_t *loaded_image;
+ int len;
+
+ mempath = grub_malloc (2 * sizeof (grub_efi_memory_mapped_device_path_t));
+ if (!mempath)
+ return grub_errno;
+
+ mempath[0].header.type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE;
+ mempath[0].header.subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE;
+ mempath[0].header.length = grub_cpu_to_le16_compile_time (sizeof (*mempath));
+ mempath[0].memory_type = GRUB_EFI_LOADER_DATA;
+ mempath[0].start_address = addr;
+ mempath[0].end_address = addr + size;
+
+ mempath[1].header.type = GRUB_EFI_END_DEVICE_PATH_TYPE;
+ mempath[1].header.subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ mempath[1].header.length = sizeof (grub_efi_device_path_t);
+
+ b = grub_efi_system_table->boot_services;
+ status = b->load_image (0, grub_efi_image_handle,
+ (grub_efi_device_path_t *) mempath,
+ (void *) addr, size, &image_handle);
+ if (status != GRUB_EFI_SUCCESS)
+ return grub_error (GRUB_ERR_BAD_OS, "cannot load image");
+
+ grub_dprintf ("linux", "linux command line: '%s'\n", args);
+
+ /* Convert command line to UCS-2 */
+ loaded_image = grub_efi_get_loaded_image (image_handle);
+ loaded_image->load_options_size = len =
+ (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t);
+ loaded_image->load_options =
+ grub_efi_allocate_pages (0,
+ GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size));
+ if (!loaded_image->load_options)
+ return grub_errno;
+
+ loaded_image->load_options_size =
+ 2 * grub_utf8_to_utf16 (loaded_image->load_options, len,
+ (grub_uint8_t *) args, len, NULL);
+
+ grub_dprintf ("linux", "starting image %p\n", image_handle);
+ status = b->start_image (image_handle, 0, NULL);
+
+ /* When successful, not reached */
+ b->unload_image (image_handle);
+ grub_efi_free_pages ((grub_efi_physical_address_t) loaded_image->load_options,
+ GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size));
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_linux_boot (void)
+{
+ if (finalize_params_linux () != GRUB_ERR_NONE)
+ return grub_errno;
+
+ return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr,
+ kernel_size, linux_args));
+}
+
+static grub_err_t
+grub_linux_unload (void)
+{
+ grub_dl_unref (my_mod);
+ loaded = 0;
+ if (initrd_start)
+ grub_efi_free_pages ((grub_efi_physical_address_t) initrd_start,
+ GRUB_EFI_BYTES_TO_PAGES (initrd_end - initrd_start));
+ initrd_start = initrd_end = 0;
+ grub_free (linux_args);
+ if (kernel_addr)
+ grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr,
+ GRUB_EFI_BYTES_TO_PAGES (kernel_size));
+ grub_fdt_unload ();
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
+ int initrd_size, initrd_pages;
+ void *initrd_mem = NULL;
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto fail;
+ }
+
+ if (!loaded)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("you need to load the kernel first"));
+ goto fail;
+ }
+
+ if (grub_initrd_init (argc, argv, &initrd_ctx))
+ goto fail;
+
+ initrd_size = grub_get_initrd_size (&initrd_ctx);
+ grub_dprintf ("linux", "Loading initrd\n");
+
+ initrd_pages = (GRUB_EFI_BYTES_TO_PAGES (initrd_size));
+ initrd_mem = grub_efi_allocate_pages (0, initrd_pages);
+ if (!initrd_mem)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ goto fail;
+ }
+
+ if (grub_initrd_load (&initrd_ctx, argv, initrd_mem))
+ goto fail;
+
+ initrd_start = (grub_addr_t) initrd_mem;
+ initrd_end = initrd_start + initrd_size;
+ grub_dprintf ("linux", "[addr=%p, size=0x%x]\n",
+ (void *) initrd_start, initrd_size);
+
+ fail:
+ grub_initrd_close (&initrd_ctx);
+ if (initrd_mem && !initrd_start)
+ grub_efi_free_pages ((grub_efi_physical_address_t) initrd_mem,
+ initrd_pages);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ grub_file_t file = 0;
+ struct grub_arm64_linux_kernel_header lh;
+
+ grub_dl_ref (my_mod);
+
+ if (argc == 0)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto fail;
+ }
+
+ file = grub_file_open (argv[0]);
+ if (!file)
+ goto fail;
+
+ kernel_size = grub_file_size (file);
+
+ if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh))
+ return grub_errno;
+
+ if (grub_arm64_uefi_check_image (&lh) != GRUB_ERR_NONE)
+ goto fail;
+
+ grub_loader_unset();
+
+ grub_dprintf ("linux", "kernel file size: %lld\n", (long long) kernel_size);
+ kernel_addr = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (kernel_size));
+ grub_dprintf ("linux", "kernel numpages: %lld\n",
+ (long long) GRUB_EFI_BYTES_TO_PAGES (kernel_size));
+ if (!kernel_addr)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ goto fail;
+ }
+
+ grub_file_seek (file, 0);
+ if (grub_file_read (file, kernel_addr, kernel_size)
+ < (grub_int64_t) kernel_size)
+ {
+ if (!grub_errno)
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]);
+ goto fail;
+ }
+
+ grub_dprintf ("linux", "kernel @ %p\n", kernel_addr);
+
+ cmdline_size = grub_loader_cmdline_size (argc, argv) + sizeof (LINUX_IMAGE);
+ linux_args = grub_malloc (cmdline_size);
+ if (!linux_args)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ goto fail;
+ }
+ grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE));
+ grub_create_loader_cmdline (argc, argv,
+ linux_args + sizeof (LINUX_IMAGE) - 1,
+ cmdline_size);
+
+ if (grub_errno == GRUB_ERR_NONE)
+ {
+ grub_loader_set (grub_linux_boot, grub_linux_unload, 0);
+ loaded = 1;
+ }
+
+fail:
+ if (file)
+ grub_file_close (file);
+
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ grub_dl_unref (my_mod);
+ loaded = 0;
+ }
+
+ if (linux_args && !loaded)
+ grub_free (linux_args);
+
+ if (kernel_addr && !loaded)
+ grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr,
+ GRUB_EFI_BYTES_TO_PAGES (kernel_size));
+
+ return grub_errno;
+}
+
+
+static grub_command_t cmd_linux, cmd_initrd;
+
+GRUB_MOD_INIT (linux)
+{
+ cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0,
+ N_("Load Linux."));
+ cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0,
+ N_("Load initrd."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI (linux)
+{
+ grub_unregister_command (cmd_linux);
+ grub_unregister_command (cmd_initrd);
+}
diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c
new file mode 100644
index 000000000..a914eb8e2
--- /dev/null
+++ b/grub-core/loader/arm64/xen_boot.c
@@ -0,0 +1,499 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2014 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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/cache.h>
+#include <grub/charset.h>
+#include <grub/command.h>
+#include <grub/err.h>
+#include <grub/file.h>
+#include <grub/fdt.h>
+#include <grub/list.h>
+#include <grub/loader.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/types.h>
+#include <grub/cpu/fdtload.h>
+#include <grub/cpu/linux.h>
+#include <grub/efi/efi.h>
+#include <grub/efi/pe32.h> /* required by struct xen_hypervisor_header */
+#include <grub/i18n.h>
+#include <grub/lib/cmdline.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+#define XEN_HYPERVISOR_NAME "xen_hypervisor"
+#define MODULE_CUSTOM_COMPATIBLE "multiboot,module"
+
+/* This maximum size is defined in Power.org ePAPR V1.1
+ * https://www.power.org/documentation/epapr-version-1-1/
+ * 2.2.1.1 Node Name Requirements
+ * node-name@unit-address
+ * 31 + 1(@) + 16(64bit address in hex format) + 1(\0) = 49
+ */
+#define FDT_NODE_NAME_MAX_SIZE (49)
+
+struct compat_string_struct
+{
+ grub_size_t size;
+ const char *compat_string;
+};
+typedef struct compat_string_struct compat_string_struct_t;
+#define FDT_COMPATIBLE(x) {.size = sizeof(x), .compat_string = (x)}
+
+enum module_type
+{
+ MODULE_IMAGE,
+ MODULE_INITRD,
+ MODULE_XSM,
+ MODULE_CUSTOM
+};
+typedef enum module_type module_type_t;
+
+struct xen_hypervisor_header
+{
+ struct grub_arm64_linux_kernel_header efi_head;
+
+ /* This is always PE\0\0. */
+ grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE];
+ /* The COFF file header. */
+ struct grub_pe32_coff_header coff_header;
+ /* The Optional header. */
+ struct grub_pe64_optional_header optional_header;
+};
+
+struct xen_boot_binary
+{
+ struct xen_boot_binary *next;
+ struct xen_boot_binary **prev;
+ int is_hypervisor;
+
+ grub_addr_t start;
+ grub_size_t size;
+ grub_size_t align;
+
+ char *cmdline;
+ int cmdline_size;
+};
+
+static grub_dl_t my_mod;
+
+static int loaded;
+
+static struct xen_boot_binary *xen_hypervisor;
+static struct xen_boot_binary *module_head;
+
+static __inline grub_addr_t
+xen_boot_address_align (grub_addr_t start, grub_size_t align)
+{
+ return (align ? (ALIGN_UP (start, align)) : start);
+}
+
+static grub_err_t
+prepare_xen_hypervisor_params (void *xen_boot_fdt)
+{
+ int chosen_node = 0;
+ int retval;
+
+ chosen_node = grub_fdt_find_subnode (xen_boot_fdt, 0, "chosen");
+ if (chosen_node < 0)
+ chosen_node = grub_fdt_add_subnode (xen_boot_fdt, 0, "chosen");
+ if (chosen_node < 1)
+ return grub_error (GRUB_ERR_IO, "failed to get chosen node in FDT");
+
+ grub_dprintf ("xen_loader",
+ "Xen Hypervisor cmdline : %s @ %p size:%d\n",
+ xen_hypervisor->cmdline, xen_hypervisor->cmdline,
+ xen_hypervisor->cmdline_size);
+
+ retval = grub_fdt_set_prop (xen_boot_fdt, chosen_node, "bootargs",
+ xen_hypervisor->cmdline,
+ xen_hypervisor->cmdline_size);
+ if (retval)
+ return grub_error (GRUB_ERR_IO, "failed to install/update FDT");
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt)
+{
+ int retval, chosen_node = 0, module_node = 0;
+ char module_name[FDT_NODE_NAME_MAX_SIZE];
+
+ retval = grub_snprintf (module_name, FDT_NODE_NAME_MAX_SIZE, "module@%lx",
+ xen_boot_address_align (module->start,
+ module->align));
+ grub_dprintf ("xen_loader", "Module node name %s \n", module_name);
+
+ if (retval < (int) sizeof ("module@"))
+ return grub_error (GRUB_ERR_IO, N_("failed to get FDT"));
+
+ chosen_node = grub_fdt_find_subnode (xen_boot_fdt, 0, "chosen");
+ if (chosen_node < 0)
+ chosen_node = grub_fdt_add_subnode (xen_boot_fdt, 0, "chosen");
+ if (chosen_node < 1)
+ return grub_error (GRUB_ERR_IO, "failed to get chosen node in FDT");
+
+ module_node =
+ grub_fdt_find_subnode (xen_boot_fdt, chosen_node, module_name);
+ if (module_node < 0)
+ module_node =
+ grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name);
+
+ retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "compatible",
+ MODULE_CUSTOM_COMPATIBLE, sizeof(MODULE_CUSTOM_COMPATIBLE) - 1);
+ if (retval)
+ return grub_error (GRUB_ERR_IO, "failed to update FDT");
+
+ grub_dprintf ("xen_loader", "Module\n");
+
+ retval = grub_fdt_set_reg64 (xen_boot_fdt, module_node,
+ xen_boot_address_align (module->start,
+ module->align),
+ module->size);
+ if (retval)
+ return grub_error (GRUB_ERR_IO, "failed to update FDT");
+
+ if (module->cmdline && module->cmdline_size > 0)
+ {
+ grub_dprintf ("xen_loader",
+ "Module cmdline : %s @ %p size:%d\n",
+ module->cmdline, module->cmdline, module->cmdline_size);
+
+ retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "bootargs",
+ module->cmdline, module->cmdline_size + 1);
+ if (retval)
+ return grub_error (GRUB_ERR_IO, "failed to update FDT");
+ }
+ else
+ {
+ grub_dprintf ("xen_loader", "Module has no bootargs!\n");
+ }
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
+finalize_params_xen_boot (void)
+{
+ struct xen_boot_binary *module;
+ void *xen_boot_fdt;
+ grub_size_t additional_size = 0x1000;
+
+ /* Hypervisor. */
+ additional_size += FDT_NODE_NAME_MAX_SIZE + xen_hypervisor->cmdline_size;
+ FOR_LIST_ELEMENTS (module, module_head)
+ {
+ additional_size += 6 * FDT_NODE_NAME_MAX_SIZE + sizeof(MODULE_CUSTOM_COMPATIBLE) - 1
+ + module->cmdline_size;
+ }
+
+ xen_boot_fdt = grub_fdt_load (additional_size);
+ if (!xen_boot_fdt)
+ return grub_error (GRUB_ERR_IO, "failed to get FDT");
+
+ if (xen_hypervisor)
+ {
+ if (prepare_xen_hypervisor_params (xen_boot_fdt) != GRUB_ERR_NONE)
+ goto fail;
+ }
+ else
+ {
+ grub_dprintf ("xen_loader", "Failed to get Xen Hypervisor info!\n");
+ goto fail;
+ }
+
+ /* Set module params info */
+ FOR_LIST_ELEMENTS (module, module_head)
+ {
+ if (module->start && module->size > 0)
+ {
+ grub_dprintf ("xen_loader", "Module @ 0x%lx size:0x%lx\n",
+ xen_boot_address_align (module->start, module->align),
+ module->size);
+ if (prepare_xen_module_params (module, xen_boot_fdt) != GRUB_ERR_NONE)
+ goto fail;
+ }
+ else
+ {
+ grub_dprintf ("xen_loader", "Module info error!\n");
+ goto fail;
+ }
+ }
+
+ if (grub_fdt_install() == GRUB_ERR_NONE)
+ return GRUB_ERR_NONE;
+
+fail:
+ grub_fdt_unload ();
+
+ return grub_error (GRUB_ERR_IO, "failed to install/update FDT");
+}
+
+
+static grub_err_t
+xen_boot (void)
+{
+ grub_err_t err = finalize_params_xen_boot ();
+ if (err)
+ return err;
+
+ return grub_arm64_uefi_boot_image (xen_hypervisor->start,
+ xen_hypervisor->size,
+ xen_hypervisor->cmdline);
+}
+
+static void
+single_binary_unload (struct xen_boot_binary *binary)
+{
+ if (!binary)
+ return;
+
+ if (binary->start && binary->size > 0)
+ {
+ grub_efi_free_pages ((grub_efi_physical_address_t) binary->start,
+ GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align));
+ }
+
+ if (binary->cmdline && binary->cmdline_size > 0)
+ {
+ grub_free (binary->cmdline);
+ grub_dprintf ("xen_loader",
+ "Module cmdline memory free @ %p size: %d\n",
+ binary->cmdline, binary->cmdline_size);
+ }
+
+ if (!binary->is_hypervisor)
+ grub_list_remove (GRUB_AS_LIST (binary));
+
+ grub_dprintf ("xen_loader",
+ "Module struct memory free @ %p size: 0x%lx\n",
+ binary, sizeof (binary));
+ grub_free (binary);
+
+ return;
+}
+
+static void
+all_binaries_unload (void)
+{
+ struct xen_boot_binary *binary;
+
+ FOR_LIST_ELEMENTS (binary, module_head)
+ {
+ single_binary_unload (binary);
+ }
+
+ if (xen_hypervisor)
+ single_binary_unload (xen_hypervisor);
+
+ return;
+}
+
+static grub_err_t
+xen_unload (void)
+{
+ loaded = 0;
+ all_binaries_unload ();
+ grub_fdt_unload ();
+ grub_dl_unref (my_mod);
+
+ return GRUB_ERR_NONE;
+}
+
+static void
+xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file,
+ int argc, char *argv[])
+{
+ binary->size = grub_file_size (file);
+ grub_dprintf ("xen_loader", "Xen_boot file size: 0x%lx\n", binary->size);
+
+ binary->start
+ = (grub_addr_t) grub_efi_allocate_pages (0,
+ GRUB_EFI_BYTES_TO_PAGES
+ (binary->size +
+ binary->align));
+ if (!binary->start)
+ {
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return;
+ }
+
+ grub_dprintf ("xen_loader", "Xen_boot numpages: 0x%lx\n",
+ GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align));
+
+ if (grub_file_read (file, (void *) xen_boot_address_align (binary->start,
+ binary->align),
+ binary->size) != (grub_ssize_t) binary->size)
+ {
+ single_binary_unload (binary);
+ grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]);
+ return;
+ }
+
+ if (argc > 1)
+ {
+ binary->cmdline_size = grub_loader_cmdline_size (argc - 1, argv + 1);
+ binary->cmdline = grub_zalloc (binary->cmdline_size);
+ if (!binary->cmdline)
+ {
+ single_binary_unload (binary);
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
+ return;
+ }
+ grub_create_loader_cmdline (argc - 1, argv + 1, binary->cmdline,
+ binary->cmdline_size);
+ grub_dprintf ("xen_loader",
+ "Xen_boot cmdline @ %p %s, size: %d\n",
+ binary->cmdline, binary->cmdline, binary->cmdline_size);
+ }
+ else
+ {
+ binary->cmdline_size = 0;
+ binary->cmdline = NULL;
+ }
+
+ grub_errno = GRUB_ERR_NONE;
+ return;
+}
+
+static grub_err_t
+grub_cmd_xen_module (grub_command_t cmd __attribute__((unused)),
+ int argc, char *argv[])
+{
+
+ struct xen_boot_binary *module = NULL;
+ grub_file_t file = 0;
+
+ if (!argc)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto fail;
+ }
+
+ if (!loaded)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("you need to load the Xen Hypervisor first"));
+ goto fail;
+ }
+
+ module =
+ (struct xen_boot_binary *) grub_zalloc (sizeof (struct xen_boot_binary));
+ if (!module)
+ return grub_errno;
+
+ module->is_hypervisor = 0;
+ module->align = 4096;
+
+ grub_dprintf ("xen_loader", "Init module and node info\n");
+
+ file = grub_file_open (argv[0]);
+ if (!file)
+ goto fail;
+
+ xen_boot_binary_load (module, file, argc, argv);
+ if (grub_errno == GRUB_ERR_NONE)
+ grub_list_push (GRUB_AS_LIST_P (&module_head), GRUB_AS_LIST (module));
+
+ fail:
+ if (file)
+ grub_file_close (file);
+ if (grub_errno != GRUB_ERR_NONE)
+ single_binary_unload (module);
+
+ return grub_errno;
+}
+
+static grub_err_t
+grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)),
+ int argc, char *argv[])
+{
+ struct xen_hypervisor_header sh;
+ grub_file_t file = NULL;
+
+ grub_dl_ref (my_mod);
+
+ if (!argc)
+ {
+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ goto fail;
+ }
+
+ file = grub_file_open (argv[0]);
+ if (!file)
+ goto fail;
+
+ if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh))
+ goto fail;
+ if (grub_arm64_uefi_check_image
+ ((struct grub_arm64_linux_kernel_header *) &sh) != GRUB_ERR_NONE)
+ goto fail;
+ grub_file_seek (file, 0);
+
+ /* if another module has called grub_loader_set,
+ we need to make sure that another module is unloaded properly */
+ grub_loader_unset ();
+
+ xen_hypervisor =
+ (struct xen_boot_binary *) grub_zalloc (sizeof (struct xen_boot_binary));
+ if (!xen_hypervisor)
+ return grub_errno;
+
+ xen_hypervisor->is_hypervisor = 1;
+ xen_hypervisor->align = (grub_size_t) sh.optional_header.section_alignment;
+
+ xen_boot_binary_load (xen_hypervisor, file, argc, argv);
+ if (grub_errno == GRUB_ERR_NONE)
+ {
+ grub_loader_set (xen_boot, xen_unload, 0);
+ loaded = 1;
+ }
+
+fail:
+ if (file)
+ grub_file_close (file);
+ if (grub_errno != GRUB_ERR_NONE)
+ {
+ loaded = 0;
+ all_binaries_unload ();
+ grub_dl_unref (my_mod);
+ }
+
+ return grub_errno;
+}
+
+static grub_command_t cmd_xen_hypervisor;
+static grub_command_t cmd_xen_module;
+
+GRUB_MOD_INIT (xen_boot)
+{
+ cmd_xen_hypervisor =
+ grub_register_command ("xen_hypervisor", grub_cmd_xen_hypervisor, 0,
+ N_("Load a xen hypervisor."));
+ cmd_xen_module =
+ grub_register_command ("xen_module", grub_cmd_xen_module, 0,
+ N_("Load a xen module."));
+ my_mod = mod;
+}
+
+GRUB_MOD_FINI (xen_boot)
+{
+ grub_unregister_command (cmd_xen_hypervisor);
+ grub_unregister_command (cmd_xen_module);
+}
diff --git a/grub-core/loader/efi/appleloader.c b/grub-core/loader/efi/appleloader.c
index 3777c7f0b..74888c463 100644
--- a/grub-core/loader/efi/appleloader.c
+++ b/grub-core/loader/efi/appleloader.c
@@ -89,8 +89,7 @@ struct piwg_full_device_path
.subtype = GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE, \
.length = sizeof (struct grub_efi_piwg_device_path) \
}, \
- .guid = {0x2B0585EB, 0xD8B8, 0x49A9, {0x8B, 0x8C, 0xE2, 0x1B, \
- 0x01, 0xAE, 0xF2, 0xB7}} \
+ .guid = GRUB_EFI_VENDOR_APPLE_GUID \
}, \
.end = \
{ \
diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
index 233237018..522a716e3 100644
--- a/grub-core/loader/efi/chainloader.c
+++ b/grub-core/loader/efi/chainloader.c
@@ -350,8 +350,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
}
loaded_image->device_handle = dev_handle;
- grub_file_close (file);
-
if (argc > 1)
{
int i, len;
@@ -381,6 +379,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
loaded_image->load_options_size = len;
}
+ grub_file_close (file);
+ grub_device_close (dev);
+
grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0);
return 0;
diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c
index ea0edfafe..7f96515da 100644
--- a/grub-core/loader/i386/bsd.c
+++ b/grub-core/loader/i386/bsd.c
@@ -234,7 +234,8 @@ grub_bsd_add_meta_ptr (grub_uint32_t type, void **ptr, grub_uint32_t len)
{
struct bsd_tag *p;
for (p = tags;
- p->type != (FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_KERNEND);
+ p && p->type != (FREEBSD_MODINFO_METADATA
+ | FREEBSD_MODINFOMD_KERNEND);
p = p->next);
if (p)
@@ -1082,7 +1083,7 @@ grub_netbsd_add_boot_disk_and_wedge (void)
grub_crypto_hash (GRUB_MD_MD5, hash,
buf.raw, GRUB_DISK_SECTOR_SIZE);
- memcpy (biw.matchhash, hash, 16);
+ grub_memcpy (biw.matchhash, hash, 16);
grub_bsd_add_meta (NETBSD_BTINFO_BOOTWEDGE, &biw, sizeof (biw));
}
@@ -1100,7 +1101,7 @@ grub_netbsd_add_boot_disk_and_wedge (void)
bid.labelsector = partmapsector;
bid.label.type = buf.label.type;
bid.label.checksum = buf.label.checksum;
- memcpy (bid.label.packname, buf.label.packname, 16);
+ grub_memcpy (bid.label.packname, buf.label.packname, 16);
}
else
{
@@ -1145,6 +1146,14 @@ grub_netbsd_boot (void)
if (err)
return err;
+#ifdef GRUB_MACHINE_EFI
+ err = grub_bsd_add_meta (NETBSD_BTINFO_EFI,
+ &grub_efi_system_table,
+ sizeof (grub_efi_system_table));
+ if (err)
+ return err;
+#endif
+
{
struct bsd_tag *tag;
tag_buf_len = 0;
@@ -1646,6 +1655,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
serial.device = (GRUB_OPENBSD_COM_MAJOR << 8) | port;
serial.speed = speed;
+ serial.addr = grub_ns8250_hw_get_port (port);
grub_bsd_add_meta (OPENBSD_BOOTARG_CONSOLE, &serial, sizeof (serial));
bootflags |= OPENBSD_RB_SERCONS;
@@ -1656,6 +1666,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
grub_memset (&serial, 0, sizeof (serial));
serial.device = (GRUB_OPENBSD_VGA_MAJOR << 8);
+ serial.addr = 0xffffffff;
grub_bsd_add_meta (OPENBSD_BOOTARG_CONSOLE, &serial, sizeof (serial));
bootflags &= ~OPENBSD_RB_SERCONS;
}
@@ -1878,6 +1889,10 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)),
grub_err_t err;
void *src;
+ if (! grub_loader_is_loaded ())
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("you need to load the kernel first"));
+
if (kernel_type != KERNEL_TYPE_FREEBSD)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no FreeBSD loaded");
@@ -1981,6 +1996,10 @@ grub_cmd_netbsd_module (grub_command_t cmd,
{
grub_uint32_t type;
+ if (! grub_loader_is_loaded ())
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("you need to load the kernel first"));
+
if (kernel_type != KERNEL_TYPE_NETBSD)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no NetBSD loaded");
@@ -2059,6 +2078,10 @@ grub_cmd_openbsd_ramdisk (grub_command_t cmd __attribute__ ((unused)),
if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
+ if (! grub_loader_is_loaded ())
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("you need to load the kernel first"));
+
if (kernel_type != KERNEL_TYPE_OPENBSD)
return grub_error (GRUB_ERR_BAD_OS, "no kOpenBSD loaded");
diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c
index 9e36cd4b6..af6741d15 100644
--- a/grub-core/loader/i386/bsdXX.c
+++ b/grub-core/loader/i386/bsdXX.c
@@ -48,15 +48,15 @@ read_headers (grub_file_t file, const char *filename, Elf_Ehdr *e, char **shdr)
if (e->e_ident[EI_CLASS] != SUFFIX (ELFCLASS))
return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
- *shdr = grub_malloc (e->e_shnum * e->e_shentsize);
+ *shdr = grub_malloc ((grub_uint32_t) e->e_shnum * e->e_shentsize);
if (! *shdr)
return grub_errno;
if (grub_file_seek (file, e->e_shoff) == (grub_off_t) -1)
return grub_errno;
- if (grub_file_read (file, *shdr, e->e_shnum * e->e_shentsize)
- != e->e_shnum * e->e_shentsize)
+ if (grub_file_read (file, *shdr, (grub_uint32_t) e->e_shnum * e->e_shentsize)
+ != (grub_ssize_t) ((grub_uint32_t) e->e_shnum * e->e_shentsize))
{
if (grub_errno)
return grub_errno;
@@ -84,11 +84,11 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator,
grub_size_t chunk_size = 0;
void *chunk_src;
+ curload = module = ALIGN_PAGE (*kern_end);
+
err = read_headers (file, argv[0], &e, &shdr);
if (err)
- return err;
-
- curload = module = ALIGN_PAGE (*kern_end);
+ goto out;
for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) ((char *) shdr
+ e.e_shnum * e.e_shentsize);
@@ -109,7 +109,7 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator,
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
module, chunk_size);
if (err)
- return err;
+ goto out;
chunk_src = get_virtual_current_address (ch);
}
@@ -135,7 +135,7 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator,
err = load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end,
s->sh_offset, s->sh_size);
if (err)
- return err;
+ goto out;
break;
case SHT_NOBITS:
grub_memset ((grub_uint8_t *) chunk_src + curload - *kern_end, 0,
@@ -159,6 +159,8 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator,
| FREEBSD_MODINFOMD_SHDR,
shdr, e.e_shnum * e.e_shentsize);
+out:
+ grub_free (shdr);
return err;
}
@@ -177,11 +179,11 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator,
grub_size_t chunk_size = 0;
void *chunk_src;
+ curload = module = ALIGN_PAGE (*kern_end);
+
err = read_headers (file, argv[0], &e, &shdr);
if (err)
- return err;
-
- curload = module = ALIGN_PAGE (*kern_end);
+ goto out;
for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) ((char *) shdr
+ e.e_shnum * e.e_shentsize);
@@ -198,8 +200,8 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator,
if (chunk_size < sizeof (e))
chunk_size = sizeof (e);
- chunk_size += e.e_phnum * e.e_phentsize;
- chunk_size += e.e_shnum * e.e_shentsize;
+ chunk_size += (grub_uint32_t) e.e_phnum * e.e_phentsize;
+ chunk_size += (grub_uint32_t) e.e_shnum * e.e_shentsize;
{
grub_relocator_chunk_t ch;
@@ -207,7 +209,7 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator,
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
module, chunk_size);
if (err)
- return err;
+ goto out;
chunk_src = get_virtual_current_address (ch);
}
@@ -235,7 +237,7 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator,
+ s->sh_addr - *kern_end,
s->sh_offset, s->sh_size);
if (err)
- return err;
+ goto out;
break;
case SHT_NOBITS:
grub_memset ((grub_uint8_t *) chunk_src + module
@@ -251,20 +253,24 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator,
curload = module + sizeof (e);
load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end, e.e_shoff,
- e.e_shnum * e.e_shentsize);
+ (grub_uint32_t) e.e_shnum * e.e_shentsize);
e.e_shoff = curload - module;
- curload += e.e_shnum * e.e_shentsize;
+ curload += (grub_uint32_t) e.e_shnum * e.e_shentsize;
load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end, e.e_phoff,
- e.e_phnum * e.e_phentsize);
+ (grub_uint32_t) e.e_phnum * e.e_phentsize);
e.e_phoff = curload - module;
- curload += e.e_phnum * e.e_phentsize;
+ curload += (grub_uint32_t) e.e_phnum * e.e_phentsize;
*kern_end = curload;
grub_freebsd_add_meta_module (argv[0], FREEBSD_MODTYPE_ELF_MODULE,
argc - 1, argv + 1, module,
curload - module);
+out:
+ grub_free (shdr);
+ if (err)
+ return err;
return SUFFIX (grub_freebsd_load_elf_meta) (relocator, file, argv[0], kern_end);
}
@@ -292,13 +298,13 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator,
err = read_headers (file, filename, &e, &shdr);
if (err)
- return err;
+ goto out;
err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
FREEBSD_MODINFOMD_ELFHDR, &e,
sizeof (e));
if (err)
- return err;
+ goto out;
for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr
+ e.e_shnum * e.e_shentsize);
@@ -307,7 +313,10 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator,
break;
if (s >= (Elf_Shdr *) ((char *) shdr
+ e.e_shnum * e.e_shentsize))
- return grub_error (GRUB_ERR_BAD_OS, N_("no symbol table"));
+ {
+ err = grub_error (GRUB_ERR_BAD_OS, N_("no symbol table"));
+ goto out;
+ }
symoff = s->sh_offset;
symsize = s->sh_size;
symentsize = s->sh_entsize;
@@ -325,7 +334,7 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator,
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
symtarget, chunk_size);
if (err)
- return err;
+ goto out;
sym_chunk = get_virtual_current_address (ch);
}
@@ -337,28 +346,38 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator,
curload += sizeof (grub_freebsd_addr_t);
if (grub_file_seek (file, symoff) == (grub_off_t) -1)
- return grub_errno;
+ {
+ err = grub_errno;
+ goto out;
+ }
sym = (Elf_Sym *) curload;
if (grub_file_read (file, curload, symsize) != (grub_ssize_t) symsize)
{
if (! grub_errno)
- return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
- filename);
- return grub_errno;
+ err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ else
+ err = grub_errno;
+ goto out;
}
curload += symsize;
*((grub_freebsd_addr_t *) curload) = strsize;
curload += sizeof (grub_freebsd_addr_t);
if (grub_file_seek (file, stroff) == (grub_off_t) -1)
- return grub_errno;
+ {
+ err = grub_errno;
+ goto out;
+ }
str = (char *) curload;
if (grub_file_read (file, curload, strsize) != (grub_ssize_t) strsize)
{
if (! grub_errno)
- return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
- filename);
- return grub_errno;
+ err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ else
+ err = grub_errno;
+ goto out;
}
for (i = 0;
@@ -378,18 +397,20 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator,
FREEBSD_MODINFOMD_DYNAMIC, &dynamic,
sizeof (dynamic));
if (err)
- return err;
+ goto out;
}
err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
FREEBSD_MODINFOMD_SSYM, &symstart,
sizeof (symstart));
if (err)
- return err;
+ goto out;
err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA |
FREEBSD_MODINFOMD_ESYM, &symend,
sizeof (symend));
+out:
+ grub_free (shdr);
if (err)
return err;
@@ -417,7 +438,10 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator,
err = read_headers (file, filename, &e, &shdr);
if (err)
- return err;
+ {
+ grub_free (shdr);
+ return grub_errno;
+ }
for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr
+ e.e_shnum * e.e_shentsize);
@@ -426,7 +450,10 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator,
break;
if (s >= (Elf_Shdr *) ((char *) shdr
+ e.e_shnum * e.e_shentsize))
- return GRUB_ERR_NONE;
+ {
+ grub_free (shdr);
+ return GRUB_ERR_NONE;
+ }
symsize = s->sh_size;
symsh = s;
s = (Elf_Shdr *) (shdr + e.e_shentsize * s->sh_link);
@@ -435,7 +462,7 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator,
chunk_size = ALIGN_UP (symsize, sizeof (grub_freebsd_addr_t))
+ ALIGN_UP (strsize, sizeof (grub_freebsd_addr_t))
- + sizeof (e) + e.e_shnum * e.e_shentsize;
+ + sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize;
symtarget = ALIGN_UP (*kern_end, sizeof (grub_freebsd_addr_t));
{
@@ -443,7 +470,7 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator,
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
symtarget, chunk_size);
if (err)
- return err;
+ goto out;
sym_chunk = get_virtual_current_address (ch);
}
@@ -471,10 +498,10 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator,
s2 = (Elf_Shdr *) curload;
grub_memcpy (curload, s, e.e_shentsize);
if (s == symsh)
- s2->sh_offset = sizeof (e) + e.e_shnum * e.e_shentsize;
+ s2->sh_offset = sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize;
else if (s == strsh)
s2->sh_offset = ALIGN_UP (symsize, sizeof (grub_freebsd_addr_t))
- + sizeof (e) + e.e_shnum * e.e_shentsize;
+ + sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize;
else
s2->sh_offset = 0;
s2->sh_addr = s2->sh_offset;
@@ -482,29 +509,41 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator,
}
if (grub_file_seek (file, symsh->sh_offset) == (grub_off_t) -1)
- return grub_errno;
+ {
+ err = grub_errno;
+ goto out;
+ }
if (grub_file_read (file, curload, symsize) != (grub_ssize_t) symsize)
{
if (! grub_errno)
- return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
- filename);
- return grub_errno;
+ err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ else
+ err = grub_errno;
+ goto out;
}
curload += ALIGN_UP (symsize, sizeof (grub_freebsd_addr_t));
if (grub_file_seek (file, strsh->sh_offset) == (grub_off_t) -1)
- return grub_errno;
+ {
+ err = grub_errno;
+ goto out;
+ }
if (grub_file_read (file, curload, strsize) != (grub_ssize_t) strsize)
{
if (! grub_errno)
- return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
- filename);
- return grub_errno;
+ err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ filename);
+ else
+ err = grub_errno;
+ goto out;
}
err = grub_bsd_add_meta (NETBSD_BTINFO_SYMTAB,
&symtab,
sizeof (symtab));
+out:
+ grub_free (shdr);
if (err)
return err;
@@ -530,7 +569,10 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file,
err = read_headers (file, filename, &e, &shdr);
if (err)
- return err;
+ {
+ grub_free (shdr);
+ return err;
+ }
for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr
+ e.e_shnum * e.e_shentsize);
@@ -583,7 +625,11 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file,
}
if (grub_file_seek (file, stroff) == (grub_off_t) -1)
- return grub_errno;
+ {
+ grub_free (syms);
+ grub_free (strs);
+ return grub_errno;
+ }
if (grub_file_read (file, strs, strsize) != (grub_ssize_t) strsize)
{
grub_free (syms);
diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
index 31fb91e2c..fddcc461d 100644
--- a/grub-core/loader/i386/linux.c
+++ b/grub-core/loader/i386/linux.c
@@ -69,7 +69,6 @@ static grub_addr_t prot_mode_target;
static void *initrd_mem;
static grub_addr_t initrd_mem_target;
static grub_size_t prot_init_space;
-static grub_uint32_t initrd_pages;
static struct grub_relocator *relocator = NULL;
static void *efi_mmap_buf;
static grub_size_t maximal_cmdline_size;
@@ -722,7 +721,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
/* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and
still not support 32-bit boot. */
- if (lh.header != grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE)
+ if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
|| grub_le_to_cpu16 (lh.version) < 0x0203)
{
grub_error (GRUB_ERR_BAD_OS, "version too old for 32-bit boot"
@@ -1046,11 +1045,11 @@ static grub_err_t
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
- grub_size_t size = 0;
+ grub_size_t size = 0, aligned_size = 0;
grub_addr_t addr_min, addr_max;
grub_addr_t addr;
grub_err_t err;
- struct grub_linux_initrd_context initrd_ctx;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
if (argc == 0)
{
@@ -1068,8 +1067,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
goto fail;
size = grub_get_initrd_size (&initrd_ctx);
-
- initrd_pages = (page_align (size) >> 12);
+ aligned_size = ALIGN_UP (size, 4096);
/* Get the highest address available for the initrd. */
if (grub_le_to_cpu16 (linux_params.version) >= 0x0203)
@@ -1097,7 +1095,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
addr_min = (grub_addr_t) prot_mode_target + prot_init_space;
/* Put the initrd as high as possible, 4KiB aligned. */
- addr = (addr_max - size) & ~0xFFF;
+ addr = (addr_max - aligned_size) & ~0xFFF;
if (addr < addr_min)
{
@@ -1108,7 +1106,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
{
grub_relocator_chunk_t ch;
err = grub_relocator_alloc_chunk_align (relocator, &ch,
- addr_min, addr, size, 0x1000,
+ addr_min, addr, aligned_size,
+ 0x1000,
GRUB_RELOCATOR_PREFERENCE_HIGH,
1);
if (err)
diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c
index 7431aa49b..f60b70234 100644
--- a/grub-core/loader/i386/multiboot_mbi.c
+++ b/grub-core/loader/i386/multiboot_mbi.c
@@ -73,6 +73,9 @@ load_kernel (grub_file_t file, const char *filename,
if (grub_multiboot_quirks & GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE)
{
err = grub_multiboot_load_elf (file, filename, buffer);
+ if (err == GRUB_ERR_NONE) {
+ return GRUB_ERR_NONE;
+ }
if (err == GRUB_ERR_UNKNOWN_OS && (header->flags & MULTIBOOT_AOUT_KLUDGE))
grub_errno = err = GRUB_ERR_NONE;
}
@@ -121,6 +124,24 @@ load_kernel (grub_file_t file, const char *filename,
return grub_multiboot_load_elf (file, filename, buffer);
}
+static struct multiboot_header *
+find_header (char *buffer, grub_ssize_t len)
+{
+ struct multiboot_header *header;
+
+ /* Look for the multiboot header in the buffer. The header should
+ be at least 12 bytes and aligned on a 4-byte boundary. */
+ for (header = (struct multiboot_header *) buffer;
+ ((char *) header <= buffer + len - 12);
+ header = (struct multiboot_header *) ((char *) header + MULTIBOOT_HEADER_ALIGN))
+ {
+ if (header->magic == MULTIBOOT_HEADER_MAGIC
+ && !(header->magic + header->flags + header->checksum))
+ return header;
+ }
+ return NULL;
+}
+
grub_err_t
grub_multiboot_load (grub_file_t file, const char *filename)
{
@@ -143,16 +164,7 @@ grub_multiboot_load (grub_file_t file, const char *filename)
return grub_errno;
}
- /* Look for the multiboot header in the buffer. The header should
- be at least 12 bytes and aligned on a 4-byte boundary. */
- for (header = (struct multiboot_header *) buffer;
- ((char *) header <= buffer + len - 12) || (header = 0);
- header = (struct multiboot_header *) ((char *) header + MULTIBOOT_HEADER_ALIGN))
- {
- if (header->magic == MULTIBOOT_HEADER_MAGIC
- && !(header->magic + header->flags + header->checksum))
- break;
- }
+ header = find_header (buffer, len);
if (header == 0)
{
@@ -446,7 +458,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target)
bufsize = grub_multiboot_get_mbi_size ();
err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch,
- 0x10000, 0x100000 - bufsize,
+ 0x10000, 0xa0000 - bufsize,
bufsize, 4,
GRUB_RELOCATOR_PREFERENCE_NONE, 0);
if (err)
diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c
index 672c013e7..a293b17aa 100644
--- a/grub-core/loader/i386/pc/linux.c
+++ b/grub-core/loader/i386/pc/linux.c
@@ -151,7 +151,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
goto fail;
}
- if (lh.boot_flag != grub_cpu_to_le16 (0xaa55))
+ if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55))
{
grub_error (GRUB_ERR_BAD_OS, "invalid magic number");
goto fail;
@@ -169,7 +169,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
maximal_cmdline_size = 256;
- if (lh.header == grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE)
+ if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
&& grub_le_to_cpu16 (lh.version) >= 0x0200)
{
grub_linux_is_bzimage = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL);
@@ -188,7 +188,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
if (grub_le_to_cpu16 (lh.version) >= 0x0201)
{
- lh.heap_end_ptr = grub_cpu_to_le16 (GRUB_LINUX_HEAP_END_OFFSET);
+ lh.heap_end_ptr = grub_cpu_to_le16_compile_time (GRUB_LINUX_HEAP_END_OFFSET);
lh.loadflags |= GRUB_LINUX_FLAG_CAN_USE_HEAP;
}
@@ -196,17 +196,17 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
lh.cmd_line_ptr = grub_linux_real_target + GRUB_LINUX_CL_OFFSET;
else
{
- lh.cl_magic = grub_cpu_to_le16 (GRUB_LINUX_CL_MAGIC);
- lh.cl_offset = grub_cpu_to_le16 (GRUB_LINUX_CL_OFFSET);
- lh.setup_move_size = grub_cpu_to_le16 (GRUB_LINUX_CL_OFFSET
+ lh.cl_magic = grub_cpu_to_le16_compile_time (GRUB_LINUX_CL_MAGIC);
+ lh.cl_offset = grub_cpu_to_le16_compile_time (GRUB_LINUX_CL_OFFSET);
+ lh.setup_move_size = grub_cpu_to_le16_compile_time (GRUB_LINUX_CL_OFFSET
+ maximal_cmdline_size);
}
}
else
{
/* Your kernel is quite old... */
- lh.cl_magic = grub_cpu_to_le16 (GRUB_LINUX_CL_MAGIC);
- lh.cl_offset = grub_cpu_to_le16 (GRUB_LINUX_CL_OFFSET);
+ lh.cl_magic = grub_cpu_to_le16_compile_time (GRUB_LINUX_CL_MAGIC);
+ lh.cl_offset = grub_cpu_to_le16_compile_time (GRUB_LINUX_CL_OFFSET);
setup_sects = GRUB_LINUX_DEFAULT_SETUP_SECTS;
@@ -280,10 +280,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
{
case 'g':
shift += 10;
+ /* Fallthrough. */
case 'm':
shift += 10;
+ /* Fallthrough. */
case 'k':
shift += 10;
+ /* Fallthrough. */
default:
break;
}
@@ -319,7 +322,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
goto fail;
}
- if (lh.header != grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE)
+ if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
|| grub_le_to_cpu16 (lh.version) < 0x0200)
/* Clear the heap space. */
grub_memset (grub_linux_real_chunk
@@ -388,7 +391,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
grub_uint8_t *initrd_chunk;
grub_addr_t initrd_addr;
grub_err_t err;
- struct grub_linux_initrd_context initrd_ctx;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
if (argc == 0)
{
@@ -404,7 +407,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
lh = (struct linux_kernel_header *) grub_linux_real_chunk;
- if (!(lh->header == grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE)
+ if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
&& grub_le_to_cpu16 (lh->version) >= 0x0200))
{
grub_error (GRUB_ERR_BAD_OS, "the kernel is too old for initrd");
diff --git a/grub-core/loader/i386/pc/plan9.c b/grub-core/loader/i386/pc/plan9.c
index 0d10b1c24..814a49d50 100644
--- a/grub-core/loader/i386/pc/plan9.c
+++ b/grub-core/loader/i386/pc/plan9.c
@@ -342,6 +342,7 @@ fill_disk (const char *name, void *data)
if (!plan9name)
{
grub_print_error ();
+ grub_device_close (dev);
return 0;
}
if (grub_extend_alloc (fill_ctx->pmapptr + grub_strlen (plan9name)
@@ -349,6 +350,7 @@ fill_disk (const char *name, void *data)
&fill_ctx->pmap))
{
grub_free (plan9name);
+ grub_device_close (dev);
return 1;
}
grub_strcpy (fill_ctx->pmap + fill_ctx->pmapptr, plan9name);
@@ -366,12 +368,19 @@ fill_disk (const char *name, void *data)
fill_ctx->noslash = 1;
grub_memset (fill_ctx->prefixescnt, 0, sizeof (fill_ctx->prefixescnt));
if (grub_partition_iterate (dev->disk, fill_partition, fill_ctx))
- return 1;
+ {
+ grub_device_close (dev);
+ return 1;
+ }
if (grub_extend_alloc (fill_ctx->pmapptr + 1, &fill_ctx->pmapalloc,
&fill_ctx->pmap))
- return 1;
+ {
+ grub_device_close (dev);
+ return 1;
+ }
fill_ctx->pmap[fill_ctx->pmapptr++] = '\n';
+ grub_device_close (dev);
return 0;
}
diff --git a/grub-core/loader/i386/pc/truecrypt.c b/grub-core/loader/i386/pc/truecrypt.c
index 159eab1a7..9ea4fde42 100644
--- a/grub-core/loader/i386/pc/truecrypt.c
+++ b/grub-core/loader/i386/pc/truecrypt.c
@@ -205,7 +205,7 @@ grub_cmd_truecrypt (grub_command_t cmd __attribute__ ((unused)),
fail:
if (!grub_errno)
- return grub_error (GRUB_ERR_BAD_OS, "bad truecrypt ISO");
+ grub_error (GRUB_ERR_BAD_OS, "bad truecrypt ISO");
if (file)
grub_file_close (file);
diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c
index c16b4b249..c4d9689f7 100644
--- a/grub-core/loader/i386/xen.c
+++ b/grub-core/loader/i386/xen.c
@@ -521,7 +521,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
{
grub_size_t size = 0;
grub_err_t err;
- struct grub_linux_initrd_context initrd_ctx;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
grub_relocator_chunk_t ch;
if (argc == 0)
diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c
index ebbf6aa11..37f9ad8ac 100644
--- a/grub-core/loader/i386/xen_file.c
+++ b/grub-core/loader/i386/xen_file.c
@@ -18,6 +18,7 @@
#include <grub/xen_file.h>
#include <grub/i386/linux.h>
+#include <grub/misc.h>
grub_elf_t
grub_xen_file (grub_file_t file)
@@ -37,8 +38,8 @@ grub_xen_file (grub_file_t file)
if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
goto fail;
- if (lh.boot_flag != grub_cpu_to_le16 (0xaa55)
- || lh.header != grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE)
+ if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)
+ || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
|| grub_le_to_cpu16 (lh.version) < 0x0208)
{
grub_error (GRUB_ERR_BAD_OS, "version too old for xen boot");
@@ -54,11 +55,11 @@ grub_xen_file (grub_file_t file)
grub_dprintf ("xen", "found bzimage payload 0x%llx-0x%llx\n",
(unsigned long long) (lh.setup_sects + 1) * 512
+ lh.payload_offset,
- (unsigned long long) lh.payload_length - 4);
+ (unsigned long long) lh.payload_length);
off_file = grub_file_offset_open (file, (lh.setup_sects + 1) * 512
+ lh.payload_offset,
- lh.payload_length - 4);
+ lh.payload_length);
if (!off_file)
goto fail;
diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c
index 6df001576..1ba5649e2 100644
--- a/grub-core/loader/i386/xen_fileXX.c
+++ b/grub-core/loader/i386/xen_fileXX.c
@@ -17,6 +17,7 @@
*/
#include <grub/xen_file.h>
+#include <grub/misc.h>
static grub_err_t
parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi,
@@ -310,14 +311,19 @@ grub_xen_get_infoXX (grub_elf_t elf, struct grub_xen_file_info *xi)
return grub_errno;
if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1)
- return grub_errno;
+ {
+ err = grub_errno;
+ goto cleanup;
+ }
if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize)
{
if (grub_errno)
- return grub_errno;
- return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
+ err = grub_errno;
+ else
+ err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
elf->file->name);
+ goto cleanup;
}
s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize);
@@ -329,18 +335,29 @@ grub_xen_get_infoXX (grub_elf_t elf, struct grub_xen_file_info *xi)
char name[sizeof("__xen_guest")];
grub_memset (name, 0, sizeof (name));
if (grub_file_seek (elf->file, stroff + s->sh_name) == (grub_off_t) -1)
- return grub_errno;
+ {
+ err = grub_errno;
+ goto cleanup;
+ }
if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name))
{
if (grub_errno)
- return grub_errno;
+ {
+ err = grub_errno;
+ goto cleanup;
+ }
continue;
}
if (grub_memcmp (name, "__xen_guest",
sizeof("__xen_guest")) != 0)
continue;
- return parse_xen_guest (elf, xi, s->sh_offset, s->sh_size);
+ err = parse_xen_guest (elf, xi, s->sh_offset, s->sh_size);
+ goto cleanup;
}
- return grub_error (GRUB_ERR_BAD_OS, "no XEN note found");
+ err = grub_error (GRUB_ERR_BAD_OS, "no XEN note found");
+
+cleanup:
+ grub_free (s0);
+ return err;
}
diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c
index e83e1e972..59ef73a73 100644
--- a/grub-core/loader/i386/xnu.c
+++ b/grub-core/loader/i386/xnu.c
@@ -35,6 +35,7 @@
#include <grub/i18n.h>
#include <grub/bitmap_scale.h>
#include <grub/cpu/io.h>
+#include <grub/random.h>
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define max(a,b) (((a) > (b)) ? (a) : (b))
@@ -126,7 +127,7 @@ guessfsb (void)
{
const grub_uint64_t sane_value = 100000000;
grub_uint32_t manufacturer[3], max_cpuid, capabilities, msrlow;
- grub_uint32_t a, b, d;
+ grub_uint32_t a, b, d, divisor;
if (! grub_cpu_is_cpuid_supported ())
return sane_value;
@@ -166,8 +167,10 @@ guessfsb (void)
r = (2000ULL << 32) - v * grub_tsc_rate;
v += r / grub_tsc_rate;
- return grub_divmod64 (v, ((msrlow >> 7) & 0x3e) | ((msrlow >> 14) & 1),
- 0);
+ divisor = ((msrlow >> 7) & 0x3e) | ((msrlow >> 14) & 1);
+ if (divisor == 0)
+ return sane_value;
+ return grub_divmod64 (v, divisor, 0);
}
struct property_descriptor
@@ -267,9 +270,9 @@ grub_xnu_devprop_add_property (struct grub_xnu_devprop_device_descriptor *dev,
prop->data = grub_malloc (prop->length);
if (!prop->data)
{
- grub_free (prop);
grub_free (prop->name);
grub_free (prop->name16);
+ grub_free (prop);
return grub_errno;
}
grub_memcpy (prop->data, data, prop->length);
@@ -336,7 +339,7 @@ grub_xnu_devprop_add_property_utf16 (struct grub_xnu_devprop_device_descriptor *
utf8 = grub_malloc (namelen * 4 + 1);
if (!utf8)
{
- grub_free (utf8);
+ grub_free (utf16);
return grub_errno;
}
@@ -575,11 +578,31 @@ static grub_err_t
grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out)
{
struct grub_xnu_devtree_key *efikey;
+ struct grub_xnu_devtree_key *chosenkey;
struct grub_xnu_devtree_key *cfgtablekey;
struct grub_xnu_devtree_key *curval;
struct grub_xnu_devtree_key *runtimesrvkey;
struct grub_xnu_devtree_key *platformkey;
unsigned i, j;
+ grub_err_t err;
+
+ chosenkey = grub_xnu_create_key (&grub_xnu_devtree_root, "chosen");
+ if (! chosenkey)
+ return grub_errno;
+
+ /* Random seed. */
+ curval = grub_xnu_create_value (&(chosenkey->first_child), "random-seed");
+ if (! curval)
+ return grub_errno;
+ curval->datasize = 64;
+ curval->data = grub_malloc (curval->datasize);
+ if (! curval->data)
+ return grub_errno;
+ /* Our random is not peer-reviewed but xnu uses this seed only for
+ ASLR in kernel. */
+ err = grub_crypto_get_random (curval->data, curval->datasize);
+ if (err)
+ return err;
/* The value "model". */
/* FIXME: may this value be sometimes different? */
@@ -741,10 +764,10 @@ grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out)
*((grub_uint64_t *) curval->data) = (grub_addr_t) ptr;
/* Create alias. */
- for (j = 0; j < sizeof (table_aliases) / sizeof (table_aliases[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(table_aliases); j++)
if (grub_memcmp (&table_aliases[j].guid, &guid, sizeof (guid)) == 0)
break;
- if (j != sizeof (table_aliases) / sizeof (table_aliases[0]))
+ if (j != ARRAY_SIZE(table_aliases))
{
curval = grub_xnu_create_value (&(curkey->first_child), "alias");
if (!curval)
@@ -895,6 +918,28 @@ grub_xnu_set_video (struct grub_xnu_boot_params_common *params)
return GRUB_ERR_NONE;
}
+static int
+total_ram_hook (grub_uint64_t addr __attribute__ ((unused)), grub_uint64_t size,
+ grub_memory_type_t type,
+ void *data)
+{
+ grub_uint64_t *result = data;
+
+ if (type != GRUB_MEMORY_AVAILABLE)
+ return 0;
+ *result += size;
+ return 0;
+}
+
+static grub_uint64_t
+get_total_ram (void)
+{
+ grub_uint64_t result = 0;
+
+ grub_mmap_iterate (total_ram_hook, &result);
+ return result;
+}
+
/* Boot xnu. */
grub_err_t
grub_xnu_boot (void)
@@ -971,6 +1016,7 @@ grub_xnu_boot (void)
{
bootparams_common = &bootparams->v2.common;
bootparams->v2.fsbfreq = fsbfreq;
+ bootparams->v2.ram_size = get_total_ram();
}
else
bootparams_common = &bootparams->v1.common;
@@ -1078,7 +1124,7 @@ grub_xnu_boot (void)
bootparams_common->efi_mmap = memory_map_target;
bootparams_common->efi_mmap_size = memory_map_size;
bootparams_common->heap_start = grub_xnu_heap_target_start;
- bootparams_common->heap_size = grub_xnu_heap_size;
+ bootparams_common->heap_size = curruntimepage * GRUB_XNU_PAGESIZE - grub_xnu_heap_target_start;
/* Parameters for asm helper. */
grub_xnu_stack = bootparams_common->heap_start
diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c
index 87ac49f8c..efaa42ccd 100644
--- a/grub-core/loader/ia64/efi/linux.c
+++ b/grub-core/loader/ia64/efi/linux.c
@@ -568,7 +568,7 @@ static grub_err_t
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
- struct grub_linux_initrd_context initrd_ctx;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
if (argc == 0)
{
diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
index 117232f0c..be6fa0f4d 100644
--- a/grub-core/loader/linux.c
+++ b/grub-core/loader/linux.c
@@ -161,6 +161,9 @@ grub_initrd_init (int argc, char *argv[],
for (i = 0; i < argc; i++)
{
const char *fname = argv[i];
+
+ initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
+
if (grub_memcmp (argv[i], "newc:", 5) == 0)
{
const char *ptr, *eptr;
@@ -205,11 +208,12 @@ grub_initrd_init (int argc, char *argv[],
initrd_ctx->nfiles++;
initrd_ctx->components[i].size
= grub_file_size (initrd_ctx->components[i].file);
- initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4);
+ initrd_ctx->size += initrd_ctx->components[i].size;
}
if (newc)
{
+ initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
+ sizeof ("TRAILER!!!") - 1, 4);
free_dir (root);
@@ -248,10 +252,12 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
int i;
int newc = 0;
struct dir *root = 0;
+ grub_ssize_t cursize = 0;
for (i = 0; i < initrd_ctx->nfiles; i++)
{
- grub_ssize_t cursize;
+ grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
+ ptr += ALIGN_UP_OVERHEAD (cursize, 4);
if (initrd_ctx->components[i].newc_name)
{
@@ -283,11 +289,13 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
return grub_errno;
}
ptr += cursize;
+ }
+ if (newc)
+ {
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
+ ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
}
- if (newc)
- ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
free_dir (root);
root = 0;
return GRUB_ERR_NONE;
diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c
index ef64a5b1d..5f383be3d 100644
--- a/grub-core/loader/mips/linux.c
+++ b/grub-core/loader/mips/linux.c
@@ -415,7 +415,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
void *initrd_src;
grub_addr_t initrd_dest;
grub_err_t err;
- struct grub_linux_initrd_context initrd_ctx;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
if (argc == 0)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c
index 4b71f3363..73aa0aa12 100644
--- a/grub-core/loader/multiboot.c
+++ b/grub-core/loader/multiboot.c
@@ -240,20 +240,27 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)),
#ifndef GRUB_USE_MULTIBOOT2
grub_multiboot_quirks = GRUB_MULTIBOOT_QUIRKS_NONE;
+ int option_found = 0;
- if (argc != 0 && grub_strcmp (argv[0], "--quirk-bad-kludge") == 0)
+ do
{
- argc--;
- argv++;
- grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE;
- }
+ option_found = 0;
+ if (argc != 0 && grub_strcmp (argv[0], "--quirk-bad-kludge") == 0)
+ {
+ argc--;
+ argv++;
+ option_found = 1;
+ grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE;
+ }
- if (argc != 0 && grub_strcmp (argv[0], "--quirk-modules-after-kernel") == 0)
- {
- argc--;
- argv++;
- grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL;
- }
+ if (argc != 0 && grub_strcmp (argv[0], "--quirk-modules-after-kernel") == 0)
+ {
+ argc--;
+ argv++;
+ option_found = 1;
+ grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL;
+ }
+ } while (option_found);
#endif
if (argc == 0)
@@ -333,6 +340,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
return grub_errno;
#ifndef GRUB_USE_MULTIBOOT2
+ lowest_addr = 0x100000;
if (grub_multiboot_quirks & GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL)
lowest_addr = ALIGN_UP (highest_load + 1048576, 4096);
#endif
diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c
index 9dc21a1ba..e3a39b609 100644
--- a/grub-core/loader/multiboot_elfxx.c
+++ b/grub-core/loader/multiboot_elfxx.c
@@ -72,7 +72,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi
return grub_error (GRUB_ERR_UNKNOWN_OS, N_("this ELF file is not of the right type"));
/* FIXME: Should we support program headers at strange locations? */
- if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH)
+ if (ehdr->e_phoff + (grub_uint32_t) ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH)
return grub_error (GRUB_ERR_BAD_OS, "program header at a too high offset");
phdr_base = (char *) buffer + ehdr->e_phoff;
@@ -164,14 +164,17 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi
{
grub_uint8_t *shdr, *shdrptr;
- shdr = grub_malloc (ehdr->e_shnum * ehdr->e_shentsize);
+ shdr = grub_malloc ((grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize);
if (!shdr)
return grub_errno;
if (grub_file_seek (file, ehdr->e_shoff) == (grub_off_t) -1)
- return grub_errno;
+ {
+ grub_free (shdr);
+ return grub_errno;
+ }
- if (grub_file_read (file, shdr, ehdr->e_shnum * ehdr->e_shentsize)
+ if (grub_file_read (file, shdr, (grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize)
!= (grub_ssize_t) ehdr->e_shnum * ehdr->e_shentsize)
{
if (!grub_errno)
diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
index 83e8919fa..f147d674d 100644
--- a/grub-core/loader/multiboot_mbi2.c
+++ b/grub-core/loader/multiboot_mbi2.c
@@ -79,6 +79,25 @@ grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize,
elf_sections = data;
}
+static struct multiboot_header *
+find_header (grub_properly_aligned_t *buffer, grub_ssize_t len)
+{
+ struct multiboot_header *header;
+ /* Look for the multiboot header in the buffer. The header should
+ be at least 12 bytes and aligned on a 4-byte boundary. */
+ for (header = (struct multiboot_header *) buffer;
+ ((char *) header <= (char *) buffer + len - 12);
+ header = (struct multiboot_header *) ((grub_uint32_t *) header + MULTIBOOT_HEADER_ALIGN / 4))
+ {
+ if (header->magic == MULTIBOOT_HEADER_MAGIC
+ && !(header->magic + header->architecture
+ + header->header_length + header->checksum)
+ && header->architecture == MULTIBOOT_ARCHITECTURE_CURRENT)
+ return header;
+ }
+ return NULL;
+}
+
grub_err_t
grub_multiboot_load (grub_file_t file, const char *filename)
{
@@ -107,18 +126,7 @@ grub_multiboot_load (grub_file_t file, const char *filename)
COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0);
- /* Look for the multiboot header in the buffer. The header should
- be at least 12 bytes and aligned on a 4-byte boundary. */
- for (header = (struct multiboot_header *) buffer;
- ((char *) header <= (char *) buffer + len - 12) || (header = 0);
- header = (struct multiboot_header *) ((grub_uint32_t *) header + MULTIBOOT_HEADER_ALIGN / 4))
- {
- if (header->magic == MULTIBOOT_HEADER_MAGIC
- && !(header->magic + header->architecture
- + header->header_length + header->checksum)
- && header->architecture == MULTIBOOT_ARCHITECTURE_CURRENT)
- break;
- }
+ header = find_header (buffer, len);
if (header == 0)
{
@@ -142,7 +150,7 @@ grub_multiboot_load (grub_file_t file, const char *filename)
= (struct multiboot_header_tag_information_request *) tag;
if (request_tag->flags & MULTIBOOT_HEADER_TAG_OPTIONAL)
break;
- for (i = 0; i < (request_tag->size - sizeof (request_tag))
+ for (i = 0; i < (request_tag->size - sizeof (*request_tag))
/ sizeof (request_tag->requests[0]); i++)
switch (request_tag->requests[i])
{
@@ -412,6 +420,7 @@ grub_fill_multiboot_mmap_iter (grub_uint64_t addr, grub_uint64_t size,
(*mmap_entry)->addr = addr;
(*mmap_entry)->len = size;
(*mmap_entry)->type = type;
+ (*mmap_entry)->zero = 0;
(*mmap_entry)++;
return 0;
diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c
index 4a14f66de..6e814649f 100644
--- a/grub-core/loader/powerpc/ieee1275/linux.c
+++ b/grub-core/loader/powerpc/ieee1275/linux.c
@@ -333,7 +333,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
grub_size_t size = 0;
grub_addr_t first_addr;
grub_addr_t addr;
- struct grub_linux_initrd_context initrd_ctx;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
if (argc == 0)
{
diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c
index de6ee2f75..67ef04883 100644
--- a/grub-core/loader/sparc64/ieee1275/linux.c
+++ b/grub-core/loader/sparc64/ieee1275/linux.c
@@ -110,7 +110,7 @@ grub_linux_boot (void)
int len = grub_strlen (linux_args) + 1;
if (bp->len < len)
len = bp->len;
- memcpy(bp->buf, linux_args, len);
+ grub_memcpy(bp->buf, linux_args, len);
bp->buf[len-1] = '\0';
bp->valid = 1;
}
@@ -140,17 +140,17 @@ grub_linux_boot (void)
grub_dprintf ("loader", "Jumping to Linux...\n");
/* Boot the kernel. */
- asm volatile ("sethi %hi(grub_ieee1275_entry_fn), %o1\n"
- "ldx [%o1 + %lo(grub_ieee1275_entry_fn)], %o4\n"
- "sethi %hi(grub_ieee1275_original_stack), %o1\n"
- "ldx [%o1 + %lo(grub_ieee1275_original_stack)], %o6\n"
- "sethi %hi(linux_addr), %o1\n"
- "ldx [%o1 + %lo(linux_addr)], %o5\n"
- "mov %g0, %o0\n"
- "mov %g0, %o2\n"
- "mov %g0, %o3\n"
- "jmp %o5\n"
- "mov %g0, %o1\n");
+ asm volatile ("ldx %0, %%o4\n"
+ "ldx %1, %%o6\n"
+ "ldx %2, %%o5\n"
+ "mov %%g0, %%o0\n"
+ "mov %%g0, %%o2\n"
+ "mov %%g0, %%o3\n"
+ "jmp %%o5\n"
+ "mov %%g0, %%o1\n": :
+ "m"(grub_ieee1275_entry_fn),
+ "m"(grub_ieee1275_original_stack),
+ "m"(linux_addr));
return GRUB_ERR_NONE;
}
@@ -196,27 +196,27 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len,
struct alloc_phys_ctx *ctx = data;
grub_addr_t end = addr + len;
- if (type != 1)
+ if (type != GRUB_MEMORY_AVAILABLE)
return 0;
addr = ALIGN_UP (addr, FOUR_MB);
if (addr + ctx->size >= end)
return 0;
- if (addr >= grub_phys_start && addr < grub_phys_end)
- {
- addr = ALIGN_UP (grub_phys_end, FOUR_MB);
- if (addr + ctx->size >= end)
- return 0;
- }
- if ((addr + ctx->size) >= grub_phys_start
- && (addr + ctx->size) < grub_phys_end)
+ /* OBP available region contains grub. Start at grub_phys_end. */
+ /* grub_phys_start does not start at the beginning of the memory region */
+ if ((grub_phys_start >= addr && grub_phys_end < end) ||
+ (addr > grub_phys_start && addr < grub_phys_end))
{
addr = ALIGN_UP (grub_phys_end, FOUR_MB);
if (addr + ctx->size >= end)
return 0;
}
+ grub_dprintf("loader",
+ "addr = 0x%lx grub_phys_start = 0x%lx grub_phys_end = 0x%lx\n",
+ addr, grub_phys_start, grub_phys_end);
+
if (loaded)
{
grub_addr_t linux_end = ALIGN_UP (linux_paddr + linux_size, FOUR_MB);
@@ -373,7 +373,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
grub_addr_t paddr;
grub_addr_t addr;
int ret;
- struct grub_linux_initrd_context initrd_ctx;
+ struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
if (argc == 0)
{
@@ -430,7 +430,7 @@ static int
get_physbase (grub_uint64_t addr, grub_uint64_t len __attribute__ ((unused)),
grub_memory_type_t type, void *data __attribute__ ((unused)))
{
- if (type != 1)
+ if (type != GRUB_MEMORY_AVAILABLE)
return 0;
if (addr < phys_base)
phys_base = addr;
diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
index cdd9715ce..c9885b1bc 100644
--- a/grub-core/loader/xnu.c
+++ b/grub-core/loader/xnu.c
@@ -689,10 +689,10 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
/* Allocate the space. */
err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE);
if (err)
- return err;
+ goto fail;
err = grub_xnu_heap_malloc (neededspace, &buf0, &buf_target);
if (err)
- return err;
+ goto fail;
buf = buf0;
exthead = (struct grub_xnu_extheader *) buf;
@@ -709,10 +709,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
else
err = grub_macho_readfile32 (macho, filename, buf);
if (err)
- {
- grub_macho_close (macho);
- return err;
- }
+ goto fail;
grub_macho_close (macho);
buf += machosize;
}
@@ -747,6 +744,10 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
/* Announce to kernel */
return grub_xnu_register_memory ("Driver-", &driversnum, buf_target,
neededspace);
+fail:
+ if (macho)
+ grub_macho_close (macho);
+ return err;
}
/* Load mkext. */
@@ -1378,6 +1379,8 @@ grub_xnu_fill_devicetree (void)
name[len] = 0;
curvalue = grub_xnu_create_value (curkey, name);
+ if (!curvalue)
+ return grub_errno;
grub_free (name);
data = grub_malloc (grub_strlen (var->value) + 1);
diff --git a/grub-core/mmap/efi/mmap.c b/grub-core/mmap/efi/mmap.c
index a77efe81d..bd495a184 100644
--- a/grub-core/mmap/efi/mmap.c
+++ b/grub-core/mmap/efi/mmap.c
@@ -73,6 +73,7 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data,
GRUB_MEMORY_AVAILABLE, hook_data);
break;
}
+ /* FALLTHROUGH */
case GRUB_EFI_RUNTIME_SERVICES_CODE:
hook (desc->physical_start, desc->num_pages * 4096,
GRUB_MEMORY_CODE, hook_data);
@@ -83,10 +84,6 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data,
GRUB_MEMORY_BADRAM, hook_data);
break;
- default:
- grub_printf ("Unknown memory type %d, considering reserved\n",
- desc->type);
-
case GRUB_EFI_BOOT_SERVICES_DATA:
if (!avoid_efi_boot_services)
{
@@ -94,6 +91,7 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data,
GRUB_MEMORY_AVAILABLE, hook_data);
break;
}
+ /* FALLTHROUGH */
case GRUB_EFI_RESERVED_MEMORY_TYPE:
case GRUB_EFI_RUNTIME_SERVICES_DATA:
case GRUB_EFI_MEMORY_MAPPED_IO:
@@ -119,6 +117,18 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data,
hook (desc->physical_start, desc->num_pages * 4096,
GRUB_MEMORY_NVS, hook_data);
break;
+
+ case GRUB_EFI_PERSISTENT_MEMORY:
+ hook (desc->physical_start, desc->num_pages * 4096,
+ GRUB_MEMORY_PERSISTENT, hook_data);
+ break;
+
+ default:
+ grub_printf ("Unknown memory type %d, considering reserved\n",
+ desc->type);
+ hook (desc->physical_start, desc->num_pages * 4096,
+ GRUB_MEMORY_RESERVED, hook_data);
+ break;
}
}
@@ -142,6 +152,13 @@ make_efi_memtype (int type)
/* No way to remove a chunk of memory from EFI mmap.
So mark it as unusable. */
case GRUB_MEMORY_HOLE:
+ /*
+ * AllocatePages() does not support GRUB_EFI_PERSISTENT_MEMORY,
+ * so no translation for GRUB_MEMORY_PERSISTENT or
+ * GRUB_MEMORY_PERSISTENT_LEGACY.
+ */
+ case GRUB_MEMORY_PERSISTENT:
+ case GRUB_MEMORY_PERSISTENT_LEGACY:
case GRUB_MEMORY_RESERVED:
return GRUB_EFI_UNUSABLE_MEMORY;
diff --git a/grub-core/mmap/i386/uppermem.c b/grub-core/mmap/i386/uppermem.c
index bd8b429c4..a6be9896d 100644
--- a/grub-core/mmap/i386/uppermem.c
+++ b/grub-core/mmap/i386/uppermem.c
@@ -31,8 +31,12 @@ lower_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type,
if (type != GRUB_MEMORY_AVAILABLE)
return 0;
+#ifdef GRUB_MACHINE_COREBOOT
+ if (addr <= 0x1000)
+#else
if (addr == 0)
- *lower = size;
+#endif
+ *lower = size + addr;
return 0;
}
diff --git a/grub-core/modinfo.sh.in b/grub-core/modinfo.sh.in
index ff31ca816..faf0ad30e 100644
--- a/grub-core/modinfo.sh.in
+++ b/grub-core/modinfo.sh.in
@@ -1,4 +1,40 @@
#!/bin/sh
+# User-controllable options
grub_modinfo_target_cpu=@target_cpu@
grub_modinfo_platform=@platform@
+grub_disk_cache_stats=@DISK_CACHE_STATS@
+grub_boot_time_stats=@BOOT_TIME_STATS@
+grub_have_font_source=@HAVE_FONT_SOURCE@
+
+# Autodetected config
+grub_have_asm_uscore=@HAVE_ASM_USCORE@
+grub_bss_start_symbol="@BSS_START_SYMBOL@"
+grub_end_symbol="@END_SYMBOL@"
+
+# Build environment
+grub_target_cc='@TARGET_CC@'
+grub_target_cc_version='@TARGET_CC_VERSION@'
+grub_target_cflags='@TARGET_CFLAGS@'
+grub_target_cppflags='@TARGET_CPPFLAGS@'
+grub_target_ccasflags='@TARGET_CCASFLAGS@'
+grub_target_ldflags='@TARGET_LDFLAGS@'
+grub_cflags='@CFLAGS@'
+grub_cppflags='@CPPFLAGS@'
+grub_ccasflags='@CCASFLAGS@'
+grub_ldflags='@LDFLAGS@'
+grub_target_strip='@TARGET_STRIP@'
+grub_target_nm='@TARGET_NM@'
+grub_target_ranlib='@TARGET_RANLIB@'
+grub_target_objconf='@TARGET_OBJCONV@'
+grub_target_obj2elf='@TARGET_OBJ2ELF@'
+grub_target_img_base_ldopt='@TARGET_IMG_BASE_LDOPT@'
+grub_target_img_ldflags='@TARGET_IMG_BASE_LDFLAGS@'
+
+# Version
+grub_version="@VERSION@"
+grub_package="@PACKAGE@"
+grub_package_string="@PACKAGE_STRING@"
+grub_package_version="@PACKAGE_VERSION@"
+grub_package_name="@PACKAGE_NAME@"
+grub_package_bugreport="@PACKAGE_BUGREPORT@"
diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c
index e92c7e7da..4b68c4151 100644
--- a/grub-core/net/arp.c
+++ b/grub-core/net/arp.c
@@ -37,12 +37,16 @@ enum
GRUB_NET_ARPHRD_ETHERNET = 1
};
-struct arphdr {
+struct arppkt {
grub_uint16_t hrd;
grub_uint16_t pro;
grub_uint8_t hln;
grub_uint8_t pln;
grub_uint16_t op;
+ grub_uint8_t sender_mac[6];
+ grub_uint32_t sender_ip;
+ grub_uint8_t recv_mac[6];
+ grub_uint32_t recv_ip;
} GRUB_PACKED;
static int have_pending;
@@ -53,21 +57,14 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf,
const grub_net_network_level_address_t *proto_addr)
{
struct grub_net_buff nb;
- struct arphdr *arp_header;
- grub_net_link_level_address_t target_hw_addr;
- grub_uint8_t *aux, arp_data[128];
+ struct arppkt *arp_packet;
+ grub_net_link_level_address_t target_mac_addr;
grub_err_t err;
int i;
- grub_size_t addrlen;
- grub_uint16_t etherpro;
grub_uint8_t *nbd;
+ grub_uint8_t arp_data[128];
- if (proto_addr->type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4)
- {
- addrlen = 4;
- etherpro = GRUB_NET_ETHERTYPE_IP;
- }
- else
+ if (proto_addr->type != GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4)
return grub_error (GRUB_ERR_BUG, "unsupported address family");
/* Build a request packet. */
@@ -76,45 +73,38 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf,
grub_netbuff_clear (&nb);
grub_netbuff_reserve (&nb, 128);
- err = grub_netbuff_push (&nb, sizeof (*arp_header) + 2 * (6 + addrlen));
+ err = grub_netbuff_push (&nb, sizeof (*arp_packet));
if (err)
return err;
- arp_header = (struct arphdr *) nb.data;
- arp_header->hrd = grub_cpu_to_be16 (GRUB_NET_ARPHRD_ETHERNET);
- arp_header->hln = 6;
- arp_header->pro = grub_cpu_to_be16 (etherpro);
- arp_header->pln = addrlen;
- arp_header->op = grub_cpu_to_be16 (ARP_REQUEST);
- aux = (grub_uint8_t *) arp_header + sizeof (*arp_header);
+ arp_packet = (struct arppkt *) nb.data;
+ arp_packet->hrd = grub_cpu_to_be16_compile_time (GRUB_NET_ARPHRD_ETHERNET);
+ arp_packet->hln = 6;
+ arp_packet->pro = grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_IP);
+ arp_packet->pln = 4;
+ arp_packet->op = grub_cpu_to_be16_compile_time (ARP_REQUEST);
/* Sender hardware address. */
- grub_memcpy (aux, &inf->hwaddress.mac, 6);
-
- aux += 6;
- /* Sender protocol address */
- grub_memcpy (aux, &inf->address.ipv4, 4);
- aux += addrlen;
- /* Target hardware address */
- for (i = 0; i < 6; i++)
- aux[i] = 0x00;
- aux += 6;
+ grub_memcpy (arp_packet->sender_mac, &inf->hwaddress.mac, 6);
+ arp_packet->sender_ip = inf->address.ipv4;
+ grub_memset (arp_packet->recv_mac, 0, 6);
+ arp_packet->recv_ip = proto_addr->ipv4;
/* Target protocol address */
- grub_memcpy (aux, &proto_addr->ipv4, 4);
- grub_memset (&target_hw_addr.mac, 0xff, 6);
+ grub_memset (&target_mac_addr.mac, 0xff, 6);
nbd = nb.data;
- send_ethernet_packet (inf, &nb, target_hw_addr, GRUB_NET_ETHERTYPE_ARP);
+ send_ethernet_packet (inf, &nb, target_mac_addr, GRUB_NET_ETHERTYPE_ARP);
for (i = 0; i < GRUB_NET_TRIES; i++)
{
if (grub_net_link_layer_resolve_check (inf, proto_addr))
return GRUB_ERR_NONE;
pending_req = proto_addr->ipv4;
have_pending = 0;
- grub_net_poll_cards (GRUB_NET_INTERVAL, &have_pending);
+ grub_net_poll_cards (GRUB_NET_INTERVAL + (i * GRUB_NET_INTERVAL_ADDITION),
+ &have_pending);
if (grub_net_link_layer_resolve_check (inf, proto_addr))
return GRUB_ERR_NONE;
nb.data = nbd;
- send_ethernet_packet (inf, &nb, target_hw_addr, GRUB_NET_ETHERTYPE_ARP);
+ send_ethernet_packet (inf, &nb, target_mac_addr, GRUB_NET_ETHERTYPE_ARP);
}
return GRUB_ERR_NONE;
@@ -124,63 +114,67 @@ grub_err_t
grub_net_arp_receive (struct grub_net_buff *nb,
struct grub_net_card *card)
{
- struct arphdr *arp_header = (struct arphdr *) nb->data;
- grub_uint8_t *sender_hardware_address;
- grub_uint8_t *target_hardware_address;
+ struct arppkt *arp_packet = (struct arppkt *) nb->data;
grub_net_network_level_address_t sender_addr, target_addr;
- grub_net_link_level_address_t sender_hw_addr;
+ grub_net_link_level_address_t sender_mac_addr;
struct grub_net_network_level_interface *inf;
- grub_uint8_t *sender_protocol_address, *target_protocol_address;
-
- sender_hardware_address =
- (grub_uint8_t *) arp_header + sizeof (*arp_header);
- sender_protocol_address = sender_hardware_address + arp_header->hln;
- target_hardware_address = sender_protocol_address + arp_header->pln;
- target_protocol_address = target_hardware_address + arp_header->hln;
- if (grub_be_to_cpu16 (arp_header->pro) == GRUB_NET_ETHERTYPE_IP
- && arp_header->pln == 4)
- {
- sender_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
- target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
- grub_memcpy (&sender_addr.ipv4, sender_protocol_address, 4);
- grub_memcpy (&target_addr.ipv4, target_protocol_address, 4);
- if (grub_memcmp (sender_protocol_address, &pending_req, 4) == 0)
- have_pending = 1;
- }
- else
+
+ if (arp_packet->pro != grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_IP)
+ || arp_packet->pln != 4 || arp_packet->hln != 6
+ || nb->tail - nb->data < (int) sizeof (*arp_packet))
return GRUB_ERR_NONE;
- sender_hw_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
- grub_memcpy (sender_hw_addr.mac, sender_hardware_address,
- sizeof (sender_hw_addr.mac));
- grub_net_link_layer_add_address (card, &sender_addr, &sender_hw_addr, 1);
+ sender_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ sender_addr.ipv4 = arp_packet->sender_ip;
+ target_addr.ipv4 = arp_packet->recv_ip;
+ if (arp_packet->sender_ip == pending_req)
+ have_pending = 1;
+
+ sender_mac_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+ grub_memcpy (sender_mac_addr.mac, arp_packet->sender_mac,
+ sizeof (sender_mac_addr.mac));
+ grub_net_link_layer_add_address (card, &sender_addr, &sender_mac_addr, 1);
FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
{
/* Am I the protocol address target? */
if (grub_net_addr_cmp (&inf->address, &target_addr) == 0
- && grub_be_to_cpu16 (arp_header->op) == ARP_REQUEST)
+ && arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST))
{
grub_net_link_level_address_t target;
- /* We've already checked that pln is either 4 or 16. */
- char tmp[16];
- grub_size_t pln = arp_header->pln;
-
- if (pln > 16)
- pln = 16;
+ struct grub_net_buff nb_reply;
+ struct arppkt *arp_reply;
+ grub_uint8_t arp_data[128];
+ grub_err_t err;
+
+ nb_reply.head = arp_data;
+ nb_reply.end = arp_data + sizeof (arp_data);
+ grub_netbuff_clear (&nb_reply);
+ grub_netbuff_reserve (&nb_reply, 128);
+
+ err = grub_netbuff_push (&nb_reply, sizeof (*arp_packet));
+ if (err)
+ return err;
+
+ arp_reply = (struct arppkt *) nb_reply.data;
+
+ arp_reply->hrd = grub_cpu_to_be16_compile_time (GRUB_NET_ARPHRD_ETHERNET);
+ arp_reply->pro = grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_IP);
+ arp_reply->pln = 4;
+ arp_reply->hln = 6;
+ arp_reply->op = grub_cpu_to_be16_compile_time (ARP_REPLY);
+ arp_reply->sender_ip = arp_packet->recv_ip;
+ arp_reply->recv_ip = arp_packet->sender_ip;
+ arp_reply->hln = 6;
target.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
- grub_memcpy (target.mac, sender_hardware_address, 6);
- grub_memcpy (target_hardware_address, target.mac, 6);
- grub_memcpy (sender_hardware_address, inf->hwaddress.mac, 6);
-
- grub_memcpy (tmp, sender_protocol_address, pln);
- grub_memcpy (sender_protocol_address, target_protocol_address, pln);
- grub_memcpy (target_protocol_address, tmp, pln);
+ grub_memcpy (target.mac, arp_packet->sender_mac, 6);
+ grub_memcpy (arp_reply->sender_mac, inf->hwaddress.mac, 6);
+ grub_memcpy (arp_reply->recv_mac, arp_packet->sender_mac, 6);
/* Change operation to REPLY and send packet */
- arp_header->op = grub_be_to_cpu16 (ARP_REPLY);
- send_ethernet_packet (inf, nb, target, GRUB_NET_ETHERTYPE_ARP);
+ send_ethernet_packet (inf, &nb_reply, target, GRUB_NET_ETHERTYPE_ARP);
}
}
return GRUB_ERR_NONE;
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
index ed159418a..189551a48 100644
--- a/grub-core/net/bootp.c
+++ b/grub-core/net/bootp.c
@@ -25,41 +25,6 @@
#include <grub/net/udp.h>
#include <grub/datetime.h>
-static char *
-grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)),
- const char *val __attribute__ ((unused)))
-{
- return NULL;
-}
-
-static void
-set_env_limn_ro (const char *intername, const char *suffix,
- const char *value, grub_size_t len)
-{
- char *varname, *varvalue;
- char *ptr;
- varname = grub_xasprintf ("net_%s_%s", intername, suffix);
- if (!varname)
- return;
- for (ptr = varname; *ptr; ptr++)
- if (*ptr == ':')
- *ptr = '_';
- varvalue = grub_malloc (len + 1);
- if (!varvalue)
- {
- grub_free (varname);
- return;
- }
-
- grub_memcpy (varvalue, value, len);
- varvalue[len] = 0;
- grub_env_set (varname, varvalue);
- grub_register_variable_hook (varname, 0, grub_env_write_readonly);
- grub_env_export (varname);
- grub_free (varname);
- grub_free (varvalue);
-}
-
static void
parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask)
{
@@ -117,7 +82,7 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask)
grub_memcpy (&gw.ipv4, ptr, sizeof (gw.ipv4));
rname = grub_xasprintf ("%s:default", name);
if (rname)
- grub_net_add_route_gw (rname, target, gw);
+ grub_net_add_route_gw (rname, target, gw, NULL);
grub_free (rname);
}
break;
@@ -136,20 +101,24 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask)
}
continue;
case GRUB_NET_BOOTP_HOSTNAME:
- set_env_limn_ro (name, "hostname", (const char *) ptr, taglength);
- break;
+ grub_env_set_net_property (name, "hostname", (const char *) ptr,
+ taglength);
+ break;
case GRUB_NET_BOOTP_DOMAIN:
- set_env_limn_ro (name, "domain", (const char *) ptr, taglength);
- break;
+ grub_env_set_net_property (name, "domain", (const char *) ptr,
+ taglength);
+ break;
case GRUB_NET_BOOTP_ROOT_PATH:
- set_env_limn_ro (name, "rootpath", (const char *) ptr, taglength);
- break;
+ grub_env_set_net_property (name, "rootpath", (const char *) ptr,
+ taglength);
+ break;
case GRUB_NET_BOOTP_EXTENSIONS_PATH:
- set_env_limn_ro (name, "extensionspath", (const char *) ptr, taglength);
- break;
+ grub_env_set_net_property (name, "extensionspath", (const char *) ptr,
+ taglength);
+ break;
/* If you need any other options please contact GRUB
development team. */
@@ -188,6 +157,15 @@ grub_net_configure_by_dhcp_ack (const char *name,
hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags);
+ if (!inter)
+ return 0;
+
+#if 0
+ /* This is likely based on misunderstanding. gateway_ip refers to
+ address of BOOTP relay and should not be used after BOOTP transaction
+ is complete.
+ See RFC1542, 3.4 Interpretation of the 'giaddr' field
+ */
if (bp->gateway_ip)
{
grub_net_network_level_netaddress_t target;
@@ -209,10 +187,11 @@ grub_net_configure_by_dhcp_ack (const char *name,
target.ipv4.masksize = 32;
grub_net_add_route (name, target, inter);
}
+#endif
if (size > OFFSET_OF (boot_file, bp))
- set_env_limn_ro (name, "boot_file", (char *) bp->boot_file,
- sizeof (bp->boot_file));
+ grub_env_set_net_property (name, "boot_file", bp->boot_file,
+ sizeof (bp->boot_file));
if (is_def)
grub_net_default_server = 0;
if (is_def && !grub_net_default_server && bp->server_ip)
@@ -243,8 +222,8 @@ grub_net_configure_by_dhcp_ack (const char *name,
if (size > OFFSET_OF (server_name, bp)
&& bp->server_name[0])
{
- set_env_limn_ro (name, "dhcp_server_name", (char *) bp->server_name,
- sizeof (bp->server_name));
+ grub_env_set_net_property (name, "dhcp_server_name", bp->server_name,
+ sizeof (bp->server_name));
if (is_def && !grub_net_default_server)
{
grub_net_default_server = grub_strdup (bp->server_name);
@@ -392,6 +371,7 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
if (grub_strcmp (args[3], "string") == 0)
{
+ grub_err_t err = GRUB_ERR_NONE;
char *val = grub_malloc (taglength + 1);
if (!val)
return grub_errno;
@@ -400,8 +380,9 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
if (args[0][0] == '-' && args[0][1] == 0)
grub_printf ("%s\n", val);
else
- return grub_env_set (args[0], val);
- return GRUB_ERR_NONE;
+ err = grub_env_set (args[0], val);
+ grub_free (val);
+ return err;
}
if (grub_strcmp (args[3], "number") == 0)
@@ -415,7 +396,7 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
else
{
char valn[64];
- grub_printf (valn, sizeof (valn), "%lld\n", (unsigned long long) val);
+ grub_snprintf (valn, sizeof (valn), "%lld\n", (unsigned long long) val);
return grub_env_set (args[0], valn);
}
return GRUB_ERR_NONE;
@@ -423,6 +404,7 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
if (grub_strcmp (args[3], "hex") == 0)
{
+ grub_err_t err = GRUB_ERR_NONE;
char *val = grub_malloc (2 * taglength + 1);
int i;
if (!val)
@@ -436,8 +418,9 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
if (args[0][0] == '-' && args[0][1] == 0)
grub_printf ("%s\n", val);
else
- return grub_env_set (args[0], val);
- return GRUB_ERR_NONE;
+ err = grub_env_set (args[0], val);
+ grub_free (val);
+ return err;
}
return grub_error (GRUB_ERR_BAD_ARGUMENT,
@@ -553,8 +536,8 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
grub_netbuff_push (nb, sizeof (*udph));
udph = (struct udphdr *) nb->data;
- udph->src = grub_cpu_to_be16 (68);
- udph->dst = grub_cpu_to_be16 (67);
+ udph->src = grub_cpu_to_be16_compile_time (68);
+ udph->dst = grub_cpu_to_be16_compile_time (67);
udph->chksum = 0;
udph->len = grub_cpu_to_be16 (nb->tail - nb->data);
target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c
index 0b771fb10..89741dd7d 100644
--- a/grub-core/net/dns.c
+++ b/grub-core/net/dns.c
@@ -262,7 +262,7 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)),
grub_netbuff_free (nb);
return GRUB_ERR_NONE;
}
- for (i = 0; i < grub_cpu_to_be16 (head->qdcount); i++)
+ for (i = 0; i < grub_be_to_cpu16 (head->qdcount); i++)
{
if (ptr >= nb->tail)
{
@@ -277,7 +277,7 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)),
ptr += 4;
}
*data->addresses = grub_malloc (sizeof ((*data->addresses)[0])
- * grub_cpu_to_be16 (head->ancount));
+ * grub_be_to_cpu16 (head->ancount));
if (!*data->addresses)
{
grub_errno = GRUB_ERR_NONE;
@@ -286,7 +286,7 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)),
}
reparse_ptr = ptr;
reparse:
- for (i = 0, ptr = reparse_ptr; i < grub_cpu_to_be16 (head->ancount); i++)
+ for (i = 0, ptr = reparse_ptr; i < grub_be_to_cpu16 (head->ancount); i++)
{
int ignored = 0;
grub_uint8_t class;
@@ -437,7 +437,7 @@ grub_net_dns_lookup (const char *name,
struct recv_data data = {naddresses, addresses, cache,
grub_cpu_to_be16 (id++), 0, 0, name, 0};
grub_uint8_t *nbd;
- int have_server = 0;
+ grub_size_t try_server = 0;
if (!servers)
{
@@ -543,38 +543,35 @@ grub_net_dns_lookup (const char *name,
for (i = 0; i < n_servers * 4; i++)
{
/* Connect to a next server. */
- while (!(i & 1) && send_servers < n_servers)
+ while (!(i & 1) && try_server < n_servers)
{
- sockets[send_servers] = grub_net_udp_open (servers[send_servers],
+ sockets[send_servers] = grub_net_udp_open (servers[try_server++],
DNS_PORT,
recv_hook,
&data);
- send_servers++;
- if (!sockets[send_servers - 1])
+ if (!sockets[send_servers])
{
err = grub_errno;
grub_errno = GRUB_ERR_NONE;
}
else
{
- have_server = 1;
+ send_servers++;
break;
}
}
- if (!have_server)
+ if (!send_servers)
goto out;
if (*data.naddresses)
goto out;
for (j = 0; j < send_servers; j++)
{
grub_err_t err2;
- if (!sockets[j])
- continue;
- nb->data = nbd;
grub_size_t t = 0;
do
{
+ nb->data = nbd;
if (servers[j].option == DNS_OPTION_IPV4 ||
((servers[j].option == DNS_OPTION_PREFER_IPV4) && (t++ == 0)) ||
((servers[j].option == DNS_OPTION_PREFER_IPV6) && (t++ == 1)))
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index 2b344d6ef..5388f952b 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -37,28 +37,29 @@ send_card_buffer (struct grub_net_card *dev,
grub_efi_status_t st;
grub_efi_simple_network_t *net = dev->efi_net;
grub_uint64_t limit_time = grub_get_time_ms () + 4000;
+ void *txbuf;
if (dev->txbusy)
while (1)
{
- void *txbuf = NULL;
+ txbuf = NULL;
st = efi_call_3 (net->get_status, net, 0, &txbuf);
if (st != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_IO,
N_("couldn't send network packet"));
- if (txbuf == dev->txbuf)
+ /*
+ Some buggy firmware could return an arbitrary address instead of the
+ txbuf address we trasmitted, so just check that txbuf is non NULL
+ for success. This is ok because we open the SNP protocol in
+ exclusive mode so we know we're the only ones transmitting on this
+ box and since we only transmit one packet at a time we know our
+ transmit was successfull.
+ */
+ if (txbuf)
{
dev->txbusy = 0;
break;
}
- if (txbuf)
- {
- st = efi_call_7 (net->transmit, net, 0, dev->last_pkt_size,
- dev->txbuf, NULL, NULL, NULL);
- if (st != GRUB_EFI_SUCCESS)
- return grub_error (GRUB_ERR_IO,
- N_("couldn't send network packet"));
- }
if (limit_time < grub_get_time_ms ())
return grub_error (GRUB_ERR_TIMEOUT,
N_("couldn't send network packet"));
@@ -74,7 +75,19 @@ send_card_buffer (struct grub_net_card *dev,
dev->txbuf, NULL, NULL, NULL);
if (st != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_IO, N_("couldn't send network packet"));
- dev->txbusy = 1;
+
+ /*
+ The card may have sent out the packet immediately - set txbusy
+ to 0 in this case.
+ Cases were observed where checking txbuf at the next call
+ of send_card_buffer() is too late: 0 is returned in txbuf and
+ we run in the GRUB_ERR_TIMEOUT case above.
+ Perhaps a timeout in the FW has discarded the recycle buffer.
+ */
+ txbuf = NULL;
+ st = efi_call_3 (net->get_status, net, 0, &txbuf);
+ dev->txbusy = !(st == GRUB_EFI_SUCCESS && txbuf);
+
return GRUB_ERR_NONE;
}
@@ -130,9 +143,80 @@ get_card_packet (struct grub_net_card *dev)
return nb;
}
+static grub_err_t
+open_card (struct grub_net_card *dev)
+{
+ grub_efi_simple_network_t *net;
+
+ /* Try to reopen SNP exlusively to close any active MNP protocol instance
+ that may compete for packet polling
+ */
+ net = grub_efi_open_protocol (dev->efi_handle, &net_io_guid,
+ GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE);
+ if (net)
+ {
+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED
+ && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS)
+ return grub_error (GRUB_ERR_NET_NO_CARD, "%s: net start failed",
+ dev->name);
+
+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED)
+ return grub_error (GRUB_ERR_NET_NO_CARD, "%s: card stopped",
+ dev->name);
+
+ if (net->mode->state == GRUB_EFI_NETWORK_STARTED
+ && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS)
+ return grub_error (GRUB_ERR_NET_NO_CARD, "%s: net initialize failed",
+ dev->name);
+
+ /* Enable hardware receive filters if driver declares support for it.
+ We need unicast and broadcast and additionaly all nodes and
+ solicited multicast for IPv6. Solicited multicast is per-IPv6
+ address and we currently do not have API to do it so simply
+ try to enable receive of all multicast packets or evertyhing in
+ the worst case (i386 PXE driver always enables promiscuous too).
+
+ This does trust firmware to do what it claims to do.
+ */
+ if (net->mode->receive_filter_mask)
+ {
+ grub_uint32_t filters = GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST |
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST |
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;
+
+ filters &= net->mode->receive_filter_mask;
+ if (!(filters & GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST))
+ filters |= (net->mode->receive_filter_mask &
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS);
+
+ efi_call_6 (net->receive_filters, net, filters, 0, 0, 0, NULL);
+ }
+
+ efi_call_4 (grub_efi_system_table->boot_services->close_protocol,
+ dev->efi_net, &net_io_guid,
+ grub_efi_image_handle, dev->efi_handle);
+ dev->efi_net = net;
+ }
+
+ /* If it failed we just try to run as best as we can */
+ return GRUB_ERR_NONE;
+}
+
+static void
+close_card (struct grub_net_card *dev)
+{
+ efi_call_1 (dev->efi_net->shutdown, dev->efi_net);
+ efi_call_1 (dev->efi_net->stop, dev->efi_net);
+ efi_call_4 (grub_efi_system_table->boot_services->close_protocol,
+ dev->efi_net, &net_io_guid,
+ grub_efi_image_handle, dev->efi_handle);
+}
+
static struct grub_net_card_driver efidriver =
{
.name = "efinet",
+ .open = open_card,
+ .close = close_card,
.send = send_card_buffer,
.recv = get_card_packet
};
@@ -162,6 +246,29 @@ grub_efinet_findcards (void)
{
grub_efi_simple_network_t *net;
struct grub_net_card *card;
+ grub_efi_device_path_t *dp, *parent = NULL, *child = NULL;
+
+ /* EDK2 UEFI PXE driver creates IPv4 and IPv6 messaging devices as
+ children of main MAC messaging device. We only need one device with
+ bound SNP per physical card, otherwise they compete with each other
+ when polling for incoming packets.
+ */
+ dp = grub_efi_get_device_path (*handle);
+ if (!dp)
+ continue;
+ for (; ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp); dp = GRUB_EFI_NEXT_DEVICE_PATH (dp))
+ {
+ parent = child;
+ child = dp;
+ }
+ if (child
+ && GRUB_EFI_DEVICE_PATH_TYPE (child) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE
+ && (GRUB_EFI_DEVICE_PATH_SUBTYPE (child) == GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE
+ || GRUB_EFI_DEVICE_PATH_SUBTYPE (child) == GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE)
+ && parent
+ && GRUB_EFI_DEVICE_PATH_TYPE (parent) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE
+ && GRUB_EFI_DEVICE_PATH_SUBTYPE (parent) == GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE)
+ continue;
net = grub_efi_open_protocol (*handle, &net_io_guid,
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
@@ -239,7 +346,33 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
if (! cdp)
continue;
if (grub_efi_compare_device_paths (dp, cdp) != 0)
- continue;
+ {
+ grub_efi_device_path_t *ldp, *dup_dp, *dup_ldp;
+ int match;
+
+ /* EDK2 UEFI PXE driver creates pseudo devices with type IPv4/IPv6
+ as children of Ethernet card and binds PXE and Load File protocols
+ to it. Loaded Image Device Path protocol will point to these pseudo
+ devices. We skip them when enumerating cards, so here we need to
+ find matching MAC device.
+ */
+ ldp = grub_efi_find_last_device_path (dp);
+ if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE
+ || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE
+ && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE))
+ continue;
+ dup_dp = grub_efi_duplicate_device_path (dp);
+ if (!dup_dp)
+ continue;
+ dup_ldp = grub_efi_find_last_device_path (dup_dp);
+ dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
+ dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ dup_ldp->length = sizeof (*dup_ldp);
+ match = grub_efi_compare_device_paths (dup_dp, cdp) == 0;
+ grub_free (dup_dp);
+ if (!match)
+ continue;
+ }
pxe = grub_efi_open_protocol (hnd, &pxe_io_guid,
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (! pxe)
diff --git a/grub-core/net/drivers/emu/emunet.c b/grub-core/net/drivers/emu/emunet.c
index 7c977cd52..b19492086 100644
--- a/grub-core/net/drivers/emu/emunet.c
+++ b/grub-core/net/drivers/emu/emunet.c
@@ -98,7 +98,7 @@ static int registered = 0;
GRUB_MOD_INIT(emunet)
{
- if (grub_emunet_create (&emucard.mtu))
+ if (!grub_emunet_create (&emucard.mtu))
{
grub_net_card_register (&emucard);
registered = 1;
diff --git a/grub-core/net/drivers/i386/pc/pxe.c b/grub-core/net/drivers/i386/pc/pxe.c
index e8c0b22e2..3f4152d03 100644
--- a/grub-core/net/drivers/i386/pc/pxe.c
+++ b/grub-core/net/drivers/i386/pc/pxe.c
@@ -218,8 +218,7 @@ grub_pxe_recv (struct grub_net_card *dev __attribute__ ((unused)))
return NULL;
/* Reserve 2 bytes so that 2 + 14/18 bytes of ethernet header is divisible
by 4. So that IP header is aligned on 4 bytes. */
- grub_netbuff_reserve (buf, 2);
- if (!buf)
+ if (grub_netbuff_reserve (buf, 2))
{
grub_netbuff_free (buf);
return NULL;
diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c
index 4483c9122..6bd3b922e 100644
--- a/grub-core/net/drivers/ieee1275/ofnet.c
+++ b/grub-core/net/drivers/ieee1275/ofnet.c
@@ -127,8 +127,111 @@ bootp_response_properties[] =
{ .name = "bootpreply-packet", .offset = 0x2a},
};
+enum
+{
+ BOOTARGS_SERVER_ADDR,
+ BOOTARGS_FILENAME,
+ BOOTARGS_CLIENT_ADDR,
+ BOOTARGS_GATEWAY_ADDR,
+ BOOTARGS_BOOTP_RETRIES,
+ BOOTARGS_TFTP_RETRIES,
+ BOOTARGS_SUBNET_MASK,
+ BOOTARGS_BLOCKSIZE
+};
+
+static int
+grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath,
+ char **device, struct grub_net_card **card)
+{
+ char *args;
+ char *comma_char = 0;
+ char *equal_char = 0;
+ grub_size_t field_counter = 0;
+
+ grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask;
+ grub_net_link_level_address_t hw_addr;
+ grub_net_interface_flags_t flags = 0;
+ struct grub_net_network_level_interface *inter = NULL;
+
+ hw_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
+
+ args = bootpath + grub_strlen (devpath) + 1;
+ do
+ {
+ comma_char = grub_strchr (args, ',');
+ if (comma_char != 0)
+ *comma_char = 0;
+
+ /* Check if it's an option (like speed=auto) and not a default parameter */
+ equal_char = grub_strchr (args, '=');
+ if (equal_char != 0)
+ {
+ *equal_char = 0;
+ grub_env_set_net_property ((*card)->name, args, equal_char + 1,
+ grub_strlen(equal_char + 1));
+ *equal_char = '=';
+ }
+ else
+ {
+ switch (field_counter++)
+ {
+ case BOOTARGS_SERVER_ADDR:
+ *device = grub_xasprintf ("tftp,%s", args);
+ if (!*device)
+ return grub_errno;
+ break;
+
+ case BOOTARGS_CLIENT_ADDR:
+ grub_net_resolve_address (args, &client_addr);
+ break;
+
+ case BOOTARGS_GATEWAY_ADDR:
+ grub_net_resolve_address (args, &gateway_addr);
+ break;
+
+ case BOOTARGS_SUBNET_MASK:
+ grub_net_resolve_address (args, &subnet_mask);
+ break;
+ }
+ }
+ args = comma_char + 1;
+ if (comma_char != 0)
+ *comma_char = ',';
+ } while (comma_char != 0);
+
+ if ((client_addr.ipv4 != 0) && (subnet_mask.ipv4 != 0))
+ {
+ grub_ieee1275_phandle_t devhandle;
+ grub_ieee1275_finddevice (devpath, &devhandle);
+ grub_ieee1275_get_property (devhandle, "mac-address",
+ hw_addr.mac, sizeof(hw_addr.mac), 0);
+ inter = grub_net_add_addr ((*card)->name, *card, &client_addr, &hw_addr,
+ flags);
+ grub_net_add_ipv4_local (inter,
+ __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4)));
+ }
+
+ if (gateway_addr.ipv4 != 0)
+ {
+ grub_net_network_level_netaddress_t target;
+ char *rname;
+
+ target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
+ target.ipv4.base = 0;
+ target.ipv4.masksize = 0;
+ rname = grub_xasprintf ("%s:default", ((*card)->name));
+ if (rname)
+ grub_net_add_route_gw (rname, target, gateway_addr, inter);
+ else
+ return grub_errno;
+ }
+
+ return 0;
+}
+
static void
-grub_ieee1275_net_config_real (const char *devpath, char **device, char **path)
+grub_ieee1275_net_config_real (const char *devpath, char **device, char **path,
+ char *bootpath)
{
struct grub_net_card *card;
@@ -158,6 +261,8 @@ grub_ieee1275_net_config_real (const char *devpath, char **device, char **path)
}
grub_free (canon);
+ grub_ieee1275_parse_bootpath (devpath, bootpath, device, &card);
+
for (i = 0; i < ARRAY_SIZE (bootp_response_properties); i++)
if (grub_ieee1275_get_property_length (grub_ieee1275_chosen,
bootp_response_properties[i].name,
@@ -200,6 +305,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
grub_uint64_t prop;
grub_uint8_t *pprop;
char *shortname;
+ char need_suffix = 1;
if (grub_strcmp (alias->type, "network") != 0)
return 0;
@@ -220,7 +326,43 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
#define SUFFIX ":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512"
- if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+ need_suffix = 0;
+
+ /* sun4v vnet devices do not support setting duplex/speed */
+ {
+ char *ptr;
+
+ grub_ieee1275_finddevice (alias->path, &devhandle);
+
+ grub_ieee1275_get_property_length (devhandle, "compatible", &prop_size);
+ if (prop_size > 0)
+ {
+ pprop = grub_malloc (prop_size);
+ if (!pprop)
+ {
+ grub_free (card);
+ grub_free (ofdata);
+ grub_print_error ();
+ return 1;
+ }
+
+ if (!grub_ieee1275_get_property (devhandle, "compatible",
+ pprop, prop_size, NULL))
+ {
+ for (ptr = (char *) pprop; ptr - (char *) pprop < prop_size;
+ ptr += grub_strlen (ptr) + 1)
+ {
+ if (!grub_strcmp(ptr, "SUNW,sun4v-network"))
+ need_suffix = 0;
+ }
+ }
+
+ grub_free (pprop);
+ }
+ }
+
+ if (need_suffix)
ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof (SUFFIX));
else
ofdata->path = grub_malloc (grub_strlen (alias->path) + 1);
@@ -230,7 +372,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
return 0;
}
ofdata->suffix = grub_stpcpy (ofdata->path, alias->path);
- if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX))
+ if (need_suffix)
grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX));
else
*ofdata->suffix = '\0';
diff --git a/grub-core/net/http.c b/grub-core/net/http.c
index 4684f8b33..5aa4ad3be 100644
--- a/grub-core/net/http.c
+++ b/grub-core/net/http.c
@@ -381,9 +381,8 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial)
ptr = nb->tail;
grub_snprintf ((char *) ptr,
sizeof ("Range: bytes=XXXXXXXXXXXXXXXXXXXX-"
- "\r\n"
"\r\n"),
- "Range: bytes=%" PRIuGRUB_UINT64_T "-\r\n\r\n",
+ "Range: bytes=%" PRIuGRUB_UINT64_T "-\r\n",
offset);
grub_netbuff_put (nb, grub_strlen ((char *) ptr));
}
@@ -450,6 +449,7 @@ http_seek (struct grub_file *file, grub_off_t off)
}
file->device->net->stall = 0;
+ file->device->net->eof = 0;
file->device->net->offset = off;
data = grub_zalloc (sizeof (*data));
diff --git a/grub-core/net/icmp.c b/grub-core/net/icmp.c
index 28d825ba0..b1eef114e 100644
--- a/grub-core/net/icmp.c
+++ b/grub-core/net/icmp.c
@@ -85,22 +85,13 @@ grub_net_recv_icmp_packet (struct grub_net_buff *nb,
struct icmp_header *icmphr;
if (icmph->code)
break;
- nb_reply = grub_netbuff_alloc (nb->tail - nb->data + 512);
+ nb_reply = grub_netbuff_make_pkt (nb->tail - nb->data + sizeof (*icmphr));
if (!nb_reply)
{
grub_netbuff_free (nb);
return grub_errno;
}
- err = grub_netbuff_reserve (nb_reply, nb->tail - nb->data + 512);
- if (err)
- goto ping_fail;
- err = grub_netbuff_push (nb_reply, nb->tail - nb->data);
- if (err)
- goto ping_fail;
- grub_memcpy (nb_reply->data, nb->data, nb->tail - nb->data);
- err = grub_netbuff_push (nb_reply, sizeof (*icmphr));
- if (err)
- goto ping_fail;
+ grub_memcpy (nb_reply->data + sizeof (*icmphr), nb->data, nb->tail - nb->data);
icmphr = (struct icmp_header *) nb_reply->data;
icmphr->type = ICMP_ECHO_REPLY;
icmphr->code = 0;
@@ -110,7 +101,6 @@ grub_net_recv_icmp_packet (struct grub_net_buff *nb,
err = grub_net_send_ip_packet (inf, src, ll_src,
nb_reply, GRUB_NET_IP_ICMP);
- ping_fail:
grub_netbuff_free (nb);
grub_netbuff_free (nb_reply);
return err;
diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c
index 2741e6f11..2cbd95dce 100644
--- a/grub-core/net/icmp6.c
+++ b/grub-core/net/icmp6.c
@@ -72,6 +72,11 @@ struct neighbour_advertise
grub_uint64_t target[2];
} GRUB_PACKED;
+struct router_solicit
+{
+ grub_uint32_t reserved;
+} GRUB_PACKED;
+
enum
{
FLAG_SLAAC = 0x40
@@ -81,6 +86,7 @@ enum
{
ICMP6_ECHO = 128,
ICMP6_ECHO_REPLY = 129,
+ ICMP6_ROUTER_SOLICIT = 133,
ICMP6_ROUTER_ADVERTISE = 134,
ICMP6_NEIGHBOUR_SOLICIT = 135,
ICMP6_NEIGHBOUR_ADVERTISE = 136,
@@ -109,6 +115,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
grub_uint8_t ttl)
{
struct icmp_header *icmph;
+ struct grub_net_network_level_interface *orig_inf = inf;
grub_err_t err;
grub_uint16_t checksum;
@@ -205,7 +212,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
if (ttl != 0xff)
break;
nbh = (struct neighbour_solicit *) nb->data;
- err = grub_netbuff_pull (nb, sizeof (struct router_adv));
+ err = grub_netbuff_pull (nb, sizeof (*nbh));
if (err)
{
grub_netbuff_free (nb);
@@ -339,14 +346,31 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
{
grub_uint8_t *ptr;
struct option_header *ohdr;
+ struct router_adv *radv;
+ struct grub_net_network_level_interface *route_inf = NULL;
+ int default_route = 0;
if (icmph->code)
break;
+ radv = (struct router_adv *)nb->data;
err = grub_netbuff_pull (nb, sizeof (struct router_adv));
if (err)
{
grub_netbuff_free (nb);
return err;
}
+ if (grub_be_to_cpu16 (radv->router_lifetime) > 0)
+ {
+ struct grub_net_route *route;
+
+ FOR_NET_ROUTES (route)
+ {
+ if (!grub_memcmp (&route->gw, source, sizeof (route->gw)))
+ break;
+ }
+ if (route == NULL)
+ default_route = 1;
+ }
+
for (ptr = (grub_uint8_t *) nb->data; ptr < nb->tail;
ptr += ohdr->len * 8)
{
@@ -407,7 +431,11 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
/* Update lease time if needed here once we have
lease times. */
if (inf)
- continue;
+ {
+ if (!route_inf)
+ route_inf = inf;
+ continue;
+ }
grub_dprintf ("net", "creating slaac\n");
@@ -423,12 +451,51 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
inf = grub_net_add_addr (name,
card, &addr,
&slaac->address, 0);
+ if (!route_inf)
+ route_inf = inf;
grub_net_add_route (name, netaddr, inf);
grub_free (name);
}
}
}
}
+ if (default_route)
+ {
+ char *name;
+ grub_net_network_level_netaddress_t netaddr;
+ name = grub_xasprintf ("%s:ra:default6", card->name);
+ if (!name)
+ {
+ grub_errno = GRUB_ERR_NONE;
+ goto next;
+ }
+ /* Default routes take alll of the traffic, so make the mask huge */
+ netaddr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ netaddr.ipv6.masksize = 0;
+ netaddr.ipv6.base[0] = 0;
+ netaddr.ipv6.base[1] = 0;
+
+ /* May not have gotten slaac info, find a global address on this
+ card. */
+ if (route_inf == NULL)
+ {
+ FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
+ {
+ if (inf->card == card && inf != orig_inf
+ && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6
+ && grub_net_hwaddr_cmp(&inf->hwaddress,
+ &orig_inf->hwaddress) == 0)
+ {
+ route_inf = inf;
+ break;
+ }
+ }
+ }
+ if (route_inf != NULL)
+ grub_net_add_route_gw (name, netaddr, *source, route_inf);
+ grub_free (name);
+ }
+next:
if (ptr != nb->tail)
break;
}
@@ -518,7 +585,8 @@ grub_net_icmp6_send_request (struct grub_net_network_level_interface *inf,
{
if (grub_net_link_layer_resolve_check (inf, proto_addr))
break;
- grub_net_poll_cards (GRUB_NET_INTERVAL, 0);
+ grub_net_poll_cards (GRUB_NET_INTERVAL + (i * GRUB_NET_INTERVAL_ADDITION),
+ 0);
if (grub_net_link_layer_resolve_check (inf, proto_addr))
break;
nb->data = nbd;
@@ -532,3 +600,80 @@ grub_net_icmp6_send_request (struct grub_net_network_level_interface *inf,
grub_netbuff_free (nb);
return err;
}
+
+grub_err_t
+grub_net_icmp6_send_router_solicit (struct grub_net_network_level_interface *inf)
+{
+ struct grub_net_buff *nb;
+ grub_err_t err = GRUB_ERR_NONE;
+ grub_net_network_level_address_t multicast;
+ grub_net_link_level_address_t ll_multicast;
+ struct option_header *ohdr;
+ struct router_solicit *sol;
+ struct icmp_header *icmphr;
+
+ multicast.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
+ multicast.ipv6[0] = grub_cpu_to_be64_compile_time (0xff02ULL << 48);
+ multicast.ipv6[1] = grub_cpu_to_be64_compile_time (0x02ULL);
+
+ err = grub_net_link_layer_resolve (inf, &multicast, &ll_multicast);
+ if (err)
+ return err;
+
+ nb = grub_netbuff_alloc (sizeof (struct router_solicit)
+ + sizeof (struct option_header)
+ + 6
+ + sizeof (struct icmp_header)
+ + GRUB_NET_OUR_IPV6_HEADER_SIZE
+ + GRUB_NET_MAX_LINK_HEADER_SIZE);
+ if (!nb)
+ return grub_errno;
+ err = grub_netbuff_reserve (nb,
+ sizeof (struct router_solicit)
+ + sizeof (struct option_header)
+ + 6
+ + sizeof (struct icmp_header)
+ + GRUB_NET_OUR_IPV6_HEADER_SIZE
+ + GRUB_NET_MAX_LINK_HEADER_SIZE);
+ if (err)
+ goto fail;
+
+ err = grub_netbuff_push (nb, 6);
+ if (err)
+ goto fail;
+
+ grub_memcpy (nb->data, inf->hwaddress.mac, 6);
+
+ err = grub_netbuff_push (nb, sizeof (*ohdr));
+ if (err)
+ goto fail;
+
+ ohdr = (struct option_header *) nb->data;
+ ohdr->type = OPTION_SOURCE_LINK_LAYER_ADDRESS;
+ ohdr->len = 1;
+
+ err = grub_netbuff_push (nb, sizeof (*sol));
+ if (err)
+ goto fail;
+
+ sol = (struct router_solicit *) nb->data;
+ sol->reserved = 0;
+
+ err = grub_netbuff_push (nb, sizeof (*icmphr));
+ if (err)
+ goto fail;
+
+ icmphr = (struct icmp_header *) nb->data;
+ icmphr->type = ICMP6_ROUTER_SOLICIT;
+ icmphr->code = 0;
+ icmphr->checksum = 0;
+ icmphr->checksum = grub_net_ip_transport_checksum (nb,
+ GRUB_NET_IP_ICMPV6,
+ &inf->address,
+ &multicast);
+ err = grub_net_send_ip_packet (inf, &multicast, &ll_multicast, nb,
+ GRUB_NET_IP_ICMPV6);
+ fail:
+ grub_netbuff_free (nb);
+ return err;
+}
diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c
index c6971f9fc..8c56baaf7 100644
--- a/grub-core/net/ip.c
+++ b/grub-core/net/ip.c
@@ -191,15 +191,18 @@ grub_net_send_ip4_packet (struct grub_net_network_level_interface *inf,
grub_net_ip_protocol_t proto)
{
struct iphdr *iph;
+ grub_err_t err;
COMPILE_TIME_ASSERT (GRUB_NET_OUR_IPV4_HEADER_SIZE == sizeof (*iph));
if (nb->tail - nb->data + sizeof (struct iphdr) > inf->card->mtu)
return send_fragmented (inf, target, nb, proto, *ll_target_addr);
- grub_netbuff_push (nb, sizeof (*iph));
- iph = (struct iphdr *) nb->data;
+ err = grub_netbuff_push (nb, sizeof (*iph));
+ if (err)
+ return err;
+ iph = (struct iphdr *) nb->data;
iph->verhdrlen = ((4 << 4) | 5);
iph->service = 0;
iph->len = grub_cpu_to_be16 (nb->tail - nb->data);
@@ -602,16 +605,19 @@ grub_net_send_ip6_packet (struct grub_net_network_level_interface *inf,
grub_net_ip_protocol_t proto)
{
struct ip6hdr *iph;
+ grub_err_t err;
COMPILE_TIME_ASSERT (GRUB_NET_OUR_IPV6_HEADER_SIZE == sizeof (*iph));
if (nb->tail - nb->data + sizeof (struct iphdr) > inf->card->mtu)
return grub_error (GRUB_ERR_NET_PACKET_TOO_BIG, "packet too big");
- grub_netbuff_push (nb, sizeof (*iph));
- iph = (struct ip6hdr *) nb->data;
+ err = grub_netbuff_push (nb, sizeof (*iph));
+ if (err)
+ return err;
- iph->version_class_flow = grub_cpu_to_be32 ((6 << 28));
+ iph = (struct ip6hdr *) nb->data;
+ iph->version_class_flow = grub_cpu_to_be32_compile_time ((6 << 28));
iph->len = grub_cpu_to_be16 (nb->tail - nb->data - sizeof (*iph));
iph->protocol = proto;
iph->ttl = 0xff;
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
index 0e57e93e8..10773fc34 100644
--- a/grub-core/net/net.c
+++ b/grub-core/net/net.c
@@ -37,21 +37,6 @@ GRUB_MOD_LICENSE ("GPLv3+");
char *grub_net_default_server;
-struct grub_net_route
-{
- struct grub_net_route *next;
- struct grub_net_route **prev;
- grub_net_network_level_netaddress_t target;
- char *name;
- struct grub_net_network_level_protocol *prot;
- int is_gateway;
- union
- {
- struct grub_net_network_level_interface *interface;
- grub_net_network_level_address_t gw;
- };
-};
-
struct grub_net_route *grub_net_routes = NULL;
struct grub_net_network_level_interface *grub_net_network_level_interfaces = NULL;
struct grub_net_card *grub_net_cards = NULL;
@@ -299,14 +284,8 @@ grub_net_ipv6_get_link_local (struct grub_net_card *card,
char *ptr;
grub_net_network_level_address_t addr;
- name = grub_malloc (grub_strlen (card->name)
- + GRUB_NET_MAX_STR_HWADDR_LEN
- + sizeof (":link"));
- if (!name)
- return NULL;
-
addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6;
- addr.ipv6[0] = grub_cpu_to_be64 (0xfe80ULL << 48);
+ addr.ipv6[0] = grub_cpu_to_be64_compile_time (0xfe80ULL << 48);
addr.ipv6[1] = grub_net_ipv6_get_id (hwaddr);
FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
@@ -317,6 +296,12 @@ grub_net_ipv6_get_link_local (struct grub_net_card *card,
return inf;
}
+ name = grub_malloc (grub_strlen (card->name)
+ + GRUB_NET_MAX_STR_HWADDR_LEN
+ + sizeof (":link"));
+ if (!name)
+ return NULL;
+
ptr = grub_stpcpy (name, card->name);
if (grub_net_hwaddr_cmp (&card->default_address, hwaddr) != 0)
{
@@ -380,12 +365,14 @@ grub_cmd_ipv6_autoconf (struct grub_command *cmd __attribute__ ((unused)),
for (interval = 200; interval < 10000; interval *= 2)
{
- /* FIXME: send router solicitation. */
int done = 1;
for (j = 0; j < ncards; j++)
{
if (slaacs[j]->slaac_counter)
continue;
+ err = grub_net_icmp6_send_router_solicit (ifaces[j]);
+ if (err)
+ err = GRUB_ERR_NONE;
done = 0;
}
if (done)
@@ -408,14 +395,6 @@ grub_cmd_ipv6_autoconf (struct grub_command *cmd __attribute__ ((unused)),
return err;
}
-static inline void
-grub_net_route_register (struct grub_net_route *route)
-{
- grub_list_push (GRUB_AS_LIST_P (&grub_net_routes),
- GRUB_AS_LIST (route));
-}
-
-#define FOR_NET_ROUTES(var) for (var = grub_net_routes; var; var = var->next)
static int
parse_ip (const char *val, grub_uint32_t *ip, const char **rest)
@@ -522,6 +501,8 @@ match_net (const grub_net_network_level_netaddress_t *net,
case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6:
{
grub_uint64_t mask[2];
+ if (net->ipv6.masksize == 0)
+ return 1;
if (net->ipv6.masksize <= 64)
{
mask[0] = 0xffffffffffffffffULL << (64 - net->ipv6.masksize);
@@ -685,7 +666,14 @@ grub_net_route_address (grub_net_network_level_address_t addr,
return GRUB_ERR_NONE;
}
if (depth == 0)
- *gateway = bestroute->gw;
+ {
+ *gateway = bestroute->gw;
+ if (bestroute->interface != NULL)
+ {
+ *interf = bestroute->interface;
+ return GRUB_ERR_NONE;
+ }
+ }
curtarget = bestroute->gw;
}
@@ -1107,7 +1095,8 @@ grub_net_add_route (const char *name,
grub_err_t
grub_net_add_route_gw (const char *name,
grub_net_network_level_netaddress_t target,
- grub_net_network_level_address_t gw)
+ grub_net_network_level_address_t gw,
+ struct grub_net_network_level_interface *inter)
{
struct grub_net_route *route;
@@ -1125,6 +1114,7 @@ grub_net_add_route_gw (const char *name,
route->target = target;
route->is_gateway = 1;
route->gw = gw;
+ route->interface = inter;
grub_net_route_register (route);
@@ -1150,7 +1140,7 @@ grub_cmd_addroute (struct grub_command *cmd __attribute__ ((unused)),
err = grub_net_resolve_address (args[3], &gw);
if (err)
return err;
- return grub_net_add_route_gw (args[0], target, gw);
+ return grub_net_add_route_gw (args[0], target, gw, NULL);
}
else
{
@@ -1320,25 +1310,64 @@ grub_net_open_real (const char *name)
if (!ret)
return NULL;
ret->protocol = proto;
- if (server)
+ ret->server = grub_strdup (server);
+ if (!ret->server)
{
- ret->server = grub_strdup (server);
- if (!ret->server)
- {
- grub_free (ret);
- return NULL;
- }
+ grub_free (ret);
+ return NULL;
}
- else
- ret->server = NULL;
ret->fs = &grub_net_fs;
- ret->offset = 0;
- ret->eof = 0;
return ret;
}
}
if (try == 0)
{
+ const char *prefix, *root;
+ char *prefdev, *comma;
+ int skip = 0;
+ grub_size_t devlen;
+
+ /* Do not attempt to load module if it requires protocol provided
+ by this module - it results in infinite recursion. Just continue,
+ fail and cleanup on next iteration.
+ */
+ prefix = grub_env_get ("prefix");
+ if (!prefix)
+ continue;
+
+ prefdev = grub_file_get_device_name (prefix);
+ if (!prefdev)
+ {
+ root = grub_env_get ("root");
+ if (!root)
+ continue;
+ prefdev = grub_strdup (root);
+ if (!prefdev)
+ continue;
+ }
+
+ if (grub_strncmp (prefdev, "pxe", sizeof ("pxe") - 1) == 0 &&
+ (!prefdev[sizeof ("pxe") - 1] || (prefdev[sizeof("pxe") - 1] == ':')))
+ {
+ grub_free (prefdev);
+ prefdev = grub_strdup ("tftp");
+ if (!prefdev)
+ continue;
+ }
+
+ comma = grub_strchr (prefdev, ',');
+ if (comma)
+ *comma = '\0';
+ devlen = grub_strlen (prefdev);
+
+ if (protnamelen == devlen && grub_memcmp (prefdev, protname, devlen) == 0)
+ skip = 1;
+
+ grub_free (prefdev);
+
+ if (skip)
+ continue;
+
if (sizeof ("http") - 1 == protnamelen
&& grub_memcmp ("http", protname, protnamelen) == 0)
{
@@ -1389,7 +1418,10 @@ grub_net_fs_open (struct grub_file *file_out, const char *name)
file->device->net->packs.last = NULL;
file->device->net->name = grub_strdup (name);
if (!file->device->net->name)
- return grub_errno;
+ {
+ grub_free (file);
+ return grub_errno;
+ }
err = file->device->net->protocol->open (file, name);
if (err)
@@ -1453,7 +1485,7 @@ receive_packets (struct grub_net_card *card, int *stop_condition)
}
card->opened = 1;
}
- while (1)
+ while (received < 100)
{
/* Maybe should be better have a fixed number of packets for each card
and just mark them as used and not used. */
@@ -1480,6 +1512,44 @@ receive_packets (struct grub_net_card *card, int *stop_condition)
grub_print_error ();
}
+static char *
+grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)),
+ const char *val __attribute__ ((unused)))
+{
+ return NULL;
+}
+
+grub_err_t
+grub_env_set_net_property (const char *intername, const char *suffix,
+ const char *value, grub_size_t len)
+{
+ char *varname, *varvalue;
+ char *ptr;
+
+ varname = grub_xasprintf ("net_%s_%s", intername, suffix);
+ if (!varname)
+ return grub_errno;
+ for (ptr = varname; *ptr; ptr++)
+ if (*ptr == ':')
+ *ptr = '_';
+ varvalue = grub_malloc (len + 1);
+ if (!varvalue)
+ {
+ grub_free (varname);
+ return grub_errno;
+ }
+
+ grub_memcpy (varvalue, value, len);
+ varvalue[len] = 0;
+ grub_err_t ret = grub_env_set (varname, varvalue);
+ grub_register_variable_hook (varname, 0, grub_env_write_readonly);
+ grub_env_export (varname);
+ grub_free (varname);
+ grub_free (varvalue);
+
+ return ret;
+}
+
void
grub_net_poll_cards (unsigned time, int *stop_condition)
{
@@ -1558,8 +1628,9 @@ grub_net_fs_read_real (grub_file_t file, char *buf, grub_size_t len)
if (!net->eof)
{
try++;
- grub_net_poll_cards (GRUB_NET_INTERVAL, &net->stall);
- }
+ grub_net_poll_cards (GRUB_NET_INTERVAL +
+ (try * GRUB_NET_INTERVAL_ADDITION), &net->stall);
+ }
else
return total;
}
@@ -1610,6 +1681,7 @@ grub_net_seek_real (struct grub_file *file, grub_off_t offset)
file->device->net->packs.last = NULL;
file->device->net->offset = 0;
file->device->net->eof = 0;
+ file->device->net->stall = 0;
err = file->device->net->protocol->open (file, file->device->net->name);
if (err)
return err;
diff --git a/grub-core/net/netbuff.c b/grub-core/net/netbuff.c
index e97ecd23e..dbeeefe47 100644
--- a/grub-core/net/netbuff.c
+++ b/grub-core/net/netbuff.c
@@ -97,6 +97,26 @@ grub_netbuff_alloc (grub_size_t len)
return nb;
}
+struct grub_net_buff *
+grub_netbuff_make_pkt (grub_size_t len)
+{
+ struct grub_net_buff *nb;
+ grub_err_t err;
+ nb = grub_netbuff_alloc (len + 512);
+ if (!nb)
+ return NULL;
+ err = grub_netbuff_reserve (nb, len + 512);
+ if (err)
+ goto fail;
+ err = grub_netbuff_push (nb, len);
+ if (err)
+ goto fail;
+ return nb;
+ fail:
+ grub_netbuff_free (nb);
+ return NULL;
+}
+
void
grub_netbuff_free (struct grub_net_buff *nb)
{
diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c
index 2077f5519..e8ad34b84 100644
--- a/grub-core/net/tcp.c
+++ b/grub-core/net/tcp.c
@@ -498,11 +498,22 @@ grub_net_tcp_accept (grub_net_tcp_socket_t sock,
struct grub_net_buff *nb_ack;
struct tcphdr *tcph;
grub_err_t err;
+ grub_net_network_level_address_t gateway;
+ struct grub_net_network_level_interface *inf;
sock->recv_hook = recv_hook;
sock->error_hook = error_hook;
sock->fin_hook = fin_hook;
sock->hook_data = hook_data;
+
+ err = grub_net_route_address (sock->out_nla, &gateway, &inf);
+ if (err)
+ return err;
+
+ err = grub_net_link_layer_resolve (sock->inf, &gateway, &(sock->ll_target_addr));
+ if (err)
+ return err;
+
nb_ack = grub_netbuff_alloc (sizeof (*tcph)
+ GRUB_NET_OUR_MAX_IP_HEADER_SIZE
+ GRUB_NET_MAX_LINK_HEADER_SIZE);
@@ -595,10 +606,15 @@ grub_net_tcp_open (char *server,
nb = grub_netbuff_alloc (sizeof (*tcph) + 128);
if (!nb)
- return NULL;
+ {
+ grub_free (socket);
+ return NULL;
+ }
+
err = grub_netbuff_reserve (nb, 128);
if (err)
{
+ grub_free (socket);
grub_netbuff_free (nb);
return NULL;
}
@@ -606,12 +622,14 @@ grub_net_tcp_open (char *server,
err = grub_netbuff_put (nb, sizeof (*tcph));
if (err)
{
+ grub_free (socket);
grub_netbuff_free (nb);
return NULL;
}
socket->pq = grub_priority_queue_new (sizeof (struct grub_net_buff *), cmp);
if (!socket->pq)
{
+ grub_free (socket);
grub_netbuff_free (nb);
return NULL;
}
@@ -882,7 +900,10 @@ grub_net_recv_tcp_packet (struct grub_net_buff *nb,
grub_priority_queue_pop (sock->pq);
}
if (grub_be_to_cpu32 (tcph->seqnr) != sock->their_cur_seq)
- return GRUB_ERR_NONE;
+ {
+ ack (sock);
+ return GRUB_ERR_NONE;
+ }
while (1)
{
nb_top_p = grub_priority_queue_top (sock->pq);
@@ -918,7 +939,7 @@ grub_net_recv_tcp_packet (struct grub_net_buff *nb,
do_ack = 1;
}
else
- grub_netbuff_free (nb);
+ grub_netbuff_free (nb_top);
}
if (do_ack)
ack (sock);
@@ -964,6 +985,7 @@ grub_net_recv_tcp_packet (struct grub_net_buff *nb,
cmp);
if (!sock->pq)
{
+ grub_free (sock);
grub_netbuff_free (nb);
return grub_errno;
}
diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c
index 9c489f1fc..7d90bf66e 100644
--- a/grub-core/net/tftp.c
+++ b/grub-core/net/tftp.c
@@ -149,7 +149,7 @@ ack (tftp_data_t data, grub_uint64_t block)
return err;
tftph_ack = (struct tftphdr *) nb_ack.data;
- tftph_ack->opcode = grub_cpu_to_be16 (TFTP_ACK);
+ tftph_ack->opcode = grub_cpu_to_be16_compile_time (TFTP_ACK);
tftph_ack->u.ack.block = grub_cpu_to_be16 (block);
err = grub_net_send_udp_packet (data->sock, &nb_ack);
@@ -326,14 +326,17 @@ tftp_open (struct grub_file *file, const char *filename)
grub_netbuff_reserve (&nb, 1500);
err = grub_netbuff_push (&nb, sizeof (*tftph));
if (err)
- return err;
+ {
+ grub_free (data);
+ return err;
+ }
tftph = (struct tftphdr *) nb.data;
rrq = (char *) tftph->u.rrq;
rrqlen = 0;
- tftph->opcode = grub_cpu_to_be16 (TFTP_RRQ);
+ tftph->opcode = grub_cpu_to_be16_compile_time (TFTP_RRQ);
grub_strcpy (rrq, filename);
rrqlen += grub_strlen (filename) + 1;
rrq += grub_strlen (filename) + 1;
@@ -361,19 +364,26 @@ tftp_open (struct grub_file *file, const char *filename)
err = grub_netbuff_unput (&nb, nb.tail - (nb.data + hdrlen));
if (err)
- return err;
+ {
+ grub_free (data);
+ return err;
+ }
file->not_easily_seekable = 1;
file->data = data;
data->pq = grub_priority_queue_new (sizeof (struct grub_net_buff *), cmp);
if (!data->pq)
- return grub_errno;
+ {
+ grub_free (data);
+ return grub_errno;
+ }
err = grub_net_resolve_address (file->device->net->server, &addr);
if (err)
{
destroy_pq (data);
+ grub_free (data);
return err;
}
@@ -383,6 +393,7 @@ tftp_open (struct grub_file *file, const char *filename)
if (!data->sock)
{
destroy_pq (data);
+ grub_free (data);
return grub_errno;
}
@@ -396,9 +407,11 @@ tftp_open (struct grub_file *file, const char *filename)
{
grub_net_udp_close (data->sock);
destroy_pq (data);
+ grub_free (data);
return err;
}
- grub_net_poll_cards (GRUB_NET_INTERVAL, &data->have_oack);
+ grub_net_poll_cards (GRUB_NET_INTERVAL + (i * GRUB_NET_INTERVAL_ADDITION),
+ &data->have_oack);
if (data->have_oack)
break;
}
@@ -411,6 +424,7 @@ tftp_open (struct grub_file *file, const char *filename)
{
grub_net_udp_close (data->sock);
destroy_pq (data);
+ grub_free (data);
return grub_errno;
}
@@ -442,8 +456,8 @@ tftp_close (struct grub_file *file)
if (!err)
{
tftph = (struct tftphdr *) nb_err.data;
- tftph->opcode = grub_cpu_to_be16 (TFTP_ERROR);
- tftph->u.err.errcode = grub_cpu_to_be16 (TFTP_EUNDEF);
+ tftph->opcode = grub_cpu_to_be16_compile_time (TFTP_ERROR);
+ tftph->u.err.errcode = grub_cpu_to_be16_compile_time (TFTP_EUNDEF);
grub_memcpy (tftph->u.err.errmsg, "closed", sizeof ("closed"));
err = grub_net_send_udp_packet (data->sock, &nb_err);
diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c
index c6bd96e28..7338f8245 100644
--- a/grub-core/normal/auth.c
+++ b/grub-core/normal/auth.c
@@ -174,8 +174,11 @@ grub_username_get (char buf[], unsigned buf_size)
if (key == '\b')
{
- cur_len--;
- grub_printf ("\b");
+ if (cur_len)
+ {
+ cur_len--;
+ grub_printf ("\b \b");
+ }
continue;
}
diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c
index 3e4c337da..eeb7ec18c 100644
--- a/grub-core/normal/charset.c
+++ b/grub-core/normal/charset.c
@@ -929,6 +929,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
case GRUB_BIDI_TYPE_R:
case GRUB_BIDI_TYPE_AL:
bidi_needed = 1;
+ /* Fallthrough. */
default:
{
if (join_state == JOIN_FORCE)
diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c
index 204d15a4b..a36180d75 100644
--- a/grub-core/normal/cmdline.c
+++ b/grub-core/normal/cmdline.c
@@ -389,6 +389,7 @@ grub_cmdline_get (const char *prompt_translated)
if (!unicode_msg)
{
grub_free (buf);
+ grub_free (cl_terms);
return 0;
}
msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len - 1,
diff --git a/grub-core/normal/color.c b/grub-core/normal/color.c
index c2654239f..d22cf903d 100644
--- a/grub-core/normal/color.c
+++ b/grub-core/normal/color.c
@@ -47,7 +47,7 @@ static int
parse_color_name (grub_uint8_t *ret, char *name)
{
grub_uint8_t i;
- for (i = 0; i < sizeof (color_list) / sizeof (*color_list); i++)
+ for (i = 0; i < ARRAY_SIZE(color_list); i++)
if (! grub_strcmp (name, color_list[i]))
{
*ret = i;
diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c
index 7e0a696f3..ee53d4a68 100644
--- a/grub-core/normal/context.c
+++ b/grub-core/normal/context.c
@@ -64,7 +64,10 @@ grub_env_new_context (int export_all)
return grub_errno;
menu = grub_zalloc (sizeof (*menu));
if (! menu)
- return grub_errno;
+ {
+ grub_free (context);
+ return grub_errno;
+ }
context->prev = grub_current_context;
grub_current_context = context;
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index 4c57e090b..78a70a8bf 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -32,6 +32,7 @@
#include <grub/i18n.h>
#include <grub/charset.h>
#include <grub/script_sh.h>
+#include <grub/bufio.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -104,7 +105,7 @@ read_config_file_getline (char **line, int cont __attribute__ ((unused)),
static grub_menu_t
read_config_file (const char *config)
{
- grub_file_t file;
+ grub_file_t rawfile, file;
char *old_file = 0, *old_dir = 0;
char *config_dir, *ptr = 0;
const char *ctmp;
@@ -122,10 +123,17 @@ read_config_file (const char *config)
}
/* Try to open the config file. */
- file = grub_file_open (config);
- if (! file)
+ rawfile = grub_file_open (config);
+ if (! rawfile)
return 0;
+ file = grub_bufio_open (rawfile, 0);
+ if (! file)
+ {
+ grub_file_close (rawfile);
+ return 0;
+ }
+
ctmp = grub_env_get ("config_file");
if (ctmp)
old_file = grub_strdup (ctmp);
@@ -194,14 +202,13 @@ grub_normal_init_page (struct grub_term_output *term,
{
grub_ssize_t msg_len;
int posx;
- const char *msg = _("GNU GRUB version %s");
char *msg_formatted;
grub_uint32_t *unicode_msg;
grub_uint32_t *last_position;
grub_term_cls (term);
- msg_formatted = grub_xasprintf (msg, PACKAGE_VERSION);
+ msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION);
if (!msg_formatted)
return;
@@ -295,7 +302,7 @@ grub_enter_normal_mode (const char *config)
nested_level++;
grub_normal_execute (config, 0, 0);
grub_boot_time ("Entering shell");
- grub_cmdline_run (0);
+ grub_cmdline_run (0, 1);
nested_level--;
if (grub_normal_exit_level)
grub_normal_exit_level--;
@@ -350,13 +357,13 @@ static grub_err_t
grub_normal_reader_init (int nested)
{
struct grub_term_output *term;
- const char *msg = _("Minimal BASH-like line editing is supported. For "
- "the first word, TAB lists possible command completions. Anywhere "
- "else TAB lists possible device or file completions. %s");
const char *msg_esc = _("ESC at any time exits.");
char *msg_formatted;
- msg_formatted = grub_xasprintf (msg, nested ? msg_esc : "");
+ msg_formatted = grub_xasprintf (_("Minimal BASH-like line editing is supported. For "
+ "the first word, TAB lists possible command completions. Anywhere "
+ "else TAB lists possible device or file completions. %s"),
+ nested ? msg_esc : "");
if (!msg_formatted)
return grub_errno;
@@ -417,11 +424,15 @@ grub_normal_read_line (char **line, int cont,
}
void
-grub_cmdline_run (int nested)
+grub_cmdline_run (int nested, int force_auth)
{
grub_err_t err = GRUB_ERR_NONE;
- err = grub_auth_check_authentication (NULL);
+ do
+ {
+ err = grub_auth_check_authentication (NULL);
+ }
+ while (err && force_auth);
if (err)
{
@@ -434,7 +445,7 @@ grub_cmdline_run (int nested)
while (1)
{
- char *line;
+ char *line = NULL;
if (grub_normal_exit_level)
break;
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
index b47991aba..719e2fb1c 100644
--- a/grub-core/normal/menu.c
+++ b/grub-core/normal/menu.c
@@ -773,7 +773,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
case 'c':
menu_fini ();
- grub_cmdline_run (1);
+ grub_cmdline_run (1, 0);
goto refresh;
case 'e':
diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
index b485df821..eeeee5580 100644
--- a/grub-core/normal/menu_entry.c
+++ b/grub-core/normal/menu_entry.c
@@ -126,9 +126,13 @@ ensure_space (struct line *linep, int extra)
static int
get_logical_num_lines (struct line *linep, struct per_term_screen *term_screen)
{
- return (grub_getstringwidth (linep->buf, linep->buf + linep->len,
- term_screen->term)
- / (unsigned) term_screen->geo.entry_width) + 1;
+ grub_size_t width = grub_getstringwidth (linep->buf, linep->buf + linep->len,
+ term_screen->term);
+
+ /* Empty line still consumes space on screen */
+ return width ? (width + (unsigned) term_screen->geo.entry_width - 1) /
+ (unsigned) term_screen->geo.entry_width
+ : 1;
}
static void
@@ -250,6 +254,8 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
mode = ALL_LINES;
}
+ grub_term_setcursor (term_screen->term, 0);
+
if (mode != NO_LINE)
{
/* Draw lines. This code is tricky, because this must calculate logical
@@ -357,6 +363,8 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
}
+ grub_term_setcursor (term_screen->term, 1);
+
grub_term_refresh (term_screen->term);
}
@@ -472,7 +480,10 @@ insert_string (struct screen *screen, const char *s, int update)
(grub_uint8_t *) s, (p - s), 0);
if (! ensure_space (current_linep, size))
- return 0;
+ {
+ grub_free (unicode_msg);
+ return 0;
+ }
grub_memmove (current_linep->buf + screen->column + size,
current_linep->buf + screen->column,
@@ -1261,6 +1272,7 @@ grub_menu_entry_run (grub_menu_entry_t entry)
if (! screen->lines[i].pos)
{
grub_print_error ();
+ destroy_screen (screen);
grub_errno = GRUB_ERR_NONE;
return;
}
@@ -1270,6 +1282,7 @@ grub_menu_entry_run (grub_menu_entry_t entry)
if (!screen->terms)
{
grub_print_error ();
+ destroy_screen (screen);
grub_errno = GRUB_ERR_NONE;
return;
}
@@ -1396,7 +1409,7 @@ grub_menu_entry_run (grub_menu_entry_t entry)
case GRUB_TERM_CTRL | 'c':
case GRUB_TERM_KEY_F2:
- grub_cmdline_run (1);
+ grub_cmdline_run (1, 0);
goto refresh;
case GRUB_TERM_CTRL | 'x':
diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c
index 90f63f0da..e22bb91f6 100644
--- a/grub-core/normal/menu_text.c
+++ b/grub-core/normal/menu_text.c
@@ -165,11 +165,11 @@ command-line or ESC to discard edits and return to the GRUB menu."),
}
else
{
- const char *msg = _("Use the %C and %C keys to select which "
- "entry is highlighted.");
char *msg_translated;
- msg_translated = grub_xasprintf (msg, GRUB_UNICODE_UPARROW,
+ msg_translated = grub_xasprintf (_("Use the %C and %C keys to select which "
+ "entry is highlighted."),
+ GRUB_UNICODE_UPARROW,
GRUB_UNICODE_DOWNARROW);
if (!msg_translated)
return 0;
@@ -369,6 +369,9 @@ grub_menu_init_page (int nested, int edit,
geo->border = 0;
}
+ if (geo->entry_width <= 0)
+ geo->entry_width = 1;
+
if (geo->num_entries - msg_num_lines < 3
&& geo->timeout_lines == 2)
{
@@ -430,9 +433,6 @@ grub_menu_init_page (int nested, int edit,
static void
menu_text_print_timeout (int timeout, void *dataptr)
{
- const char *msg =
- _("The highlighted entry will be executed automatically in %ds.");
- const char *msg_terse = _("%ds");
struct menu_viewer_data *data = dataptr;
char *msg_translated = 0;
@@ -441,9 +441,9 @@ menu_text_print_timeout (int timeout, void *dataptr)
if (data->timeout_msg == TIMEOUT_TERSE
|| data->timeout_msg == TIMEOUT_TERSE_NO_MARGIN)
- msg_translated = grub_xasprintf (msg_terse, timeout);
+ msg_translated = grub_xasprintf (_("%ds"), timeout);
else
- msg_translated = grub_xasprintf (msg, timeout);
+ msg_translated = grub_xasprintf (_("The highlighted entry will be executed automatically in %ds."), timeout);
if (!msg_translated)
{
grub_print_error ();
@@ -459,7 +459,7 @@ menu_text_print_timeout (int timeout, void *dataptr)
if (data->timeout_msg == TIMEOUT_TERSE)
{
grub_free (msg_translated);
- msg_translated = grub_xasprintf (msg_terse, timeout);
+ msg_translated = grub_xasprintf (_("%ds"), timeout);
if (grub_term_width (data->term) < 10)
data->timeout_msg = TIMEOUT_TERSE_NO_MARGIN;
}
diff --git a/grub-core/normal/misc.c b/grub-core/normal/misc.c
index 34d505eda..38f91b9b9 100644
--- a/grub-core/normal/misc.c
+++ b/grub-core/normal/misc.c
@@ -184,10 +184,11 @@ grub_normal_print_device_info (const char *name)
/* TRANSLATORS: Replace dot with appropriate decimal separator for
your language. */
(grub_disk_get_size (dev->disk) & 1) ? _(".5") : "");
-
- grub_device_close (dev);
}
+ if (dev)
+ grub_device_close (dev);
+
grub_xputs ("\n");
return grub_errno;
}
diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c
index 4c2238b25..ac5d69f0f 100644
--- a/grub-core/normal/term.c
+++ b/grub-core/normal/term.c
@@ -77,8 +77,6 @@ print_more (void)
grub_term_output_t term;
grub_uint32_t *unicode_str, *unicode_last_position;
- pos = grub_term_save_pos ();
-
/* TRANSLATORS: This has to fit on one line. It's ok to include few
words but don't write poems. */
grub_utf8_to_ucs4_alloc (_("--MORE--"), &unicode_str,
@@ -90,6 +88,8 @@ print_more (void)
return;
}
+ pos = grub_term_save_pos ();
+
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
FOR_ACTIVE_TERM_OUTPUTS(term)
diff --git a/grub-core/osdep/apple/hostdisk.c b/grub-core/osdep/apple/hostdisk.c
index d0641744b..8d9b4b402 100644
--- a/grub-core/osdep/apple/hostdisk.c
+++ b/grub-core/osdep/apple/hostdisk.c
@@ -80,11 +80,11 @@ grub_util_fd_open (const char *os_dev, int flags)
flags |= O_BINARY;
#endif
- ret = open (os_dev, flags, S_IRUSR | S_IWUSR);
+ ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
/* If we can't have exclusive access, try shared access */
if (ret < 0)
- ret = open (os_dev, flags | O_SHLOCK, S_IRUSR | S_IWUSR);
+ ret = open (os_dev, flags | O_SHLOCK, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
return ret;
}
diff --git a/grub-core/osdep/aros/config.c b/grub-core/osdep/aros/config.c
index 99f3009e2..c82d0ea8e 100644
--- a/grub-core/osdep/aros/config.c
+++ b/grub-core/osdep/aros/config.c
@@ -89,6 +89,6 @@ grub_util_load_config (struct grub_util_config *cfg)
fclose (f);
}
else
- grub_util_warn (_("cannot open config file `%s': %s"),
+ grub_util_warn (_("cannot open configuration file `%s': %s"),
cfgfile, strerror (errno));
}
diff --git a/grub-core/osdep/aros/hostdisk.c b/grub-core/osdep/aros/hostdisk.c
index c7efb9608..7d99b54b8 100644
--- a/grub-core/osdep/aros/hostdisk.c
+++ b/grub-core/osdep/aros/hostdisk.c
@@ -61,7 +61,7 @@
static ULONG *bounce;
char *
-canonicalize_file_name (const char *path)
+grub_canonicalize_file_name (const char *path)
{
char *ret;
BPTR lck;
@@ -180,7 +180,7 @@ grub_util_fd_open (const char *dev, int flg)
if (dev[0] != '/' || dev[1] != '/' || dev[2] != ':')
{
ret->type = GRUB_UTIL_FD_FILE;
- ret->fd = open (dev, flg, S_IRUSR | S_IWUSR);
+ ret->fd = open (dev, flg, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
if (ret->fd < 0)
{
free (ret);
diff --git a/grub-core/osdep/basic/random.c b/grub-core/osdep/basic/random.c
index bb9758c77..b5ccad4ad 100644
--- a/grub-core/osdep/basic/random.c
+++ b/grub-core/osdep/basic/random.c
@@ -37,5 +37,7 @@ grub_get_random (void *out, grub_size_t len)
Some functions like grub-mkpaswd and installing on UUID-less disks will be \
disabled."
grub_util_error ("%s",
+ /* TRANSLATORS: The OS itself may very well have a random
+ number generator but GRUB doesn't know how to access it. */
_("no random number generator is available for your OS"));
}
diff --git a/grub-core/osdep/bsd/hostdisk.c b/grub-core/osdep/bsd/hostdisk.c
index c82d60e11..5912d14bf 100644
--- a/grub-core/osdep/bsd/hostdisk.c
+++ b/grub-core/osdep/bsd/hostdisk.c
@@ -90,7 +90,7 @@ grub_util_fd_open (const char *os_dev, int flags)
flags |= O_BINARY;
#endif
- ret = open (os_dev, flags, S_IRUSR | S_IWUSR);
+ ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
if (ret >= 0)
configure_device_driver (fd);
return ret;
diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c
index 2639a71ea..72e558275 100644
--- a/grub-core/osdep/devmapper/getroot.c
+++ b/grub-core/osdep/devmapper/getroot.c
@@ -40,6 +40,12 @@
#include <limits.h>
#endif
+#if defined(MAJOR_IN_MKDEV)
+#include <sys/mkdev.h>
+#elif defined(MAJOR_IN_SYSMACROS)
+#include <sys/sysmacros.h>
+#endif
+
#include <libdevmapper.h>
#include <grub/types.h>
@@ -160,7 +166,10 @@ grub_util_pull_devmapper (const char *os_dev)
uuid = get_dm_uuid (os_dev);
if (!grub_util_open_dm (os_dev, &tree, &node))
- return;
+ {
+ grub_free (uuid);
+ return;
+ }
while ((child = dm_tree_next_child (&handle, node, 0)))
{
@@ -192,146 +201,23 @@ grub_util_pull_devmapper (const char *os_dev)
}
else
dm_tree_free (tree);
+ grub_free (uuid);
}
char *
grub_util_devmapper_part_to_disk (struct stat *st,
int *is_part, const char *path)
{
- struct dm_tree *tree;
- uint32_t maj, min;
- struct dm_tree_node *node = NULL, *child;
- void *handle;
- const char *node_uuid, *mapper_name = NULL, *child_uuid, *child_name;
-
- tree = dm_tree_create ();
- if (! tree)
- {
- grub_util_info ("dm_tree_create failed");
- goto devmapper_out;
- }
-
- maj = major (st->st_rdev);
- min = minor (st->st_rdev);
- if (! dm_tree_add_dev (tree, maj, min))
- {
- grub_util_info ("dm_tree_add_dev failed");
- goto devmapper_out;
- }
-
- node = dm_tree_find_node (tree, maj, min);
- if (! node)
- {
- grub_util_info ("dm_tree_find_node failed");
- goto devmapper_out;
- }
- reiterate:
- node_uuid = dm_tree_node_get_uuid (node);
- if (! node_uuid)
- {
- grub_util_info ("%s has no DM uuid", path);
- goto devmapper_out;
- }
- if (strncmp (node_uuid, "LVM-", 4) == 0)
- {
- grub_util_info ("%s is an LVM", path);
- goto devmapper_out;
- }
- if (strncmp (node_uuid, "mpath-", 6) == 0)
- {
- /* Multipath partitions have partN-mpath-* UUIDs, and are
- linear mappings so are handled by
- grub_util_get_dm_node_linear_info. Multipath disks are not
- linear mappings and must be handled specially. */
- grub_util_info ("%s is a multipath disk", path);
- goto devmapper_out;
- }
- if (strncmp (node_uuid, "DMRAID-", 7) != 0)
- {
- int major, minor;
- const char *node_name;
- grub_util_info ("%s is not DM-RAID", path);
+ int major, minor;
- if ((node_name = dm_tree_node_get_name (node))
- && grub_util_get_dm_node_linear_info (node_name,
- &major, &minor, 0))
- {
- *is_part = 1;
- if (tree)
- dm_tree_free (tree);
- char *ret = grub_find_device ("/dev",
- (major << 8) | minor);
- return ret;
- }
-
- goto devmapper_out;
- }
-
- handle = NULL;
- /* Counter-intuitively, device-mapper refers to the disk-like
- device containing a DM-RAID partition device as a "child" of
- the partition device. */
- child = dm_tree_next_child (&handle, node, 0);
- if (! child)
- {
- grub_util_info ("%s has no DM children", path);
- goto devmapper_out;
- }
- child_uuid = dm_tree_node_get_uuid (child);
- if (! child_uuid)
+ if (grub_util_get_dm_node_linear_info (st->st_rdev,
+ &major, &minor, 0))
{
- grub_util_info ("%s child has no DM uuid", path);
- goto devmapper_out;
+ *is_part = 1;
+ return grub_find_device ("/dev", makedev (major, minor));
}
- else if (strncmp (child_uuid, "DMRAID-", 7) != 0)
- {
- grub_util_info ("%s child is not DM-RAID", path);
- goto devmapper_out;
- }
- child_name = dm_tree_node_get_name (child);
- if (! child_name)
- {
- grub_util_info ("%s child has no DM name", path);
- goto devmapper_out;
- }
- mapper_name = child_name;
- *is_part = 1;
- node = child;
- goto reiterate;
-
- devmapper_out:
- if (! mapper_name && node)
- {
- /* This is a DM-RAID disk, not a partition. */
- mapper_name = dm_tree_node_get_name (node);
- if (! mapper_name)
- grub_util_info ("%s has no DM name", path);
- }
- char *ret;
- if (mapper_name)
- ret = xasprintf ("/dev/mapper/%s", mapper_name);
- else
- ret = NULL;
-
- if (tree)
- dm_tree_free (tree);
- return ret;
-}
-
-int
-grub_util_device_is_mapped_stat (struct stat *st)
-{
-#if GRUB_DISK_DEVS_ARE_CHAR
- if (! S_ISCHR (st->st_mode))
-#else
- if (! S_ISBLK (st->st_mode))
-#endif
- return 0;
-
- if (!grub_device_mapper_supported ())
- return 0;
-
- return dm_is_dm_major (major (st->st_rdev));
+ *is_part = 0;
+ return xstrdup (path);
}
char *
@@ -343,11 +229,14 @@ grub_util_get_devmapper_grub_dev (const char *os_dev)
uuid = get_dm_uuid (os_dev);
if (!uuid)
return NULL;
-
- if (strncmp (uuid, "LVM-", sizeof ("LVM-") - 1) == 0)
+
+ switch (grub_util_get_dev_abstraction (os_dev))
{
+ case GRUB_DEV_ABSTRACTION_LVM:
+ {
unsigned i;
int dashes[] = { 0, 6, 10, 14, 18, 22, 26, 32, 38, 42, 46, 50, 54, 58};
+
grub_dev = xmalloc (grub_strlen (uuid) + 40);
optr = grub_stpcpy (grub_dev, "lvmid/");
for (i = 0; i < ARRAY_SIZE (dashes) - 1; i++)
@@ -365,18 +254,23 @@ grub_util_get_devmapper_grub_dev (const char *os_dev)
return grub_dev;
}
- if (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0)
- {
- char *dash;
- dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-');
- if (dash)
- *dash = 0;
- grub_dev = grub_xasprintf ("cryptouuid/%s",
- uuid + sizeof ("CRYPT-LUKS1-") - 1);
+ case GRUB_DEV_ABSTRACTION_LUKS:
+ {
+ char *dash;
+
+ dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-');
+ if (dash)
+ *dash = 0;
+ grub_dev = grub_xasprintf ("cryptouuid/%s",
+ uuid + sizeof ("CRYPT-LUKS1-") - 1);
+ grub_free (uuid);
+ return grub_dev;
+ }
+
+ default:
grub_free (uuid);
- return grub_dev;
+ return NULL;
}
- return NULL;
}
char *
@@ -402,6 +296,7 @@ grub_util_get_vg_uuid (const char *os_dev)
}
optr--;
*optr = '\0';
+ grub_free (uuid);
return vgid;
}
@@ -418,12 +313,6 @@ grub_util_pull_devmapper (const char *os_dev __attribute__ ((unused)))
return;
}
-int
-grub_util_device_is_mapped_stat (struct stat *st __attribute__ ((unused)))
-{
- return 0;
-}
-
void
grub_util_devmapper_cleanup (void)
{
diff --git a/grub-core/osdep/devmapper/hostdisk.c b/grub-core/osdep/devmapper/hostdisk.c
index 1078f3591..a697bcb4d 100644
--- a/grub-core/osdep/devmapper/hostdisk.c
+++ b/grub-core/osdep/devmapper/hostdisk.c
@@ -24,6 +24,11 @@
#include <errno.h>
#include <limits.h>
+#if defined(MAJOR_IN_MKDEV)
+#include <sys/mkdev.h>
+#elif defined(MAJOR_IN_SYSMACROS)
+#include <sys/sysmacros.h>
+#endif
#ifdef HAVE_DEVICE_MAPPER
# include <libdevmapper.h>
@@ -83,7 +88,24 @@ grub_util_device_is_mapped (const char *dev)
}
int
-grub_util_get_dm_node_linear_info (const char *dev,
+grub_util_device_is_mapped_stat (struct stat *st)
+{
+#if GRUB_DISK_DEVS_ARE_CHAR
+ if (! S_ISCHR (st->st_mode))
+#else
+ if (! S_ISBLK (st->st_mode))
+#endif
+ return 0;
+
+ if (!grub_device_mapper_supported ())
+ return 0;
+
+ return dm_is_dm_major (major (st->st_rdev));
+}
+
+
+int
+grub_util_get_dm_node_linear_info (dev_t dev,
int *maj, int *min,
grub_disk_addr_t *st)
{
@@ -97,14 +119,16 @@ grub_util_get_dm_node_linear_info (const char *dev,
grub_disk_addr_t partstart = 0;
const char *node_uuid;
+ major = major (dev);
+ minor = minor (dev);
+
while (1)
{
dmt = dm_task_create(DM_DEVICE_TABLE);
if (!dmt)
break;
- if (! (first ? dm_task_set_name (dmt, dev)
- : dm_task_set_major_minor (dmt, major, minor, 0)))
+ if (! (dm_task_set_major_minor (dmt, major, minor, 0)))
{
dm_task_destroy (dmt);
break;
@@ -117,8 +141,7 @@ grub_util_get_dm_node_linear_info (const char *dev,
}
node_uuid = dm_task_get_uuid (dmt);
if (node_uuid && (strncmp (node_uuid, "LVM-", 4) == 0
- || strncmp (node_uuid, "mpath-", 6) == 0
- || strncmp (node_uuid, "DMRAID-", 7) == 0))
+ || strncmp (node_uuid, "mpath-", 6) == 0))
{
dm_task_destroy (dmt);
break;
@@ -190,7 +213,7 @@ grub_util_device_is_mapped (const char *dev __attribute__ ((unused)))
}
int
-grub_util_get_dm_node_linear_info (const char *dev __attribute__ ((unused)),
+grub_util_get_dm_node_linear_info (dev_t dev __attribute__ ((unused)),
int *maj __attribute__ ((unused)),
int *min __attribute__ ((unused)),
grub_disk_addr_t *st __attribute__ ((unused)))
@@ -198,4 +221,10 @@ grub_util_get_dm_node_linear_info (const char *dev __attribute__ ((unused)),
return 0;
}
+int
+grub_util_device_is_mapped_stat (struct stat *st __attribute__ ((unused)))
+{
+ return 0;
+}
+
#endif
diff --git a/grub-core/osdep/freebsd/hostdisk.c b/grub-core/osdep/freebsd/hostdisk.c
index 944e4be02..6145d0735 100644
--- a/grub-core/osdep/freebsd/hostdisk.c
+++ b/grub-core/osdep/freebsd/hostdisk.c
@@ -102,13 +102,20 @@ grub_util_fd_open (const char *os_dev, int flags)
if (! (sysctl_oldflags & 0x10)
&& sysctlbyname ("kern.geom.debugflags", NULL , 0, &sysctl_flags, sysctl_size))
{
- grub_error (GRUB_ERR_BAD_DEVICE, "cannot set flags of sysctl kern.geom.debugflags");
- return GRUB_UTIL_FD_INVALID;
+ if (errno == EPERM)
+ /* Running as an unprivileged user; don't worry about restoring
+ flags, although if we try to write to anything interesting such
+ as the MBR then we may fail later. */
+ sysctl_oldflags = 0x10;
+ else
+ {
+ grub_error (GRUB_ERR_BAD_DEVICE, "cannot set flags of sysctl kern.geom.debugflags");
+ return GRUB_UTIL_FD_INVALID;
+ }
}
- ret = open (os_dev, flags, S_IRUSR | S_IWUSR);
+ ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (! (sysctl_oldflags & 0x10)
&& sysctlbyname ("kern.geom.debugflags", NULL , 0, &sysctl_oldflags, sysctl_size))
{
@@ -116,7 +123,6 @@ grub_util_fd_open (const char *os_dev, int flags)
close (ret);
return GRUB_UTIL_FD_INVALID;
}
-#endif
return ret;
}
diff --git a/grub-core/osdep/haiku/getroot.c b/grub-core/osdep/haiku/getroot.c
index 0852c5e5e..4e123c090 100644
--- a/grub-core/osdep/haiku/getroot.c
+++ b/grub-core/osdep/haiku/getroot.c
@@ -65,7 +65,7 @@ grub_util_find_partition_start_os (const char *dev)
device_geometry geo;
if (ioctl (fd, B_GET_GEOMETRY, &geo, sizeof (geo)) < 0)
return 0;
- ret /= geo.bytes_per_sector;
+ ret /= geo.bytes_per_sector ? : 512;
close (fd);
return ret;
}
diff --git a/grub-core/osdep/hurd/hostdisk.c b/grub-core/osdep/hurd/hostdisk.c
index 57560e1e2..c47b5a5ea 100644
--- a/grub-core/osdep/hurd/hostdisk.c
+++ b/grub-core/osdep/hurd/hostdisk.c
@@ -70,12 +70,12 @@ grub_util_hurd_get_disk_info (const char *dev, grub_uint32_t *secsize, grub_disk
&data, &data_len);
if (num_ints < 1)
- grub_util_error (_("Storage info for `%s' does not include type"), dev);
+ grub_util_error (_("Storage information for `%s' does not include type"), dev);
if (ints[0] != STORAGE_DEVICE)
grub_util_error (_("`%s' is not a local disk"), dev);
if (num_offsets != 2)
- grub_util_error (_("Storage info for `%s' does indicate neither plain partition nor plain disk"), dev);
+ grub_util_error (_("Storage information for `%s' indicates neither a plain partition nor a plain disk"), dev);
if (parent)
{
*parent = NULL;
diff --git a/grub-core/osdep/linux/blocklist.c b/grub-core/osdep/linux/blocklist.c
index f33a7d507..c77d6085c 100644
--- a/grub-core/osdep/linux/blocklist.c
+++ b/grub-core/osdep/linux/blocklist.c
@@ -82,6 +82,8 @@ grub_install_get_blocklist (grub_device_t root_dev,
strerror (errno));
if (bsize & (GRUB_DISK_SECTOR_SIZE - 1))
grub_util_error ("%s", _("blocksize is not divisible by 512"));
+ if (!bsize)
+ grub_util_error ("%s", _("invalid zero blocksize"));
mul = bsize >> GRUB_DISK_SECTOR_BITS;
nblocks = (core_size + bsize - 1) / bsize;
if (mul == 0 || nblocks == 0)
@@ -128,6 +130,7 @@ grub_install_get_blocklist (grub_device_t root_dev,
& (GRUB_DISK_SECTOR_SIZE - 1),
fie2->fm_extents[i].fe_length, hook_data);
}
+ free (fie2);
}
close (fd);
}
diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
index 786863527..09e7e6e6d 100644
--- a/grub-core/osdep/linux/getroot.c
+++ b/grub-core/osdep/linux/getroot.c
@@ -35,6 +35,12 @@
#include <limits.h>
#endif
+#if defined(MAJOR_IN_MKDEV)
+#include <sys/mkdev.h>
+#elif defined(MAJOR_IN_SYSMACROS)
+#include <sys/sysmacros.h>
+#endif
+
#include <grub/types.h>
#include <sys/ioctl.h> /* ioctl */
#include <sys/mount.h>
@@ -226,7 +232,7 @@ grub_find_root_devices_from_btrfs (const char *dir)
char **ret;
fd = open (dir, 0);
- if (!fd)
+ if (fd < 0)
return NULL;
if (ioctl (fd, BTRFS_IOC_FS_INFO, &fsi) < 0)
@@ -274,11 +280,11 @@ get_btrfs_fs_prefix (const char *mount_path)
args.objectid = GRUB_BTRFS_TREE_ROOT_OBJECTID;
if (ioctl (fd, BTRFS_IOC_INO_LOOKUP, &args) < 0)
- return NULL;
+ goto fail;
tree_id = args.treeid;
if (fstat (fd, &st) < 0)
- return NULL;
+ goto fail;
inode_id = st.st_ino;
while (tree_id != GRUB_BTRFS_ROOT_VOL_OBJECTID
@@ -309,16 +315,16 @@ get_btrfs_fs_prefix (const char *mount_path)
sargs.key.nr_items = 1;
if (ioctl (fd, BTRFS_IOC_TREE_SEARCH, &sargs) < 0)
- return NULL;
+ goto fail;
if (sargs.key.nr_items == 0)
- return NULL;
-
+ goto fail;
+
tree_id = sargs.buf[2];
br = (struct grub_btrfs_root_backref *) (sargs.buf + 4);
- inode_id = br->inode_id;
+ inode_id = grub_le_to_cpu64 (br->inode_id);
name = br->name;
- namelen = br->n;
+ namelen = grub_le_to_cpu16 (br->n);
}
else
{
@@ -336,16 +342,16 @@ get_btrfs_fs_prefix (const char *mount_path)
sargs.key.max_type = GRUB_BTRFS_ITEM_TYPE_INODE_REF;
if (ioctl (fd, BTRFS_IOC_TREE_SEARCH, &sargs) < 0)
- return NULL;
+ goto fail;
if (sargs.key.nr_items == 0)
- return NULL;
+ goto fail;
inode_id = sargs.buf[2];
ir = (struct grub_btrfs_inode_ref *) (sargs.buf + 4);
name = ir->name;
- namelen = ir->n;
+ namelen = grub_le_to_cpu16 (ir->n);
}
old = ret;
ret = xmalloc (namelen + (old ? strlen (old) : 0) + 2);
@@ -360,8 +366,14 @@ get_btrfs_fs_prefix (const char *mount_path)
ret[1+namelen] = '\0';
}
if (!ret)
- return xstrdup ("/");
+ ret = xstrdup ("/");
+ close (fd);
return ret;
+
+ fail:
+ free (ret);
+ close (fd);
+ return NULL;
}
@@ -688,7 +700,7 @@ char *
grub_util_part_to_disk (const char *os_dev, struct stat *st,
int *is_part)
{
- char *path = xmalloc (PATH_MAX);
+ char *path;
if (! S_ISBLK (st->st_mode))
{
@@ -696,6 +708,8 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st,
return xstrdup (os_dev);
}
+ path = xmalloc (PATH_MAX);
+
if (! realpath (os_dev, path))
return NULL;
@@ -883,12 +897,42 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st,
*pp = '\0';
return path;
}
+
+ /* If this is a loop device */
+ if ((strncmp ("loop", p, 4) == 0) && p[4] >= '0' && p[4] <= '9')
+ {
+ char *pp = p + 4;
+ while (*pp >= '0' && *pp <= '9')
+ pp++;
+ if (*pp == 'p')
+ *is_part = 1;
+ /* /dev/loop[0-9]+p[0-9]* */
+ *pp = '\0';
+ return path;
+ }
+
+ /* If this is a NVMe device */
+ if ((strncmp ("nvme", p, 4) == 0) && p[4] >= '0' && p[4] <= '9')
+ {
+ char *pp = p + 4;
+ while (*pp >= '0' && *pp <= '9')
+ pp++;
+ if (*pp == 'n')
+ pp++;
+ while (*pp >= '0' && *pp <= '9')
+ pp++;
+ if (*pp == 'p')
+ *is_part = 1;
+ /* /dev/nvme[0-9]+n[0-9]+p[0-9]* */
+ *pp = '\0';
+ return path;
+ }
}
return path;
}
-char *
+static char *
grub_util_get_raid_grub_dev (const char *os_dev)
{
char *grub_dev = NULL;
@@ -1037,7 +1081,7 @@ grub_util_get_grub_dev_os (const char *os_dev)
switch (grub_util_get_dev_abstraction (os_dev))
{
/* Fallback for non-devmapper build. In devmapper-builds LVM is handled
- in rub_util_get_devmapper_grub_dev and this point isn't reached.
+ in grub_util_get_devmapper_grub_dev and this point isn't reached.
*/
case GRUB_DEV_ABSTRACTION_LVM:
{
diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c
index abaaf2847..06179fca7 100644
--- a/grub-core/osdep/linux/hostdisk.c
+++ b/grub-core/osdep/linux/hostdisk.c
@@ -237,6 +237,8 @@ have_devfs (void)
return dev_devfsd_exists;
}
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static int
grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector)
{
@@ -286,6 +288,7 @@ grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector)
{
grub_util_fd_t fd;
grub_disk_addr_t start;
+ struct stat st;
sprintf (p, format, i);
@@ -298,14 +301,16 @@ grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector)
return 0;
}
missing = 0;
- close (fd);
- if (!grub_util_device_is_mapped (real_dev)
- || !grub_util_get_dm_node_linear_info (real_dev, 0, 0, &start))
+ if (fstat (fd, &st) < 0
+ || !grub_util_device_is_mapped_stat (&st)
+ || !grub_util_get_dm_node_linear_info (st.st_rdev, 0, 0, &start))
start = grub_util_find_partition_start_os (real_dev);
/* We don't care about errors here. */
grub_errno = GRUB_ERR_NONE;
+ close (fd);
+
if (start == sector)
{
struct linux_partition_cache *new_cache_item;
@@ -325,6 +330,8 @@ grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector)
return 0;
}
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
void
grub_hostdisk_flush_initial_buffer (const char *os_dev)
{
@@ -369,7 +376,8 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f
part_start = grub_partition_get_start (disk->partition);
- strcpy (dev, grub_util_biosdisk_get_osdev (disk));
+ strncpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev) - 1);
+ dev[sizeof(dev) - 1] = '\0';
if (disk->partition
&& strncmp (dev, "/dev/", 5) == 0)
{
@@ -432,7 +440,8 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f
if (*max == 0)
*max = ~0ULL;
is_partition = 0;
- strcpy (dev, grub_util_biosdisk_get_osdev (disk));
+ strncpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev) - 1);
+ dev[sizeof(dev) - 1] = '\0';
goto reopen;
}
sector -= part_start;
diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c
index 8f24bc9e8..a79682a5e 100644
--- a/grub-core/osdep/linux/ofpath.c
+++ b/grub-core/osdep/linux/ofpath.c
@@ -122,12 +122,16 @@ find_obppath (const char *sysfs_path_orig)
fd = open(path, O_RDONLY);
if (fd < 0 || fstat (fd, &st) < 0)
{
+ if (fd >= 0)
+ close (fd);
snprintf(path, path_size, "%s/devspec", sysfs_path);
fd = open(path, O_RDONLY);
}
if (fd < 0 || fstat (fd, &st) < 0)
{
+ if (fd >= 0)
+ close (fd);
kill_trailing_dir(sysfs_path);
if (!strcmp(sysfs_path, "/sys"))
{
@@ -147,6 +151,9 @@ find_obppath (const char *sysfs_path_orig)
{
grub_util_info (_("cannot read `%s': %s"), path, strerror (errno));
close(fd);
+ free (path);
+ free (of_path);
+ free (sysfs_path);
return NULL;
}
close(fd);
@@ -329,7 +336,7 @@ vendor_is_ATA(const char *path)
}
static void
-check_sas (char *sysfs_path, int *tgt, unsigned long int *sas_address)
+check_sas (const char *sysfs_path, int *tgt, unsigned long int *sas_address)
{
char *ed = strstr (sysfs_path, "end_device");
char *p, *q, *path;
@@ -341,8 +348,10 @@ check_sas (char *sysfs_path, int *tgt, unsigned long int *sas_address)
return;
/* SAS devices are identified using disk@$PHY_ID */
- p = strdup (sysfs_path);
+ p = xstrdup (sysfs_path);
ed = strstr(p, "end_device");
+ if (!ed)
+ return;
q = ed;
while (*q && *q != '/')
@@ -480,6 +489,7 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
snprintf(disk, sizeof (disk),
"/sas/%s@%lx,%lu:%c", disk_name, sas_address, longlun, 'a' + (part - 1));
}
+ free (lunstr);
}
}
strcat(of_path, disk);
@@ -529,8 +539,8 @@ grub_util_devname_to_ofpath (const char *sys_devname)
ofpath = xstrdup ("floppy");
else
{
- grub_util_warn (_("unknown device type %s\n"), device);
- return NULL;
+ grub_util_warn (_("unknown device type %s"), device);
+ ofpath = NULL;
}
free (devnode);
diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c
index 4b9f6ef9d..775b6c031 100644
--- a/grub-core/osdep/linux/platform.c
+++ b/grub-core/osdep/linux/platform.c
@@ -60,6 +60,43 @@ is_64_kernel (void)
return strcmp (un.machine, "x86_64") == 0;
}
+static int
+read_platform_size (void)
+{
+ FILE *fp;
+ char *buf = NULL;
+ size_t len = 0;
+ int ret = 0;
+
+ /* Newer kernels can tell us directly about the size of the
+ * underlying firmware - let's see if that interface is there. */
+ fp = grub_util_fopen ("/sys/firmware/efi/fw_platform_size", "r");
+ if (fp != NULL)
+ {
+ if (getline (&buf, &len, fp) >= 3) /* 2 digits plus newline */
+ {
+ if (strncmp (buf, "32", 2) == 0)
+ ret = 32;
+ else if (strncmp (buf, "64", 2) == 0)
+ ret = 64;
+ }
+ free (buf);
+ fclose (fp);
+ }
+
+ if (ret == 0)
+ {
+ /* Unrecognised - fall back to matching the kernel size
+ * instead */
+ if (is_64_kernel ())
+ ret = 64;
+ else
+ ret = 32;
+ }
+
+ return ret;
+}
+
const char *
grub_install_get_default_x86_platform (void)
{
@@ -77,7 +114,7 @@ grub_install_get_default_x86_platform (void)
if (is_not_empty_directory ("/sys/firmware/efi"))
{
grub_util_info ("...found");
- if (is_64_kernel ())
+ if (read_platform_size() == 64)
return "x86_64-efi";
else
return "i386-efi";
diff --git a/grub-core/osdep/unix/config.c b/grub-core/osdep/unix/config.c
index c093e91ad..65effa9f3 100644
--- a/grub-core/osdep/unix/config.c
+++ b/grub-core/osdep/unix/config.c
@@ -105,8 +105,8 @@ grub_util_load_config (struct grub_util_config *cfg)
*ptr++ = *iptr;
}
- strcpy (ptr, "'; printf \"GRUB_ENABLE_CRYPTODISK=%s\\nGRUB_DISTRIBUTOR=%s\\n\", "
- "\"$GRUB_ENABLE_CRYPTODISK\", \"$GRUB_DISTRIBUTOR\"");
+ strcpy (ptr, "'; printf \"GRUB_ENABLE_CRYPTODISK=%s\\nGRUB_DISTRIBUTOR=%s\\n\" "
+ "\"$GRUB_ENABLE_CRYPTODISK\" \"$GRUB_DISTRIBUTOR\"");
argv[2] = script;
argv[3] = '\0';
@@ -134,6 +134,6 @@ grub_util_load_config (struct grub_util_config *cfg)
fclose (f);
}
else
- grub_util_warn (_("cannot open config file `%s': %s"),
+ grub_util_warn (_("cannot open configuration file `%s': %s"),
cfgfile, strerror (errno));
}
diff --git a/grub-core/osdep/unix/cputime.c b/grub-core/osdep/unix/cputime.c
index 47e3abc77..cff359a3b 100644
--- a/grub-core/osdep/unix/cputime.c
+++ b/grub-core/osdep/unix/cputime.c
@@ -9,7 +9,14 @@ grub_uint64_t
grub_util_get_cpu_time_ms (void)
{
struct tms tm;
+ static long sc_clk_tck;
+ if (!sc_clk_tck)
+ {
+ sc_clk_tck = sysconf(_SC_CLK_TCK);
+ if (sc_clk_tck <= 0)
+ sc_clk_tck = 1000;
+ }
times (&tm);
- return (tm.tms_utime * 1000ULL) / sysconf(_SC_CLK_TCK);
+ return (tm.tms_utime * 1000ULL) / sc_clk_tck;
}
diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c
index 260465844..4bf37b027 100644
--- a/grub-core/osdep/unix/getroot.c
+++ b/grub-core/osdep/unix/getroot.c
@@ -45,18 +45,17 @@
#ifdef __linux__
#include <sys/ioctl.h> /* ioctl */
#include <sys/mount.h>
-#ifndef MAJOR
-# ifndef MINORBITS
-# define MINORBITS 8
-# endif /* ! MINORBITS */
-# define MAJOR(dev) ((unsigned) ((dev) >> MINORBITS))
-#endif /* ! MAJOR */
#ifndef FLOPPY_MAJOR
# define FLOPPY_MAJOR 2
#endif /* ! FLOPPY_MAJOR */
#endif
#include <sys/types.h>
+#if defined(MAJOR_IN_MKDEV)
+#include <sys/mkdev.h>
+#elif defined(MAJOR_IN_SYSMACROS)
+#include <sys/sysmacros.h>
+#endif
#if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
# include <grub/util/libzfs.h>
@@ -70,7 +69,6 @@
#include <grub/emu/getroot.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-# define MAJOR(dev) major(dev)
# define FLOPPY_MAJOR 2
#endif
@@ -87,7 +85,6 @@
#endif /* defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) */
#if defined(__NetBSD__) || defined(__OpenBSD__)
-# define MAJOR(dev) major(dev)
# ifdef HAVE_GETRAWPARTITION
# include <util.h> /* getrawpartition */
# endif /* HAVE_GETRAWPARTITION */
@@ -116,6 +113,7 @@
#include <sys/mount.h>
#endif
+#if !defined (__GNU__)
static void
strip_extra_slashes (char *dir)
{
@@ -155,7 +153,6 @@ xgetcwd (void)
return path;
}
-#if !defined (__GNU__)
char **
grub_util_find_root_devices_from_poolname (char *poolname)
{
@@ -443,17 +440,18 @@ grub_find_device (const char *dir, dev_t dev)
/* Found! */
char *res;
char *cwd;
-#if defined(__NetBSD__) || defined(__OpenBSD__)
- /* Convert this block device to its character (raw) device. */
- const char *template = "%s/r%s";
-#else
- /* Keep the device name as it is. */
- const char *template = "%s/%s";
-#endif
cwd = xgetcwd ();
res = xmalloc (strlen (cwd) + strlen (ent->d_name) + 3);
- sprintf (res, template, cwd, ent->d_name);
+ sprintf (res,
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ /* Convert this block device to its character (raw) device. */
+ "%s/r%s",
+#else
+ /* Keep the device name as it is. */
+ "%s/%s",
+#endif
+ cwd, ent->d_name);
strip_extra_slashes (res);
free (cwd);
@@ -490,7 +488,7 @@ grub_guess_root_devices (const char *dir_in)
char **os_dev = NULL;
struct stat st;
dev_t dev;
- char *dir = canonicalize_file_name (dir_in);
+ char *dir = grub_canonicalize_file_name (dir_in);
if (!dir)
grub_util_error (_("failed to get canonical path of `%s'"), dir_in);
@@ -515,7 +513,7 @@ grub_guess_root_devices (const char *dir_in)
*cur = tmp;
else
{
- *cur = canonicalize_file_name (tmp);
+ *cur = grub_canonicalize_file_name (tmp);
if (*cur == NULL)
grub_util_error (_("failed to get canonical path of `%s'"), tmp);
free (tmp);
@@ -540,6 +538,7 @@ grub_guess_root_devices (const char *dir_in)
if (stat (dir, &st) < 0)
grub_util_error (_("cannot stat `%s': %s"), dir, strerror (errno));
+ free (dir);
dev = st.st_dev;
@@ -620,7 +619,10 @@ grub_util_pull_lvm_by_command (const char *os_dev)
free (vgname);
if (!pid)
- return;
+ {
+ free (vgid);
+ return;
+ }
/* Parent. Read vgs' output. */
vgs = fdopen (fd, "r");
@@ -652,6 +654,7 @@ out:
close (fd);
waitpid (pid, NULL, 0);
free (buf);
+ free (vgid);
}
/* ZFS has similar problems to those of btrfs (see above). */
@@ -763,6 +766,8 @@ grub_util_biosdisk_is_floppy (grub_disk_t disk)
#else
+#include <grub/emu/getroot.h>
+
void
grub_util_pull_lvm_by_command (const char *os_dev __attribute__ ((unused)))
{
diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hostdisk.c
index fa83f26e2..2a8c5882e 100644
--- a/grub-core/osdep/unix/hostdisk.c
+++ b/grub-core/osdep/unix/hostdisk.c
@@ -48,11 +48,6 @@
#ifdef __linux__
# include <sys/ioctl.h> /* ioctl */
# include <sys/mount.h>
-# if !defined(__GLIBC__) || \
- ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1)))
-/* Maybe libc doesn't have large file support. */
-# include <linux/unistd.h> /* _llseek */
-# endif /* (GLIBC < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR < 1)) */
#endif /* __linux__ */
grub_uint64_t
@@ -79,24 +74,6 @@ grub_util_get_fd_size (grub_util_fd_t fd, const char *name, unsigned *log_secsiz
return st.st_size;
}
-#if defined(__linux__) && (!defined(__GLIBC__) || \
- ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))))
- /* Maybe libc doesn't have large file support. */
-int
-grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
-{
- loff_t offset, result;
- static int _llseek (uint filedes, ulong hi, ulong lo,
- loff_t *res, uint wh);
- _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo,
- loff_t *, res, uint, wh);
-
- offset = (loff_t) off;
- if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET))
- return -1;
- return GRUB_ERR_NONE;
-}
-#else
int
grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
{
@@ -107,7 +84,6 @@ grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off)
return 0;
}
-#endif
/* Read LEN bytes from FD in BUF. Return less than or equal to zero if an
@@ -181,7 +157,7 @@ grub_util_fd_open (const char *os_dev, int flags)
flags |= O_BINARY;
#endif
- return open (os_dev, flags, S_IRUSR | S_IWUSR);
+ return open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
}
#endif
@@ -222,7 +198,7 @@ grub_util_fd_close (grub_util_fd_t fd)
}
char *
-canonicalize_file_name (const char *path)
+grub_canonicalize_file_name (const char *path)
{
#if defined (PATH_MAX)
char *ret;
diff --git a/grub-core/osdep/unix/password.c b/grub-core/osdep/unix/password.c
index 470a6ea62..9996b244b 100644
--- a/grub-core/osdep/unix/password.c
+++ b/grub-core/osdep/unix/password.c
@@ -53,7 +53,11 @@ grub_password_get (char buf[], unsigned buf_size)
tty_changed = 0;
grub_memset (buf, 0, buf_size);
if (!fgets (buf, buf_size, stdin))
- return 0;
+ {
+ if (in != stdin)
+ fclose (in);
+ return 0;
+ }
ptr = buf + strlen (buf) - 1;
while (buf <= ptr && (*ptr == '\n' || *ptr == '\r'))
*ptr-- = 0;
@@ -64,5 +68,8 @@ grub_password_get (char buf[], unsigned buf_size)
grub_xputs ("\n");
grub_refresh ();
+ if (in != stdin)
+ fclose (in);
+
return 1;
}
diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c
index a6dc07093..a3fcfcaca 100644
--- a/grub-core/osdep/unix/platform.c
+++ b/grub-core/osdep/unix/platform.c
@@ -74,7 +74,7 @@ get_ofpathname (const char *dev)
return ret;
fail:
- grub_util_error (_("couldn't find IEEE1275 device tree path for %s.\nYou will have to set `boot-device' variable manually"),
+ grub_util_error (_("couldn't find IEEE1275 device path for %s.\nYou will have to set `boot-device' variable manually"),
dev);
}
diff --git a/grub-core/osdep/unix/relpath.c b/grub-core/osdep/unix/relpath.c
index 71c19d867..f719950fd 100644
--- a/grub-core/osdep/unix/relpath.c
+++ b/grub-core/osdep/unix/relpath.c
@@ -44,14 +44,17 @@ grub_make_system_path_relative_to_its_root (const char *path)
char *poolfs = NULL;
/* canonicalize. */
- p = canonicalize_file_name (path);
+ p = grub_canonicalize_file_name (path);
if (p == NULL)
grub_util_error (_("failed to get canonical path of `%s'"), path);
#ifdef __linux__
ret = grub_make_system_path_relative_to_its_root_os (p);
if (ret)
- return ret;
+ {
+ free (p);
+ return ret;
+ }
#endif
/* For ZFS sub-pool filesystems. */
diff --git a/grub-core/osdep/windows/config.c b/grub-core/osdep/windows/config.c
index 823eac884..928ab1a49 100644
--- a/grub-core/osdep/windows/config.c
+++ b/grub-core/osdep/windows/config.c
@@ -52,6 +52,6 @@ grub_util_load_config (struct grub_util_config *cfg)
fclose (f);
}
else
- grub_util_warn (_("cannot open config file `%s': %s"),
+ grub_util_warn (_("cannot open configuration file `%s': %s"),
cfgfile, strerror (errno));
}
diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c
index d390b25fc..85507af88 100644
--- a/grub-core/osdep/windows/hostdisk.c
+++ b/grub-core/osdep/windows/hostdisk.c
@@ -328,7 +328,7 @@ grub_util_fd_strerror (void)
}
char *
-canonicalize_file_name (const char *path)
+grub_canonicalize_file_name (const char *path)
{
char *ret;
LPTSTR windows_path;
diff --git a/grub-core/osdep/windows/init.c b/grub-core/osdep/windows/init.c
index 98c325c20..e8ffd62c6 100644
--- a/grub-core/osdep/windows/init.c
+++ b/grub-core/osdep/windows/init.c
@@ -170,7 +170,7 @@ grub_util_host_init (int *argc __attribute__ ((unused)),
#error "Unsupported TCHAR size"
#endif
- grub_util_base_directory = canonicalize_file_name ((*argv)[0]);
+ grub_util_base_directory = grub_canonicalize_file_name ((*argv)[0]);
if (!grub_util_base_directory)
grub_util_base_directory = xstrdup ((*argv)[0]);
for (ptr = grub_util_base_directory + strlen (grub_util_base_directory) - 1;
diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c
index 1046a6ca3..912269191 100644
--- a/grub-core/osdep/windows/platform.c
+++ b/grub-core/osdep/windows/platform.c
@@ -94,13 +94,13 @@ get_platform (void)
if (!get_efi_privilegies ())
{
- grub_util_warn (_("Insufficient privilegies to access firmware, assuming BIOS"));
+ grub_util_warn (_("Insufficient privileges to access firmware, assuming BIOS"));
platform = PLAT_BIOS;
}
if (!func_GetFirmwareEnvironmentVariableW (L"BootOrder", GRUB_EFI_GLOBAL_VARIABLE_GUID_WINDOWS_STR,
buffer, sizeof (buffer))
- && GetLastError () != ERROR_INVALID_FUNCTION)
+ && GetLastError () == ERROR_INVALID_FUNCTION)
{
platform = PLAT_BIOS;
return;
@@ -370,9 +370,9 @@ grub_install_register_efi (grub_device_t efidir_grub_dev,
}
hddp->partition_start = grub_partition_get_start (efidir_grub_dev->disk->partition)
- << (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
+ >> (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
hddp->partition_size = grub_disk_get_size (efidir_grub_dev->disk)
- << (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
+ >> (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
pathptr = hddp + 1;
filep = pathptr;
diff --git a/grub-core/partmap/acorn.c b/grub-core/partmap/acorn.c
index 7bb93d9be..c022c61dd 100644
--- a/grub-core/partmap/acorn.c
+++ b/grub-core/partmap/acorn.c
@@ -25,8 +25,8 @@
GRUB_MOD_LICENSE ("GPLv3+");
-#define LINUX_NATIVE_MAGIC grub_cpu_to_le32 (0xdeafa1de)
-#define LINUX_SWAP_MAGIC grub_cpu_to_le32 (0xdeafab1e)
+#define LINUX_NATIVE_MAGIC grub_cpu_to_le32_compile_time (0xdeafa1de)
+#define LINUX_SWAP_MAGIC grub_cpu_to_le32_compile_time (0xdeafab1e)
#define LINUX_MAP_ENTRIES (512 / 12)
#define NONADFS_PARTITION_TYPE_LINUX 9
diff --git a/grub-core/partmap/bsdlabel.c b/grub-core/partmap/bsdlabel.c
index cf0f967c1..1d785906b 100644
--- a/grub-core/partmap/bsdlabel.c
+++ b/grub-core/partmap/bsdlabel.c
@@ -53,7 +53,7 @@ iterate_real (grub_disk_t disk, grub_disk_addr_t sector, int freebsd,
return grub_errno;
/* Check if it is valid. */
- if (label.magic != grub_cpu_to_le32 (GRUB_PC_PARTITION_BSD_LABEL_MAGIC))
+ if (label.magic != grub_cpu_to_le32_compile_time (GRUB_PC_PARTITION_BSD_LABEL_MAGIC))
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
/* A kludge to determine a base of be.offset. */
diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c
index 38df7b3c9..83bcba779 100644
--- a/grub-core/partmap/gpt.c
+++ b/grub-core/partmap/gpt.c
@@ -65,7 +65,7 @@ grub_gpt_partition_map_iterate (grub_disk_t disk,
return grub_errno;
/* Check if it is valid. */
- if (mbr.signature != grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE))
+ if (mbr.signature != grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE))
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
/* Make sure the MBR is a protective MBR and not a normal MBR. */
diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c
index 0d0a6b7d0..6d4b455a1 100644
--- a/grub-core/partmap/msdos.c
+++ b/grub-core/partmap/msdos.c
@@ -162,7 +162,7 @@ grub_partition_msdos_iterate (grub_disk_t disk,
lastaddr = p.offset;
/* Check if it is valid. */
- if (mbr.signature != grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE))
+ if (mbr.signature != grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE))
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
for (i = 0; i < 4; i++)
@@ -229,6 +229,9 @@ grub_partition_msdos_iterate (grub_disk_t disk,
}
#ifdef GRUB_UTIL
+
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static grub_err_t
pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
unsigned int max_nsectors,
@@ -246,7 +249,7 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
if (embed_type != GRUB_EMBED_PCBIOS)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
- "PC-style partitions curently support "
+ "PC-style partitions currently support "
"only PC-BIOS embedding");
if (disk->partition)
@@ -277,7 +280,7 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
lastaddr = offset;
/* Check if it is valid. */
- if (mbr.signature != grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE))
+ if (mbr.signature != grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE))
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
for (i = 0; i < 4; i++)
@@ -401,6 +404,9 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
N_("your embedding area is unusually small. "
"core.img won't fit in it."));
}
+
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
#endif
diff --git a/grub-core/partmap/sun.c b/grub-core/partmap/sun.c
index dae360269..aac30a320 100644
--- a/grub-core/partmap/sun.c
+++ b/grub-core/partmap/sun.c
@@ -91,7 +91,7 @@ sun_partition_map_iterate (grub_disk_t disk,
struct grub_partition p;
union
{
- struct grub_sun_block sun;
+ struct grub_sun_block sun_block;
grub_uint16_t raw[0];
} block;
int partnum;
@@ -103,7 +103,7 @@ sun_partition_map_iterate (grub_disk_t disk,
if (err)
return err;
- if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.sun.magic))
+ if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.sun_block.magic))
return grub_error (GRUB_ERR_BAD_PART_TABLE, "not a sun partition table");
if (! grub_sun_is_valid (block.raw))
@@ -115,14 +115,14 @@ sun_partition_map_iterate (grub_disk_t disk,
{
struct grub_sun_partition_descriptor *desc;
- if (block.sun.infos[partnum].id == 0
- || block.sun.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID)
+ if (block.sun_block.infos[partnum].id == 0
+ || block.sun_block.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID)
continue;
- desc = &block.sun.partitions[partnum];
+ desc = &block.sun_block.partitions[partnum];
p.start = ((grub_uint64_t) grub_be_to_cpu32 (desc->start_cylinder)
- * grub_be_to_cpu16 (block.sun.ntrks)
- * grub_be_to_cpu16 (block.sun.nsect));
+ * grub_be_to_cpu16 (block.sun_block.ntrks)
+ * grub_be_to_cpu16 (block.sun_block.nsect));
p.len = grub_be_to_cpu32 (desc->num_sectors);
p.number = p.index = partnum;
if (p.len)
diff --git a/grub-core/partmap/sunpc.c b/grub-core/partmap/sunpc.c
index 442763ee5..73a430c14 100644
--- a/grub-core/partmap/sunpc.c
+++ b/grub-core/partmap/sunpc.c
@@ -74,7 +74,7 @@ sun_pc_partition_map_iterate (grub_disk_t disk,
grub_partition_t p;
union
{
- struct grub_sun_pc_block sun;
+ struct grub_sun_pc_block sun_block;
grub_uint16_t raw[0];
} block;
int partnum;
@@ -92,7 +92,7 @@ sun_pc_partition_map_iterate (grub_disk_t disk,
return err;
}
- if (GRUB_PARTMAP_SUN_PC_MAGIC != grub_le_to_cpu16 (block.sun.magic))
+ if (GRUB_PARTMAP_SUN_PC_MAGIC != grub_le_to_cpu16 (block.sun_block.magic))
{
grub_free (p);
return grub_error (GRUB_ERR_BAD_PART_TABLE,
@@ -111,12 +111,12 @@ sun_pc_partition_map_iterate (grub_disk_t disk,
{
struct grub_sun_pc_partition_descriptor *desc;
- if (block.sun.partitions[partnum].id == 0
- || block.sun.partitions[partnum].id
+ if (block.sun_block.partitions[partnum].id == 0
+ || block.sun_block.partitions[partnum].id
== GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID)
continue;
- desc = &block.sun.partitions[partnum];
+ desc = &block.sun_block.partitions[partnum];
p->start = grub_le_to_cpu32 (desc->start_sector);
p->len = grub_le_to_cpu32 (desc->num_sectors);
p->number = partnum;
diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
index afd551320..a8502d907 100644
--- a/grub-core/script/execute.c
+++ b/grub-core/script/execute.c
@@ -635,57 +635,73 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
{
case GRUB_SCRIPT_ARG_TYPE_VAR:
case GRUB_SCRIPT_ARG_TYPE_DQVAR:
- values = grub_script_env_get (arg->str, arg->type);
- for (i = 0; values && values[i]; i++)
- {
- if (i != 0 && grub_script_argv_next (&result))
- goto fail;
+ {
+ int need_cleanup = 0;
- if (arg->type == GRUB_SCRIPT_ARG_TYPE_VAR)
- {
- int len;
- char ch;
- char *p;
- char *op;
- const char *s = values[i];
-
- len = grub_strlen (values[i]);
- /* \? -> \\\? */
- /* \* -> \\\* */
- /* \ -> \\ */
- p = grub_malloc (len * 2 + 1);
- if (! p)
- goto fail;
-
- op = p;
- while ((ch = *s++))
- {
- if (ch == '\\')
- {
- *op++ = '\\';
- if (*s == '?' || *s == '*')
- *op++ = '\\';
- }
- *op++ = ch;
- }
- *op = '\0';
-
- if (grub_script_argv_append (&result, p, op - p))
- {
- grub_free (p);
- goto fail;
- }
- }
- else
- {
- if (append (&result, values[i], 1))
- goto fail;
- }
-
- grub_free (values[i]);
- }
- grub_free (values);
- break;
+ values = grub_script_env_get (arg->str, arg->type);
+ for (i = 0; values && values[i]; i++)
+ {
+ if (!need_cleanup)
+ {
+ if (i != 0 && grub_script_argv_next (&result))
+ {
+ need_cleanup = 1;
+ goto cleanup;
+ }
+
+ if (arg->type == GRUB_SCRIPT_ARG_TYPE_VAR)
+ {
+ int len;
+ char ch;
+ char *p;
+ char *op;
+ const char *s = values[i];
+
+ len = grub_strlen (values[i]);
+ /* \? -> \\\? */
+ /* \* -> \\\* */
+ /* \ -> \\ */
+ p = grub_malloc (len * 2 + 1);
+ if (! p)
+ {
+ need_cleanup = 1;
+ goto cleanup;
+ }
+
+ op = p;
+ while ((ch = *s++))
+ {
+ if (ch == '\\')
+ {
+ *op++ = '\\';
+ if (*s == '?' || *s == '*')
+ *op++ = '\\';
+ }
+ *op++ = ch;
+ }
+ *op = '\0';
+
+ need_cleanup = grub_script_argv_append (&result, p, op - p);
+ grub_free (p);
+ /* Fall through to cleanup */
+ }
+ else
+ {
+ need_cleanup = append (&result, values[i], 1);
+ /* Fall through to cleanup */
+ }
+ }
+
+cleanup:
+ grub_free (values[i]);
+ }
+ grub_free (values);
+
+ if (need_cleanup)
+ goto fail;
+
+ break;
+ }
case GRUB_SCRIPT_ARG_TYPE_BLOCK:
{
diff --git a/grub-core/script/lexer.c b/grub-core/script/lexer.c
index 128d23822..89cf67706 100644
--- a/grub-core/script/lexer.c
+++ b/grub-core/script/lexer.c
@@ -164,6 +164,7 @@ grub_script_lexer_yywrap (struct grub_parser_param *parserstate,
{
grub_free (line);
line = grub_strdup ("\n");
+ len = 1;
}
else if (len && line[len - 1] != '\n')
{
diff --git a/grub-core/script/parser.y b/grub-core/script/parser.y
index 1d60e9de2..4f0ab8319 100644
--- a/grub-core/script/parser.y
+++ b/grub-core/script/parser.y
@@ -30,7 +30,6 @@
#include "grub_script.tab.h"
-#pragma GCC diagnostic ignored "-Wunreachable-code"
#pragma GCC diagnostic ignored "-Wmissing-declarations"
%}
diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l
index 9c2cfe115..95b219170 100644
--- a/grub-core/script/yylex.l
+++ b/grub-core/script/yylex.l
@@ -92,7 +92,7 @@ typedef size_t yy_size_t;
#define stdout 0
#define fprintf(...) 0
-#define exit(...)
+#define exit(...) grub_fatal("fatal error in lexer")
#endif
}
diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c
index f5071ce69..c234e92f2 100644
--- a/grub-core/term/at_keyboard.c
+++ b/grub-core/term/at_keyboard.c
@@ -226,7 +226,7 @@ static const struct
{0x7d, GRUB_KEYBOARD_KEY_PPAGE},
};
-static int alive = 0, ping_sent;
+static int ping_sent;
static void
keyboard_controller_wait_until_ready (void)
@@ -373,7 +373,7 @@ set_scancodes (void)
grub_dprintf ("atkeyb", "returned set %d\n", current_set);
if (current_set == 1)
return;
- grub_printf ("No supported scancode set found\n");
+ grub_dprintf ("atkeyb", "no supported scancode set found\n");
#endif
}
@@ -396,6 +396,9 @@ fetch_key (int *is_break)
if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))
return -1;
at_key = grub_inb (KEYBOARD_REG_DATA);
+ /* May happen if no keyboard is connected. Just ignore this. */
+ if (at_key == 0xff)
+ return -1;
if (at_key == 0xe0)
{
e0_received = 1;
@@ -540,7 +543,7 @@ grub_keyboard_getkey (void)
int
grub_at_keyboard_is_alive (void)
{
- if (alive)
+ if (current_set != 0)
return 1;
if (ping_sent
&& KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))
@@ -608,7 +611,6 @@ static void
grub_keyboard_controller_init (void)
{
at_keyboard_status = 0;
- alive = 1;
/* Drain input buffer. */
while (1)
{
@@ -636,7 +638,7 @@ grub_keyboard_controller_init (void)
static grub_err_t
grub_keyboard_controller_fini (struct grub_term_input *term __attribute__ ((unused)))
{
- if (!alive)
+ if (current_set == 0)
return GRUB_ERR_NONE;
if (grub_keyboard_orig_set)
write_mode (grub_keyboard_orig_set);
@@ -653,7 +655,7 @@ grub_at_fini_hw (int noreturn __attribute__ ((unused)))
static grub_err_t
grub_at_restore_hw (void)
{
- if (!alive)
+ if (current_set == 0)
return GRUB_ERR_NONE;
/* Drain input buffer. */
diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c
index a37eb841c..7d31095b1 100644
--- a/grub-core/term/efi/console.c
+++ b/grub-core/term/efi/console.c
@@ -104,26 +104,12 @@ const unsigned efi_codes[] =
GRUB_TERM_KEY_DC, GRUB_TERM_KEY_PPAGE, GRUB_TERM_KEY_NPAGE, GRUB_TERM_KEY_F1,
GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3, GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5,
GRUB_TERM_KEY_F6, GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9,
- GRUB_TERM_KEY_F10, 0, 0, '\e'
+ GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12, '\e'
};
-
static int
-grub_console_getkey (struct grub_term_input *term __attribute__ ((unused)))
+grub_efi_translate_key (grub_efi_input_key_t key)
{
- grub_efi_simple_input_interface_t *i;
- grub_efi_input_key_t key;
- grub_efi_status_t status;
-
- if (grub_efi_is_finished)
- return 0;
-
- i = grub_efi_system_table->con_in;
- status = efi_call_2 (i->read_key_stroke, i, &key);
-
- if (status != GRUB_EFI_SUCCESS)
- return GRUB_TERM_NO_KEY;
-
if (key.scan_code == 0)
{
/* Some firmware implementations use VT100-style codes against the spec.
@@ -139,9 +125,100 @@ grub_console_getkey (struct grub_term_input *term __attribute__ ((unused)))
else if (key.scan_code < ARRAY_SIZE (efi_codes))
return efi_codes[key.scan_code];
+ if ((key.unicode_char >= 0x20 && key.unicode_char <= 0x7f)
+ || key.unicode_char == '\t' || key.unicode_char == '\b'
+ || key.unicode_char == '\n' || key.unicode_char == '\r')
+ return key.unicode_char;
+
return GRUB_TERM_NO_KEY;
}
+static int
+grub_console_getkey_con (struct grub_term_input *term __attribute__ ((unused)))
+{
+ grub_efi_simple_input_interface_t *i;
+ grub_efi_input_key_t key;
+ grub_efi_status_t status;
+
+ i = grub_efi_system_table->con_in;
+ status = efi_call_2 (i->read_key_stroke, i, &key);
+
+ if (status != GRUB_EFI_SUCCESS)
+ return GRUB_TERM_NO_KEY;
+
+ return grub_efi_translate_key(key);
+}
+
+static int
+grub_console_getkey_ex(struct grub_term_input *term)
+{
+ grub_efi_key_data_t key_data;
+ grub_efi_status_t status;
+ grub_efi_uint32_t kss;
+ int key = -1;
+
+ grub_efi_simple_text_input_ex_interface_t *text_input = term->data;
+
+ status = efi_call_2 (text_input->read_key_stroke, text_input, &key_data);
+
+ if (status != GRUB_EFI_SUCCESS)
+ return GRUB_TERM_NO_KEY;
+
+ kss = key_data.key_state.key_shift_state;
+ key = grub_efi_translate_key(key_data.key);
+
+ if (key == GRUB_TERM_NO_KEY)
+ return GRUB_TERM_NO_KEY;
+
+ if (kss & GRUB_EFI_SHIFT_STATE_VALID)
+ {
+ if ((kss & GRUB_EFI_LEFT_SHIFT_PRESSED
+ || kss & GRUB_EFI_RIGHT_SHIFT_PRESSED)
+ && (key & GRUB_TERM_EXTENDED))
+ key |= GRUB_TERM_SHIFT;
+ if (kss & GRUB_EFI_LEFT_ALT_PRESSED || kss & GRUB_EFI_RIGHT_ALT_PRESSED)
+ key |= GRUB_TERM_ALT;
+ if (kss & GRUB_EFI_LEFT_CONTROL_PRESSED
+ || kss & GRUB_EFI_RIGHT_CONTROL_PRESSED)
+ key |= GRUB_TERM_CTRL;
+ }
+
+ return key;
+}
+
+static grub_err_t
+grub_efi_console_input_init (struct grub_term_input *term)
+{
+ grub_efi_guid_t text_input_ex_guid =
+ GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID;
+
+ if (grub_efi_is_finished)
+ return 0;
+
+ grub_efi_simple_text_input_ex_interface_t *text_input = term->data;
+ if (text_input)
+ return 0;
+
+ text_input = grub_efi_open_protocol(grub_efi_system_table->console_in_handler,
+ &text_input_ex_guid,
+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ term->data = (void *)text_input;
+
+ return 0;
+}
+
+static int
+grub_console_getkey (struct grub_term_input *term)
+{
+ if (grub_efi_is_finished)
+ return 0;
+
+ if (term->data)
+ return grub_console_getkey_ex(term);
+ else
+ return grub_console_getkey_con(term);
+}
+
static struct grub_term_coordinate
grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
{
@@ -243,7 +320,7 @@ grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)),
}
static grub_err_t
-grub_efi_console_init (struct grub_term_output *term)
+grub_efi_console_output_init (struct grub_term_output *term)
{
grub_efi_set_text_mode (1);
grub_console_setcursor (term, 1);
@@ -251,7 +328,7 @@ grub_efi_console_init (struct grub_term_output *term)
}
static grub_err_t
-grub_efi_console_fini (struct grub_term_output *term)
+grub_efi_console_output_fini (struct grub_term_output *term)
{
grub_console_setcursor (term, 0);
grub_efi_set_text_mode (0);
@@ -262,13 +339,14 @@ static struct grub_term_input grub_console_term_input =
{
.name = "console",
.getkey = grub_console_getkey,
+ .init = grub_efi_console_input_init,
};
static struct grub_term_output grub_console_term_output =
{
.name = "console",
- .init = grub_efi_console_init,
- .fini = grub_efi_console_fini,
+ .init = grub_efi_console_output_init,
+ .fini = grub_efi_console_output_fini,
.putchar = grub_console_putchar,
.getwh = grub_console_getwh,
.getxy = grub_console_getxy,
@@ -291,8 +369,8 @@ grub_console_init (void)
return;
}
- grub_term_register_input ("console", &grub_console_term_input);
grub_term_register_output ("console", &grub_console_term_output);
+ grub_term_register_input ("console", &grub_console_term_input);
}
void
diff --git a/grub-core/term/efi/serial.c b/grub-core/term/efi/serial.c
index c0911ad7b..4c94723c5 100644
--- a/grub-core/term/efi/serial.c
+++ b/grub-core/term/efi/serial.c
@@ -173,7 +173,10 @@ grub_efiserial_init (void)
port->name = grub_malloc (sizeof ("efiXXXXXXXXXXXXXXXXXXXX"));
if (!port->name)
- return;
+ {
+ grub_free (port);
+ return;
+ }
grub_snprintf (port->name, sizeof ("efiXXXXXXXXXXXXXXXXXXXX"),
"efi%d", num_serial++);
diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c
index dc0669b35..70f10f19c 100644
--- a/grub-core/term/gfxterm.c
+++ b/grub-core/term/gfxterm.c
@@ -221,6 +221,8 @@ grub_virtual_screen_setup (unsigned int x, unsigned int y,
calculate_normal_character_width (virtual_screen.font);
virtual_screen.normal_char_height =
grub_font_get_max_char_height (virtual_screen.font);
+ if (virtual_screen.normal_char_height == 0)
+ virtual_screen.normal_char_height = 16;
virtual_screen.cursor_x = 0;
virtual_screen.cursor_y = 0;
virtual_screen.cursor_state = 1;
diff --git a/grub-core/term/ns8250.c b/grub-core/term/ns8250.c
index 2959632a9..39809d042 100644
--- a/grub-core/term/ns8250.c
+++ b/grub-core/term/ns8250.c
@@ -57,6 +57,8 @@ serial_get_divisor (const struct grub_serial_port *port __attribute__ ((unused))
base_clock = config->base_clock ? (config->base_clock >> 4) : DEFAULT_BASE_CLOCK;
divisor = (base_clock + (config->speed / 2)) / config->speed;
+ if (config->speed == 0)
+ return 0;
if (divisor > 0xffff || divisor == 0)
return 0;
actual_speed = base_clock / divisor;
diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c
index eac665c85..db80b3ba0 100644
--- a/grub-core/term/serial.c
+++ b/grub-core/term/serial.c
@@ -60,7 +60,7 @@ static const struct grub_arg_option options[] =
{"word", 'w', 0, N_("Set the serial port word length."), 0, ARG_TYPE_INT},
{"parity", 'r', 0, N_("Set the serial port parity."), 0, ARG_TYPE_STRING},
{"stop", 't', 0, N_("Set the serial port stop bits."), 0, ARG_TYPE_INT},
- {"base-clock", 'b', 0, N_("Set the base clock."), 0, ARG_TYPE_STRING},
+ {"base-clock", 'b', 0, N_("Set the base frequency."), 0, ARG_TYPE_STRING},
{"rtscts", 'f', 0, N_("Enable/disable RTS/CTS."), "on|off", ARG_TYPE_STRING},
{0, 0, 0, 0, 0, 0}
};
@@ -220,8 +220,12 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args)
config = port->config;
- if (state[OPTION_SPEED].set)
+ if (state[OPTION_SPEED].set) {
config.speed = grub_strtoul (state[OPTION_SPEED].arg, 0, 0);
+ if (config.speed == 0)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
+ N_("unsupported serial port parity"));
+ }
if (state[OPTION_WORD].set)
config.word_len = grub_strtoul (state[OPTION_WORD].arg, 0, 0);
@@ -241,13 +245,13 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args)
if (state[OPTION_RTSCTS].set)
{
- if (grub_strcmp (state[OPTION_PARITY].arg, "on") == 0)
+ if (grub_strcmp (state[OPTION_RTSCTS].arg, "on") == 0)
config.rtscts = 1;
- if (grub_strcmp (state[OPTION_PARITY].arg, "off") == 0)
+ else if (grub_strcmp (state[OPTION_RTSCTS].arg, "off") == 0)
config.rtscts = 0;
else
return grub_error (GRUB_ERR_BAD_ARGUMENT,
- N_("unsupported serial port flow"));
+ N_("unsupported serial port flow control"));
}
if (state[OPTION_STOP].set)
@@ -275,6 +279,9 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args)
config.base_clock *= 1000;
}
+ if (config.speed == 0)
+ config.speed = 9600;
+
/* Initialize with new settings. */
err = port->driver->configure (port, &config);
if (err)
@@ -338,23 +345,23 @@ grub_serial_register (struct grub_serial_port *port)
grub_free (indata);
return grub_errno;
}
-
- out = grub_malloc (sizeof (*out));
+
+ out = grub_zalloc (sizeof (*out));
if (!out)
{
- grub_free (in);
grub_free (indata);
grub_free ((char *) in->name);
+ grub_free (in);
return grub_errno;
}
outdata = grub_malloc (sizeof (*outdata));
if (!outdata)
{
- grub_free (in);
grub_free (indata);
grub_free ((char *) in->name);
grub_free (out);
+ grub_free (in);
return grub_errno;
}
diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c
index 3d48b198f..f0d3e3deb 100644
--- a/grub-core/term/terminfo.c
+++ b/grub-core/term/terminfo.c
@@ -460,28 +460,31 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
{'@', GRUB_TERM_KEY_INSERT},
};
- static struct
- {
- char key;
- unsigned ascii;
- }
- four_code_table[] =
+ static unsigned four_code_table[] =
{
- {'1', GRUB_TERM_KEY_HOME},
- {'3', GRUB_TERM_KEY_DC},
- {'5', GRUB_TERM_KEY_PPAGE},
- {'6', GRUB_TERM_KEY_NPAGE},
- {'7', GRUB_TERM_KEY_HOME},
- {'8', GRUB_TERM_KEY_END}
+ [1] = GRUB_TERM_KEY_HOME,
+ [3] = GRUB_TERM_KEY_DC,
+ [5] = GRUB_TERM_KEY_PPAGE,
+ [6] = GRUB_TERM_KEY_NPAGE,
+ [7] = GRUB_TERM_KEY_HOME,
+ [8] = GRUB_TERM_KEY_END,
+ [17] = GRUB_TERM_KEY_F6,
+ [18] = GRUB_TERM_KEY_F7,
+ [19] = GRUB_TERM_KEY_F8,
+ [20] = GRUB_TERM_KEY_F9,
+ [21] = GRUB_TERM_KEY_F10,
+ [23] = GRUB_TERM_KEY_F11,
+ [24] = GRUB_TERM_KEY_F12,
};
char fx_key[] =
{ 'P', 'Q', 'w', 'x', 't', 'u',
- 'q', 'r', 'p', 'M', 'A', 'B' };
+ 'q', 'r', 'p', 'M', 'A', 'B', 'H', 'F' };
unsigned fx_code[] =
{ GRUB_TERM_KEY_F1, GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3,
GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, GRUB_TERM_KEY_F6,
GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9,
- GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12 };
+ GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12,
+ GRUB_TERM_KEY_HOME, GRUB_TERM_KEY_END };
unsigned i;
if (c == '\e')
@@ -492,19 +495,13 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
{
CONTINUE_READ;
- switch (c)
- {
- case 'H':
- keys[0] = GRUB_TERM_KEY_HOME;
- *len = 1;
- return;
- case 'F':
- keys[0] = GRUB_TERM_KEY_END;
- *len = 1;
- return;
- default:
- return;
- }
+ for (i = 0; i < ARRAY_SIZE (fx_key); i++)
+ if (fx_key[i] == c)
+ {
+ keys[0] = fx_code[i];
+ *len = 1;
+ return;
+ }
}
if (c != '[')
@@ -523,6 +520,15 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
switch (c)
{
+ case '[':
+ CONTINUE_READ;
+ if (c >= 'A' && c <= 'E')
+ {
+ keys[0] = GRUB_TERM_KEY_F1 + c - 'A';
+ *len = 1;
+ return;
+ }
+ return;
case 'O':
CONTINUE_READ;
for (i = 0; i < ARRAY_SIZE (fx_key); i++)
@@ -555,18 +561,26 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
return;
}
- default:
- for (i = 0; i < ARRAY_SIZE (four_code_table); i++)
- if (four_code_table[i].key == c)
+ case '1' ... '9':
+ {
+ unsigned val = c - '0';
+ CONTINUE_READ;
+ if (c >= '0' && c <= '9')
{
+ val = val * 10 + (c - '0');
CONTINUE_READ;
- if (c != '~')
- return;
- keys[0] = four_code_table[i].ascii;
- *len = 1;
- return;
}
- return;
+ if (c != '~')
+ return;
+ if (val >= ARRAY_SIZE (four_code_table)
+ || four_code_table[val] == 0)
+ return;
+ keys[0] = four_code_table[val];
+ *len = 1;
+ return;
+ }
+ default:
+ return;
}
}
#undef CONTINUE_READ
diff --git a/grub-core/term/tparm.c b/grub-core/term/tparm.c
index fce7dd479..fb5b15a88 100644
--- a/grub-core/term/tparm.c
+++ b/grub-core/term/tparm.c
@@ -158,6 +158,8 @@ get_space(grub_size_t need)
}
}
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static inline void
save_text(const char *fmt, const char *s, int len)
{
@@ -183,6 +185,8 @@ save_number(const char *fmt, int number, int len)
out_used += grub_strlen(out_buff + out_used);
}
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
static inline void
save_char(int c)
{
diff --git a/grub-core/term/usb_keyboard.c b/grub-core/term/usb_keyboard.c
index 3b7484635..e67b8f785 100644
--- a/grub-core/term/usb_keyboard.c
+++ b/grub-core/term/usb_keyboard.c
@@ -19,7 +19,6 @@
#include <grub/term.h>
#include <grub/time.h>
-#include <grub/cpu/io.h>
#include <grub/misc.h>
#include <grub/term.h>
#include <grub/usb.h>
diff --git a/grub-core/tests/boot/kernel-8086.S b/grub-core/tests/boot/kernel-8086.S
index 510897c88..5ec5368ff 100644
--- a/grub-core/tests/boot/kernel-8086.S
+++ b/grub-core/tests/boot/kernel-8086.S
@@ -46,5 +46,5 @@ message:
.ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n"
.byte 0
- . = base + 510
- .short 0xaa55 \ No newline at end of file
+ .org 510
+ .short 0xaa55
diff --git a/grub-core/tests/bswap_test.c b/grub-core/tests/bswap_test.c
new file mode 100644
index 000000000..4eb3a9814
--- /dev/null
+++ b/grub-core/tests/bswap_test.c
@@ -0,0 +1,121 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2015 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/test.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_uint64_t vectors[] = {
+ 0xffffffffffffffffULL, 1, 2, 0, 0x0102030405060708ULL
+};
+
+static void
+test16 (grub_uint16_t a)
+{
+ grub_uint16_t b, c;
+ grub_uint8_t *ap, *bp;
+ int i;
+ b = grub_swap_bytes16 (a);
+ c = grub_swap_bytes16 (b);
+ grub_test_assert (a == c, "bswap not idempotent: 0x%llx, 0x%llx, 0x%llx",
+ (long long) a, (long long) b, (long long) c);
+ ap = (grub_uint8_t *) &a;
+ bp = (grub_uint8_t *) &b;
+ for (i = 0; i < 2; i++)
+ {
+ grub_test_assert (ap[i] == bp[1 - i],
+ "bswap bytes wrong: 0x%llx, 0x%llx",
+ (long long) a, (long long) b);
+ }
+}
+
+static void
+test32 (grub_uint32_t a)
+{
+ grub_uint32_t b, c;
+ grub_uint8_t *ap, *bp;
+ int i;
+ b = grub_swap_bytes32 (a);
+ c = grub_swap_bytes32 (b);
+ grub_test_assert (a == c, "bswap not idempotent: 0x%llx, 0x%llx, 0x%llx",
+ (long long) a, (long long) b, (long long) c);
+ ap = (grub_uint8_t *) &a;
+ bp = (grub_uint8_t *) &b;
+ for (i = 0; i < 4; i++)
+ {
+ grub_test_assert (ap[i] == bp[3 - i],
+ "bswap bytes wrong: 0x%llx, 0x%llx",
+ (long long) a, (long long) b);
+ }
+}
+
+static void
+test64 (grub_uint64_t a)
+{
+ grub_uint64_t b, c;
+ grub_uint8_t *ap, *bp;
+ int i;
+ b = grub_swap_bytes64 (a);
+ c = grub_swap_bytes64 (b);
+ grub_test_assert (a == c, "bswap not idempotent: 0x%llx, 0x%llx, 0x%llx",
+ (long long) a, (long long) b, (long long) c);
+ ap = (grub_uint8_t *) &a;
+ bp = (grub_uint8_t *) &b;
+ for (i = 0; i < 4; i++)
+ {
+ grub_test_assert (ap[i] == bp[7 - i],
+ "bswap bytes wrong: 0x%llx, 0x%llx",
+ (long long) a, (long long) b);
+ }
+}
+
+static void
+test_all(grub_uint64_t a)
+{
+ test64 (a);
+ test32 (a);
+ test16 (a);
+}
+
+static void
+bswap_test (void)
+{
+ grub_uint64_t a = 404, b = 7;
+ grub_size_t i;
+
+ for (i = 0; i < ARRAY_SIZE (vectors); i++)
+ {
+ test_all (vectors[i]);
+ }
+ for (i = 0; i < 40000; i++)
+ {
+ a = 17 * a + 13 * b;
+ b = 23 * a + 29 * b;
+ if (b == 0)
+ b = 1;
+ if (a == 0)
+ a = 1;
+ test_all (a);
+ test_all (b);
+ }
+}
+
+/* Register example_test method as a functional test. */
+GRUB_FUNCTIONAL_TEST (bswap_test, bswap_test);
diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h
index c9807a0dc..2320158d4 100644
--- a/grub-core/tests/checksums.h
+++ b/grub-core/tests/checksums.h
@@ -1,465 +1,129 @@
- { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x7dbff368, 0x7dbff368, 0x5a5bdc8d, 0x5a5bdc8d, 0x79753177, 0x79753177, 0xd01ede5b, 0xd01ede5b, 0x13708a73, 0x13708a73, 0x90186de3, 0x90186de3, 0xe63d02a2, 0xe63d02a2, 0x2c9dc262, 0x2c9dc262, 0x3eebd7b, 0x3eebd7b, 0xe8f3a5d8, 0xe8f3a5d8, 0xd38ecfe3, 0xd38ecfe3, 0x51878485, 0x51878485, 0xcbdb6d67, 0xcbdb6d67, 0xca25582, 0xca25582, 0x5bea0484, 0x5bea0484, 0x9ec5f71d, 0x9ec5f71d, 0x3f0bd7bc, 0x3f0bd7bc, 0xdbb0a5d2, 0xdbb0a5d2, 0xea710e2f, 0xea710e2f, 0xd14933fe, 0xd14933fe, 0x4906b783, 0xffd1d04b, 0xa159bdf9, 0xa159bdf9, }, 45 },
- { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf1546749, 0xf1546749, 0x95d30576, 0x95d30576, 0x77f13935, 0x77f13935, 0xcc296836, 0xcc296836, 0x9af42bc7, 0x9af42bc7, 0x84c23709, 0x84c23709, 0x26b5a3c5, 0x26b5a3c5, 0x52d943fb, 0x52d943fb, 0x38beda82, 0x38beda82, 0xc12306b1, 0xc12306b1, 0xed251115, 0xed251115, 0xe0099a2f, 0xe0099a2f, 0xee929157, 0xee929157, 0xd96a1169, 0xd96a1169, 0x42fac799, 0x42fac799, 0x635af416, 0x635af416, 0x8e90342f, 0x8e90342f, 0xed467cbf, 0xed467cbf, 0x999fc60b, 0x999fc60b, 0xb45d2b1f, 0xb45d2b1f, 0x7e23ccef, 0x8e988beb, 0x8783fdf8, 0x8783fdf8, }, 45 },
- { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x50b82239, 0x50b82239, 0x82c36c12, 0x82c36c12, 0x6311208d, 0x6311208d, 0x816bd4b3, 0x816bd4b3, 0xc9281fd0, 0xc9281fd0, 0x75767bac, 0x75767bac, 0x52edeac, 0x52edeac, 0xfdb551f7, 0xfdb551f7, 0xba21cd3, 0xba21cd3, 0xf2b3468a, 0xf2b3468a, 0xd5560323, 0xd5560323, 0x12c650f6, 0x12c650f6, 0x3d6c5861, 0x3d6c5861, 0x50062423, 0x50062423, 0x2ce22983, 0x2ce22983, 0x4996bc4d, 0x4996bc4d, 0x50450525, 0x50450525, 0xe1c94312, 0xe1c94312, 0x21224aac, 0x21224aac, 0x94cbe214, 0x94cbe214, 0x4578c664, 0x38a9dbd2, 0xa9eb4c48, 0xa9eb4c48, }, 45 },
- { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xbb687653, 0xbb687653, 0xa81427a7, 0xa81427a7, 0x71d7f3b, 0x71d7f3b, 0x25fea6ca, 0x25fea6ca, 0x17c19d74, 0x17c19d74, 0x4779bf48, 0x4779bf48, 0xe424e759, 0xe424e759, 0xb57fb5ae, 0xb57fb5ae, 0xd877002b, 0xd877002b, 0xdd8d7442, 0xdd8d7442, 0xe2536fde, 0xe2536fde, 0x1ebba341, 0x1ebba341, 0xef042176, 0xef042176, 0x6137f228, 0x6137f228, 0xf04a8558, 0xf04a8558, 0xff72172d, 0xff72172d, 0x5f26278f, 0x5f26278f, 0x3ed777c, 0x3ed777c, 0xb1d686e, 0xb1d686e, 0x5cead249, 0x5cead249, 0x271487f6, 0x9b7201b9, 0x6c2f147d, 0x6c2f147d, }, 45 },
- { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x378dc141, 0x378dc141, 0xc7564497, 0xc7564497, 0xd20e9dba, 0xd20e9dba, 0xf84e8efb, 0xf84e8efb, 0x620d984, 0x620d984, 0x509042b4, 0x509042b4, 0x2bf32e11, 0x2bf32e11, 0x7c6fe3a0, 0x7c6fe3a0, 0x18106e6f, 0x18106e6f, 0xba983948, 0xba983948, 0xd85321cc, 0xd85321cc, 0xc22777cd, 0xc22777cd, 0x85b737c8, 0x85b737c8, 0x55590c10, 0x55590c10, 0x371ba701, 0x371ba701, 0x2da6264, 0x2da6264, 0x77c1ff46, 0x77c1ff46, 0xf2485577, 0xf2485577, 0x93e9eeeb, 0x93e9eeeb, 0x1460059, 0x1460059, 0xfbbbaa1, 0xa03c490a, 0x234dcb08, 0x234dcb08, }, 45 },
- { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd803b53b, 0xd803b53b, 0x70b7ae8b, 0x70b7ae8b, 0xa20d9a15, 0xa20d9a15, 0x6113d33b, 0x6113d33b, 0xfd38d301, 0xfd38d301, 0x8b04db4, 0x8b04db4, 0xdae859df, 0xdae859df, 0x80cf138b, 0x80cf138b, 0xdfa6ef9, 0xdfa6ef9, 0x856adaf0, 0x856adaf0, 0x7023cc2d, 0x7023cc2d, 0xad7e7d54, 0xad7e7d54, 0xde8eff49, 0xde8eff49, 0x34355cc3, 0x34355cc3, 0x25adccda, 0x25adccda, 0x6d6c350d, 0x6d6c350d, 0x1c49b499, 0x1c49b499, 0x8188f1b4, 0x8188f1b4, 0x5556dc0c, 0x5556dc0c, 0xbd9ef1f5, 0xbd9ef1f5, 0x5176575b, 0x19da9ee1, 0x6e2f07c, 0x6e2f07c, }, 45 },
- { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xed7d2809, 0xed7d2809, 0x52c14224, 0x52c14224, 0xec52d912, 0xec52d912, 0x63276ae2, 0x63276ae2, 0xeeb4bfa4, 0xeeb4bfa4, 0xdf0f1ff0, 0xdf0f1ff0, 0xe2021708, 0xe2021708, 0x67c17085, 0x67c17085, 0x646e4d78, 0x646e4d78, 0x3b15f4b6, 0x3b15f4b6, 0xf4945ac5, 0xf4945ac5, 0x6cf60c00, 0x6cf60c00, 0x126648cd, 0x126648cd, 0xe7b8e348, 0xe7b8e348, 0x1626e35f, 0x1626e35f, 0x8022976c, 0x8022976c, 0xbc7e6d22, 0xbc7e6d22, 0xa2d50ad6, 0xa2d50ad6, 0x5072fea, 0x5072fea, 0x8481a563, 0x8481a563, 0x60a95143, 0x12fda168, 0xc8fe0549, 0xc8fe0549, }, 45 },
- { "cmdline_cat", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x7dbff368, 0x7dbff368, 0x5a5bdc8d, 0x5a5bdc8d, 0x79753177, 0x79753177, 0xd01ede5b, 0xd01ede5b, 0x13708a73, 0x13708a73, 0x90186de3, 0x90186de3, 0xe63d02a2, 0xe63d02a2, 0x2c9dc262, 0x2c9dc262, 0x3eebd7b, 0x3eebd7b, 0xe8f3a5d8, 0xe8f3a5d8, 0xd38ecfe3, 0xd38ecfe3, 0x51878485, 0x51878485, 0xcbdb6d67, 0xcbdb6d67, 0xca25582, 0xca25582, 0x5bea0484, 0x5bea0484, 0x9ec5f71d, 0x9ec5f71d, 0x3f0bd7bc, 0x3f0bd7bc, 0xdbb0a5d2, 0xdbb0a5d2, 0xea710e2f, 0xea710e2f, 0xd14933fe, 0xd14933fe, 0x4906b783, 0xffd1d04b, 0xa159bdf9, 0xa159bdf9, }, 45 },
- { "cmdline_cat", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0xf1546749, 0xf1546749, 0x95d30576, 0x95d30576, 0x77f13935, 0x77f13935, 0xcc296836, 0xcc296836, 0x9af42bc7, 0x9af42bc7, 0x84c23709, 0x84c23709, 0x26b5a3c5, 0x26b5a3c5, 0x52d943fb, 0x52d943fb, 0x38beda82, 0x38beda82, 0xc12306b1, 0xc12306b1, 0xed251115, 0xed251115, 0xe0099a2f, 0xe0099a2f, 0xee929157, 0xee929157, 0xd96a1169, 0xd96a1169, 0x42fac799, 0x42fac799, 0x635af416, 0x635af416, 0x8e90342f, 0x8e90342f, 0xed467cbf, 0xed467cbf, 0x999fc60b, 0x999fc60b, 0xb45d2b1f, 0xb45d2b1f, 0x7e23ccef, 0x8e988beb, 0x8783fdf8, 0x8783fdf8, }, 45 },
- { "cmdline_cat", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x50b82239, 0x50b82239, 0x82c36c12, 0x82c36c12, 0x6311208d, 0x6311208d, 0x816bd4b3, 0x816bd4b3, 0xc9281fd0, 0xc9281fd0, 0x75767bac, 0x75767bac, 0x52edeac, 0x52edeac, 0xfdb551f7, 0xfdb551f7, 0xba21cd3, 0xba21cd3, 0xf2b3468a, 0xf2b3468a, 0xd5560323, 0xd5560323, 0x12c650f6, 0x12c650f6, 0x3d6c5861, 0x3d6c5861, 0x50062423, 0x50062423, 0x2ce22983, 0x2ce22983, 0x4996bc4d, 0x4996bc4d, 0x50450525, 0x50450525, 0xe1c94312, 0xe1c94312, 0x21224aac, 0x21224aac, 0x94cbe214, 0x94cbe214, 0x4578c664, 0x38a9dbd2, 0xa9eb4c48, 0xa9eb4c48, }, 45 },
- { "cmdline_cat", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0x93fbd3a3, 0x93fbd3a3, 0x1617bee0, 0x1617bee0, 0x4bfbae7f, 0x4bfbae7f, 0xa3558248, 0xa3558248, 0xaf468a11, 0xaf468a11, 0x68ac5986, 0x68ac5986, 0xd8065600, 0xd8065600, 0xef6c6222, 0xef6c6222, 0x1a04371, 0x1a04371, 0xc92981b6, 0xc92981b6, 0x53f9bfc8, 0x53f9bfc8, 0xfef01300, 0xfef01300, 0xce753805, 0xce753805, 0x858f6540, 0x858f6540, 0x6429dae4, 0x6429dae4, 0x19222aa5, 0x19222aa5, 0x3f9a0303, 0x3f9a0303, 0x978a47da, 0x978a47da, 0x6bf7f199, 0x6bf7f199, 0x97dab6d, 0x97dab6d, 0xeb643dbd, 0x9fe6a006, 0x2b7a0b5b, 0x2b7a0b5b, }, 45 },
- { "cmdline_cat", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xe8381636, 0xe8381636, 0x977b32f5, 0x977b32f5, 0x54bb62c1, 0x54bb62c1, 0xe26211f2, 0xe26211f2, 0xb0d0aca3, 0xb0d0aca3, 0x8d1f7491, 0x8d1f7491, 0x261a3820, 0x261a3820, 0x571c16d3, 0x571c16d3, 0xdc5fb880, 0xdc5fb880, 0xc8b086fe, 0xc8b086fe, 0x55b07770, 0x55b07770, 0x1d5e160, 0x1d5e160, 0x5e5dddc8, 0x5e5dddc8, 0xceeaa332, 0xceeaa332, 0x81c9d3f3, 0x81c9d3f3, 0xa6bbab67, 0xa6bbab67, 0x9366a264, 0x9366a264, 0x4bcbc84c, 0x4bcbc84c, 0x8aacda73, 0x8aacda73, 0x356159d0, 0x356159d0, 0x74872545, 0x5a28a86f, 0x3a1f5494, 0x3a1f5494, }, 45 },
- { "cmdline_cat", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xccbd401, 0xccbd401, 0x35859629, 0x35859629, 0x269f013b, 0x269f013b, 0xe8c8196, 0xe8c8196, 0x95e2849c, 0x95e2849c, 0xb2019543, 0xb2019543, 0xf739b6c9, 0xf739b6c9, 0xd8227519, 0xd8227519, 0x6b1ae8cf, 0x6b1ae8cf, 0x84fbe9b2, 0x84fbe9b2, 0xed69a305, 0xed69a305, 0x15f4f0cf, 0x15f4f0cf, 0x57ce0973, 0x57ce0973, 0x3f5b0b97, 0x3f5b0b97, 0xc3e87bef, 0xc3e87bef, 0x3ac7584b, 0x3ac7584b, 0xdb95f2c7, 0xdb95f2c7, 0xc1942d4c, 0xc1942d4c, 0x17e9634e, 0x17e9634e, 0xd8dd41a3, 0xd8dd41a3, 0x927a8a2f, 0x339d3240, 0x398e6a2a, 0x398e6a2a, }, 45 },
- { "cmdline_cat", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xa06498a0, 0xa06498a0, 0xd1336ad7, 0xd1336ad7, 0x68c888e0, 0x68c888e0, 0xf01fb74, 0xf01fb74, 0x6b743235, 0x6b743235, 0xe7b71a49, 0xe7b71a49, 0x798da4d7, 0x798da4d7, 0x5398f44b, 0x5398f44b, 0x4794ee5e, 0x4794ee5e, 0x61c2cb0d, 0x61c2cb0d, 0xad3fcef3, 0xad3fcef3, 0xd9b6f291, 0xd9b6f291, 0xbaf0962d, 0xbaf0962d, 0x11848b9e, 0x11848b9e, 0xb8f3d2bf, 0xb8f3d2bf, 0x3f9978, 0x3f9978, 0xafd76c24, 0xafd76c24, 0xee0b9b9e, 0xee0b9b9e, 0x1f80451e, 0x1f80451e, 0x817e030a, 0x817e030a, 0x64ee9a5d, 0x1d187aed, 0xb2c05a4a, 0xb2c05a4a, }, 45 },
- { "cmdline_cat", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x95c83b7d, 0x95c83b7d, 0xb8cac2b5, 0xb8cac2b5, 0xf0ef977f, 0xf0ef977f, 0xc4640770, 0xc4640770, 0x8ea8595e, 0x8ea8595e, 0xc7d26302, 0xc7d26302, 0x6f756fbc, 0x6f756fbc, 0x68bc6258, 0x68bc6258, 0xe77cff10, 0xe77cff10, 0x835ae8e5, 0x835ae8e5, 0x622cfc05, 0x622cfc05, 0xe192499f, 0xe192499f, 0x3b976218, 0x3b976218, 0xe2dcd75, 0xe2dcd75, 0xed05eae8, 0xed05eae8, 0xc0b8ee9a, 0xc0b8ee9a, 0x255ec66a, 0x255ec66a, 0x3391d9b6, 0x3391d9b6, 0x779834b3, 0x779834b3, 0xdf77a37f, 0xdf77a37f, 0xd3cc8a1d, 0xfec30b6e, 0x884fa360, 0x884fa360, }, 45 },
- { "cmdline_cat", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x698515fa, 0x698515fa, 0xc313ebe6, 0xc313ebe6, 0x32b9228f, 0x32b9228f, 0xa58d78e8, 0xa58d78e8, 0xf41d5153, 0xf41d5153, 0xdfa3af16, 0xdfa3af16, 0xd4a68422, 0xd4a68422, 0xa7ea67e0, 0xa7ea67e0, 0xaee4c8f6, 0xaee4c8f6, 0x78ddd8aa, 0x78ddd8aa, 0xe662b827, 0xe662b827, 0x190ab892, 0x190ab892, 0x7c1e04ab, 0x7c1e04ab, 0xae4e2ed2, 0xae4e2ed2, 0x9ac52f8d, 0x9ac52f8d, 0x7e7b6776, 0x7e7b6776, 0x21c37700, 0x21c37700, 0x4fc11e7c, 0x4fc11e7c, 0x612a17d, 0x612a17d, 0x1f549440, 0x1f549440, 0xd6ce5af0, 0x2751d45f, 0x41e24797, 0x41e24797, }, 45 },
- { "cmdline_cat", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x7a06e04b, 0x7a06e04b, 0x122f59ab, 0x122f59ab, 0x993a50b9, 0x993a50b9, 0x5545f8f, 0x5545f8f, 0xcdd2b587, 0xcdd2b587, 0x18bec138, 0x18bec138, 0xa9b4345d, 0xa9b4345d, 0x92c6eb1c, 0x92c6eb1c, 0x2aa44d63, 0x2aa44d63, 0xc9e7b549, 0xc9e7b549, 0x24732d85, 0x24732d85, 0xeedce06, 0xeedce06, 0x69a732a1, 0x69a732a1, 0xc53906e5, 0xc53906e5, 0x306e0f4b, 0x306e0f4b, 0x895e6f09, 0x895e6f09, 0x27f1c24e, 0x27f1c24e, 0x76a2b606, 0x76a2b606, 0x9fdd1ff3, 0x9fdd1ff3, 0x408d0a19, 0x408d0a19, 0xc9b3f877, 0xce19a637, 0x8cfd7321, 0x8cfd7321, }, 45 },
- { "cmdline_cat", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x9fa21cbe, 0x9fa21cbe, 0xa9ad84e6, 0xa9ad84e6, 0x4f4ccbc, 0x4f4ccbc, 0x6a4f5fda, 0x6a4f5fda, 0x4d4ccb50, 0x4d4ccb50, 0xb854236c, 0xb854236c, 0x990a5b4a, 0x990a5b4a, 0xa9dba8c8, 0xa9dba8c8, 0xe12b4ca1, 0xe12b4ca1, 0x4200ebc0, 0x4200ebc0, 0x86a931cf, 0x86a931cf, 0xda3a178, 0xda3a178, 0x2739917d, 0x2739917d, 0x48005e41, 0x48005e41, 0x550a94ac, 0x550a94ac, 0x73f363b6, 0x73f363b6, 0x4811082a, 0x4811082a, 0xdc025f10, 0xdc025f10, 0x4f18937e, 0x4f18937e, 0xa3749fd8, 0xa3749fd8, 0x93ce5c0b, 0xdddd4de6, 0x97f43654, 0x97f43654, }, 45 },
- { "cmdline_cat", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x7d9b5dd7, 0x7d9b5dd7, 0x42e1176a, 0x42e1176a, 0x7e2da576, 0x7e2da576, 0xd5a8afa, 0xd5a8afa, 0x3eb2146b, 0x3eb2146b, 0x60d9b3, 0x60d9b3, 0xb893f5ca, 0xb893f5ca, 0xd431b2bf, 0xd431b2bf, 0x8ea1b6a6, 0x8ea1b6a6, 0x4d730ad0, 0x4d730ad0, 0x28d1888b, 0x28d1888b, 0x6d8c3672, 0x6d8c3672, 0x65dec2dd, 0x65dec2dd, 0x9d7c6d99, 0x9d7c6d99, 0xdfcd1eba, 0xdfcd1eba, 0xed4fb650, 0xed4fb650, 0xd9f1574c, 0xd9f1574c, 0x2b05a17e, 0x2b05a17e, 0x64e652f5, 0x64e652f5, 0x5f83fdb1, 0x5f83fdb1, 0x7918b180, 0xf54e3c4a, 0xe26cf2de, 0xe26cf2de, }, 45 },
- { "cmdline_cat", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x93fbd3a3, 0x93fbd3a3, 0x1617bee0, 0x1617bee0, 0x4bfbae7f, 0x4bfbae7f, 0xa3558248, 0xa3558248, 0xaf468a11, 0xaf468a11, 0x68ac5986, 0x68ac5986, 0xd8065600, 0xd8065600, 0xef6c6222, 0xef6c6222, 0x1a04371, 0x1a04371, 0xc92981b6, 0xc92981b6, 0x53f9bfc8, 0x53f9bfc8, 0xfef01300, 0xfef01300, 0xce753805, 0xce753805, 0x858f6540, 0x858f6540, 0x6429dae4, 0x6429dae4, 0x19222aa5, 0x19222aa5, 0x3f9a0303, 0x3f9a0303, 0x978a47da, 0x978a47da, 0x6bf7f199, 0x6bf7f199, 0x97dab6d, 0x97dab6d, 0xeb643dbd, 0x9fe6a006, 0x2b7a0b5b, 0x2b7a0b5b, }, 45 },
- { "cmdline_cat", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xe8381636, 0xe8381636, 0x977b32f5, 0x977b32f5, 0x54bb62c1, 0x54bb62c1, 0xe26211f2, 0xe26211f2, 0xb0d0aca3, 0xb0d0aca3, 0x8d1f7491, 0x8d1f7491, 0x261a3820, 0x261a3820, 0x571c16d3, 0x571c16d3, 0xdc5fb880, 0xdc5fb880, 0xc8b086fe, 0xc8b086fe, 0x55b07770, 0x55b07770, 0x1d5e160, 0x1d5e160, 0x5e5dddc8, 0x5e5dddc8, 0xceeaa332, 0xceeaa332, 0x81c9d3f3, 0x81c9d3f3, 0xa6bbab67, 0xa6bbab67, 0x9366a264, 0x9366a264, 0x4bcbc84c, 0x4bcbc84c, 0x8aacda73, 0x8aacda73, 0x356159d0, 0x356159d0, 0x74872545, 0x5a28a86f, 0x3a1f5494, 0x3a1f5494, }, 45 },
- { "cmdline_cat", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xccbd401, 0xccbd401, 0x35859629, 0x35859629, 0x269f013b, 0x269f013b, 0xe8c8196, 0xe8c8196, 0x95e2849c, 0x95e2849c, 0xb2019543, 0xb2019543, 0xf739b6c9, 0xf739b6c9, 0xd8227519, 0xd8227519, 0x6b1ae8cf, 0x6b1ae8cf, 0x84fbe9b2, 0x84fbe9b2, 0xed69a305, 0xed69a305, 0x15f4f0cf, 0x15f4f0cf, 0x57ce0973, 0x57ce0973, 0x3f5b0b97, 0x3f5b0b97, 0xc3e87bef, 0xc3e87bef, 0x3ac7584b, 0x3ac7584b, 0xdb95f2c7, 0xdb95f2c7, 0xc1942d4c, 0xc1942d4c, 0x17e9634e, 0x17e9634e, 0xd8dd41a3, 0xd8dd41a3, 0x927a8a2f, 0x339d3240, 0x398e6a2a, 0x398e6a2a, }, 45 },
- { "cmdline_cat", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xa06498a0, 0xa06498a0, 0xd1336ad7, 0xd1336ad7, 0x68c888e0, 0x68c888e0, 0xf01fb74, 0xf01fb74, 0x6b743235, 0x6b743235, 0xe7b71a49, 0xe7b71a49, 0x798da4d7, 0x798da4d7, 0x5398f44b, 0x5398f44b, 0x4794ee5e, 0x4794ee5e, 0x61c2cb0d, 0x61c2cb0d, 0xad3fcef3, 0xad3fcef3, 0xd9b6f291, 0xd9b6f291, 0xbaf0962d, 0xbaf0962d, 0x11848b9e, 0x11848b9e, 0xb8f3d2bf, 0xb8f3d2bf, 0x3f9978, 0x3f9978, 0xafd76c24, 0xafd76c24, 0xee0b9b9e, 0xee0b9b9e, 0x1f80451e, 0x1f80451e, 0x817e030a, 0x817e030a, 0x64ee9a5d, 0x1d187aed, 0xb2c05a4a, 0xb2c05a4a, }, 45 },
- { "cmdline_cat", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x95c83b7d, 0x95c83b7d, 0xb8cac2b5, 0xb8cac2b5, 0xf0ef977f, 0xf0ef977f, 0xc4640770, 0xc4640770, 0x8ea8595e, 0x8ea8595e, 0xc7d26302, 0xc7d26302, 0x6f756fbc, 0x6f756fbc, 0x68bc6258, 0x68bc6258, 0xe77cff10, 0xe77cff10, 0x835ae8e5, 0x835ae8e5, 0x622cfc05, 0x622cfc05, 0xe192499f, 0xe192499f, 0x3b976218, 0x3b976218, 0xe2dcd75, 0xe2dcd75, 0xed05eae8, 0xed05eae8, 0xc0b8ee9a, 0xc0b8ee9a, 0x255ec66a, 0x255ec66a, 0x3391d9b6, 0x3391d9b6, 0x779834b3, 0x779834b3, 0xdf77a37f, 0xdf77a37f, 0xd3cc8a1d, 0xfec30b6e, 0x884fa360, 0x884fa360, }, 45 },
- { "cmdline_cat", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x698515fa, 0x698515fa, 0xc313ebe6, 0xc313ebe6, 0x32b9228f, 0x32b9228f, 0xa58d78e8, 0xa58d78e8, 0xf41d5153, 0xf41d5153, 0xdfa3af16, 0xdfa3af16, 0xd4a68422, 0xd4a68422, 0xa7ea67e0, 0xa7ea67e0, 0xaee4c8f6, 0xaee4c8f6, 0x78ddd8aa, 0x78ddd8aa, 0xe662b827, 0xe662b827, 0x190ab892, 0x190ab892, 0x7c1e04ab, 0x7c1e04ab, 0xae4e2ed2, 0xae4e2ed2, 0x9ac52f8d, 0x9ac52f8d, 0x7e7b6776, 0x7e7b6776, 0x21c37700, 0x21c37700, 0x4fc11e7c, 0x4fc11e7c, 0x612a17d, 0x612a17d, 0x1f549440, 0x1f549440, 0xd6ce5af0, 0x2751d45f, 0x41e24797, 0x41e24797, }, 45 },
- { "cmdline_cat", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x7a06e04b, 0x7a06e04b, 0x122f59ab, 0x122f59ab, 0x993a50b9, 0x993a50b9, 0x5545f8f, 0x5545f8f, 0xcdd2b587, 0xcdd2b587, 0x18bec138, 0x18bec138, 0xa9b4345d, 0xa9b4345d, 0x92c6eb1c, 0x92c6eb1c, 0x2aa44d63, 0x2aa44d63, 0xc9e7b549, 0xc9e7b549, 0x24732d85, 0x24732d85, 0xeedce06, 0xeedce06, 0x69a732a1, 0x69a732a1, 0xc53906e5, 0xc53906e5, 0x306e0f4b, 0x306e0f4b, 0x895e6f09, 0x895e6f09, 0x27f1c24e, 0x27f1c24e, 0x76a2b606, 0x76a2b606, 0x9fdd1ff3, 0x9fdd1ff3, 0x408d0a19, 0x408d0a19, 0xc9b3f877, 0xce19a637, 0x8cfd7321, 0x8cfd7321, }, 45 },
- { "cmdline_cat", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x9fa21cbe, 0x9fa21cbe, 0xa9ad84e6, 0xa9ad84e6, 0x4f4ccbc, 0x4f4ccbc, 0x6a4f5fda, 0x6a4f5fda, 0x4d4ccb50, 0x4d4ccb50, 0xb854236c, 0xb854236c, 0x990a5b4a, 0x990a5b4a, 0xa9dba8c8, 0xa9dba8c8, 0xe12b4ca1, 0xe12b4ca1, 0x4200ebc0, 0x4200ebc0, 0x86a931cf, 0x86a931cf, 0xda3a178, 0xda3a178, 0x2739917d, 0x2739917d, 0x48005e41, 0x48005e41, 0x550a94ac, 0x550a94ac, 0x73f363b6, 0x73f363b6, 0x4811082a, 0x4811082a, 0xdc025f10, 0xdc025f10, 0x4f18937e, 0x4f18937e, 0xa3749fd8, 0xa3749fd8, 0x93ce5c0b, 0xdddd4de6, 0x97f43654, 0x97f43654, }, 45 },
- { "cmdline_cat", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x7d9b5dd7, 0x7d9b5dd7, 0x42e1176a, 0x42e1176a, 0x7e2da576, 0x7e2da576, 0xd5a8afa, 0xd5a8afa, 0x3eb2146b, 0x3eb2146b, 0x60d9b3, 0x60d9b3, 0xb893f5ca, 0xb893f5ca, 0xd431b2bf, 0xd431b2bf, 0x8ea1b6a6, 0x8ea1b6a6, 0x4d730ad0, 0x4d730ad0, 0x28d1888b, 0x28d1888b, 0x6d8c3672, 0x6d8c3672, 0x65dec2dd, 0x65dec2dd, 0x9d7c6d99, 0x9d7c6d99, 0xdfcd1eba, 0xdfcd1eba, 0xed4fb650, 0xed4fb650, 0xd9f1574c, 0xd9f1574c, 0x2b05a17e, 0x2b05a17e, 0x64e652f5, 0x64e652f5, 0x5f83fdb1, 0x5f83fdb1, 0x7918b180, 0xf54e3c4a, 0xe26cf2de, 0xe26cf2de, }, 45 },
- { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xbb687653, 0xbb687653, 0xa81427a7, 0xa81427a7, 0x71d7f3b, 0x71d7f3b, 0x25fea6ca, 0x25fea6ca, 0x17c19d74, 0x17c19d74, 0x4779bf48, 0x4779bf48, 0xe424e759, 0xe424e759, 0xb57fb5ae, 0xb57fb5ae, 0xd877002b, 0xd877002b, 0xdd8d7442, 0xdd8d7442, 0xe2536fde, 0xe2536fde, 0x1ebba341, 0x1ebba341, 0xef042176, 0xef042176, 0x6137f228, 0x6137f228, 0xf04a8558, 0xf04a8558, 0xff72172d, 0xff72172d, 0x5f26278f, 0x5f26278f, 0x3ed777c, 0x3ed777c, 0xb1d686e, 0xb1d686e, 0x5cead249, 0x5cead249, 0x271487f6, 0x9b7201b9, 0x6c2f147d, 0x6c2f147d, }, 45 },
- { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x378dc141, 0x378dc141, 0xc7564497, 0xc7564497, 0xd20e9dba, 0xd20e9dba, 0xf84e8efb, 0xf84e8efb, 0x620d984, 0x620d984, 0x509042b4, 0x509042b4, 0x2bf32e11, 0x2bf32e11, 0x7c6fe3a0, 0x7c6fe3a0, 0x18106e6f, 0x18106e6f, 0xba983948, 0xba983948, 0xd85321cc, 0xd85321cc, 0xc22777cd, 0xc22777cd, 0x85b737c8, 0x85b737c8, 0x55590c10, 0x55590c10, 0x371ba701, 0x371ba701, 0x2da6264, 0x2da6264, 0x77c1ff46, 0x77c1ff46, 0xf2485577, 0xf2485577, 0x93e9eeeb, 0x93e9eeeb, 0x1460059, 0x1460059, 0xfbbbaa1, 0xa03c490a, 0x234dcb08, 0x234dcb08, }, 45 },
- { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd803b53b, 0xd803b53b, 0x70b7ae8b, 0x70b7ae8b, 0xa20d9a15, 0xa20d9a15, 0x6113d33b, 0x6113d33b, 0xfd38d301, 0xfd38d301, 0x8b04db4, 0x8b04db4, 0xdae859df, 0xdae859df, 0x80cf138b, 0x80cf138b, 0xdfa6ef9, 0xdfa6ef9, 0x856adaf0, 0x856adaf0, 0x7023cc2d, 0x7023cc2d, 0xad7e7d54, 0xad7e7d54, 0xde8eff49, 0xde8eff49, 0x34355cc3, 0x34355cc3, 0x25adccda, 0x25adccda, 0x6d6c350d, 0x6d6c350d, 0x1c49b499, 0x1c49b499, 0x8188f1b4, 0x8188f1b4, 0x5556dc0c, 0x5556dc0c, 0xbd9ef1f5, 0xbd9ef1f5, 0x5176575b, 0x19da9ee1, 0x6e2f07c, 0x6e2f07c, }, 45 },
- { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xc5faf369, 0x64eb297a, 0xc5faf369, 0x860c3e2e, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x860c3e2e, 0x860c3e2e, 0x59c36f00, }, 20 },
- { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd50b0276, 0x23b87c98, 0xd50b0276, 0xfb0e8709, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0xfb0e8709, 0xfb0e8709, 0xaa4593fe, }, 20 },
- { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x353bd15d, 0x79836ff2, 0x353bd15d, 0x682cbcd9, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0x682cbcd9, 0x682cbcd9, 0xc9cbf769, }, 20 },
- { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x22bcc2fc, 0xc6c23ab4, 0x22bcc2fc, 0x72a46652, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0x72a46652, 0x72a46652, 0x9813a416, }, 20 },
- { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x3afb9165, 0x767dd6a7, 0x3afb9165, 0x31409f, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x31409f, 0x31409f, 0x5fcf013d, }, 20 },
- { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe13f0039, 0xb5783cd1, 0xe13f0039, 0x814ca453, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x814ca453, 0x814ca453, 0xdd28f52b, }, 20 },
- { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x154ac813, 0x5c191673, 0x154ac813, 0xeb0cc57e, 0x43d1f34, 0x43d1f34, 0xd204ac75, 0xd204ac75, 0xd204ac75, 0xad0e05dd, 0xad0e05dd, 0xad0e05dd, 0x452e3cf4, 0x452e3cf4, 0x452e3cf4, 0x43d1f34, 0xeb0cc57e, 0xeb0cc57e, 0x43d1f34, }, 20 },
- { "gfxterm_menu", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xc5faf369, 0x64eb297a, 0xc5faf369, 0x860c3e2e, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x860c3e2e, 0x860c3e2e, 0x59c36f00, }, 20 },
- { "gfxterm_menu", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0xd50b0276, 0x23b87c98, 0xd50b0276, 0xfb0e8709, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0xfb0e8709, 0xfb0e8709, 0xaa4593fe, }, 20 },
- { "gfxterm_menu", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x353bd15d, 0x79836ff2, 0x353bd15d, 0x682cbcd9, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0x682cbcd9, 0x682cbcd9, 0xc9cbf769, }, 20 },
- { "gfxterm_menu", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe967dfb6, 0x7fedccee, 0xe967dfb6, 0xad6c250a, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0xad6c250a, 0xad6c250a, 0x5387d57f, }, 20 },
- { "gfxterm_menu", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x985bd9b5, 0xd5604814, 0x985bd9b5, 0x2233942a, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x2233942a, 0x2233942a, 0xf83ee7aa, }, 20 },
- { "gfxterm_menu", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x928c0a8e, 0xd25dcf03, 0x928c0a8e, 0x83f9bfdb, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x83f9bfdb, 0x83f9bfdb, 0x724366e5, }, 20 },
- { "gfxterm_menu", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x116c0258, 0xed7d4786, 0x116c0258, 0xfef8bf61, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0xfef8bf61, 0xfef8bf61, 0x5387d57f, }, 20 },
- { "gfxterm_menu", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xd49b1c35, 0x37f70b09, 0xd49b1c35, 0xa55122d9, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xa55122d9, 0xa55122d9, 0xf83ee7aa, }, 20 },
- { "gfxterm_menu", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x2b3f0273, 0x6da0f134, 0x2b3f0273, 0xd9ed8903, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0xd9ed8903, 0xd9ed8903, 0x724366e5, }, 20 },
- { "gfxterm_menu", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x1e6b0284, 0x18f0ad39, 0x1e6b0284, 0x1e0bba22, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0x1e0bba22, 0x1e0bba22, 0x1c955882, }, 20 },
- { "gfxterm_menu", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x1f279ca1, 0x976cb6e3, 0x1f279ca1, 0xdb3505a5, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0xdb3505a5, 0xdb3505a5, 0x4d266f7a, }, 20 },
- { "gfxterm_menu", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x21235dde, 0x13b8b442, 0x21235dde, 0xbdd75c39, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0xbdd75c39, 0xbdd75c39, 0x1ed9d731, }, 20 },
- { "gfxterm_menu", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe967dfb6, 0x7fedccee, 0xe967dfb6, 0xad6c250a, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0xad6c250a, 0xad6c250a, 0x5387d57f, }, 20 },
- { "gfxterm_menu", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x985bd9b5, 0xd5604814, 0x985bd9b5, 0x2233942a, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x2233942a, 0x2233942a, 0xf83ee7aa, }, 20 },
- { "gfxterm_menu", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x928c0a8e, 0xd25dcf03, 0x928c0a8e, 0x83f9bfdb, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x83f9bfdb, 0x83f9bfdb, 0x724366e5, }, 20 },
- { "gfxterm_menu", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x116c0258, 0xed7d4786, 0x116c0258, 0xfef8bf61, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0xfef8bf61, 0xfef8bf61, 0x5387d57f, }, 20 },
- { "gfxterm_menu", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xd49b1c35, 0x37f70b09, 0xd49b1c35, 0xa55122d9, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xa55122d9, 0xa55122d9, 0xf83ee7aa, }, 20 },
- { "gfxterm_menu", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x2b3f0273, 0x6da0f134, 0x2b3f0273, 0xd9ed8903, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0xd9ed8903, 0xd9ed8903, 0x724366e5, }, 20 },
- { "gfxterm_menu", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x1e6b0284, 0x18f0ad39, 0x1e6b0284, 0x1e0bba22, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0x1e0bba22, 0x1e0bba22, 0x1c955882, }, 20 },
- { "gfxterm_menu", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x1f279ca1, 0x976cb6e3, 0x1f279ca1, 0xdb3505a5, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0xdb3505a5, 0xdb3505a5, 0x4d266f7a, }, 20 },
- { "gfxterm_menu", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x21235dde, 0x13b8b442, 0x21235dde, 0xbdd75c39, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0xbdd75c39, 0xbdd75c39, 0x1ed9d731, }, 20 },
- { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x22bcc2fc, 0xc6c23ab4, 0x22bcc2fc, 0x72a46652, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0x72a46652, 0x72a46652, 0x9813a416, }, 20 },
- { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x3afb9165, 0x767dd6a7, 0x3afb9165, 0x31409f, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x31409f, 0x31409f, 0x5fcf013d, }, 20 },
- { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe13f0039, 0xb5783cd1, 0xe13f0039, 0x814ca453, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x814ca453, 0x814ca453, 0xdd28f52b, }, 20 },
- { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x28e6b07d, 0xf54b3d6a, 0x28e6b07d, 0x7d0bdbfb, 0x9a2e0d26, 0xb22b0963, 0xb22b0963, 0xb22b0963, 0xeef3ffa3, 0xeef3ffa3, 0xeef3ffa3, 0x36f73b6, 0x36f73b6, 0x36f73b6, 0x59c36f00, 0x7d0bdbfb, 0x7d0bdbfb, }, 18 },
- { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x15bb581c, 0x7da084c6, 0x15bb581c, 0xcedba42f, 0xbc06c96d, 0xb3a8a15b, 0xb3a8a15b, 0xb3a8a15b, 0xe6f70b51, 0xe6f70b51, 0xe6f70b51, 0x8ce38109, 0x8ce38109, 0x8ce38109, 0xaa4593fe, 0xcedba42f, 0xcedba42f, }, 18 },
- { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x817e5fe2, 0x134e87ff, 0x817e5fe2, 0xb83ddd98, 0xdcd8c986, 0x79244533, 0x79244533, 0x79244533, 0x69ae3a7, 0x69ae3a7, 0x69ae3a7, 0xfc10b74f, 0xfc10b74f, 0xfc10b74f, 0xc9cbf769, 0xb83ddd98, 0xb83ddd98, }, 18 },
- { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0x95048302, 0x9f5bac7c, 0x95048302, 0x28413b7c, 0x740d78cf, 0x620e8524, 0x620e8524, 0x620e8524, 0x89ab6f58, 0x89ab6f58, 0x89ab6f58, 0x90218e3d, 0x90218e3d, 0x90218e3d, 0x1c3742c9, 0x28413b7c, 0x28413b7c, }, 18 },
- { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x6cf38a7e, 0x35fcd6e8, 0x6cf38a7e, 0x618c203c, 0xe925e70d, 0xff9c8a81, 0xff9c8a81, 0xff9c8a81, 0x90d55690, 0x90d55690, 0x90d55690, 0xd3df13a0, 0xd3df13a0, 0xd3df13a0, 0xcc5a7bed, 0x618c203c, 0x618c203c, }, 18 },
- { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xd610d630, 0x98774981, 0xd610d630, 0x4469957c, 0x9869130b, 0xfb592a0d, 0xfb592a0d, 0xfb592a0d, 0x3deb6e13, 0x3deb6e13, 0x3deb6e13, 0xeaf96ec4, 0xeaf96ec4, 0xeaf96ec4, 0xef4a3312, 0x4469957c, 0x4469957c, }, 18 },
- { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0xf5c7a904, 0xaf9e8139, 0xf5c7a904, 0xf108ef6b, 0x91c7d0fe, 0xb57ab567, 0xb57ab567, 0xb57ab567, 0x348943b6, 0x348943b6, 0x348943b6, 0x9b076791, 0x9b076791, 0x9b076791, 0x54e48d80, 0xf108ef6b, 0xf108ef6b, }, 18 },
- { "gfxmenu", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xff8ab96b, 0x72a93e7f, 0xff8ab96b, 0x47d54a82, 0x42b837cf, 0x6abd338a, 0x6abd338a, 0x6abd338a, 0x3665c54a, 0x3665c54a, 0x3665c54a, 0xdbf9495f, 0xdbf9495f, 0xdbf9495f, 0x59c36f00, 0x47d54a82, 0x47d54a82, }, 18 },
- { "gfxmenu", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x73ad05f, 0x8434d91c, 0x73ad05f, 0x5316d3c6, 0xd7e75590, 0xd8493da6, 0xd8493da6, 0xd8493da6, 0x8d1697ac, 0x8d1697ac, 0x8d1697ac, 0xe7021df4, 0xe7021df4, 0xe7021df4, 0xaa4593fe, 0x5316d3c6, 0x5316d3c6, }, 18 },
- { "gfxmenu", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x83e29007, 0xd4329e28, 0x83e29007, 0x8c37fac6, 0x97d4f246, 0x32287ef3, 0x32287ef3, 0x32287ef3, 0x4d96d867, 0x4d96d867, 0x4d96d867, 0xb71c8c8f, 0xb71c8c8f, 0xb71c8c8f, 0xc9cbf769, 0x8c37fac6, 0x8c37fac6, }, 18 },
- { "gfxmenu", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe535f843, 0x39fb9c6c, 0xe535f843, 0x2fbd1b9, 0x7c892c8d, 0x3a8a1482, 0x3a8a1482, 0x3a8a1482, 0x2d7a2495, 0x2d7a2495, 0x2d7a2495, 0x84d821d, 0x84d821d, 0x84d821d, 0x5387d57f, 0x2fbd1b9, 0x2fbd1b9, }, 18 },
- { "gfxmenu", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8f8338d3, 0xdcad6ccd, 0x8f8338d3, 0x30c612d8, 0x36353d2b, 0xa9546353, 0xa9546353, 0xa9546353, 0x960ace5a, 0x960ace5a, 0x960ace5a, 0x62e43bb9, 0x62e43bb9, 0x62e43bb9, 0xf83ee7aa, 0x30c612d8, 0x30c612d8, }, 18 },
- { "gfxmenu", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xb7a13882, 0x68141e3a, 0xb7a13882, 0x65f6d15, 0x3101c32f, 0xc2b93e36, 0xc2b93e36, 0xc2b93e36, 0x1bee651a, 0x1bee651a, 0x1bee651a, 0xf7d3f08f, 0xf7d3f08f, 0xf7d3f08f, 0x724366e5, 0x65f6d15, 0x65f6d15, }, 18 },
- { "gfxmenu", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x88a3c3aa, 0x8eade265, 0x88a3c3aa, 0xa5bf47d6, 0x9f8ae196, 0x56e34121, 0x56e34121, 0x56e34121, 0x2ccef01f, 0x2ccef01f, 0x2ccef01f, 0x7d1eee3b, 0x7d1eee3b, 0x7d1eee3b, 0x5387d57f, 0xa5bf47d6, 0xa5bf47d6, }, 18 },
- { "gfxmenu", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8452c39c, 0x65759f4c, 0x8452c39c, 0x7459c042, 0xf9023dca, 0xe78b8902, 0xe78b8902, 0xe78b8902, 0xf0960107, 0xf0960107, 0xf0960107, 0xd52b2285, 0xd52b2285, 0xd52b2285, 0xf83ee7aa, 0x7459c042, 0x7459c042, }, 18 },
- { "gfxmenu", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x938d42a2, 0x709bc8ab, 0x938d42a2, 0x4db0e2de, 0xd710f4c, 0x4e9cc80d, 0x4e9cc80d, 0x4e9cc80d, 0x9bc8a372, 0x9bc8a372, 0x9bc8a372, 0xbac90ac7, 0xbac90ac7, 0xbac90ac7, 0x724366e5, 0x4db0e2de, 0x4db0e2de, }, 18 },
- { "gfxmenu", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0xc060102b, 0x960bef0c, 0xc060102b, 0x1589677a, 0xe97d0978, 0xc795e31, 0xc795e31, 0xc795e31, 0xab33090, 0xab33090, 0xab33090, 0xbeea3971, 0xbeea3971, 0xbeea3971, 0x1c955882, 0x1589677a, 0x1589677a, }, 18 },
- { "gfxmenu", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x6a4b2b8d, 0x274440b, 0x6a4b2b8d, 0xdef115d2, 0xed0808ad, 0x8d8ebcbb, 0x8d8ebcbb, 0x8d8ebcbb, 0x2b9b5d26, 0x2b9b5d26, 0x2b9b5d26, 0x790e10e2, 0x790e10e2, 0x790e10e2, 0x4d266f7a, 0xdef115d2, 0xdef115d2, }, 18 },
- { "gfxmenu", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xdb8085be, 0x51d897c7, 0xdb8085be, 0xa3ce0221, 0x30fbd5f9, 0x12d25f5, 0x12d25f5, 0x12d25f5, 0xa4a480cb, 0xa4a480cb, 0xa4a480cb, 0xf3adca34, 0xf3adca34, 0xf3adca34, 0x1ed9d731, 0xa3ce0221, 0xa3ce0221, }, 18 },
- { "gfxmenu", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x475beaa4, 0xa62db977, 0x475beaa4, 0x3a62be0, 0x311b5810, 0x7718601f, 0x7718601f, 0x7718601f, 0x60e85008, 0x60e85008, 0x60e85008, 0x45dff680, 0x45dff680, 0x45dff680, 0x5387d57f, 0x3a62be0, 0x3a62be0, }, 18 },
- { "gfxmenu", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x5788a7ac, 0xd4336209, 0x5788a7ac, 0x354678e9, 0x783d77de, 0xe75c29a6, 0xe75c29a6, 0xe75c29a6, 0xd80284af, 0xd80284af, 0xd80284af, 0x2cec714c, 0x2cec714c, 0x2cec714c, 0xf83ee7aa, 0x354678e9, 0x354678e9, }, 18 },
- { "gfxmenu", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xd1f64ea0, 0x4abd595a, 0xd1f64ea0, 0x97a6bea1, 0xf22a4cdb, 0x192b1c2, 0x192b1c2, 0x192b1c2, 0xd8c5eaee, 0xd8c5eaee, 0xd8c5eaee, 0x34f87f7b, 0x34f87f7b, 0x34f87f7b, 0x724366e5, 0x97a6bea1, 0x97a6bea1, }, 18 },
- { "gfxmenu", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xfcd5f4bb, 0x36d1826d, 0xfcd5f4bb, 0x43d7de40, 0x84467c83, 0x4d2fdc34, 0x4d2fdc34, 0x4d2fdc34, 0x37026d0a, 0x37026d0a, 0x37026d0a, 0x66d2732e, 0x66d2732e, 0x66d2732e, 0x5387d57f, 0x43d7de40, 0x43d7de40, }, 18 },
- { "gfxmenu", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x21e820a3, 0x2f9bf273, 0x21e820a3, 0xaa229449, 0x61b241cd, 0x7f3bf505, 0x7f3bf505, 0x7f3bf505, 0x68267d00, 0x68267d00, 0x68267d00, 0x4d9b5e82, 0x4d9b5e82, 0x4d9b5e82, 0xf83ee7aa, 0xaa229449, 0xaa229449, }, 18 },
- { "gfxmenu", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x6fe66840, 0x64229598, 0x6fe66840, 0xedc02d98, 0x7131f7aa, 0x32dc30eb, 0x32dc30eb, 0x32dc30eb, 0xe7885b94, 0xe7885b94, 0xe7885b94, 0xc689f221, 0xc689f221, 0xc689f221, 0x724366e5, 0xedc02d98, 0xedc02d98, }, 18 },
- { "gfxmenu", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xdb159e45, 0x9b1475c9, 0xdb159e45, 0xaee6597b, 0x573454, 0xe553631d, 0xe553631d, 0xe553631d, 0xe3990dbc, 0xe3990dbc, 0xe3990dbc, 0x57c0045d, 0x57c0045d, 0x57c0045d, 0x1c955882, 0xaee6597b, 0xaee6597b, }, 18 },
- { "gfxmenu", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x9a43dfc6, 0x67153087, 0x9a43dfc6, 0xe9bd482c, 0xe763cddd, 0x87e579cb, 0x87e579cb, 0x87e579cb, 0x21f09856, 0x21f09856, 0x21f09856, 0x7365d592, 0x7365d592, 0x7365d592, 0x4d266f7a, 0xe9bd482c, 0xe9bd482c, }, 18 },
- { "gfxmenu", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x78bf287, 0x8e68ddb4, 0x78bf287, 0xb2b0d4a4, 0xcb49fd6e, 0xfa9f0d62, 0xfa9f0d62, 0xfa9f0d62, 0x5f16a85c, 0x5f16a85c, 0x5f16a85c, 0x81fe2a3, 0x81fe2a3, 0x81fe2a3, 0x1ed9d731, 0xb2b0d4a4, 0xb2b0d4a4, }, 18 },
- { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xb7ccf7ca, 0xfe517937, 0xb7ccf7ca, 0xfa1f93fd, 0x83d93b90, 0x95dac67b, 0x95dac67b, 0x95dac67b, 0x7e7f2c07, 0x7e7f2c07, 0x7e7f2c07, 0x67f5cd62, 0x67f5cd62, 0x67f5cd62, 0x1c3742c9, 0xfa1f93fd, 0xfa1f93fd, }, 18 },
- { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x663d292a, 0xa008c39, 0x663d292a, 0xcd82113f, 0x1c0b0f02, 0xab2628e, 0xab2628e, 0xab2628e, 0x65fbbe9f, 0x65fbbe9f, 0x65fbbe9f, 0x26f1fbaf, 0x26f1fbaf, 0x26f1fbaf, 0xcc5a7bed, 0xcd82113f, 0xcd82113f, }, 18 },
- { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xef4a3312, 0xfc2f0ab1, 0x6861f25e, 0xfc2f0ab1, 0x11b6b6f7, 0xcd618f3f, 0xae51b639, 0xae51b639, 0xae51b639, 0x68e3f227, 0x68e3f227, 0x68e3f227, 0xbff1f2f0, 0xbff1f2f0, 0xbff1f2f0, 0xef4a3312, 0x11b6b6f7, 0x11b6b6f7, }, 18 },
- { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe0b5a23e, 0xee551fa6, 0xe0b5a23e, 0xa3436f79, 0x59c36f00, 0x59c36f00, 0x5e67c1f2, 0x5e67c1f2, 0x5e67c1f2, 0x20e7ac94, 0x20e7ac94, 0x20e7ac94, 0xe3c59159, 0xe3c59159, 0xe3c59159, 0x59c36f00, 0xa3436f79, 0xa3436f79, 0x59c36f00, }, 20 },
- { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2bb3c18d, 0xdfae36a1, 0x2bb3c18d, 0x5b644f2, 0xaa4593fe, 0xaa4593fe, 0xccb764da, 0xccb764da, 0xccb764da, 0x6a4269bd, 0x6a4269bd, 0x6a4269bd, 0xe8e58bd6, 0xe8e58bd6, 0xe8e58bd6, 0xaa4593fe, 0x5b644f2, 0x5b644f2, 0xaa4593fe, }, 20 },
- { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xdae90963, 0xc865b2ee, 0xdae90963, 0x87fe64e7, 0xc9cbf769, 0xc9cbf769, 0xbdb21287, 0xbdb21287, 0xbdb21287, 0x436ad34b, 0x436ad34b, 0x436ad34b, 0xab3c7c47, 0xab3c7c47, 0xab3c7c47, 0xc9cbf769, 0x87fe64e7, 0x87fe64e7, 0xc9cbf769, }, 20 },
- { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd5ca4355, 0xc8fbf114, 0xd5ca4355, 0x85d2e7fb, 0x9813a416, 0x9813a416, 0x4a1e101b, 0x4a1e101b, 0x4a1e101b, 0xdbc59628, 0xdbc59628, 0xdbc59628, 0x47b063ea, 0x47b063ea, 0x47b063ea, 0x9813a416, 0x85d2e7fb, 0x85d2e7fb, 0x9813a416, }, 20 },
- { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x722a297e, 0xb34f27df, 0x722a297e, 0x48e0f884, 0x5fcf013d, 0x5fcf013d, 0xee9e0d69, 0xee9e0d69, 0xee9e0d69, 0x3c8e151f, 0x3c8e151f, 0x3c8e151f, 0x23a594e2, 0x23a594e2, 0x23a594e2, 0x5fcf013d, 0x48e0f884, 0x48e0f884, 0x5fcf013d, }, 20 },
- { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x87be67c4, 0x484106d9, 0x87be67c4, 0xe7cdc3ae, 0xdd28f52b, 0xdd28f52b, 0x2063d7c8, 0x2063d7c8, 0x2063d7c8, 0x15f2e2c, 0x15f2e2c, 0x15f2e2c, 0x1b2e4dbd, 0x1b2e4dbd, 0x1b2e4dbd, 0xdd28f52b, 0xe7cdc3ae, 0xe7cdc3ae, 0xdd28f52b, }, 20 },
- { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbf799219, 0xcec61405, 0xbf799219, 0x413f9f74, 0x43d1f34, 0x43d1f34, 0x9dc6a6fb, 0x9dc6a6fb, 0x9dc6a6fb, 0xe2cc0f53, 0xe2cc0f53, 0xe2cc0f53, 0xaec367a, 0xaec367a, 0xaec367a, 0x43d1f34, 0x413f9f74, 0x413f9f74, 0x43d1f34, }, 20 },
- { "gfxterm_ar", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xe0b5a23e, 0xee551fa6, 0xe0b5a23e, 0xa3436f79, 0x59c36f00, 0x59c36f00, 0x5e67c1f2, 0x5e67c1f2, 0x5e67c1f2, 0x20e7ac94, 0x20e7ac94, 0x20e7ac94, 0xe3c59159, 0xe3c59159, 0xe3c59159, 0x59c36f00, 0xa3436f79, 0xa3436f79, 0x59c36f00, }, 20 },
- { "gfxterm_ar", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x2bb3c18d, 0xdfae36a1, 0x2bb3c18d, 0x5b644f2, 0xaa4593fe, 0xaa4593fe, 0xccb764da, 0xccb764da, 0xccb764da, 0x6a4269bd, 0x6a4269bd, 0x6a4269bd, 0xe8e58bd6, 0xe8e58bd6, 0xe8e58bd6, 0xaa4593fe, 0x5b644f2, 0x5b644f2, 0xaa4593fe, }, 20 },
- { "gfxterm_ar", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0xdae90963, 0xc865b2ee, 0xdae90963, 0x87fe64e7, 0xc9cbf769, 0xc9cbf769, 0xbdb21287, 0xbdb21287, 0xbdb21287, 0x436ad34b, 0x436ad34b, 0x436ad34b, 0xab3c7c47, 0xab3c7c47, 0xab3c7c47, 0xc9cbf769, 0x87fe64e7, 0x87fe64e7, 0xc9cbf769, }, 20 },
- { "gfxterm_ar", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0x3b1768ca, 0xf9e5eedd, 0x3b1768ca, 0x7f1c9276, 0x5387d57f, 0x5387d57f, 0x927c1c5d, 0x927c1c5d, 0x927c1c5d, 0x52257091, 0x52257091, 0x52257091, 0xb5fbf207, 0xb5fbf207, 0xb5fbf207, 0x5387d57f, 0x7f1c9276, 0x7f1c9276, 0x5387d57f, }, 20 },
- { "gfxterm_ar", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x54190c0f, 0xb6b42319, 0x54190c0f, 0xee714190, 0xf83ee7aa, 0xf83ee7aa, 0x1cbd869f, 0x1cbd869f, 0x1cbd869f, 0x80c4566c, 0x80c4566c, 0x80c4566c, 0xb877fdc4, 0xb877fdc4, 0xb877fdc4, 0xf83ee7aa, 0xee714190, 0xee714190, 0xf83ee7aa, }, 20 },
- { "gfxterm_ar", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x25774ca3, 0x3d74e13a, 0x25774ca3, 0x3402f9f6, 0x724366e5, 0x724366e5, 0x447ccdbb, 0x447ccdbb, 0x447ccdbb, 0x3458f41, 0x3458f41, 0x3458f41, 0x6e6ba80b, 0x6e6ba80b, 0x6e6ba80b, 0x724366e5, 0x3402f9f6, 0x3402f9f6, 0x724366e5, }, 20 },
- { "gfxterm_ar", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x9143e2a6, 0x6e596cd4, 0x9143e2a6, 0x7ed75f9f, 0x5387d57f, 0x5387d57f, 0x86a0aae, 0x86a0aae, 0x86a0aae, 0xd6a44573, 0xd6a44573, 0xd6a44573, 0x4527d76d, 0x4527d76d, 0x4527d76d, 0x5387d57f, 0x7ed75f9f, 0x7ed75f9f, 0x5387d57f, }, 20 },
- { "gfxterm_ar", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf943d873, 0xced7704, 0xf943d873, 0x8889e69f, 0xf83ee7aa, 0xf83ee7aa, 0x82576edb, 0x82576edb, 0x82576edb, 0xf08d7deb, 0xf08d7deb, 0xf08d7deb, 0xc1182c2d, 0xc1182c2d, 0xc1182c2d, 0xf83ee7aa, 0x8889e69f, 0x8889e69f, 0xf83ee7aa, }, 20 },
- { "gfxterm_ar", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x63bd59d2, 0xf34f52d5, 0x63bd59d2, 0x916fd2a2, 0x724366e5, 0x724366e5, 0x11262bd6, 0x11262bd6, 0x11262bd6, 0x48b6d886, 0x48b6d886, 0x48b6d886, 0x8001b6c4, 0x8001b6c4, 0x8001b6c4, 0x724366e5, 0x916fd2a2, 0x916fd2a2, 0x724366e5, }, 20 },
- { "gfxterm_ar", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0xed6af547, 0x9ff43eec, 0xed6af547, 0xed0a4de1, 0x1c955882, 0x1c955882, 0xa9dce4cb, 0xa9dce4cb, 0xa9dce4cb, 0x662ba95c, 0x662ba95c, 0x662ba95c, 0x9842a549, 0x9842a549, 0x9842a549, 0x1c955882, 0xed0a4de1, 0xed0a4de1, 0x1c955882, }, 20 },
- { "gfxterm_ar", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xbda49d55, 0xf5b57989, 0xbda49d55, 0x79b60451, 0x4d266f7a, 0x4d266f7a, 0xeb1807b5, 0xeb1807b5, 0xeb1807b5, 0xd6f1c0a, 0xd6f1c0a, 0xd6f1c0a, 0x9556489a, 0x9556489a, 0x9556489a, 0x4d266f7a, 0x79b60451, 0x79b60451, 0x4d266f7a, }, 20 },
- { "gfxterm_ar", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x90b1e6bc, 0xabcab9fe, 0x90b1e6bc, 0xc45e75b, 0x1ed9d731, 0x1ed9d731, 0xa6ac3ed0, 0xa6ac3ed0, 0xa6ac3ed0, 0x8c82015, 0x8c82015, 0x8c82015, 0x2ba131a3, 0x2ba131a3, 0x2ba131a3, 0x1ed9d731, 0xc45e75b, 0xc45e75b, 0x1ed9d731, }, 20 },
- { "gfxterm_ar", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x3b1768ca, 0xf9e5eedd, 0x3b1768ca, 0x7f1c9276, 0x5387d57f, 0x5387d57f, 0x927c1c5d, 0x927c1c5d, 0x927c1c5d, 0x52257091, 0x52257091, 0x52257091, 0xb5fbf207, 0xb5fbf207, 0xb5fbf207, 0x5387d57f, 0x7f1c9276, 0x7f1c9276, 0x5387d57f, }, 20 },
- { "gfxterm_ar", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x54190c0f, 0xb6b42319, 0x54190c0f, 0xee714190, 0xf83ee7aa, 0xf83ee7aa, 0x1cbd869f, 0x1cbd869f, 0x1cbd869f, 0x80c4566c, 0x80c4566c, 0x80c4566c, 0xb877fdc4, 0xb877fdc4, 0xb877fdc4, 0xf83ee7aa, 0xee714190, 0xee714190, 0xf83ee7aa, }, 20 },
- { "gfxterm_ar", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x25774ca3, 0x3d74e13a, 0x25774ca3, 0x3402f9f6, 0x724366e5, 0x724366e5, 0x447ccdbb, 0x447ccdbb, 0x447ccdbb, 0x3458f41, 0x3458f41, 0x3458f41, 0x6e6ba80b, 0x6e6ba80b, 0x6e6ba80b, 0x724366e5, 0x3402f9f6, 0x3402f9f6, 0x724366e5, }, 20 },
- { "gfxterm_ar", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x9143e2a6, 0x6e596cd4, 0x9143e2a6, 0x7ed75f9f, 0x5387d57f, 0x5387d57f, 0x86a0aae, 0x86a0aae, 0x86a0aae, 0xd6a44573, 0xd6a44573, 0xd6a44573, 0x4527d76d, 0x4527d76d, 0x4527d76d, 0x5387d57f, 0x7ed75f9f, 0x7ed75f9f, 0x5387d57f, }, 20 },
- { "gfxterm_ar", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf943d873, 0xced7704, 0xf943d873, 0x8889e69f, 0xf83ee7aa, 0xf83ee7aa, 0x82576edb, 0x82576edb, 0x82576edb, 0xf08d7deb, 0xf08d7deb, 0xf08d7deb, 0xc1182c2d, 0xc1182c2d, 0xc1182c2d, 0xf83ee7aa, 0x8889e69f, 0x8889e69f, 0xf83ee7aa, }, 20 },
- { "gfxterm_ar", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x63bd59d2, 0xf34f52d5, 0x63bd59d2, 0x916fd2a2, 0x724366e5, 0x724366e5, 0x11262bd6, 0x11262bd6, 0x11262bd6, 0x48b6d886, 0x48b6d886, 0x48b6d886, 0x8001b6c4, 0x8001b6c4, 0x8001b6c4, 0x724366e5, 0x916fd2a2, 0x916fd2a2, 0x724366e5, }, 20 },
- { "gfxterm_ar", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xed6af547, 0x9ff43eec, 0xed6af547, 0xed0a4de1, 0x1c955882, 0x1c955882, 0xa9dce4cb, 0xa9dce4cb, 0xa9dce4cb, 0x662ba95c, 0x662ba95c, 0x662ba95c, 0x9842a549, 0x9842a549, 0x9842a549, 0x1c955882, 0xed0a4de1, 0xed0a4de1, 0x1c955882, }, 20 },
- { "gfxterm_ar", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xbda49d55, 0xf5b57989, 0xbda49d55, 0x79b60451, 0x4d266f7a, 0x4d266f7a, 0xeb1807b5, 0xeb1807b5, 0xeb1807b5, 0xd6f1c0a, 0xd6f1c0a, 0xd6f1c0a, 0x9556489a, 0x9556489a, 0x9556489a, 0x4d266f7a, 0x79b60451, 0x79b60451, 0x4d266f7a, }, 20 },
- { "gfxterm_ar", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x90b1e6bc, 0xabcab9fe, 0x90b1e6bc, 0xc45e75b, 0x1ed9d731, 0x1ed9d731, 0xa6ac3ed0, 0xa6ac3ed0, 0xa6ac3ed0, 0x8c82015, 0x8c82015, 0x8c82015, 0x2ba131a3, 0x2ba131a3, 0x2ba131a3, 0x1ed9d731, 0xc45e75b, 0xc45e75b, 0x1ed9d731, }, 20 },
- { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xd5ca4355, 0xc8fbf114, 0xd5ca4355, 0x85d2e7fb, 0x9813a416, 0x9813a416, 0x4a1e101b, 0x4a1e101b, 0x4a1e101b, 0xdbc59628, 0xdbc59628, 0xdbc59628, 0x47b063ea, 0x47b063ea, 0x47b063ea, 0x9813a416, 0x85d2e7fb, 0x85d2e7fb, 0x9813a416, }, 20 },
- { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x722a297e, 0xb34f27df, 0x722a297e, 0x48e0f884, 0x5fcf013d, 0x5fcf013d, 0xee9e0d69, 0xee9e0d69, 0xee9e0d69, 0x3c8e151f, 0x3c8e151f, 0x3c8e151f, 0x23a594e2, 0x23a594e2, 0x23a594e2, 0x5fcf013d, 0x48e0f884, 0x48e0f884, 0x5fcf013d, }, 20 },
- { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x87be67c4, 0x484106d9, 0x87be67c4, 0xe7cdc3ae, 0xdd28f52b, 0xdd28f52b, 0x2063d7c8, 0x2063d7c8, 0x2063d7c8, 0x15f2e2c, 0x15f2e2c, 0x15f2e2c, 0x1b2e4dbd, 0x1b2e4dbd, 0x1b2e4dbd, 0xdd28f52b, 0xe7cdc3ae, 0xe7cdc3ae, 0xdd28f52b, }, 20 },
- { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x36622078, 0x979da8f3, 0x36622078, 0x7594ed3f, 0x59c36f00, 0x59c36f00, 0xe5e5cf13, 0xe5e5cf13, 0xe5e5cf13, 0x9b65a275, 0x9b65a275, 0x9b65a275, 0x58479fb8, 0x58479fb8, 0x58479fb8, 0x59c36f00, 0x7594ed3f, 0x7594ed3f, 0x59c36f00, }, 20 },
- { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x48ee0ceb, 0xc6eb6d53, 0x48ee0ceb, 0x66eb8994, 0xaa4593fe, 0xaa4593fe, 0x86ac5984, 0x86ac5984, 0x86ac5984, 0x205954e3, 0x205954e3, 0x205954e3, 0xa2feb688, 0xa2feb688, 0xa2feb688, 0xaa4593fe, 0x66eb8994, 0x66eb8994, 0xaa4593fe, }, 20 },
- { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xfa53f185, 0xaf8fa3eb, 0xfa53f185, 0xa7449c01, 0xc9cbf769, 0xc9cbf769, 0x50b94b47, 0x50b94b47, 0x50b94b47, 0xae618a8b, 0xae618a8b, 0xae618a8b, 0x46372587, 0x46372587, 0x46372587, 0xc9cbf769, 0xa7449c01, 0xa7449c01, 0xc9cbf769, }, 20 },
- { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xc6eb6e6e, 0xc5217d5b, 0xc6eb6e6e, 0x96f3cac0, 0x9813a416, 0x9813a416, 0x5752c3fe, 0x5752c3fe, 0x5752c3fe, 0xc68945cd, 0xc68945cd, 0xc68945cd, 0x5afcb00f, 0x5afcb00f, 0x5afcb00f, 0x9813a416, 0x96f3cac0, 0x96f3cac0, 0x9813a416, }, 20 },
- { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7fd1def2, 0x98a2e53a, 0x7fd1def2, 0x451b0f08, 0x5fcf013d, 0x5fcf013d, 0x9f19ac09, 0x9f19ac09, 0x9f19ac09, 0x4d09b47f, 0x4d09b47f, 0x4d09b47f, 0x52223582, 0x52223582, 0x52223582, 0x5fcf013d, 0x451b0f08, 0x451b0f08, 0x5fcf013d, }, 20 },
- { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xaac2ae55, 0x3e7a25f, 0xaac2ae55, 0xcab10a3f, 0xdd28f52b, 0xdd28f52b, 0x5f2b8179, 0x5f2b8179, 0x5f2b8179, 0x7e17789d, 0x7e17789d, 0x7e17789d, 0x64661b0c, 0x64661b0c, 0x64661b0c, 0xdd28f52b, 0xcab10a3f, 0xcab10a3f, 0xdd28f52b, }, 20 },
- { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfbdee88, 0x812f047f, 0xfbdee88, 0xf1fbe3e5, 0x43d1f34, 0x43d1f34, 0x6694d5e, 0x6694d5e, 0x6694d5e, 0x7963e4f6, 0x7963e4f6, 0x7963e4f6, 0x9143dddf, 0x9143dddf, 0x9143dddf, 0x43d1f34, 0xf1fbe3e5, 0xf1fbe3e5, 0x43d1f34, }, 20 },
- { "gfxterm_cyr", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x36622078, 0x979da8f3, 0x36622078, 0x7594ed3f, 0x59c36f00, 0x59c36f00, 0xe5e5cf13, 0xe5e5cf13, 0xe5e5cf13, 0x9b65a275, 0x9b65a275, 0x9b65a275, 0x58479fb8, 0x58479fb8, 0x58479fb8, 0x59c36f00, 0x7594ed3f, 0x7594ed3f, 0x59c36f00, }, 20 },
- { "gfxterm_cyr", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x48ee0ceb, 0xc6eb6d53, 0x48ee0ceb, 0x66eb8994, 0xaa4593fe, 0xaa4593fe, 0x86ac5984, 0x86ac5984, 0x86ac5984, 0x205954e3, 0x205954e3, 0x205954e3, 0xa2feb688, 0xa2feb688, 0xa2feb688, 0xaa4593fe, 0x66eb8994, 0x66eb8994, 0xaa4593fe, }, 20 },
- { "gfxterm_cyr", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0xfa53f185, 0xaf8fa3eb, 0xfa53f185, 0xa7449c01, 0xc9cbf769, 0xc9cbf769, 0x50b94b47, 0x50b94b47, 0x50b94b47, 0xae618a8b, 0xae618a8b, 0xae618a8b, 0x46372587, 0x46372587, 0x46372587, 0xc9cbf769, 0xa7449c01, 0xa7449c01, 0xc9cbf769, }, 20 },
- { "gfxterm_cyr", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xd8d870b3, 0x9128b01a, 0xd8d870b3, 0x9cd38a0f, 0x5387d57f, 0x5387d57f, 0x136cad2, 0x136cad2, 0x136cad2, 0xc16fa61e, 0xc16fa61e, 0xc16fa61e, 0x26b12488, 0x26b12488, 0x26b12488, 0x5387d57f, 0x9cd38a0f, 0x9cd38a0f, 0x5387d57f, }, 20 },
- { "gfxterm_cyr", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xeaeda16f, 0x36d21de0, 0xeaeda16f, 0x5085ecf0, 0xf83ee7aa, 0xf83ee7aa, 0x3eac591b, 0x3eac591b, 0x3eac591b, 0xa2d589e8, 0xa2d589e8, 0xa2d589e8, 0x9a662240, 0x9a662240, 0x9a662240, 0xf83ee7aa, 0x5085ecf0, 0x5085ecf0, 0xf83ee7aa, }, 20 },
- { "gfxterm_cyr", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x333a0d08, 0x47d0c238, 0x333a0d08, 0x224fb85d, 0x724366e5, 0x724366e5, 0xf4044671, 0xf4044671, 0xf4044671, 0xb33d048b, 0xb33d048b, 0xb33d048b, 0xde1323c1, 0xde1323c1, 0xde1323c1, 0x724366e5, 0x224fb85d, 0x224fb85d, 0x724366e5, }, 20 },
- { "gfxterm_cyr", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x4a43c1c8, 0xe019a943, 0x4a43c1c8, 0xa5d77cf1, 0x5387d57f, 0x5387d57f, 0x8171a604, 0x8171a604, 0x8171a604, 0x5fbfe9d9, 0x5fbfe9d9, 0x5fbfe9d9, 0xcc3c7bc7, 0xcc3c7bc7, 0xcc3c7bc7, 0x5387d57f, 0xa5d77cf1, 0xa5d77cf1, 0x5387d57f, }, 20 },
- { "gfxterm_cyr", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xb770c3fe, 0x50b21ef7, 0xb770c3fe, 0xc6bafd12, 0xf83ee7aa, 0xf83ee7aa, 0x8df53a5d, 0x8df53a5d, 0x8df53a5d, 0xff2f296d, 0xff2f296d, 0xff2f296d, 0xceba78ab, 0xceba78ab, 0xceba78ab, 0xf83ee7aa, 0xc6bafd12, 0xc6bafd12, 0xf83ee7aa, }, 20 },
- { "gfxterm_cyr", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0xe8f75cfb, 0x402c0692, 0xe8f75cfb, 0x1a25d78b, 0x724366e5, 0x724366e5, 0xaf01e304, 0xaf01e304, 0xaf01e304, 0xf6911054, 0xf6911054, 0xf6911054, 0x3e267e16, 0x3e267e16, 0x3e267e16, 0x724366e5, 0x1a25d78b, 0x1a25d78b, 0x724366e5, }, 20 },
- { "gfxterm_cyr", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x89f843d3, 0xc27ae37d, 0x89f843d3, 0x8998fb75, 0x1c955882, 0x1c955882, 0x698caa77, 0x698caa77, 0x698caa77, 0xa67be7e0, 0xa67be7e0, 0xa67be7e0, 0x5812ebf5, 0x5812ebf5, 0x5812ebf5, 0x1c955882, 0x8998fb75, 0x8998fb75, 0x1c955882, }, 20 },
- { "gfxterm_cyr", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xa10c24e6, 0x12eeef09, 0xa10c24e6, 0x651ebde2, 0x4d266f7a, 0x4d266f7a, 0x8ed47731, 0x8ed47731, 0x8ed47731, 0x68a36c8e, 0x68a36c8e, 0x68a36c8e, 0xf09a381e, 0xf09a381e, 0xf09a381e, 0x4d266f7a, 0x651ebde2, 0x651ebde2, 0x4d266f7a, }, 20 },
- { "gfxterm_cyr", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x85a30869, 0xbaa08e30, 0x85a30869, 0x1957098e, 0x1ed9d731, 0x1ed9d731, 0x4ffc007b, 0x4ffc007b, 0x4ffc007b, 0xe1981ebe, 0xe1981ebe, 0xe1981ebe, 0xc2f10f08, 0xc2f10f08, 0xc2f10f08, 0x1ed9d731, 0x1957098e, 0x1957098e, 0x1ed9d731, }, 20 },
- { "gfxterm_cyr", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xd8d870b3, 0x9128b01a, 0xd8d870b3, 0x9cd38a0f, 0x5387d57f, 0x5387d57f, 0x136cad2, 0x136cad2, 0x136cad2, 0xc16fa61e, 0xc16fa61e, 0xc16fa61e, 0x26b12488, 0x26b12488, 0x26b12488, 0x5387d57f, 0x9cd38a0f, 0x9cd38a0f, 0x5387d57f, }, 20 },
- { "gfxterm_cyr", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xeaeda16f, 0x36d21de0, 0xeaeda16f, 0x5085ecf0, 0xf83ee7aa, 0xf83ee7aa, 0x3eac591b, 0x3eac591b, 0x3eac591b, 0xa2d589e8, 0xa2d589e8, 0xa2d589e8, 0x9a662240, 0x9a662240, 0x9a662240, 0xf83ee7aa, 0x5085ecf0, 0x5085ecf0, 0xf83ee7aa, }, 20 },
- { "gfxterm_cyr", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x333a0d08, 0x47d0c238, 0x333a0d08, 0x224fb85d, 0x724366e5, 0x724366e5, 0xf4044671, 0xf4044671, 0xf4044671, 0xb33d048b, 0xb33d048b, 0xb33d048b, 0xde1323c1, 0xde1323c1, 0xde1323c1, 0x724366e5, 0x224fb85d, 0x224fb85d, 0x724366e5, }, 20 },
- { "gfxterm_cyr", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x4a43c1c8, 0xe019a943, 0x4a43c1c8, 0xa5d77cf1, 0x5387d57f, 0x5387d57f, 0x8171a604, 0x8171a604, 0x8171a604, 0x5fbfe9d9, 0x5fbfe9d9, 0x5fbfe9d9, 0xcc3c7bc7, 0xcc3c7bc7, 0xcc3c7bc7, 0x5387d57f, 0xa5d77cf1, 0xa5d77cf1, 0x5387d57f, }, 20 },
- { "gfxterm_cyr", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xb770c3fe, 0x50b21ef7, 0xb770c3fe, 0xc6bafd12, 0xf83ee7aa, 0xf83ee7aa, 0x8df53a5d, 0x8df53a5d, 0x8df53a5d, 0xff2f296d, 0xff2f296d, 0xff2f296d, 0xceba78ab, 0xceba78ab, 0xceba78ab, 0xf83ee7aa, 0xc6bafd12, 0xc6bafd12, 0xf83ee7aa, }, 20 },
- { "gfxterm_cyr", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0xe8f75cfb, 0x402c0692, 0xe8f75cfb, 0x1a25d78b, 0x724366e5, 0x724366e5, 0xaf01e304, 0xaf01e304, 0xaf01e304, 0xf6911054, 0xf6911054, 0xf6911054, 0x3e267e16, 0x3e267e16, 0x3e267e16, 0x724366e5, 0x1a25d78b, 0x1a25d78b, 0x724366e5, }, 20 },
- { "gfxterm_cyr", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x89f843d3, 0xc27ae37d, 0x89f843d3, 0x8998fb75, 0x1c955882, 0x1c955882, 0x698caa77, 0x698caa77, 0x698caa77, 0xa67be7e0, 0xa67be7e0, 0xa67be7e0, 0x5812ebf5, 0x5812ebf5, 0x5812ebf5, 0x1c955882, 0x8998fb75, 0x8998fb75, 0x1c955882, }, 20 },
- { "gfxterm_cyr", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xa10c24e6, 0x12eeef09, 0xa10c24e6, 0x651ebde2, 0x4d266f7a, 0x4d266f7a, 0x8ed47731, 0x8ed47731, 0x8ed47731, 0x68a36c8e, 0x68a36c8e, 0x68a36c8e, 0xf09a381e, 0xf09a381e, 0xf09a381e, 0x4d266f7a, 0x651ebde2, 0x651ebde2, 0x4d266f7a, }, 20 },
- { "gfxterm_cyr", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x85a30869, 0xbaa08e30, 0x85a30869, 0x1957098e, 0x1ed9d731, 0x1ed9d731, 0x4ffc007b, 0x4ffc007b, 0x4ffc007b, 0xe1981ebe, 0xe1981ebe, 0xe1981ebe, 0xc2f10f08, 0xc2f10f08, 0xc2f10f08, 0x1ed9d731, 0x1957098e, 0x1957098e, 0x1ed9d731, }, 20 },
- { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xc6eb6e6e, 0xc5217d5b, 0xc6eb6e6e, 0x96f3cac0, 0x9813a416, 0x9813a416, 0x5752c3fe, 0x5752c3fe, 0x5752c3fe, 0xc68945cd, 0xc68945cd, 0xc68945cd, 0x5afcb00f, 0x5afcb00f, 0x5afcb00f, 0x9813a416, 0x96f3cac0, 0x96f3cac0, 0x9813a416, }, 20 },
- { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7fd1def2, 0x98a2e53a, 0x7fd1def2, 0x451b0f08, 0x5fcf013d, 0x5fcf013d, 0x9f19ac09, 0x9f19ac09, 0x9f19ac09, 0x4d09b47f, 0x4d09b47f, 0x4d09b47f, 0x52223582, 0x52223582, 0x52223582, 0x5fcf013d, 0x451b0f08, 0x451b0f08, 0x5fcf013d, }, 20 },
- { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xaac2ae55, 0x3e7a25f, 0xaac2ae55, 0xcab10a3f, 0xdd28f52b, 0xdd28f52b, 0x5f2b8179, 0x5f2b8179, 0x5f2b8179, 0x7e17789d, 0x7e17789d, 0x7e17789d, 0x64661b0c, 0x64661b0c, 0x64661b0c, 0xdd28f52b, 0xcab10a3f, 0xcab10a3f, 0xdd28f52b, }, 20 },
- { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x99e53699, 0x9b30b9b8, 0x99e53699, 0xda13fbde, 0x59c36f00, 0x59c36f00, 0xc6c80006, 0xc6c80006, 0xc6c80006, 0xb8486d60, 0xb8486d60, 0xb8486d60, 0x7b6a50ad, 0x7b6a50ad, 0x7b6a50ad, 0x59c36f00, 0xda13fbde, 0xda13fbde, 0x59c36f00, }, 20 },
- { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x5596d8c4, 0xe6c08467, 0x5596d8c4, 0x7b935dbb, 0xaa4593fe, 0xaa4593fe, 0xb2094db6, 0xb2094db6, 0xb2094db6, 0x14fc40d1, 0x14fc40d1, 0x14fc40d1, 0x965ba2ba, 0x965ba2ba, 0x965ba2ba, 0xaa4593fe, 0x7b935dbb, 0x7b935dbb, 0xaa4593fe, }, 20 },
- { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8b963803, 0x3a329278, 0x8b963803, 0xd6815587, 0xc9cbf769, 0xc9cbf769, 0x85733bd7, 0x85733bd7, 0x85733bd7, 0x7babfa1b, 0x7babfa1b, 0x7babfa1b, 0x93fd5517, 0x93fd5517, 0x93fd5517, 0xc9cbf769, 0xd6815587, 0xd6815587, 0xc9cbf769, }, 20 },
- { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x27813091, 0xd32064ba, 0x27813091, 0x7799943f, 0x9813a416, 0x9813a416, 0x5cfa5159, 0x5cfa5159, 0x5cfa5159, 0xcd21d76a, 0xcd21d76a, 0xcd21d76a, 0x515422a8, 0x515422a8, 0x515422a8, 0x9813a416, 0x7799943f, 0x7799943f, 0x9813a416, }, 20 },
- { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf107273d, 0xd1d8f23b, 0xf107273d, 0xcbcdf6c7, 0x5fcf013d, 0x5fcf013d, 0x164d5584, 0x164d5584, 0x164d5584, 0xc45d4df2, 0xc45d4df2, 0xc45d4df2, 0xdb76cc0f, 0xdb76cc0f, 0xdb76cc0f, 0x5fcf013d, 0xcbcdf6c7, 0xcbcdf6c7, 0x5fcf013d, }, 20 },
- { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xa54fb200, 0x92d6596f, 0xa54fb200, 0xc53c166a, 0xdd28f52b, 0xdd28f52b, 0x97b266c9, 0x97b266c9, 0x97b266c9, 0xb68e9f2d, 0xb68e9f2d, 0xb68e9f2d, 0xacfffcbc, 0xacfffcbc, 0xacfffcbc, 0xdd28f52b, 0xc53c166a, 0xc53c166a, 0xdd28f52b, }, 20 },
- { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6d1ede55, 0x4bb31527, 0x6d1ede55, 0x9358d338, 0x43d1f34, 0x43d1f34, 0xa3f91b32, 0xa3f91b32, 0xa3f91b32, 0xdcf3b29a, 0xdcf3b29a, 0xdcf3b29a, 0x34d38bb3, 0x34d38bb3, 0x34d38bb3, 0x43d1f34, 0x9358d338, 0x9358d338, 0x43d1f34, }, 20 },
- { "gfxterm_heb", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x99e53699, 0x9b30b9b8, 0x99e53699, 0xda13fbde, 0x59c36f00, 0x59c36f00, 0xc6c80006, 0xc6c80006, 0xc6c80006, 0xb8486d60, 0xb8486d60, 0xb8486d60, 0x7b6a50ad, 0x7b6a50ad, 0x7b6a50ad, 0x59c36f00, 0xda13fbde, 0xda13fbde, 0x59c36f00, }, 20 },
- { "gfxterm_heb", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x5596d8c4, 0xe6c08467, 0x5596d8c4, 0x7b935dbb, 0xaa4593fe, 0xaa4593fe, 0xb2094db6, 0xb2094db6, 0xb2094db6, 0x14fc40d1, 0x14fc40d1, 0x14fc40d1, 0x965ba2ba, 0x965ba2ba, 0x965ba2ba, 0xaa4593fe, 0x7b935dbb, 0x7b935dbb, 0xaa4593fe, }, 20 },
- { "gfxterm_heb", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x8b963803, 0x3a329278, 0x8b963803, 0xd6815587, 0xc9cbf769, 0xc9cbf769, 0x85733bd7, 0x85733bd7, 0x85733bd7, 0x7babfa1b, 0x7babfa1b, 0x7babfa1b, 0x93fd5517, 0x93fd5517, 0x93fd5517, 0xc9cbf769, 0xd6815587, 0xd6815587, 0xc9cbf769, }, 20 },
- { "gfxterm_heb", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xeada5358, 0xa5081c9c, 0xeada5358, 0xaed1a9e4, 0x5387d57f, 0x5387d57f, 0xe7380617, 0xe7380617, 0xe7380617, 0x27616adb, 0x27616adb, 0x27616adb, 0xc0bfe84d, 0xc0bfe84d, 0xc0bfe84d, 0x5387d57f, 0xaed1a9e4, 0xaed1a9e4, 0x5387d57f, }, 20 },
- { "gfxterm_heb", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x167e9ac0, 0xc5a57b5f, 0x167e9ac0, 0xac16d75f, 0xf83ee7aa, 0xf83ee7aa, 0xb47ab0cb, 0xb47ab0cb, 0xb47ab0cb, 0x28036038, 0x28036038, 0x28036038, 0x10b0cb90, 0x10b0cb90, 0x10b0cb90, 0xf83ee7aa, 0xac16d75f, 0xac16d75f, 0xf83ee7aa, }, 20 },
- { "gfxterm_heb", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xfd0449a3, 0xb946b16a, 0xfd0449a3, 0xec71fcf6, 0x724366e5, 0x724366e5, 0xab4d15ce, 0xab4d15ce, 0xab4d15ce, 0xec745734, 0xec745734, 0xec745734, 0x815a707e, 0x815a707e, 0x815a707e, 0x724366e5, 0xec71fcf6, 0xec71fcf6, 0x724366e5, }, 20 },
- { "gfxterm_heb", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x1eb746a, 0x74afe43, 0x1eb746a, 0xee7fc953, 0x5387d57f, 0x5387d57f, 0x704981d6, 0x704981d6, 0x704981d6, 0xae87ce0b, 0xae87ce0b, 0xae87ce0b, 0x3d045c15, 0x3d045c15, 0x3d045c15, 0x5387d57f, 0xee7fc953, 0xee7fc953, 0x5387d57f, }, 20 },
- { "gfxterm_heb", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xb9fa44c, 0xff4e04c7, 0xb9fa44c, 0x7a559aa0, 0xf83ee7aa, 0xf83ee7aa, 0xfccbce43, 0xfccbce43, 0xfccbce43, 0x8e11dd73, 0x8e11dd73, 0x8e11dd73, 0xbf848cb5, 0xbf848cb5, 0xbf848cb5, 0xf83ee7aa, 0x7a559aa0, 0x7a559aa0, 0xf83ee7aa, }, 20 },
- { "gfxterm_heb", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0xcc83dbb8, 0x7fa3d9db, 0xcc83dbb8, 0x3e5150c8, 0x724366e5, 0x724366e5, 0x3d838d1c, 0x3d838d1c, 0x3d838d1c, 0x64137e4c, 0x64137e4c, 0x64137e4c, 0xaca4100e, 0xaca4100e, 0xaca4100e, 0x724366e5, 0x3e5150c8, 0x3e5150c8, 0x724366e5, }, 20 },
- { "gfxterm_heb", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x2a9a3393, 0xc249bea, 0x2a9a3393, 0x2afa8b35, 0x1c955882, 0x1c955882, 0x9c6441e2, 0x9c6441e2, 0x9c6441e2, 0x53930c75, 0x53930c75, 0x53930c75, 0xadfa0060, 0xadfa0060, 0xadfa0060, 0x1c955882, 0x2afa8b35, 0x2afa8b35, 0x1c955882, }, 20 },
- { "gfxterm_heb", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xcf807eaa, 0x4af8ad98, 0xcf807eaa, 0xb92e7ae, 0x4d266f7a, 0x4d266f7a, 0x15d955c1, 0x15d955c1, 0x15d955c1, 0xf3ae4e7e, 0xf3ae4e7e, 0xf3ae4e7e, 0x6b971aee, 0x6b971aee, 0x6b971aee, 0x4d266f7a, 0xb92e7ae, 0xb92e7ae, 0x4d266f7a, }, 20 },
- { "gfxterm_heb", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x98e40974, 0xf0ed7ac2, 0x98e40974, 0x4100893, 0x1ed9d731, 0x1ed9d731, 0x7d102c2f, 0x7d102c2f, 0x7d102c2f, 0xd37432ea, 0xd37432ea, 0xd37432ea, 0xf01d235c, 0xf01d235c, 0xf01d235c, 0x1ed9d731, 0x4100893, 0x4100893, 0x1ed9d731, }, 20 },
- { "gfxterm_heb", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xeada5358, 0xa5081c9c, 0xeada5358, 0xaed1a9e4, 0x5387d57f, 0x5387d57f, 0xe7380617, 0xe7380617, 0xe7380617, 0x27616adb, 0x27616adb, 0x27616adb, 0xc0bfe84d, 0xc0bfe84d, 0xc0bfe84d, 0x5387d57f, 0xaed1a9e4, 0xaed1a9e4, 0x5387d57f, }, 20 },
- { "gfxterm_heb", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x167e9ac0, 0xc5a57b5f, 0x167e9ac0, 0xac16d75f, 0xf83ee7aa, 0xf83ee7aa, 0xb47ab0cb, 0xb47ab0cb, 0xb47ab0cb, 0x28036038, 0x28036038, 0x28036038, 0x10b0cb90, 0x10b0cb90, 0x10b0cb90, 0xf83ee7aa, 0xac16d75f, 0xac16d75f, 0xf83ee7aa, }, 20 },
- { "gfxterm_heb", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xfd0449a3, 0xb946b16a, 0xfd0449a3, 0xec71fcf6, 0x724366e5, 0x724366e5, 0xab4d15ce, 0xab4d15ce, 0xab4d15ce, 0xec745734, 0xec745734, 0xec745734, 0x815a707e, 0x815a707e, 0x815a707e, 0x724366e5, 0xec71fcf6, 0xec71fcf6, 0x724366e5, }, 20 },
- { "gfxterm_heb", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x1eb746a, 0x74afe43, 0x1eb746a, 0xee7fc953, 0x5387d57f, 0x5387d57f, 0x704981d6, 0x704981d6, 0x704981d6, 0xae87ce0b, 0xae87ce0b, 0xae87ce0b, 0x3d045c15, 0x3d045c15, 0x3d045c15, 0x5387d57f, 0xee7fc953, 0xee7fc953, 0x5387d57f, }, 20 },
- { "gfxterm_heb", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xb9fa44c, 0xff4e04c7, 0xb9fa44c, 0x7a559aa0, 0xf83ee7aa, 0xf83ee7aa, 0xfccbce43, 0xfccbce43, 0xfccbce43, 0x8e11dd73, 0x8e11dd73, 0x8e11dd73, 0xbf848cb5, 0xbf848cb5, 0xbf848cb5, 0xf83ee7aa, 0x7a559aa0, 0x7a559aa0, 0xf83ee7aa, }, 20 },
- { "gfxterm_heb", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0xcc83dbb8, 0x7fa3d9db, 0xcc83dbb8, 0x3e5150c8, 0x724366e5, 0x724366e5, 0x3d838d1c, 0x3d838d1c, 0x3d838d1c, 0x64137e4c, 0x64137e4c, 0x64137e4c, 0xaca4100e, 0xaca4100e, 0xaca4100e, 0x724366e5, 0x3e5150c8, 0x3e5150c8, 0x724366e5, }, 20 },
- { "gfxterm_heb", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x2a9a3393, 0xc249bea, 0x2a9a3393, 0x2afa8b35, 0x1c955882, 0x1c955882, 0x9c6441e2, 0x9c6441e2, 0x9c6441e2, 0x53930c75, 0x53930c75, 0x53930c75, 0xadfa0060, 0xadfa0060, 0xadfa0060, 0x1c955882, 0x2afa8b35, 0x2afa8b35, 0x1c955882, }, 20 },
- { "gfxterm_heb", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xcf807eaa, 0x4af8ad98, 0xcf807eaa, 0xb92e7ae, 0x4d266f7a, 0x4d266f7a, 0x15d955c1, 0x15d955c1, 0x15d955c1, 0xf3ae4e7e, 0xf3ae4e7e, 0xf3ae4e7e, 0x6b971aee, 0x6b971aee, 0x6b971aee, 0x4d266f7a, 0xb92e7ae, 0xb92e7ae, 0x4d266f7a, }, 20 },
- { "gfxterm_heb", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x98e40974, 0xf0ed7ac2, 0x98e40974, 0x4100893, 0x1ed9d731, 0x1ed9d731, 0x7d102c2f, 0x7d102c2f, 0x7d102c2f, 0xd37432ea, 0xd37432ea, 0xd37432ea, 0xf01d235c, 0xf01d235c, 0xf01d235c, 0x1ed9d731, 0x4100893, 0x4100893, 0x1ed9d731, }, 20 },
- { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x27813091, 0xd32064ba, 0x27813091, 0x7799943f, 0x9813a416, 0x9813a416, 0x5cfa5159, 0x5cfa5159, 0x5cfa5159, 0xcd21d76a, 0xcd21d76a, 0xcd21d76a, 0x515422a8, 0x515422a8, 0x515422a8, 0x9813a416, 0x7799943f, 0x7799943f, 0x9813a416, }, 20 },
- { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf107273d, 0xd1d8f23b, 0xf107273d, 0xcbcdf6c7, 0x5fcf013d, 0x5fcf013d, 0x164d5584, 0x164d5584, 0x164d5584, 0xc45d4df2, 0xc45d4df2, 0xc45d4df2, 0xdb76cc0f, 0xdb76cc0f, 0xdb76cc0f, 0x5fcf013d, 0xcbcdf6c7, 0xcbcdf6c7, 0x5fcf013d, }, 20 },
- { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xa54fb200, 0x92d6596f, 0xa54fb200, 0xc53c166a, 0xdd28f52b, 0xdd28f52b, 0x97b266c9, 0x97b266c9, 0x97b266c9, 0xb68e9f2d, 0xb68e9f2d, 0xb68e9f2d, 0xacfffcbc, 0xacfffcbc, 0xacfffcbc, 0xdd28f52b, 0xc53c166a, 0xc53c166a, 0xdd28f52b, }, 20 },
- { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xfe511789, 0x421405b3, 0xfe511789, 0xbda7dace, 0x59c36f00, 0x59c36f00, 0x2a367884, 0x2a367884, 0x2a367884, 0x54b615e2, 0x54b615e2, 0x54b615e2, 0x9794282f, 0x9794282f, 0x9794282f, 0x59c36f00, 0xbda7dace, 0xbda7dace, 0x59c36f00, }, 20 },
- { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2616eaaf, 0xd0263182, 0x2616eaaf, 0x8136fd0, 0xaa4593fe, 0xaa4593fe, 0x5b85b7a8, 0x5b85b7a8, 0x5b85b7a8, 0xfd70bacf, 0xfd70bacf, 0xfd70bacf, 0x7fd758a4, 0x7fd758a4, 0x7fd758a4, 0xaa4593fe, 0x8136fd0, 0x8136fd0, 0xaa4593fe, }, 20 },
- { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9214e205, 0x211e70db, 0x9214e205, 0xcf038f81, 0xc9cbf769, 0xc9cbf769, 0x5a304c, 0x5a304c, 0x5a304c, 0xfe82f180, 0xfe82f180, 0xfe82f180, 0x16d45e8c, 0x16d45e8c, 0x16d45e8c, 0xc9cbf769, 0xcf038f81, 0xcf038f81, 0xc9cbf769, }, 20 },
- { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x8bbe1e38, 0xfef8974b, 0x8bbe1e38, 0xdba6ba96, 0x9813a416, 0x9813a416, 0xdf1a19a3, 0xdf1a19a3, 0xdf1a19a3, 0x4ec19f90, 0x4ec19f90, 0x4ec19f90, 0xd2b46a52, 0xd2b46a52, 0xd2b46a52, 0x9813a416, 0xdba6ba96, 0xdba6ba96, 0x9813a416, }, 20 },
- { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xda045c37, 0xb8ae26e3, 0xda045c37, 0xe0ce8dcd, 0x5fcf013d, 0x5fcf013d, 0xee7a1c7, 0xee7a1c7, 0xee7a1c7, 0xdcf7b9b1, 0xdcf7b9b1, 0xdcf7b9b1, 0xc3dc384c, 0xc3dc384c, 0xc3dc384c, 0x5fcf013d, 0xe0ce8dcd, 0xe0ce8dcd, 0x5fcf013d, }, 20 },
- { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2e35339d, 0x798918b, 0x2e35339d, 0x4e4697f7, 0xdd28f52b, 0xdd28f52b, 0x92c68d60, 0x92c68d60, 0x92c68d60, 0xb3fa7484, 0xb3fa7484, 0xb3fa7484, 0xa98b1715, 0xa98b1715, 0xa98b1715, 0xdd28f52b, 0x4e4697f7, 0x4e4697f7, 0xdd28f52b, }, 20 },
- { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xb5c5482e, 0xeec9616, 0xb5c5482e, 0x4b834543, 0x43d1f34, 0x43d1f34, 0xd4fadab2, 0xd4fadab2, 0xd4fadab2, 0xabf0731a, 0xabf0731a, 0xabf0731a, 0x43d04a33, 0x43d04a33, 0x43d04a33, 0x43d1f34, 0x4b834543, 0x4b834543, 0x43d1f34, }, 20 },
- { "gfxterm_gre", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xfe511789, 0x421405b3, 0xfe511789, 0xbda7dace, 0x59c36f00, 0x59c36f00, 0x2a367884, 0x2a367884, 0x2a367884, 0x54b615e2, 0x54b615e2, 0x54b615e2, 0x9794282f, 0x9794282f, 0x9794282f, 0x59c36f00, 0xbda7dace, 0xbda7dace, 0x59c36f00, }, 20 },
- { "gfxterm_gre", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x2616eaaf, 0xd0263182, 0x2616eaaf, 0x8136fd0, 0xaa4593fe, 0xaa4593fe, 0x5b85b7a8, 0x5b85b7a8, 0x5b85b7a8, 0xfd70bacf, 0xfd70bacf, 0xfd70bacf, 0x7fd758a4, 0x7fd758a4, 0x7fd758a4, 0xaa4593fe, 0x8136fd0, 0x8136fd0, 0xaa4593fe, }, 20 },
- { "gfxterm_gre", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x9214e205, 0x211e70db, 0x9214e205, 0xcf038f81, 0xc9cbf769, 0xc9cbf769, 0x5a304c, 0x5a304c, 0x5a304c, 0xfe82f180, 0xfe82f180, 0xfe82f180, 0x16d45e8c, 0x16d45e8c, 0x16d45e8c, 0xc9cbf769, 0xcf038f81, 0xcf038f81, 0xc9cbf769, }, 20 },
- { "gfxterm_gre", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xa841a245, 0x7c4a37aa, 0xa841a245, 0xec4a58f9, 0x5387d57f, 0x5387d57f, 0x8670fc38, 0x8670fc38, 0x8670fc38, 0x462990f4, 0x462990f4, 0x462990f4, 0xa1f71262, 0xa1f71262, 0xa1f71262, 0x5387d57f, 0xec4a58f9, 0xec4a58f9, 0x5387d57f, }, 20 },
- { "gfxterm_gre", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc589c63a, 0xda1b2d71, 0xc589c63a, 0x7fe18ba5, 0xf83ee7aa, 0xf83ee7aa, 0x74883fe5, 0x74883fe5, 0x74883fe5, 0xe8f1ef16, 0xe8f1ef16, 0xe8f1ef16, 0xd04244be, 0xd04244be, 0xd04244be, 0xf83ee7aa, 0x7fe18ba5, 0x7fe18ba5, 0xf83ee7aa, }, 20 },
- { "gfxterm_gre", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x5df86da, 0x97465d78, 0x5df86da, 0x14aa338f, 0x724366e5, 0x724366e5, 0x60829227, 0x60829227, 0x60829227, 0x27bbd0dd, 0x27bbd0dd, 0x27bbd0dd, 0x4a95f797, 0x4a95f797, 0x4a95f797, 0x724366e5, 0x14aa338f, 0x14aa338f, 0x724366e5, }, 20 },
- { "gfxterm_gre", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xebf6bdc1, 0xaf2c370b, 0xebf6bdc1, 0x46200f8, 0x5387d57f, 0x5387d57f, 0x81cd0740, 0x81cd0740, 0x81cd0740, 0x5f03489d, 0x5f03489d, 0x5f03489d, 0xcc80da83, 0xcc80da83, 0xcc80da83, 0x5387d57f, 0x46200f8, 0x46200f8, 0x5387d57f, }, 20 },
- { "gfxterm_gre", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x5455b923, 0x93681ea, 0x5455b923, 0x259f87cf, 0xf83ee7aa, 0xf83ee7aa, 0xf5cd3d43, 0xf5cd3d43, 0xf5cd3d43, 0x87172e73, 0x87172e73, 0x87172e73, 0xb6827fb5, 0xb6827fb5, 0xb6827fb5, 0xf83ee7aa, 0x259f87cf, 0x259f87cf, 0xf83ee7aa, }, 20 },
- { "gfxterm_gre", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0xec9a1f85, 0x74e0a22a, 0xec9a1f85, 0x1e4894f5, 0x724366e5, 0x724366e5, 0xa74db0e6, 0xa74db0e6, 0xa74db0e6, 0xfedd43b6, 0xfedd43b6, 0xfedd43b6, 0x366a2df4, 0x366a2df4, 0x366a2df4, 0x724366e5, 0x1e4894f5, 0x1e4894f5, 0x724366e5, }, 20 },
- { "gfxterm_gre", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x8cac1ee1, 0x7824cfba, 0x8cac1ee1, 0x8ccca647, 0x1c955882, 0x1c955882, 0xec40c88e, 0xec40c88e, 0xec40c88e, 0x23b78519, 0x23b78519, 0x23b78519, 0xddde890c, 0xddde890c, 0xddde890c, 0x1c955882, 0x8ccca647, 0x8ccca647, 0x1c955882, }, 20 },
- { "gfxterm_gre", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xccb8f998, 0x89af656f, 0xccb8f998, 0x8aa609c, 0x4d266f7a, 0x4d266f7a, 0x863eb372, 0x863eb372, 0x863eb372, 0x6049a8cd, 0x6049a8cd, 0x6049a8cd, 0xf870fc5d, 0xf870fc5d, 0xf870fc5d, 0x4d266f7a, 0x8aa609c, 0x8aa609c, 0x4d266f7a, }, 20 },
- { "gfxterm_gre", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xa3bd882a, 0x5adc164, 0xa3bd882a, 0x3f4989cd, 0x1ed9d731, 0x1ed9d731, 0x46a1472c, 0x46a1472c, 0x46a1472c, 0xe8c559e9, 0xe8c559e9, 0xe8c559e9, 0xcbac485f, 0xcbac485f, 0xcbac485f, 0x1ed9d731, 0x3f4989cd, 0x3f4989cd, 0x1ed9d731, }, 20 },
- { "gfxterm_gre", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xa841a245, 0x7c4a37aa, 0xa841a245, 0xec4a58f9, 0x5387d57f, 0x5387d57f, 0x8670fc38, 0x8670fc38, 0x8670fc38, 0x462990f4, 0x462990f4, 0x462990f4, 0xa1f71262, 0xa1f71262, 0xa1f71262, 0x5387d57f, 0xec4a58f9, 0xec4a58f9, 0x5387d57f, }, 20 },
- { "gfxterm_gre", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc589c63a, 0xda1b2d71, 0xc589c63a, 0x7fe18ba5, 0xf83ee7aa, 0xf83ee7aa, 0x74883fe5, 0x74883fe5, 0x74883fe5, 0xe8f1ef16, 0xe8f1ef16, 0xe8f1ef16, 0xd04244be, 0xd04244be, 0xd04244be, 0xf83ee7aa, 0x7fe18ba5, 0x7fe18ba5, 0xf83ee7aa, }, 20 },
- { "gfxterm_gre", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x5df86da, 0x97465d78, 0x5df86da, 0x14aa338f, 0x724366e5, 0x724366e5, 0x60829227, 0x60829227, 0x60829227, 0x27bbd0dd, 0x27bbd0dd, 0x27bbd0dd, 0x4a95f797, 0x4a95f797, 0x4a95f797, 0x724366e5, 0x14aa338f, 0x14aa338f, 0x724366e5, }, 20 },
- { "gfxterm_gre", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xebf6bdc1, 0xaf2c370b, 0xebf6bdc1, 0x46200f8, 0x5387d57f, 0x5387d57f, 0x81cd0740, 0x81cd0740, 0x81cd0740, 0x5f03489d, 0x5f03489d, 0x5f03489d, 0xcc80da83, 0xcc80da83, 0xcc80da83, 0x5387d57f, 0x46200f8, 0x46200f8, 0x5387d57f, }, 20 },
- { "gfxterm_gre", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x5455b923, 0x93681ea, 0x5455b923, 0x259f87cf, 0xf83ee7aa, 0xf83ee7aa, 0xf5cd3d43, 0xf5cd3d43, 0xf5cd3d43, 0x87172e73, 0x87172e73, 0x87172e73, 0xb6827fb5, 0xb6827fb5, 0xb6827fb5, 0xf83ee7aa, 0x259f87cf, 0x259f87cf, 0xf83ee7aa, }, 20 },
- { "gfxterm_gre", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0xec9a1f85, 0x74e0a22a, 0xec9a1f85, 0x1e4894f5, 0x724366e5, 0x724366e5, 0xa74db0e6, 0xa74db0e6, 0xa74db0e6, 0xfedd43b6, 0xfedd43b6, 0xfedd43b6, 0x366a2df4, 0x366a2df4, 0x366a2df4, 0x724366e5, 0x1e4894f5, 0x1e4894f5, 0x724366e5, }, 20 },
- { "gfxterm_gre", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x8cac1ee1, 0x7824cfba, 0x8cac1ee1, 0x8ccca647, 0x1c955882, 0x1c955882, 0xec40c88e, 0xec40c88e, 0xec40c88e, 0x23b78519, 0x23b78519, 0x23b78519, 0xddde890c, 0xddde890c, 0xddde890c, 0x1c955882, 0x8ccca647, 0x8ccca647, 0x1c955882, }, 20 },
- { "gfxterm_gre", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xccb8f998, 0x89af656f, 0xccb8f998, 0x8aa609c, 0x4d266f7a, 0x4d266f7a, 0x863eb372, 0x863eb372, 0x863eb372, 0x6049a8cd, 0x6049a8cd, 0x6049a8cd, 0xf870fc5d, 0xf870fc5d, 0xf870fc5d, 0x4d266f7a, 0x8aa609c, 0x8aa609c, 0x4d266f7a, }, 20 },
- { "gfxterm_gre", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xa3bd882a, 0x5adc164, 0xa3bd882a, 0x3f4989cd, 0x1ed9d731, 0x1ed9d731, 0x46a1472c, 0x46a1472c, 0x46a1472c, 0xe8c559e9, 0xe8c559e9, 0xe8c559e9, 0xcbac485f, 0xcbac485f, 0xcbac485f, 0x1ed9d731, 0x3f4989cd, 0x3f4989cd, 0x1ed9d731, }, 20 },
- { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x8bbe1e38, 0xfef8974b, 0x8bbe1e38, 0xdba6ba96, 0x9813a416, 0x9813a416, 0xdf1a19a3, 0xdf1a19a3, 0xdf1a19a3, 0x4ec19f90, 0x4ec19f90, 0x4ec19f90, 0xd2b46a52, 0xd2b46a52, 0xd2b46a52, 0x9813a416, 0xdba6ba96, 0xdba6ba96, 0x9813a416, }, 20 },
- { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xda045c37, 0xb8ae26e3, 0xda045c37, 0xe0ce8dcd, 0x5fcf013d, 0x5fcf013d, 0xee7a1c7, 0xee7a1c7, 0xee7a1c7, 0xdcf7b9b1, 0xdcf7b9b1, 0xdcf7b9b1, 0xc3dc384c, 0xc3dc384c, 0xc3dc384c, 0x5fcf013d, 0xe0ce8dcd, 0xe0ce8dcd, 0x5fcf013d, }, 20 },
- { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2e35339d, 0x798918b, 0x2e35339d, 0x4e4697f7, 0xdd28f52b, 0xdd28f52b, 0x92c68d60, 0x92c68d60, 0x92c68d60, 0xb3fa7484, 0xb3fa7484, 0xb3fa7484, 0xa98b1715, 0xa98b1715, 0xa98b1715, 0xdd28f52b, 0x4e4697f7, 0x4e4697f7, 0xdd28f52b, }, 20 },
- { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xef4073b7, 0x7c0ec717, 0xef4073b7, 0xacb6bef0, 0x59c36f00, 0x59c36f00, 0x1b206d14, 0x1b206d14, 0x1b206d14, 0x65a00072, 0x65a00072, 0x65a00072, 0xa6823dbf, 0xa6823dbf, 0xa6823dbf, 0x59c36f00, 0xacb6bef0, 0xacb6bef0, 0x59c36f00, }, 20 },
- { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x439c3f9c, 0xb979a570, 0x439c3f9c, 0x6d99bae3, 0xaa4593fe, 0xaa4593fe, 0x7c7873ca, 0x7c7873ca, 0x7c7873ca, 0xda8d7ead, 0xda8d7ead, 0xda8d7ead, 0x582a9cc6, 0x582a9cc6, 0x582a9cc6, 0xaa4593fe, 0x6d99bae3, 0x6d99bae3, 0xaa4593fe, }, 20 },
- { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5ba2c945, 0x8734093, 0x5ba2c945, 0x6b5a4c1, 0xc9cbf769, 0xc9cbf769, 0xa3843a5a, 0xa3843a5a, 0xa3843a5a, 0x5d5cfb96, 0x5d5cfb96, 0x5d5cfb96, 0xb50a549a, 0xb50a549a, 0xb50a549a, 0xc9cbf769, 0x6b5a4c1, 0x6b5a4c1, 0xc9cbf769, }, 20 },
- { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1d557c7b, 0x8d172abd, 0x1d557c7b, 0x4d4dd8d5, 0x9813a416, 0x9813a416, 0xae45df54, 0xae45df54, 0xae45df54, 0x3f9e5967, 0x3f9e5967, 0x3f9e5967, 0xa3ebaca5, 0xa3ebaca5, 0xa3ebaca5, 0x9813a416, 0x4d4dd8d5, 0x4d4dd8d5, 0x9813a416, }, 20 },
- { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x75e8bbc6, 0x79f972a, 0x75e8bbc6, 0x4f226a3c, 0x5fcf013d, 0x5fcf013d, 0xe1849dd3, 0xe1849dd3, 0xe1849dd3, 0x339485a5, 0x339485a5, 0x339485a5, 0x2cbf0458, 0x2cbf0458, 0x2cbf0458, 0x5fcf013d, 0x4f226a3c, 0x4f226a3c, 0x5fcf013d, }, 20 },
- { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7391ddfb, 0x7d352e1, 0x7391ddfb, 0x13e27991, 0xdd28f52b, 0xdd28f52b, 0x25591550, 0x25591550, 0x25591550, 0x465ecb4, 0x465ecb4, 0x465ecb4, 0x1e148f25, 0x1e148f25, 0x1e148f25, 0xdd28f52b, 0x13e27991, 0x13e27991, 0xdd28f52b, }, 20 },
- { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc009461b, 0xbaf1821c, 0xc009461b, 0x3e4f4b76, 0x43d1f34, 0x43d1f34, 0x19165017, 0x19165017, 0x19165017, 0x661cf9bf, 0x661cf9bf, 0x661cf9bf, 0x8e3cc096, 0x8e3cc096, 0x8e3cc096, 0x43d1f34, 0x3e4f4b76, 0x3e4f4b76, 0x43d1f34, }, 20 },
- { "gfxterm_ru", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xef4073b7, 0x7c0ec717, 0xef4073b7, 0xacb6bef0, 0x59c36f00, 0x59c36f00, 0x1b206d14, 0x1b206d14, 0x1b206d14, 0x65a00072, 0x65a00072, 0x65a00072, 0xa6823dbf, 0xa6823dbf, 0xa6823dbf, 0x59c36f00, 0xacb6bef0, 0xacb6bef0, 0x59c36f00, }, 20 },
- { "gfxterm_ru", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x439c3f9c, 0xb979a570, 0x439c3f9c, 0x6d99bae3, 0xaa4593fe, 0xaa4593fe, 0x7c7873ca, 0x7c7873ca, 0x7c7873ca, 0xda8d7ead, 0xda8d7ead, 0xda8d7ead, 0x582a9cc6, 0x582a9cc6, 0x582a9cc6, 0xaa4593fe, 0x6d99bae3, 0x6d99bae3, 0xaa4593fe, }, 20 },
- { "gfxterm_ru", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x5ba2c945, 0x8734093, 0x5ba2c945, 0x6b5a4c1, 0xc9cbf769, 0xc9cbf769, 0xa3843a5a, 0xa3843a5a, 0xa3843a5a, 0x5d5cfb96, 0x5d5cfb96, 0x5d5cfb96, 0xb50a549a, 0xb50a549a, 0xb50a549a, 0xc9cbf769, 0x6b5a4c1, 0x6b5a4c1, 0xc9cbf769, }, 20 },
- { "gfxterm_ru", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xb36b0c97, 0x8089853c, 0xb36b0c97, 0xf760f62b, 0x5387d57f, 0x5387d57f, 0x26a49a0, 0x26a49a0, 0x26a49a0, 0xc233256c, 0xc233256c, 0xc233256c, 0x25eda7fa, 0x25eda7fa, 0x25eda7fa, 0x5387d57f, 0xf760f62b, 0xf760f62b, 0x5387d57f, }, 20 },
- { "gfxterm_ru", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x73036285, 0xc9508972, 0x73036285, 0xc96b2f1a, 0xf83ee7aa, 0xf83ee7aa, 0xd1a3be96, 0xd1a3be96, 0xd1a3be96, 0x4dda6e65, 0x4dda6e65, 0x4dda6e65, 0x7569c5cd, 0x7569c5cd, 0x7569c5cd, 0xf83ee7aa, 0xc96b2f1a, 0xc96b2f1a, 0xf83ee7aa, }, 20 },
- { "gfxterm_ru", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x2f903fa3, 0xb074c7d0, 0x2f903fa3, 0x3ee58af6, 0x724366e5, 0x724366e5, 0xd7d194f8, 0xd7d194f8, 0xd7d194f8, 0x90e8d602, 0x90e8d602, 0x90e8d602, 0xfdc6f148, 0xfdc6f148, 0xfdc6f148, 0x724366e5, 0x3ee58af6, 0x3ee58af6, 0x724366e5, }, 20 },
- { "gfxterm_ru", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xa54ffd19, 0xf7cc7ac2, 0xa54ffd19, 0x4adb4020, 0x5387d57f, 0x5387d57f, 0x5dbc1d5, 0x5dbc1d5, 0x5dbc1d5, 0xdb158e08, 0xdb158e08, 0xdb158e08, 0x48961c16, 0x48961c16, 0x48961c16, 0x5387d57f, 0x4adb4020, 0x4adb4020, 0x5387d57f, }, 20 },
- { "gfxterm_ru", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc66fad35, 0x8aac8190, 0xc66fad35, 0xb7a593d9, 0xf83ee7aa, 0xf83ee7aa, 0xb36d8105, 0xb36d8105, 0xb36d8105, 0xc1b79235, 0xc1b79235, 0xc1b79235, 0xf022c3f3, 0xf022c3f3, 0xf022c3f3, 0xf83ee7aa, 0xb7a593d9, 0xb7a593d9, 0xf83ee7aa, }, 20 },
- { "gfxterm_ru", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x7f916214, 0x1c80967c, 0x7f916214, 0x8d43e964, 0x724366e5, 0x724366e5, 0xe456696, 0xe456696, 0xe456696, 0x57d595c6, 0x57d595c6, 0x57d595c6, 0x9f62fb84, 0x9f62fb84, 0x9f62fb84, 0x724366e5, 0x8d43e964, 0x8d43e964, 0x724366e5, }, 20 },
- { "gfxterm_ru", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x4aeca683, 0xffbbb38e, 0x4aeca683, 0x4a8c1e25, 0x1c955882, 0x1c955882, 0xa0d2f3f6, 0xa0d2f3f6, 0xa0d2f3f6, 0x6f25be61, 0x6f25be61, 0x6f25be61, 0x914cb274, 0x914cb274, 0x914cb274, 0x1c955882, 0x4a8c1e25, 0x4a8c1e25, 0x1c955882, }, 20 },
- { "gfxterm_ru", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb44532a7, 0x73b09a92, 0xb44532a7, 0x7057aba3, 0x4d266f7a, 0x4d266f7a, 0x83606d88, 0x83606d88, 0x83606d88, 0x65177637, 0x65177637, 0x65177637, 0xfd2e22a7, 0xfd2e22a7, 0xfd2e22a7, 0x4d266f7a, 0x7057aba3, 0x7057aba3, 0x4d266f7a, }, 20 },
- { "gfxterm_ru", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x62257381, 0xd5d910, 0x62257381, 0xfed17266, 0x1ed9d731, 0x1ed9d731, 0x12670373, 0x12670373, 0x12670373, 0xbc031db6, 0xbc031db6, 0xbc031db6, 0x9f6a0c00, 0x9f6a0c00, 0x9f6a0c00, 0x1ed9d731, 0xfed17266, 0xfed17266, 0x1ed9d731, }, 20 },
- { "gfxterm_ru", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xb36b0c97, 0x8089853c, 0xb36b0c97, 0xf760f62b, 0x5387d57f, 0x5387d57f, 0x26a49a0, 0x26a49a0, 0x26a49a0, 0xc233256c, 0xc233256c, 0xc233256c, 0x25eda7fa, 0x25eda7fa, 0x25eda7fa, 0x5387d57f, 0xf760f62b, 0xf760f62b, 0x5387d57f, }, 20 },
- { "gfxterm_ru", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x73036285, 0xc9508972, 0x73036285, 0xc96b2f1a, 0xf83ee7aa, 0xf83ee7aa, 0xd1a3be96, 0xd1a3be96, 0xd1a3be96, 0x4dda6e65, 0x4dda6e65, 0x4dda6e65, 0x7569c5cd, 0x7569c5cd, 0x7569c5cd, 0xf83ee7aa, 0xc96b2f1a, 0xc96b2f1a, 0xf83ee7aa, }, 20 },
- { "gfxterm_ru", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x2f903fa3, 0xb074c7d0, 0x2f903fa3, 0x3ee58af6, 0x724366e5, 0x724366e5, 0xd7d194f8, 0xd7d194f8, 0xd7d194f8, 0x90e8d602, 0x90e8d602, 0x90e8d602, 0xfdc6f148, 0xfdc6f148, 0xfdc6f148, 0x724366e5, 0x3ee58af6, 0x3ee58af6, 0x724366e5, }, 20 },
- { "gfxterm_ru", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xa54ffd19, 0xf7cc7ac2, 0xa54ffd19, 0x4adb4020, 0x5387d57f, 0x5387d57f, 0x5dbc1d5, 0x5dbc1d5, 0x5dbc1d5, 0xdb158e08, 0xdb158e08, 0xdb158e08, 0x48961c16, 0x48961c16, 0x48961c16, 0x5387d57f, 0x4adb4020, 0x4adb4020, 0x5387d57f, }, 20 },
- { "gfxterm_ru", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc66fad35, 0x8aac8190, 0xc66fad35, 0xb7a593d9, 0xf83ee7aa, 0xf83ee7aa, 0xb36d8105, 0xb36d8105, 0xb36d8105, 0xc1b79235, 0xc1b79235, 0xc1b79235, 0xf022c3f3, 0xf022c3f3, 0xf022c3f3, 0xf83ee7aa, 0xb7a593d9, 0xb7a593d9, 0xf83ee7aa, }, 20 },
- { "gfxterm_ru", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x7f916214, 0x1c80967c, 0x7f916214, 0x8d43e964, 0x724366e5, 0x724366e5, 0xe456696, 0xe456696, 0xe456696, 0x57d595c6, 0x57d595c6, 0x57d595c6, 0x9f62fb84, 0x9f62fb84, 0x9f62fb84, 0x724366e5, 0x8d43e964, 0x8d43e964, 0x724366e5, }, 20 },
- { "gfxterm_ru", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x4aeca683, 0xffbbb38e, 0x4aeca683, 0x4a8c1e25, 0x1c955882, 0x1c955882, 0xa0d2f3f6, 0xa0d2f3f6, 0xa0d2f3f6, 0x6f25be61, 0x6f25be61, 0x6f25be61, 0x914cb274, 0x914cb274, 0x914cb274, 0x1c955882, 0x4a8c1e25, 0x4a8c1e25, 0x1c955882, }, 20 },
- { "gfxterm_ru", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb44532a7, 0x73b09a92, 0xb44532a7, 0x7057aba3, 0x4d266f7a, 0x4d266f7a, 0x83606d88, 0x83606d88, 0x83606d88, 0x65177637, 0x65177637, 0x65177637, 0xfd2e22a7, 0xfd2e22a7, 0xfd2e22a7, 0x4d266f7a, 0x7057aba3, 0x7057aba3, 0x4d266f7a, }, 20 },
- { "gfxterm_ru", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x62257381, 0xd5d910, 0x62257381, 0xfed17266, 0x1ed9d731, 0x1ed9d731, 0x12670373, 0x12670373, 0x12670373, 0xbc031db6, 0xbc031db6, 0xbc031db6, 0x9f6a0c00, 0x9f6a0c00, 0x9f6a0c00, 0x1ed9d731, 0xfed17266, 0xfed17266, 0x1ed9d731, }, 20 },
- { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x1d557c7b, 0x8d172abd, 0x1d557c7b, 0x4d4dd8d5, 0x9813a416, 0x9813a416, 0xae45df54, 0xae45df54, 0xae45df54, 0x3f9e5967, 0x3f9e5967, 0x3f9e5967, 0xa3ebaca5, 0xa3ebaca5, 0xa3ebaca5, 0x9813a416, 0x4d4dd8d5, 0x4d4dd8d5, 0x9813a416, }, 20 },
- { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x75e8bbc6, 0x79f972a, 0x75e8bbc6, 0x4f226a3c, 0x5fcf013d, 0x5fcf013d, 0xe1849dd3, 0xe1849dd3, 0xe1849dd3, 0x339485a5, 0x339485a5, 0x339485a5, 0x2cbf0458, 0x2cbf0458, 0x2cbf0458, 0x5fcf013d, 0x4f226a3c, 0x4f226a3c, 0x5fcf013d, }, 20 },
- { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7391ddfb, 0x7d352e1, 0x7391ddfb, 0x13e27991, 0xdd28f52b, 0xdd28f52b, 0x25591550, 0x25591550, 0x25591550, 0x465ecb4, 0x465ecb4, 0x465ecb4, 0x1e148f25, 0x1e148f25, 0x1e148f25, 0xdd28f52b, 0x13e27991, 0x13e27991, 0xdd28f52b, }, 20 },
- { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x371337c9, 0x8aa416bc, 0x371337c9, 0x74e5fa8e, 0x59c36f00, 0x59c36f00, 0xb169e11b, 0xb169e11b, 0xb169e11b, 0xcfe98c7d, 0xcfe98c7d, 0xcfe98c7d, 0xccbb1b0, 0xccbb1b0, 0xccbb1b0, 0x59c36f00, 0x74e5fa8e, 0x74e5fa8e, 0x59c36f00, }, 20 },
- { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x38692869, 0xefb9c2f4, 0x38692869, 0x166cad16, 0xaa4593fe, 0xaa4593fe, 0xe4f03f82, 0xe4f03f82, 0xe4f03f82, 0x420532e5, 0x420532e5, 0x420532e5, 0xc0a2d08e, 0xc0a2d08e, 0xc0a2d08e, 0xaa4593fe, 0x166cad16, 0x166cad16, 0xaa4593fe, }, 20 },
- { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x7eb7ddfd, 0x19db9bb1, 0x7eb7ddfd, 0x23a0b079, 0xc9cbf769, 0xc9cbf769, 0x4500ac91, 0x4500ac91, 0x4500ac91, 0xbbd86d5d, 0xbbd86d5d, 0xbbd86d5d, 0x538ec251, 0x538ec251, 0x538ec251, 0xc9cbf769, 0x23a0b079, 0x23a0b079, 0xc9cbf769, }, 20 },
- { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x35512c6d, 0xe29deaf0, 0x35512c6d, 0x654988c3, 0x9813a416, 0x9813a416, 0xc6920c94, 0xc6920c94, 0xc6920c94, 0x57498aa7, 0x57498aa7, 0x57498aa7, 0xcb3c7f65, 0xcb3c7f65, 0xcb3c7f65, 0x9813a416, 0x654988c3, 0x654988c3, 0x9813a416, }, 20 },
- { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x73ff9071, 0x72b83f24, 0x73ff9071, 0x4935418b, 0x5fcf013d, 0x5fcf013d, 0x9963ff63, 0x9963ff63, 0x9963ff63, 0x4b73e715, 0x4b73e715, 0x4b73e715, 0x545866e8, 0x545866e8, 0x545866e8, 0x5fcf013d, 0x4935418b, 0x4935418b, 0x5fcf013d, }, 20 },
- { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x46811b4e, 0xa463f7aa, 0x46811b4e, 0x26f2bf24, 0xdd28f52b, 0xdd28f52b, 0x452cf740, 0x452cf740, 0x452cf740, 0x64100ea4, 0x64100ea4, 0x64100ea4, 0x7e616d35, 0x7e616d35, 0x7e616d35, 0xdd28f52b, 0x26f2bf24, 0x26f2bf24, 0xdd28f52b, }, 20 },
- { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xd89b7256, 0xe60a4e85, 0xd89b7256, 0x26dd7f3b, 0x43d1f34, 0x43d1f34, 0x55b946c0, 0x55b946c0, 0x55b946c0, 0x2ab3ef68, 0x2ab3ef68, 0x2ab3ef68, 0xc293d641, 0xc293d641, 0xc293d641, 0x43d1f34, 0x26dd7f3b, 0x26dd7f3b, 0x43d1f34, }, 20 },
- { "gfxterm_fr", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x371337c9, 0x8aa416bc, 0x371337c9, 0x74e5fa8e, 0x59c36f00, 0x59c36f00, 0xb169e11b, 0xb169e11b, 0xb169e11b, 0xcfe98c7d, 0xcfe98c7d, 0xcfe98c7d, 0xccbb1b0, 0xccbb1b0, 0xccbb1b0, 0x59c36f00, 0x74e5fa8e, 0x74e5fa8e, 0x59c36f00, }, 20 },
- { "gfxterm_fr", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x38692869, 0xefb9c2f4, 0x38692869, 0x166cad16, 0xaa4593fe, 0xaa4593fe, 0xe4f03f82, 0xe4f03f82, 0xe4f03f82, 0x420532e5, 0x420532e5, 0x420532e5, 0xc0a2d08e, 0xc0a2d08e, 0xc0a2d08e, 0xaa4593fe, 0x166cad16, 0x166cad16, 0xaa4593fe, }, 20 },
- { "gfxterm_fr", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x7eb7ddfd, 0x19db9bb1, 0x7eb7ddfd, 0x23a0b079, 0xc9cbf769, 0xc9cbf769, 0x4500ac91, 0x4500ac91, 0x4500ac91, 0xbbd86d5d, 0xbbd86d5d, 0xbbd86d5d, 0x538ec251, 0x538ec251, 0x538ec251, 0xc9cbf769, 0x23a0b079, 0x23a0b079, 0xc9cbf769, }, 20 },
- { "gfxterm_fr", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0x60f63dde, 0xcb069f7a, 0x60f63dde, 0x24fdc762, 0x5387d57f, 0x5387d57f, 0xf5998b00, 0xf5998b00, 0xf5998b00, 0x35c0e7cc, 0x35c0e7cc, 0x35c0e7cc, 0xd21e655a, 0xd21e655a, 0xd21e655a, 0x5387d57f, 0x24fdc762, 0x24fdc762, 0x5387d57f, }, 20 },
- { "gfxterm_fr", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8fa5f86d, 0xed066d2c, 0x8fa5f86d, 0x35cdb5f2, 0xf83ee7aa, 0xf83ee7aa, 0x26e9dc45, 0x26e9dc45, 0x26e9dc45, 0xba900cb6, 0xba900cb6, 0xba900cb6, 0x8223a71e, 0x8223a71e, 0x8223a71e, 0xf83ee7aa, 0x35cdb5f2, 0x35cdb5f2, 0xf83ee7aa, }, 20 },
- { "gfxterm_fr", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xf3ebce27, 0x64821e83, 0xf3ebce27, 0xe29e7b72, 0x724366e5, 0x724366e5, 0xf2920fc5, 0xf2920fc5, 0xf2920fc5, 0xb5ab4d3f, 0xb5ab4d3f, 0xb5ab4d3f, 0xd8856a75, 0xd8856a75, 0xd8856a75, 0x724366e5, 0xe29e7b72, 0xe29e7b72, 0x724366e5, }, 20 },
- { "gfxterm_fr", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xda2165d2, 0x5f811c6d, 0xda2165d2, 0x35b5d8eb, 0x5387d57f, 0x5387d57f, 0xe5a2fdfd, 0xe5a2fdfd, 0xe5a2fdfd, 0x3b6cb220, 0x3b6cb220, 0x3b6cb220, 0xa8ef203e, 0xa8ef203e, 0xa8ef203e, 0x5387d57f, 0x35b5d8eb, 0x35b5d8eb, 0x5387d57f, }, 20 },
- { "gfxterm_fr", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf52ba155, 0x4866b5cd, 0xf52ba155, 0x84e19fb9, 0xf83ee7aa, 0xf83ee7aa, 0xc1a44e99, 0xc1a44e99, 0xc1a44e99, 0xb37e5da9, 0xb37e5da9, 0xb37e5da9, 0x82eb0c6f, 0x82eb0c6f, 0x82eb0c6f, 0xf83ee7aa, 0x84e19fb9, 0x84e19fb9, 0xf83ee7aa, }, 20 },
- { "gfxterm_fr", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x16d37834, 0x72eb8d00, 0x16d37834, 0xe401f344, 0x724366e5, 0x724366e5, 0xc80f0332, 0xc80f0332, 0xc80f0332, 0x919ff062, 0x919ff062, 0x919ff062, 0x59289e20, 0x59289e20, 0x59289e20, 0x724366e5, 0xe401f344, 0xe401f344, 0x724366e5, }, 20 },
- { "gfxterm_fr", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x501ed137, 0x3eb913d3, 0x501ed137, 0x507e6991, 0x1c955882, 0x1c955882, 0xc988465d, 0xc988465d, 0xc988465d, 0x67f0bca, 0x67f0bca, 0x67f0bca, 0xf81607df, 0xf81607df, 0xf81607df, 0x1c955882, 0x507e6991, 0x507e6991, 0x1c955882, }, 20 },
- { "gfxterm_fr", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xdbf45ff0, 0x4b12f903, 0xdbf45ff0, 0x1fe6c6f4, 0x4d266f7a, 0x4d266f7a, 0xee77b36d, 0xee77b36d, 0xee77b36d, 0x800a8d2, 0x800a8d2, 0x800a8d2, 0x9039fc42, 0x9039fc42, 0x9039fc42, 0x4d266f7a, 0x1fe6c6f4, 0x1fe6c6f4, 0x4d266f7a, }, 20 },
- { "gfxterm_fr", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x6c3a9814, 0xaa19882a, 0x6c3a9814, 0xf0ce99f3, 0x1ed9d731, 0x1ed9d731, 0x5819ad52, 0x5819ad52, 0x5819ad52, 0xf67db397, 0xf67db397, 0xf67db397, 0xd514a221, 0xd514a221, 0xd514a221, 0x1ed9d731, 0xf0ce99f3, 0xf0ce99f3, 0x1ed9d731, }, 20 },
- { "gfxterm_fr", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x60f63dde, 0xcb069f7a, 0x60f63dde, 0x24fdc762, 0x5387d57f, 0x5387d57f, 0xf5998b00, 0xf5998b00, 0xf5998b00, 0x35c0e7cc, 0x35c0e7cc, 0x35c0e7cc, 0xd21e655a, 0xd21e655a, 0xd21e655a, 0x5387d57f, 0x24fdc762, 0x24fdc762, 0x5387d57f, }, 20 },
- { "gfxterm_fr", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8fa5f86d, 0xed066d2c, 0x8fa5f86d, 0x35cdb5f2, 0xf83ee7aa, 0xf83ee7aa, 0x26e9dc45, 0x26e9dc45, 0x26e9dc45, 0xba900cb6, 0xba900cb6, 0xba900cb6, 0x8223a71e, 0x8223a71e, 0x8223a71e, 0xf83ee7aa, 0x35cdb5f2, 0x35cdb5f2, 0xf83ee7aa, }, 20 },
- { "gfxterm_fr", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xf3ebce27, 0x64821e83, 0xf3ebce27, 0xe29e7b72, 0x724366e5, 0x724366e5, 0xf2920fc5, 0xf2920fc5, 0xf2920fc5, 0xb5ab4d3f, 0xb5ab4d3f, 0xb5ab4d3f, 0xd8856a75, 0xd8856a75, 0xd8856a75, 0x724366e5, 0xe29e7b72, 0xe29e7b72, 0x724366e5, }, 20 },
- { "gfxterm_fr", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xda2165d2, 0x5f811c6d, 0xda2165d2, 0x35b5d8eb, 0x5387d57f, 0x5387d57f, 0xe5a2fdfd, 0xe5a2fdfd, 0xe5a2fdfd, 0x3b6cb220, 0x3b6cb220, 0x3b6cb220, 0xa8ef203e, 0xa8ef203e, 0xa8ef203e, 0x5387d57f, 0x35b5d8eb, 0x35b5d8eb, 0x5387d57f, }, 20 },
- { "gfxterm_fr", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf52ba155, 0x4866b5cd, 0xf52ba155, 0x84e19fb9, 0xf83ee7aa, 0xf83ee7aa, 0xc1a44e99, 0xc1a44e99, 0xc1a44e99, 0xb37e5da9, 0xb37e5da9, 0xb37e5da9, 0x82eb0c6f, 0x82eb0c6f, 0x82eb0c6f, 0xf83ee7aa, 0x84e19fb9, 0x84e19fb9, 0xf83ee7aa, }, 20 },
- { "gfxterm_fr", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x16d37834, 0x72eb8d00, 0x16d37834, 0xe401f344, 0x724366e5, 0x724366e5, 0xc80f0332, 0xc80f0332, 0xc80f0332, 0x919ff062, 0x919ff062, 0x919ff062, 0x59289e20, 0x59289e20, 0x59289e20, 0x724366e5, 0xe401f344, 0xe401f344, 0x724366e5, }, 20 },
- { "gfxterm_fr", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x501ed137, 0x3eb913d3, 0x501ed137, 0x507e6991, 0x1c955882, 0x1c955882, 0xc988465d, 0xc988465d, 0xc988465d, 0x67f0bca, 0x67f0bca, 0x67f0bca, 0xf81607df, 0xf81607df, 0xf81607df, 0x1c955882, 0x507e6991, 0x507e6991, 0x1c955882, }, 20 },
- { "gfxterm_fr", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xdbf45ff0, 0x4b12f903, 0xdbf45ff0, 0x1fe6c6f4, 0x4d266f7a, 0x4d266f7a, 0xee77b36d, 0xee77b36d, 0xee77b36d, 0x800a8d2, 0x800a8d2, 0x800a8d2, 0x9039fc42, 0x9039fc42, 0x9039fc42, 0x4d266f7a, 0x1fe6c6f4, 0x1fe6c6f4, 0x4d266f7a, }, 20 },
- { "gfxterm_fr", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x6c3a9814, 0xaa19882a, 0x6c3a9814, 0xf0ce99f3, 0x1ed9d731, 0x1ed9d731, 0x5819ad52, 0x5819ad52, 0x5819ad52, 0xf67db397, 0xf67db397, 0xf67db397, 0xd514a221, 0xd514a221, 0xd514a221, 0x1ed9d731, 0xf0ce99f3, 0xf0ce99f3, 0x1ed9d731, }, 20 },
- { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x35512c6d, 0xe29deaf0, 0x35512c6d, 0x654988c3, 0x9813a416, 0x9813a416, 0xc6920c94, 0xc6920c94, 0xc6920c94, 0x57498aa7, 0x57498aa7, 0x57498aa7, 0xcb3c7f65, 0xcb3c7f65, 0xcb3c7f65, 0x9813a416, 0x654988c3, 0x654988c3, 0x9813a416, }, 20 },
- { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x73ff9071, 0x72b83f24, 0x73ff9071, 0x4935418b, 0x5fcf013d, 0x5fcf013d, 0x9963ff63, 0x9963ff63, 0x9963ff63, 0x4b73e715, 0x4b73e715, 0x4b73e715, 0x545866e8, 0x545866e8, 0x545866e8, 0x5fcf013d, 0x4935418b, 0x4935418b, 0x5fcf013d, }, 20 },
- { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x46811b4e, 0xa463f7aa, 0x46811b4e, 0x26f2bf24, 0xdd28f52b, 0xdd28f52b, 0x452cf740, 0x452cf740, 0x452cf740, 0x64100ea4, 0x64100ea4, 0x64100ea4, 0x7e616d35, 0x7e616d35, 0x7e616d35, 0xdd28f52b, 0x26f2bf24, 0x26f2bf24, 0xdd28f52b, }, 20 },
- { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x791b97c6, 0xd80a4dd5, 0x791b97c6, 0x3aed5a81, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x3aed5a81, 0x3aed5a81, 0x59c36f00, }, 20 },
- { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x6c6b27f2, 0x9ad8591c, 0x6c6b27f2, 0x426ea28d, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0x426ea28d, 0x426ea28d, 0xaa4593fe, }, 20 },
- { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb553210b, 0xf9eb9fa4, 0xb553210b, 0xe8444c8f, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0xe8444c8f, 0xe8444c8f, 0xc9cbf769, }, 20 },
- { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x979d71de, 0x73e38996, 0x979d71de, 0xc785d570, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0xc785d570, 0xc785d570, 0x9813a416, }, 20 },
- { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x78d87f9d, 0x345e385f, 0x78d87f9d, 0x4212ae67, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x4212ae67, 0x4212ae67, 0x5fcf013d, }, 20 },
- { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x750f8146, 0x2148bdae, 0x750f8146, 0x157c252c, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x157c252c, 0x157c252c, 0xdd28f52b, }, 20 },
- { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x58828a1e, 0x11d1547e, 0x58828a1e, 0xa6c48773, 0x43d1f34, 0x43d1f34, 0xd204ac75, 0xd204ac75, 0xd204ac75, 0xad0e05dd, 0xad0e05dd, 0xad0e05dd, 0x452e3cf4, 0x452e3cf4, 0x452e3cf4, 0x43d1f34, 0xa6c48773, 0xa6c48773, 0x43d1f34, }, 20 },
- { "gfxterm_quot", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x791b97c6, 0xd80a4dd5, 0x791b97c6, 0x3aed5a81, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x3aed5a81, 0x3aed5a81, 0x59c36f00, }, 20 },
- { "gfxterm_quot", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x6c6b27f2, 0x9ad8591c, 0x6c6b27f2, 0x426ea28d, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0x426ea28d, 0x426ea28d, 0xaa4593fe, }, 20 },
- { "gfxterm_quot", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0xb553210b, 0xf9eb9fa4, 0xb553210b, 0xe8444c8f, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0xe8444c8f, 0xe8444c8f, 0xc9cbf769, }, 20 },
- { "gfxterm_quot", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe0300e88, 0x76ba1dd0, 0xe0300e88, 0xa43bf434, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0xa43bf434, 0xa43bf434, 0x5387d57f, }, 20 },
- { "gfxterm_quot", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xa26081d9, 0xef5b1078, 0xa26081d9, 0x1808cc46, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x1808cc46, 0x1808cc46, 0xf83ee7aa, }, 20 },
- { "gfxterm_quot", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x6f16d50f, 0x2fc71082, 0x6f16d50f, 0x7e63605a, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x7e63605a, 0x7e63605a, 0x724366e5, }, 20 },
- { "gfxterm_quot", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xc959920b, 0x3548d7d5, 0xc959920b, 0x26cd2f32, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0x26cd2f32, 0x26cd2f32, 0x5387d57f, }, 20 },
- { "gfxterm_quot", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x93c26040, 0x70ae777c, 0x93c26040, 0xe2085eac, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xe2085eac, 0xe2085eac, 0xf83ee7aa, }, 20 },
- { "gfxterm_quot", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x73b37a76, 0x352c8931, 0x73b37a76, 0x8161f106, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0x8161f106, 0x8161f106, 0x724366e5, }, 20 },
- { "gfxterm_quot", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0xe12eaf27, 0xe7b5009a, 0xe12eaf27, 0xe14e1781, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0xe14e1781, 0xe14e1781, 0x1c955882, }, 20 },
- { "gfxterm_quot", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x5a376c04, 0xd27c4646, 0x5a376c04, 0x9e25f500, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0x9e25f500, 0x9e25f500, 0x4d266f7a, }, 20 },
- { "gfxterm_quot", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x3f02033b, 0xd99eaa7, 0x3f02033b, 0xa3f602dc, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0xa3f602dc, 0xa3f602dc, 0x1ed9d731, }, 20 },
- { "gfxterm_quot", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe0300e88, 0x76ba1dd0, 0xe0300e88, 0xa43bf434, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0xa43bf434, 0xa43bf434, 0x5387d57f, }, 20 },
- { "gfxterm_quot", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xa26081d9, 0xef5b1078, 0xa26081d9, 0x1808cc46, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x1808cc46, 0x1808cc46, 0xf83ee7aa, }, 20 },
- { "gfxterm_quot", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x6f16d50f, 0x2fc71082, 0x6f16d50f, 0x7e63605a, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x7e63605a, 0x7e63605a, 0x724366e5, }, 20 },
- { "gfxterm_quot", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xc959920b, 0x3548d7d5, 0xc959920b, 0x26cd2f32, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0x26cd2f32, 0x26cd2f32, 0x5387d57f, }, 20 },
- { "gfxterm_quot", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x93c26040, 0x70ae777c, 0x93c26040, 0xe2085eac, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xe2085eac, 0xe2085eac, 0xf83ee7aa, }, 20 },
- { "gfxterm_quot", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x73b37a76, 0x352c8931, 0x73b37a76, 0x8161f106, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0x8161f106, 0x8161f106, 0x724366e5, }, 20 },
- { "gfxterm_quot", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xe12eaf27, 0xe7b5009a, 0xe12eaf27, 0xe14e1781, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0xe14e1781, 0xe14e1781, 0x1c955882, }, 20 },
- { "gfxterm_quot", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x5a376c04, 0xd27c4646, 0x5a376c04, 0x9e25f500, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0x9e25f500, 0x9e25f500, 0x4d266f7a, }, 20 },
- { "gfxterm_quot", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x3f02033b, 0xd99eaa7, 0x3f02033b, 0xa3f602dc, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0xa3f602dc, 0xa3f602dc, 0x1ed9d731, }, 20 },
- { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x979d71de, 0x73e38996, 0x979d71de, 0xc785d570, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0xc785d570, 0xc785d570, 0x9813a416, }, 20 },
- { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x78d87f9d, 0x345e385f, 0x78d87f9d, 0x4212ae67, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x4212ae67, 0x4212ae67, 0x5fcf013d, }, 20 },
- { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x750f8146, 0x2148bdae, 0x750f8146, 0x157c252c, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x157c252c, 0x157c252c, 0xdd28f52b, }, 20 },
- { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xaabbbcdc, 0x5f5dabb0, 0xaabbbcdc, 0xe94d719b, 0x59c36f00, 0x59c36f00, 0x18f47430, 0x18f47430, 0x18f47430, 0x66741956, 0x66741956, 0x66741956, 0xa556249b, 0xa556249b, 0xa556249b, 0x59c36f00, 0xe94d719b, 0xe94d719b, 0x59c36f00, }, 20 },
- { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb6fa31f0, 0xc274fbe9, 0xb6fa31f0, 0x98ffb48f, 0xaa4593fe, 0xaa4593fe, 0x4fb2120a, 0x4fb2120a, 0x4fb2120a, 0xe9471f6d, 0xe9471f6d, 0xe9471f6d, 0x6be0fd06, 0x6be0fd06, 0x6be0fd06, 0xaa4593fe, 0x98ffb48f, 0x98ffb48f, 0xaa4593fe, }, 20 },
- { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9c83aa67, 0x67876bdc, 0x9c83aa67, 0xc194c7e3, 0xc9cbf769, 0xc9cbf769, 0xd6fd9f4a, 0xd6fd9f4a, 0xd6fd9f4a, 0x28255e86, 0x28255e86, 0x28255e86, 0xc073f18a, 0xc073f18a, 0xc073f18a, 0xc9cbf769, 0xc194c7e3, 0xc194c7e3, 0xc9cbf769, }, 20 },
- { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4878468, 0x58d7f660, 0x4878468, 0x549f20c6, 0x9813a416, 0x9813a416, 0x7c4d228e, 0x7c4d228e, 0x7c4d228e, 0xed96a4bd, 0xed96a4bd, 0xed96a4bd, 0x71e3517f, 0x71e3517f, 0x71e3517f, 0x9813a416, 0x549f20c6, 0x549f20c6, 0x9813a416, }, 20 },
- { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc24f3617, 0xe92e5f60, 0xc24f3617, 0xf885e7ed, 0x5fcf013d, 0x5fcf013d, 0x9a58adbf, 0x9a58adbf, 0x9a58adbf, 0x4848b5c9, 0x4848b5c9, 0x4848b5c9, 0x57633434, 0x57633434, 0x57633434, 0x5fcf013d, 0xf885e7ed, 0xf885e7ed, 0x5fcf013d, }, 20 },
- { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe0056f23, 0xe723a6de, 0xe0056f23, 0x8076cb49, 0xdd28f52b, 0xdd28f52b, 0x7cf3620d, 0x7cf3620d, 0x7cf3620d, 0x5dcf9be9, 0x5dcf9be9, 0x5dcf9be9, 0x47bef878, 0x47bef878, 0x47bef878, 0xdd28f52b, 0x8076cb49, 0x8076cb49, 0xdd28f52b, }, 20 },
- { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x74a1734e, 0x3152f141, 0x74a1734e, 0x8ae77e23, 0x43d1f34, 0x43d1f34, 0x83c19830, 0x83c19830, 0x83c19830, 0xfccb3198, 0xfccb3198, 0xfccb3198, 0x14eb08b1, 0x14eb08b1, 0x14eb08b1, 0x43d1f34, 0x8ae77e23, 0x8ae77e23, 0x43d1f34, }, 20 },
- { "gfxterm_piglatin", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xaabbbcdc, 0x5f5dabb0, 0xaabbbcdc, 0xe94d719b, 0x59c36f00, 0x59c36f00, 0x18f47430, 0x18f47430, 0x18f47430, 0x66741956, 0x66741956, 0x66741956, 0xa556249b, 0xa556249b, 0xa556249b, 0x59c36f00, 0xe94d719b, 0xe94d719b, 0x59c36f00, }, 20 },
- { "gfxterm_piglatin", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0xb6fa31f0, 0xc274fbe9, 0xb6fa31f0, 0x98ffb48f, 0xaa4593fe, 0xaa4593fe, 0x4fb2120a, 0x4fb2120a, 0x4fb2120a, 0xe9471f6d, 0xe9471f6d, 0xe9471f6d, 0x6be0fd06, 0x6be0fd06, 0x6be0fd06, 0xaa4593fe, 0x98ffb48f, 0x98ffb48f, 0xaa4593fe, }, 20 },
- { "gfxterm_piglatin", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x9c83aa67, 0x67876bdc, 0x9c83aa67, 0xc194c7e3, 0xc9cbf769, 0xc9cbf769, 0xd6fd9f4a, 0xd6fd9f4a, 0xd6fd9f4a, 0x28255e86, 0x28255e86, 0x28255e86, 0xc073f18a, 0xc073f18a, 0xc073f18a, 0xc9cbf769, 0xc194c7e3, 0xc194c7e3, 0xc9cbf769, }, 20 },
- { "gfxterm_piglatin", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xd63f83a3, 0x3dc5a0b4, 0xd63f83a3, 0x9234791f, 0x5387d57f, 0x5387d57f, 0x4cb03e4e, 0x4cb03e4e, 0x4cb03e4e, 0x8ce95282, 0x8ce95282, 0x8ce95282, 0x6b37d014, 0x6b37d014, 0x6b37d014, 0x5387d57f, 0x9234791f, 0x9234791f, 0x5387d57f, }, 20 },
- { "gfxterm_piglatin", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x89626ffa, 0xb4d6175c, 0x89626ffa, 0x330a2265, 0xf83ee7aa, 0xf83ee7aa, 0xbbfb89b5, 0xbbfb89b5, 0xbbfb89b5, 0x27825946, 0x27825946, 0x27825946, 0x1f31f2ee, 0x1f31f2ee, 0x1f31f2ee, 0xf83ee7aa, 0x330a2265, 0x330a2265, 0xf83ee7aa, }, 20 },
- { "gfxterm_piglatin", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x3df87fc2, 0x8c55d02c, 0x3df87fc2, 0x2c8dca97, 0x724366e5, 0x724366e5, 0x3f06ba55, 0x3f06ba55, 0x3f06ba55, 0x783ff8af, 0x783ff8af, 0x783ff8af, 0x1511dfe5, 0x1511dfe5, 0x1511dfe5, 0x724366e5, 0x2c8dca97, 0x2c8dca97, 0x724366e5, }, 20 },
- { "gfxterm_piglatin", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xe39cde76, 0x443930df, 0xe39cde76, 0xc08634f, 0x5387d57f, 0x5387d57f, 0x44754e5f, 0x44754e5f, 0x44754e5f, 0x9abb0182, 0x9abb0182, 0x9abb0182, 0x938939c, 0x938939c, 0x938939c, 0x5387d57f, 0xc08634f, 0xc08634f, 0x5387d57f, }, 20 },
- { "gfxterm_piglatin", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xa0b7c23d, 0x8cd3be29, 0xa0b7c23d, 0xd17dfcd1, 0xf83ee7aa, 0xf83ee7aa, 0x5feda75, 0x5feda75, 0x5feda75, 0x7724c945, 0x7724c945, 0x7724c945, 0x46b19883, 0x46b19883, 0x46b19883, 0xf83ee7aa, 0xd17dfcd1, 0xd17dfcd1, 0xf83ee7aa, }, 20 },
- { "gfxterm_piglatin", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0xa994524d, 0xc1900d08, 0xa994524d, 0x5b46d93d, 0x724366e5, 0x724366e5, 0x6d0a4799, 0x6d0a4799, 0x6d0a4799, 0x349ab4c9, 0x349ab4c9, 0x349ab4c9, 0xfc2dda8b, 0xfc2dda8b, 0xfc2dda8b, 0x724366e5, 0x5b46d93d, 0x5b46d93d, 0x724366e5, }, 20 },
- { "gfxterm_piglatin", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x41755bc6, 0xf207b232, 0x41755bc6, 0x4115e360, 0x1c955882, 0x1c955882, 0x428d20f6, 0x428d20f6, 0x428d20f6, 0x8d7a6d61, 0x8d7a6d61, 0x8d7a6d61, 0x73136174, 0x73136174, 0x73136174, 0x1c955882, 0x4115e360, 0x4115e360, 0x1c955882, }, 20 },
- { "gfxterm_piglatin", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xe47ded44, 0x862f2131, 0xe47ded44, 0x206f7440, 0x4d266f7a, 0x4d266f7a, 0x95d7f079, 0x95d7f079, 0x95d7f079, 0x73a0ebc6, 0x73a0ebc6, 0x73a0ebc6, 0xeb99bf56, 0xeb99bf56, 0xeb99bf56, 0x4d266f7a, 0x206f7440, 0x206f7440, 0x4d266f7a, }, 20 },
- { "gfxterm_piglatin", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x946b2f62, 0x30dad54, 0x946b2f62, 0x89f2e85, 0x1ed9d731, 0x1ed9d731, 0xf20ee132, 0xf20ee132, 0xf20ee132, 0x5c6afff7, 0x5c6afff7, 0x5c6afff7, 0x7f03ee41, 0x7f03ee41, 0x7f03ee41, 0x1ed9d731, 0x89f2e85, 0x89f2e85, 0x1ed9d731, }, 20 },
- { "gfxterm_piglatin", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xd63f83a3, 0x3dc5a0b4, 0xd63f83a3, 0x9234791f, 0x5387d57f, 0x5387d57f, 0x4cb03e4e, 0x4cb03e4e, 0x4cb03e4e, 0x8ce95282, 0x8ce95282, 0x8ce95282, 0x6b37d014, 0x6b37d014, 0x6b37d014, 0x5387d57f, 0x9234791f, 0x9234791f, 0x5387d57f, }, 20 },
- { "gfxterm_piglatin", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x89626ffa, 0xb4d6175c, 0x89626ffa, 0x330a2265, 0xf83ee7aa, 0xf83ee7aa, 0xbbfb89b5, 0xbbfb89b5, 0xbbfb89b5, 0x27825946, 0x27825946, 0x27825946, 0x1f31f2ee, 0x1f31f2ee, 0x1f31f2ee, 0xf83ee7aa, 0x330a2265, 0x330a2265, 0xf83ee7aa, }, 20 },
- { "gfxterm_piglatin", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x3df87fc2, 0x8c55d02c, 0x3df87fc2, 0x2c8dca97, 0x724366e5, 0x724366e5, 0x3f06ba55, 0x3f06ba55, 0x3f06ba55, 0x783ff8af, 0x783ff8af, 0x783ff8af, 0x1511dfe5, 0x1511dfe5, 0x1511dfe5, 0x724366e5, 0x2c8dca97, 0x2c8dca97, 0x724366e5, }, 20 },
- { "gfxterm_piglatin", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xe39cde76, 0x443930df, 0xe39cde76, 0xc08634f, 0x5387d57f, 0x5387d57f, 0x44754e5f, 0x44754e5f, 0x44754e5f, 0x9abb0182, 0x9abb0182, 0x9abb0182, 0x938939c, 0x938939c, 0x938939c, 0x5387d57f, 0xc08634f, 0xc08634f, 0x5387d57f, }, 20 },
- { "gfxterm_piglatin", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xa0b7c23d, 0x8cd3be29, 0xa0b7c23d, 0xd17dfcd1, 0xf83ee7aa, 0xf83ee7aa, 0x5feda75, 0x5feda75, 0x5feda75, 0x7724c945, 0x7724c945, 0x7724c945, 0x46b19883, 0x46b19883, 0x46b19883, 0xf83ee7aa, 0xd17dfcd1, 0xd17dfcd1, 0xf83ee7aa, }, 20 },
- { "gfxterm_piglatin", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0xa994524d, 0xc1900d08, 0xa994524d, 0x5b46d93d, 0x724366e5, 0x724366e5, 0x6d0a4799, 0x6d0a4799, 0x6d0a4799, 0x349ab4c9, 0x349ab4c9, 0x349ab4c9, 0xfc2dda8b, 0xfc2dda8b, 0xfc2dda8b, 0x724366e5, 0x5b46d93d, 0x5b46d93d, 0x724366e5, }, 20 },
- { "gfxterm_piglatin", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x41755bc6, 0xf207b232, 0x41755bc6, 0x4115e360, 0x1c955882, 0x1c955882, 0x428d20f6, 0x428d20f6, 0x428d20f6, 0x8d7a6d61, 0x8d7a6d61, 0x8d7a6d61, 0x73136174, 0x73136174, 0x73136174, 0x1c955882, 0x4115e360, 0x4115e360, 0x1c955882, }, 20 },
- { "gfxterm_piglatin", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xe47ded44, 0x862f2131, 0xe47ded44, 0x206f7440, 0x4d266f7a, 0x4d266f7a, 0x95d7f079, 0x95d7f079, 0x95d7f079, 0x73a0ebc6, 0x73a0ebc6, 0x73a0ebc6, 0xeb99bf56, 0xeb99bf56, 0xeb99bf56, 0x4d266f7a, 0x206f7440, 0x206f7440, 0x4d266f7a, }, 20 },
- { "gfxterm_piglatin", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x946b2f62, 0x30dad54, 0x946b2f62, 0x89f2e85, 0x1ed9d731, 0x1ed9d731, 0xf20ee132, 0xf20ee132, 0xf20ee132, 0x5c6afff7, 0x5c6afff7, 0x5c6afff7, 0x7f03ee41, 0x7f03ee41, 0x7f03ee41, 0x1ed9d731, 0x89f2e85, 0x89f2e85, 0x1ed9d731, }, 20 },
- { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x4878468, 0x58d7f660, 0x4878468, 0x549f20c6, 0x9813a416, 0x9813a416, 0x7c4d228e, 0x7c4d228e, 0x7c4d228e, 0xed96a4bd, 0xed96a4bd, 0xed96a4bd, 0x71e3517f, 0x71e3517f, 0x71e3517f, 0x9813a416, 0x549f20c6, 0x549f20c6, 0x9813a416, }, 20 },
- { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc24f3617, 0xe92e5f60, 0xc24f3617, 0xf885e7ed, 0x5fcf013d, 0x5fcf013d, 0x9a58adbf, 0x9a58adbf, 0x9a58adbf, 0x4848b5c9, 0x4848b5c9, 0x4848b5c9, 0x57633434, 0x57633434, 0x57633434, 0x5fcf013d, 0xf885e7ed, 0xf885e7ed, 0x5fcf013d, }, 20 },
- { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe0056f23, 0xe723a6de, 0xe0056f23, 0x8076cb49, 0xdd28f52b, 0xdd28f52b, 0x7cf3620d, 0x7cf3620d, 0x7cf3620d, 0x5dcf9be9, 0x5dcf9be9, 0x5dcf9be9, 0x47bef878, 0x47bef878, 0x47bef878, 0xdd28f52b, 0x8076cb49, 0x8076cb49, 0xdd28f52b, }, 20 },
- { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x5ee30ef2, 0xcb34e9e1, 0x5ee30ef2, 0x1d15c3b5, 0x59c36f00, 0x59c36f00, 0x201d9661, 0x201d9661, 0x201d9661, 0x5e9dfb07, 0x5e9dfb07, 0x5e9dfb07, 0x9dbfc6ca, 0x9dbfc6ca, 0x9dbfc6ca, 0x59c36f00, 0x1d15c3b5, 0x1d15c3b5, 0x59c36f00, }, 20 },
- { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8f30caea, 0xabe72645, 0x8f30caea, 0xa1354f95, 0xaa4593fe, 0xaa4593fe, 0xe17bf494, 0xe17bf494, 0xe17bf494, 0x478ef9f3, 0x478ef9f3, 0x478ef9f3, 0xc5291b98, 0xc5291b98, 0xc5291b98, 0xaa4593fe, 0xa1354f95, 0xa1354f95, 0xaa4593fe, }, 20 },
- { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x3a734c3, 0x18bd52c, 0x3a734c3, 0x5eb05947, 0xc9cbf769, 0xc9cbf769, 0x128d62c1, 0x128d62c1, 0x128d62c1, 0xec55a30d, 0xec55a30d, 0xec55a30d, 0x4030c01, 0x4030c01, 0x4030c01, 0xc9cbf769, 0x5eb05947, 0x5eb05947, 0xc9cbf769, }, 20 },
- { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x34a86f24, 0xfae0384, 0x34a86f24, 0x64b0cb8a, 0x9813a416, 0x9813a416, 0x13b7fe00, 0x13b7fe00, 0x13b7fe00, 0x826c7833, 0x826c7833, 0x826c7833, 0x1e198df1, 0x1e198df1, 0x1e198df1, 0x9813a416, 0x64b0cb8a, 0x64b0cb8a, 0x9813a416, }, 20 },
- { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7cf1a92b, 0x413f2fa3, 0x7cf1a92b, 0x463b78d1, 0x5fcf013d, 0x5fcf013d, 0x4f98bcd5, 0x4f98bcd5, 0x4f98bcd5, 0x9d88a4a3, 0x9d88a4a3, 0x9d88a4a3, 0x82a3255e, 0x82a3255e, 0x82a3255e, 0x5fcf013d, 0x463b78d1, 0x463b78d1, 0x5fcf013d, }, 20 },
- { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7d24f50c, 0x85834892, 0x7d24f50c, 0x1d575166, 0xdd28f52b, 0xdd28f52b, 0x167fd4de, 0x167fd4de, 0x167fd4de, 0x37432d3a, 0x37432d3a, 0x37432d3a, 0x2d324eab, 0x2d324eab, 0x2d324eab, 0xdd28f52b, 0x1d575166, 0x1d575166, 0xdd28f52b, }, 20 },
- { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x505523f2, 0x24d00e51, 0x505523f2, 0xae132e9f, 0x43d1f34, 0x43d1f34, 0xcaaadc5e, 0xcaaadc5e, 0xcaaadc5e, 0xb5a075f6, 0xb5a075f6, 0xb5a075f6, 0x5d804cdf, 0x5d804cdf, 0x5d804cdf, 0x43d1f34, 0xae132e9f, 0xae132e9f, 0x43d1f34, }, 20 },
- { "gfxterm_ch", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x5ee30ef2, 0xcb34e9e1, 0x5ee30ef2, 0x1d15c3b5, 0x59c36f00, 0x59c36f00, 0x201d9661, 0x201d9661, 0x201d9661, 0x5e9dfb07, 0x5e9dfb07, 0x5e9dfb07, 0x9dbfc6ca, 0x9dbfc6ca, 0x9dbfc6ca, 0x59c36f00, 0x1d15c3b5, 0x1d15c3b5, 0x59c36f00, }, 20 },
- { "gfxterm_ch", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x8f30caea, 0xabe72645, 0x8f30caea, 0xa1354f95, 0xaa4593fe, 0xaa4593fe, 0xe17bf494, 0xe17bf494, 0xe17bf494, 0x478ef9f3, 0x478ef9f3, 0x478ef9f3, 0xc5291b98, 0xc5291b98, 0xc5291b98, 0xaa4593fe, 0xa1354f95, 0xa1354f95, 0xaa4593fe, }, 20 },
- { "gfxterm_ch", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x3a734c3, 0x18bd52c, 0x3a734c3, 0x5eb05947, 0xc9cbf769, 0xc9cbf769, 0x128d62c1, 0x128d62c1, 0x128d62c1, 0xec55a30d, 0xec55a30d, 0xec55a30d, 0x4030c01, 0x4030c01, 0x4030c01, 0xc9cbf769, 0x5eb05947, 0x5eb05947, 0xc9cbf769, }, 20 },
- { "gfxterm_ch", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xeba6cfbb, 0xcfb5c41c, 0xeba6cfbb, 0xafad3507, 0x5387d57f, 0x5387d57f, 0x71f3f018, 0x71f3f018, 0x71f3f018, 0xb1aa9cd4, 0xb1aa9cd4, 0xb1aa9cd4, 0x56741e42, 0x56741e42, 0x56741e42, 0x5387d57f, 0xafad3507, 0xafad3507, 0x5387d57f, }, 20 },
- { "gfxterm_ch", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x9003ad29, 0xb92d2c38, 0x9003ad29, 0x2a6be0b6, 0xf83ee7aa, 0xf83ee7aa, 0x49d26800, 0x49d26800, 0x49d26800, 0xd5abb8f3, 0xd5abb8f3, 0xd5abb8f3, 0xed18135b, 0xed18135b, 0xed18135b, 0xf83ee7aa, 0x2a6be0b6, 0x2a6be0b6, 0xf83ee7aa, }, 20 },
- { "gfxterm_ch", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x238c7b12, 0x2eefc892, 0x238c7b12, 0x32f9ce47, 0x724366e5, 0x724366e5, 0x3d1942f9, 0x3d1942f9, 0x3d1942f9, 0x7a200003, 0x7a200003, 0x7a200003, 0x170e2749, 0x170e2749, 0x170e2749, 0x724366e5, 0x32f9ce47, 0x32f9ce47, 0x724366e5, }, 20 },
- { "gfxterm_ch", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x9e1c123, 0xa92b0ab6, 0x9e1c123, 0xe6757c1a, 0x5387d57f, 0x5387d57f, 0xa443a74a, 0xa443a74a, 0xa443a74a, 0x7a8de897, 0x7a8de897, 0x7a8de897, 0xe90e7a89, 0xe90e7a89, 0xe90e7a89, 0x5387d57f, 0xe6757c1a, 0xe6757c1a, 0x5387d57f, }, 20 },
- { "gfxterm_ch", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xabb151dd, 0xfa21aa13, 0xabb151dd, 0xda7b6f31, 0xf83ee7aa, 0xf83ee7aa, 0x9d6ae4fd, 0x9d6ae4fd, 0x9d6ae4fd, 0xefb0f7cd, 0xefb0f7cd, 0xefb0f7cd, 0xde25a60b, 0xde25a60b, 0xde25a60b, 0xf83ee7aa, 0xda7b6f31, 0xda7b6f31, 0xf83ee7aa, }, 20 },
- { "gfxterm_ch", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x6dd9406d, 0xde872977, 0x6dd9406d, 0x9f0bcb1d, 0x724366e5, 0x724366e5, 0x8b3051ad, 0x8b3051ad, 0x8b3051ad, 0xd2a0a2fd, 0xd2a0a2fd, 0xd2a0a2fd, 0x1a17ccbf, 0x1a17ccbf, 0x1a17ccbf, 0x724366e5, 0x9f0bcb1d, 0x9f0bcb1d, 0x724366e5, }, 20 },
- { "gfxterm_ch", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x397d3da2, 0xeb896cf, 0x397d3da2, 0x391d8504, 0x1c955882, 0x1c955882, 0x16aa0778, 0x16aa0778, 0x16aa0778, 0xd95d4aef, 0xd95d4aef, 0xd95d4aef, 0x273446fa, 0x273446fa, 0x273446fa, 0x1c955882, 0x391d8504, 0x391d8504, 0x1c955882, }, 20 },
- { "gfxterm_ch", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb4b2e2fa, 0x74314de8, 0xb4b2e2fa, 0x70a07bfe, 0x4d266f7a, 0x4d266f7a, 0xe69c42f4, 0xe69c42f4, 0xe69c42f4, 0xeb594b, 0xeb594b, 0xeb594b, 0x98d20ddb, 0x98d20ddb, 0x98d20ddb, 0x4d266f7a, 0x70a07bfe, 0x70a07bfe, 0x4d266f7a, }, 20 },
- { "gfxterm_ch", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xd2db665c, 0xcb12d20c, 0xd2db665c, 0x4e2f67bb, 0x1ed9d731, 0x1ed9d731, 0x1952ab15, 0x1952ab15, 0x1952ab15, 0xb736b5d0, 0xb736b5d0, 0xb736b5d0, 0x945fa466, 0x945fa466, 0x945fa466, 0x1ed9d731, 0x4e2f67bb, 0x4e2f67bb, 0x1ed9d731, }, 20 },
- { "gfxterm_ch", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xeba6cfbb, 0xcfb5c41c, 0xeba6cfbb, 0xafad3507, 0x5387d57f, 0x5387d57f, 0x71f3f018, 0x71f3f018, 0x71f3f018, 0xb1aa9cd4, 0xb1aa9cd4, 0xb1aa9cd4, 0x56741e42, 0x56741e42, 0x56741e42, 0x5387d57f, 0xafad3507, 0xafad3507, 0x5387d57f, }, 20 },
- { "gfxterm_ch", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x9003ad29, 0xb92d2c38, 0x9003ad29, 0x2a6be0b6, 0xf83ee7aa, 0xf83ee7aa, 0x49d26800, 0x49d26800, 0x49d26800, 0xd5abb8f3, 0xd5abb8f3, 0xd5abb8f3, 0xed18135b, 0xed18135b, 0xed18135b, 0xf83ee7aa, 0x2a6be0b6, 0x2a6be0b6, 0xf83ee7aa, }, 20 },
- { "gfxterm_ch", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x238c7b12, 0x2eefc892, 0x238c7b12, 0x32f9ce47, 0x724366e5, 0x724366e5, 0x3d1942f9, 0x3d1942f9, 0x3d1942f9, 0x7a200003, 0x7a200003, 0x7a200003, 0x170e2749, 0x170e2749, 0x170e2749, 0x724366e5, 0x32f9ce47, 0x32f9ce47, 0x724366e5, }, 20 },
- { "gfxterm_ch", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x9e1c123, 0xa92b0ab6, 0x9e1c123, 0xe6757c1a, 0x5387d57f, 0x5387d57f, 0xa443a74a, 0xa443a74a, 0xa443a74a, 0x7a8de897, 0x7a8de897, 0x7a8de897, 0xe90e7a89, 0xe90e7a89, 0xe90e7a89, 0x5387d57f, 0xe6757c1a, 0xe6757c1a, 0x5387d57f, }, 20 },
- { "gfxterm_ch", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xabb151dd, 0xfa21aa13, 0xabb151dd, 0xda7b6f31, 0xf83ee7aa, 0xf83ee7aa, 0x9d6ae4fd, 0x9d6ae4fd, 0x9d6ae4fd, 0xefb0f7cd, 0xefb0f7cd, 0xefb0f7cd, 0xde25a60b, 0xde25a60b, 0xde25a60b, 0xf83ee7aa, 0xda7b6f31, 0xda7b6f31, 0xf83ee7aa, }, 20 },
- { "gfxterm_ch", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x6dd9406d, 0xde872977, 0x6dd9406d, 0x9f0bcb1d, 0x724366e5, 0x724366e5, 0x8b3051ad, 0x8b3051ad, 0x8b3051ad, 0xd2a0a2fd, 0xd2a0a2fd, 0xd2a0a2fd, 0x1a17ccbf, 0x1a17ccbf, 0x1a17ccbf, 0x724366e5, 0x9f0bcb1d, 0x9f0bcb1d, 0x724366e5, }, 20 },
- { "gfxterm_ch", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x397d3da2, 0xeb896cf, 0x397d3da2, 0x391d8504, 0x1c955882, 0x1c955882, 0x16aa0778, 0x16aa0778, 0x16aa0778, 0xd95d4aef, 0xd95d4aef, 0xd95d4aef, 0x273446fa, 0x273446fa, 0x273446fa, 0x1c955882, 0x391d8504, 0x391d8504, 0x1c955882, }, 20 },
- { "gfxterm_ch", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb4b2e2fa, 0x74314de8, 0xb4b2e2fa, 0x70a07bfe, 0x4d266f7a, 0x4d266f7a, 0xe69c42f4, 0xe69c42f4, 0xe69c42f4, 0xeb594b, 0xeb594b, 0xeb594b, 0x98d20ddb, 0x98d20ddb, 0x98d20ddb, 0x4d266f7a, 0x70a07bfe, 0x70a07bfe, 0x4d266f7a, }, 20 },
- { "gfxterm_ch", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xd2db665c, 0xcb12d20c, 0xd2db665c, 0x4e2f67bb, 0x1ed9d731, 0x1ed9d731, 0x1952ab15, 0x1952ab15, 0x1952ab15, 0xb736b5d0, 0xb736b5d0, 0xb736b5d0, 0x945fa466, 0x945fa466, 0x945fa466, 0x1ed9d731, 0x4e2f67bb, 0x4e2f67bb, 0x1ed9d731, }, 20 },
- { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x34a86f24, 0xfae0384, 0x34a86f24, 0x64b0cb8a, 0x9813a416, 0x9813a416, 0x13b7fe00, 0x13b7fe00, 0x13b7fe00, 0x826c7833, 0x826c7833, 0x826c7833, 0x1e198df1, 0x1e198df1, 0x1e198df1, 0x9813a416, 0x64b0cb8a, 0x64b0cb8a, 0x9813a416, }, 20 },
- { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7cf1a92b, 0x413f2fa3, 0x7cf1a92b, 0x463b78d1, 0x5fcf013d, 0x5fcf013d, 0x4f98bcd5, 0x4f98bcd5, 0x4f98bcd5, 0x9d88a4a3, 0x9d88a4a3, 0x9d88a4a3, 0x82a3255e, 0x82a3255e, 0x82a3255e, 0x5fcf013d, 0x463b78d1, 0x463b78d1, 0x5fcf013d, }, 20 },
- { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7d24f50c, 0x85834892, 0x7d24f50c, 0x1d575166, 0xdd28f52b, 0xdd28f52b, 0x167fd4de, 0x167fd4de, 0x167fd4de, 0x37432d3a, 0x37432d3a, 0x37432d3a, 0x2d324eab, 0x2d324eab, 0x2d324eab, 0xdd28f52b, 0x1d575166, 0x1d575166, 0xdd28f52b, }, 20 },
- { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa64abc46, 0x75b6655, 0xa64abc46, 0x8ab5be58, 0x59c36f00, 0x59c36f00, 0xa119c4f4, 0xa119c4f4, 0xa119c4f4, 0xdf99a992, 0xdf99a992, 0xdf99a992, 0x1cbb945f, 0x1cbb945f, 0x1cbb945f, 0x59c36f00, 0x8ab5be58, 0x8ab5be58, 0x59c36f00, }, 20 },
- { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x58be41e7, 0xae0d3f09, 0x58be41e7, 0xda7a6cbf, 0xaa4593fe, 0xaa4593fe, 0x794b67, 0x794b67, 0x794b67, 0xa68c4600, 0xa68c4600, 0xa68c4600, 0x242ba46b, 0x242ba46b, 0x242ba46b, 0xaa4593fe, 0xda7a6cbf, 0xda7a6cbf, 0xaa4593fe, }, 20 },
- { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xaaa4d3ad, 0xe61c6d02, 0xaaa4d3ad, 0xff557024, 0xc9cbf769, 0xc9cbf769, 0x780542e8, 0x780542e8, 0x780542e8, 0x86dd8324, 0x86dd8324, 0x86dd8324, 0x6e8b2c28, 0x6e8b2c28, 0x6e8b2c28, 0xc9cbf769, 0xff557024, 0xff557024, 0xc9cbf769, }, 20 },
- { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf168f0ba, 0x151608f2, 0xf168f0ba, 0x1f8e266b, 0x9813a416, 0x9813a416, 0x358d1fb0, 0x358d1fb0, 0x358d1fb0, 0xa4569983, 0xa4569983, 0xa4569983, 0x38236c41, 0x38236c41, 0x38236c41, 0x9813a416, 0x1f8e266b, 0x1f8e266b, 0x9813a416, }, 20 },
- { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x927c4cf9, 0xdefa0b3b, 0x927c4cf9, 0x64636a93, 0x5fcf013d, 0x5fcf013d, 0xae2ee3eb, 0xae2ee3eb, 0xae2ee3eb, 0x7c3efb9d, 0x7c3efb9d, 0x7c3efb9d, 0x63157a60, 0x63157a60, 0x63157a60, 0x5fcf013d, 0x64636a93, 0x64636a93, 0x5fcf013d, }, 20 },
- { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2d254926, 0x796275ce, 0x2d254926, 0x17c0c9cb, 0xdd28f52b, 0xdd28f52b, 0x79439443, 0x79439443, 0x79439443, 0x587f6da7, 0x587f6da7, 0x587f6da7, 0x420e0e36, 0x420e0e36, 0x420e0e36, 0xdd28f52b, 0x17c0c9cb, 0x17c0c9cb, 0xdd28f52b, }, 20 },
- { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x755377f, 0x4e06e91f, 0x755377f, 0xe42f3a5, 0x43d1f34, 0x43d1f34, 0x3ac2d7b5, 0x3ac2d7b5, 0x3ac2d7b5, 0x45c87e1d, 0x45c87e1d, 0x45c87e1d, 0xade84734, 0xade84734, 0xade84734, 0x43d1f34, 0xe42f3a5, 0xe42f3a5, 0x43d1f34, }, 20 },
- { "gfxterm_red", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xa64abc46, 0x75b6655, 0xa64abc46, 0x8ab5be58, 0x59c36f00, 0x59c36f00, 0xa119c4f4, 0xa119c4f4, 0xa119c4f4, 0xdf99a992, 0xdf99a992, 0xdf99a992, 0x1cbb945f, 0x1cbb945f, 0x1cbb945f, 0x59c36f00, 0x8ab5be58, 0x8ab5be58, 0x59c36f00, }, 20 },
- { "gfxterm_red", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x58be41e7, 0xae0d3f09, 0x58be41e7, 0xda7a6cbf, 0xaa4593fe, 0xaa4593fe, 0x794b67, 0x794b67, 0x794b67, 0xa68c4600, 0xa68c4600, 0xa68c4600, 0x242ba46b, 0x242ba46b, 0x242ba46b, 0xaa4593fe, 0xda7a6cbf, 0xda7a6cbf, 0xaa4593fe, }, 20 },
- { "gfxterm_red", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0xaaa4d3ad, 0xe61c6d02, 0xaaa4d3ad, 0xff557024, 0xc9cbf769, 0xc9cbf769, 0x780542e8, 0x780542e8, 0x780542e8, 0x86dd8324, 0x86dd8324, 0x86dd8324, 0x6e8b2c28, 0x6e8b2c28, 0x6e8b2c28, 0xc9cbf769, 0xff557024, 0xff557024, 0xc9cbf769, }, 20 },
- { "gfxterm_red", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xcffd463e, 0x59775566, 0xcffd463e, 0xb4e87140, 0x5387d57f, 0x5387d57f, 0xc2a27e06, 0xc2a27e06, 0xc2a27e06, 0x2fb12ca, 0x2fb12ca, 0x2fb12ca, 0xe525905c, 0xe525905c, 0xe525905c, 0x5387d57f, 0xb4e87140, 0xb4e87140, 0x5387d57f, }, 20 },
- { "gfxterm_red", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x91d12daf, 0xdceabc0e, 0x91d12daf, 0xf372b81f, 0xf83ee7aa, 0xf83ee7aa, 0x85a69692, 0x85a69692, 0x85a69692, 0x19df4661, 0x19df4661, 0x19df4661, 0x216cedc9, 0x216cedc9, 0x216cedc9, 0xf83ee7aa, 0xf372b81f, 0xf372b81f, 0xf83ee7aa, }, 20 },
- { "gfxterm_red", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x5f5953b3, 0x1f88963e, 0x5f5953b3, 0x6aeb9112, 0x724366e5, 0x724366e5, 0xc5da2432, 0xc5da2432, 0xc5da2432, 0x82e366c8, 0x82e366c8, 0x82e366c8, 0xefcd4182, 0xefcd4182, 0xefcd4182, 0x724366e5, 0x6aeb9112, 0x6aeb9112, 0x724366e5, }, 20 },
- { "gfxterm_red", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x1227533e, 0xee3616e0, 0x1227533e, 0xc32db32e, 0x5387d57f, 0x5387d57f, 0xa347c834, 0xa347c834, 0xa347c834, 0x7d8987e9, 0x7d8987e9, 0x7d8987e9, 0xee0a15f7, 0xee0a15f7, 0xee0a15f7, 0x5387d57f, 0xc32db32e, 0xc32db32e, 0x5387d57f, }, 20 },
- { "gfxterm_red", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc548a908, 0x2624be34, 0xc548a908, 0x1745599, 0xf83ee7aa, 0xf83ee7aa, 0xaaaf7e14, 0xaaaf7e14, 0xaaaf7e14, 0xd8756d24, 0xd8756d24, 0xd8756d24, 0xe9e03ce2, 0xe9e03ce2, 0xe9e03ce2, 0xf83ee7aa, 0x1745599, 0x1745599, 0xf83ee7aa, }, 20 },
- { "gfxterm_red", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x30506e44, 0x76cf9d03, 0x30506e44, 0x33485d71, 0x724366e5, 0x724366e5, 0xd12bc953, 0xd12bc953, 0xd12bc953, 0x88bb3a03, 0x88bb3a03, 0x88bb3a03, 0x400c5441, 0x400c5441, 0x400c5441, 0x724366e5, 0x33485d71, 0x33485d71, 0x724366e5, }, 20 },
- { "gfxterm_red", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0xa3238023, 0xa5b82f9e, 0xa3238023, 0x93f8a252, 0x1c955882, 0x1c955882, 0x205b041f, 0x205b041f, 0x205b041f, 0xefac4988, 0xefac4988, 0xefac4988, 0x11c5459d, 0x11c5459d, 0x11c5459d, 0x1c955882, 0x93f8a252, 0x93f8a252, 0x1c955882, }, 20 },
- { "gfxterm_red", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xf651c995, 0x7e1ae3d7, 0xf651c995, 0xdab860af, 0x4d266f7a, 0x4d266f7a, 0x6272be10, 0x6272be10, 0x6272be10, 0x8405a5af, 0x8405a5af, 0x8405a5af, 0x1c3cf13f, 0x1c3cf13f, 0x1c3cf13f, 0x4d266f7a, 0xdab860af, 0xdab860af, 0x4d266f7a, }, 20 },
- { "gfxterm_red", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x2fa6119, 0x30618885, 0x2fa6119, 0xbfbe1b6a, 0x1ed9d731, 0x1ed9d731, 0x11353cf5, 0x11353cf5, 0x11353cf5, 0xbf512230, 0xbf512230, 0xbf512230, 0x9c383386, 0x9c383386, 0x9c383386, 0x1ed9d731, 0xbfbe1b6a, 0xbfbe1b6a, 0x1ed9d731, }, 20 },
- { "gfxterm_red", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x4caf1997, 0xda250acf, 0x4caf1997, 0x2183903f, 0x5387d57f, 0x5387d57f, 0x6be656ff, 0x6be656ff, 0x6be656ff, 0xabbf3a33, 0xabbf3a33, 0xabbf3a33, 0x4c61b8a5, 0x4c61b8a5, 0x4c61b8a5, 0x5387d57f, 0x2183903f, 0x2183903f, 0x5387d57f, }, 20 },
- { "gfxterm_red", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x7b29cc8e, 0x36125d2f, 0x7b29cc8e, 0x1277092, 0xf83ee7aa, 0xf83ee7aa, 0x4830d5b5, 0x4830d5b5, 0x4830d5b5, 0xd4490546, 0xd4490546, 0xd4490546, 0xecfaaeee, 0xecfaaeee, 0xecfaaeee, 0xf83ee7aa, 0x1277092, 0x1277092, 0xf83ee7aa, }, 20 },
- { "gfxterm_red", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x2e644de2, 0x6eb5886f, 0x2e644de2, 0x3d66c6af, 0x724366e5, 0x724366e5, 0x5d800f18, 0x5d800f18, 0x5d800f18, 0x1ab94de2, 0x1ab94de2, 0x1ab94de2, 0x77976aa8, 0x77976aa8, 0x77976aa8, 0x724366e5, 0x3d66c6af, 0x3d66c6af, 0x724366e5, }, 20 },
- { "gfxterm_red", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x5f11f8eb, 0xa300bd35, 0x5f11f8eb, 0xe2cba3fa, 0x5387d57f, 0x5387d57f, 0xfa2cee75, 0xfa2cee75, 0xfa2cee75, 0x24e2a1a8, 0x24e2a1a8, 0x24e2a1a8, 0xb76133b6, 0xb76133b6, 0xb76133b6, 0x5387d57f, 0xe2cba3fa, 0xe2cba3fa, 0x5387d57f, }, 20 },
- { "gfxterm_red", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x179340b2, 0xf4ff578e, 0x179340b2, 0xe378eba9, 0xf83ee7aa, 0xf83ee7aa, 0xf787fcc2, 0xf787fcc2, 0xf787fcc2, 0x855deff2, 0x855deff2, 0x855deff2, 0xb4c8be34, 0xb4c8be34, 0xb4c8be34, 0xf83ee7aa, 0xe378eba9, 0xe378eba9, 0xf83ee7aa, }, 20 },
- { "gfxterm_red", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x5703fa5a, 0x119c091d, 0x5703fa5a, 0xa13f0d1a, 0x724366e5, 0x724366e5, 0xd989a04d, 0xd989a04d, 0xd989a04d, 0x8019531d, 0x8019531d, 0x8019531d, 0x48ae3d5f, 0x48ae3d5f, 0x48ae3d5f, 0x724366e5, 0xa13f0d1a, 0xa13f0d1a, 0x724366e5, }, 20 },
- { "gfxterm_red", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xf38c2b36, 0xf517848b, 0xf38c2b36, 0xa2621779, 0x1c955882, 0x1c955882, 0x153777fa, 0x153777fa, 0x153777fa, 0xdac03a6d, 0xdac03a6d, 0xdac03a6d, 0x24a93678, 0x24a93678, 0x24a93678, 0x1c955882, 0xa2621779, 0xa2621779, 0x1c955882, }, 20 },
- { "gfxterm_red", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb8253868, 0x306e122a, 0xb8253868, 0x83b58e9b, 0x4d266f7a, 0x4d266f7a, 0x98183444, 0x98183444, 0x98183444, 0x7e6f2ffb, 0x7e6f2ffb, 0x7e6f2ffb, 0xe6567b6b, 0xe6567b6b, 0xe6567b6b, 0x4d266f7a, 0x83b58e9b, 0x83b58e9b, 0x4d266f7a, }, 20 },
- { "gfxterm_red", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x40c62f40, 0x725dc6dc, 0x40c62f40, 0x50dfba34, 0x1ed9d731, 0x1ed9d731, 0x32e89a68, 0x32e89a68, 0x32e89a68, 0x9c8c84ad, 0x9c8c84ad, 0x9c8c84ad, 0xbfe5951b, 0xbfe5951b, 0xbfe5951b, 0x1ed9d731, 0x50dfba34, 0x50dfba34, 0x1ed9d731, }, 20 },
- { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xfaeb56f1, 0x1e95aeb9, 0xfaeb56f1, 0xe4ddf18b, 0x9813a416, 0x9813a416, 0x5da5926f, 0x5da5926f, 0x5da5926f, 0xcc7e145c, 0xcc7e145c, 0xcc7e145c, 0x500be19e, 0x500be19e, 0x500be19e, 0x9813a416, 0xe4ddf18b, 0xe4ddf18b, 0x9813a416, }, 20 },
- { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa11f0307, 0xed9944c5, 0xa11f0307, 0x93a8828e, 0x5fcf013d, 0x5fcf013d, 0xeabf61dc, 0xeabf61dc, 0xeabf61dc, 0x38af79aa, 0x38af79aa, 0x38af79aa, 0x2784f857, 0x2784f857, 0x2784f857, 0x5fcf013d, 0x93a8828e, 0x93a8828e, 0x5fcf013d, }, 20 },
- { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xeedd0ec5, 0xba9a322d, 0xeedd0ec5, 0x32205338, 0xdd28f52b, 0xdd28f52b, 0x14854a2b, 0x14854a2b, 0x14854a2b, 0x35b9b3cf, 0x35b9b3cf, 0x35b9b3cf, 0x2fc8d05e, 0x2fc8d05e, 0x2fc8d05e, 0xdd28f52b, 0x32205338, 0x32205338, 0xdd28f52b, }, 20 },
- { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe7baf88f, 0x46ab229c, 0xe7baf88f, 0x2422eb85, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x2422eb85, 0x2422eb85, 0x59c36f00, }, 20 },
- { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x86184b5, 0xfed2fa5b, 0x86184b5, 0xf984bb34, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0xf984bb34, 0xf984bb34, 0xaa4593fe, }, 20 },
- { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x2dda8793, 0x6162393c, 0x2dda8793, 0x2a6bc689, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0x2a6bc689, 0x2a6bc689, 0xc9cbf769, }, 20 },
- { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf2b1715, 0xeb55ef5d, 0xf2b1715, 0x61e172d4, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0x61e172d4, 0x61e172d4, 0x9813a416, }, 20 },
- { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x2a517b4, 0x4e235076, 0x2a517b4, 0x85b73555, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x85b73555, 0x85b73555, 0x5fcf013d, }, 20 },
- { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x53e34b0f, 0x7a477e7, 0x53e34b0f, 0x7b92ba0b, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x7b92ba0b, 0x7b92ba0b, 0xdd28f52b, }, 20 },
- { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xcccbb8c0, 0x859866a0, 0xcccbb8c0, 0x2bf5b2f8, 0x43d1f34, 0x43d1f34, 0xd204ac75, 0xd204ac75, 0xd204ac75, 0xad0e05dd, 0xad0e05dd, 0xad0e05dd, 0x452e3cf4, 0x452e3cf4, 0x452e3cf4, 0x43d1f34, 0x2bf5b2f8, 0x2bf5b2f8, 0x43d1f34, }, 20 },
- { "gfxterm_high", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xe7baf88f, 0x46ab229c, 0xe7baf88f, 0x2422eb85, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x2422eb85, 0x2422eb85, 0x59c36f00, }, 20 },
- { "gfxterm_high", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x86184b5, 0xfed2fa5b, 0x86184b5, 0xf984bb34, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0xf984bb34, 0xf984bb34, 0xaa4593fe, }, 20 },
- { "gfxterm_high", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x2dda8793, 0x6162393c, 0x2dda8793, 0x2a6bc689, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0x2a6bc689, 0x2a6bc689, 0xc9cbf769, }, 20 },
- { "gfxterm_high", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xc2dae336, 0x5450f06e, 0xc2dae336, 0x2fd25c3, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0x2fd25c3, 0x2fd25c3, 0x5387d57f, }, 20 },
- { "gfxterm_high", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf910eb1d, 0xb42b7abc, 0xf910eb1d, 0x6d5e8f22, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x6d5e8f22, 0x6d5e8f22, 0xf83ee7aa, }, 20 },
- { "gfxterm_high", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xa038bbb4, 0xe0e97e39, 0xa038bbb4, 0x4211aeac, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x4211aeac, 0x4211aeac, 0x724366e5, }, 20 },
- { "gfxterm_high", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x4a2dd1b7, 0xb63c9469, 0x4a2dd1b7, 0xe8aea440, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0xe8aea440, 0xe8aea440, 0x5387d57f, }, 20 },
- { "gfxterm_high", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8597e648, 0x66fbf174, 0x8597e648, 0xa99c8f36, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xa99c8f36, 0xa99c8f36, 0xf83ee7aa, }, 20 },
- { "gfxterm_high", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x7c1b6088, 0x3a8493cf, 0x7c1b6088, 0xd5d88a3e, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0xd5d88a3e, 0xd5d88a3e, 0x724366e5, }, 20 },
- { "gfxterm_high", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x9f45f149, 0x99de5ef4, 0x9f45f149, 0x84437bc3, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0x84437bc3, 0x84437bc3, 0x1c955882, }, 20 },
- { "gfxterm_high", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x60f3276d, 0xe8b80d2f, 0x60f3276d, 0x1d7bae65, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0x1d7bae65, 0x1d7bae65, 0x4d266f7a, }, 20 },
- { "gfxterm_high", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x66a98ee6, 0x5432677a, 0x66a98ee6, 0x691b88fb, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0x691b88fb, 0x691b88fb, 0x1ed9d731, }, 20 },
- { "gfxterm_high", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xc26d8183, 0x54e792db, 0xc26d8183, 0x1473f9a0, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0x1473f9a0, 0x1473f9a0, 0x5387d57f, }, 20 },
- { "gfxterm_high", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x3ed65cd5, 0x73edcd74, 0x3ed65cd5, 0xb2351146, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0xb2351146, 0xb2351146, 0xf83ee7aa, }, 20 },
- { "gfxterm_high", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xc576da57, 0x85a71fda, 0xc576da57, 0x1ef86a3, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x1ef86a3, 0x1ef86a3, 0x724366e5, }, 20 },
- { "gfxterm_high", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x4778be32, 0xbb69fbec, 0x4778be32, 0x892b70c4, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0x892b70c4, 0x892b70c4, 0x5387d57f, }, 20 },
- { "gfxterm_high", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x9c6c6004, 0x7f007738, 0x9c6c6004, 0x80b05ef0, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0x80b05ef0, 0x80b05ef0, 0xf83ee7aa, }, 20 },
- { "gfxterm_high", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x84caa3c1, 0xc2555086, 0x84caa3c1, 0xd82d8d02, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0xd82d8d02, 0xd82d8d02, 0x724366e5, }, 20 },
- { "gfxterm_high", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xe4dec6e6, 0xe245695b, 0xe4dec6e6, 0x9eed5252, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0x9eed5252, 0x9eed5252, 0x1c955882, }, 20 },
- { "gfxterm_high", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x19a935eb, 0x91e21fa9, 0x19a935eb, 0x7358a32a, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0x7358a32a, 0x7358a32a, 0x4d266f7a, }, 20 },
- { "gfxterm_high", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xb2b10aa1, 0x802ae33d, 0xb2b10aa1, 0x105ee3bb, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0x105ee3bb, 0x105ee3bb, 0x1ed9d731, }, 20 },
- { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xeedf19a8, 0xaa1e1e0, 0xeedf19a8, 0x70c50dc2, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0x70c50dc2, 0x70c50dc2, 0x9813a416, }, 20 },
- { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa474246a, 0xe8f263a8, 0xa474246a, 0xe7cea168, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0xe7cea168, 0xe7cea168, 0x5fcf013d, }, 20 },
- { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x653aabb4, 0x317d975c, 0x653aabb4, 0xab5387a0, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0xab5387a0, 0xab5387a0, 0xdd28f52b, }, 20 },
- { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x7f1853ba, 0x7f1853ba, 0x7f1853ba, 0x7f1853ba, 0x7f1853ba, }, 5 },
- { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xff1957f0, 0xff1957f0, 0xff1957f0, 0xff1957f0, 0xff1957f0, }, 5 },
- { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xcb45d8c5, 0xcb45d8c5, 0xcb45d8c5, 0xcb45d8c5, 0xcb45d8c5, }, 5 },
- { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x2b154617, 0x692e98df, 0xaf62fb87, 0xed59254f, 0x26164bc6, }, 5 },
- { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x3b0fbc56, 0xd9d57c0e, 0xfb564a17, 0x198c8a4f, 0xbe502625, }, 5 },
- { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0x6e6c9b36, 0x4ae9f137, 0x27664f34, 0x3e32535, 0xfc793332, }, 5 },
- { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x91692eef, 0x89773091, 0xa1551213, 0xb94b0c6d, 0xf1115717, }, 5 },
- { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x2d1b122b, 0x2d1b122b, 0x2d1b122b, 0x2d1b122b, 0x2d1b122b, }, 5 },
- { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0x327d1082, 0x327d1082, 0x327d1082, 0x327d1082, 0x327d1082, }, 5 },
- { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xadd0f186, 0xadd0f186, 0xadd0f186, 0xadd0f186, 0xadd0f186, }, 5 },
- { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x2c97569c, 0x2c97569c, 0x2c97569c, 0x2c97569c, 0x2c97569c, }, 5 },
- { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x9bd7a3ac, 0x9bd7a3ac, 0x9bd7a3ac, 0x9bd7a3ac, 0x9bd7a3ac, }, 5 },
- { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xedbceb9c, 0xedbceb9c, 0xedbceb9c, 0xedbceb9c, 0xedbceb9c, }, 5 },
- { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x3c2a42f1, 0x3c2a42f1, 0x3c2a42f1, 0x3c2a42f1, 0x3c2a42f1, }, 5 },
- { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xb25ce62a, 0xb25ce62a, 0xb25ce62a, 0xb25ce62a, 0xb25ce62a, }, 5 },
- { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x66cee14c, 0x66cee14c, 0x66cee14c, 0x66cee14c, 0x66cee14c, }, 5 },
- { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x61db45b7, 0x1d867efe, 0x99613325, 0xe53c086c, 0x9543de62, }, 5 },
- { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0xa46eb37f, 0xd2a59656, 0x49f8f92d, 0x3f33dc04, 0x7aae512a, }, 5 },
- { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0xb864a496, 0x6c22313b, 0x1505f93d, 0xc1436c90, 0xe74a6931, }, 5 },
- { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x9056f776, 0x9056f776, 0x9056f776, 0x9056f776, 0x9056f776, }, 5 },
- { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2bde3c67, 0x2bde3c67, 0x2bde3c67, 0x2bde3c67, 0x2bde3c67, }, 5 },
- { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xb04615f3, 0xb04615f3, 0xb04615f3, 0xb04615f3, 0xb04615f3, }, 5 },
- { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0xba8df8dd, 0xba8df8dd, 0xba8df8dd, 0xba8df8dd, 0xba8df8dd, }, 5 },
- { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x84ac1329, 0x84ac1329, 0x84ac1329, 0x84ac1329, 0x84ac1329, }, 5 },
- { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x145ad698, 0x145ad698, 0x145ad698, 0x145ad698, 0x145ad698, }, 5 },
- { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x4af6b480, 0x923db79c, 0xfe8cc449, 0x2647c755, 0x27ee23e3, }, 5 },
- { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x121d5e29, 0xf66c0aed, 0xdf138150, 0x3b62d594, 0x8dec962a, }, 5 },
- { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0xae86a12c, 0x4dabbe89, 0x6d30e897, 0x8e1df732, 0x2c0644ab, }, 5 },
- { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x2605d280, 0xc06e3172, 0xef3e6395, 0x9558067, 0xb19ec65b, }, 5 },
- { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x9404ef3b, 0xa4fdf18, 0xad7ef98c, 0x3335c9af, 0xe6f0c255, }, 5 },
- { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xa008b770, 0xb98eb0d8, 0x9304b820, 0x8a82bf88, 0xc610a9d0, }, 5 },
+ { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24285504, 0x24285504, 0x3cc7ae1, 0x3cc7ae1, 0x20e2971b, 0x20e2971b, 0xc295b4fc, 0xc295b4fc, 0x1fbe0d4, 0x1fbe0d4, 0x82930744, 0x82930744, 0xf4b66805, 0xf4b66805, 0x3e16a8c5, 0x3e16a8c5, 0x1165d7dc, 0x1165d7dc, 0xfa78cf7f, 0xfa78cf7f, 0xc105a544, 0xc105a544, 0x430cee22, 0x430cee22, 0xbcf938a0, 0xbcf938a0, 0x7b800045, 0x7b800045, 0x2cc85143, 0x2cc85143, 0x80e0a4b4, 0x80e0a4b4, 0x212e8415, 0x212e8415, 0x151d5163, 0x151d5163, 0x24dcfa9e, 0x24dcfa9e, 0xb1df21b2, 0xb1df21b2, 0x2990a5cf, 0x8c1740a5, 0xd29f2d17, 0xd29f2d17, }, 45 },
+ { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2b224886, 0x2b224886, 0x4fa52ab9, 0x4fa52ab9, 0xad8716fa, 0xad8716fa, 0x97a64f1, 0x97a64f1, 0x5fa72700, 0x5fa72700, 0x41913bce, 0x41913bce, 0xe3e6af02, 0xe3e6af02, 0x978a4f3c, 0x978a4f3c, 0xfdedd645, 0xfdedd645, 0x4700a76, 0x4700a76, 0x28761dd2, 0x28761dd2, 0x255a96e8, 0x255a96e8, 0x6eb066fa, 0x6eb066fa, 0x5948e6c4, 0x5948e6c4, 0xc2d83034, 0xc2d83034, 0xe9cc8934, 0xe9cc8934, 0x406490d, 0x406490d, 0x2287423f, 0x2287423f, 0x565ef88b, 0x565ef88b, 0x31af9b10, 0x31af9b10, 0xfbd17ce0, 0xdb686c61, 0xd2731a72, 0xd2731a72, }, 45 },
+ { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x999febcd, 0x999febcd, 0x4be4a5e6, 0x4be4a5e6, 0xaa36e979, 0xaa36e979, 0x27ebab0f, 0x27ebab0f, 0x6fa8606c, 0x6fa8606c, 0xd3f60410, 0xd3f60410, 0xa3aea110, 0xa3aea110, 0x5b352e4b, 0x5b352e4b, 0xad22636f, 0xad22636f, 0x54333936, 0x54333936, 0x73d67c9f, 0x73d67c9f, 0xb4462f4a, 0xb4462f4a, 0x1dffdbca, 0x1dffdbca, 0x7095a788, 0x7095a788, 0xc71aa28, 0xc71aa28, 0x215e8dfc, 0x215e8dfc, 0x388d3494, 0x388d3494, 0x5804733d, 0x5804733d, 0x98ef7a83, 0x98ef7a83, 0xc986bddb, 0xc986bddb, 0x183599ab, 0xf4204ada, 0x6562dd40, 0x6562dd40, }, 45 },
+ { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xea25e7f1, 0xea25e7f1, 0xf959b605, 0xf959b605, 0x5650ee99, 0x5650ee99, 0xbf3bec3c, 0xbf3bec3c, 0x8d04d782, 0x8d04d782, 0xddbcf5be, 0xddbcf5be, 0x7ee1adaf, 0x7ee1adaf, 0x2fbaff58, 0x2fbaff58, 0x42b24add, 0x42b24add, 0x47483eb4, 0x47483eb4, 0x78962528, 0x78962528, 0x847ee9b7, 0x847ee9b7, 0xc826c0f, 0xc826c0f, 0x82b1bf51, 0x82b1bf51, 0x13ccc821, 0x13ccc821, 0x7d783b1e, 0x7d783b1e, 0xdd2c0bbc, 0xdd2c0bbc, 0x7b71ebd7, 0x7b71ebd7, 0x7381f4c5, 0x7381f4c5, 0xfe20bc9c, 0xfe20bc9c, 0x85dee923, 0x85611b00, 0x723c0ec4, 0x723c0ec4, }, 45 },
+ { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xbc52dc5f, 0xbc52dc5f, 0x4c895989, 0x4c895989, 0x59d180a4, 0x59d180a4, 0x50eb81b9, 0x50eb81b9, 0xae85d6c6, 0xae85d6c6, 0xf8354df6, 0xf8354df6, 0x83562153, 0x83562153, 0xd4caece2, 0xd4caece2, 0xb0b5612d, 0xb0b5612d, 0x123d360a, 0x123d360a, 0x70f62e8e, 0x70f62e8e, 0x6a82788f, 0x6a82788f, 0xb0a3ee68, 0xb0a3ee68, 0x604dd5b0, 0x604dd5b0, 0x20f7ea1, 0x20f7ea1, 0x3f6db6bf, 0x3f6db6bf, 0x4a762b9d, 0x4a762b9d, 0xea026ad4, 0xea026ad4, 0x8ba3d148, 0x8ba3d148, 0x434f2359, 0x434f2359, 0x4db299a1, 0x73536949, 0xf022eb4b, 0xf022eb4b, }, 45 },
+ { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7cfd676, 0x7cfd676, 0xaf7bcdc6, 0xaf7bcdc6, 0x7dc1f958, 0x7dc1f958, 0xc902ad3e, 0xc902ad3e, 0x5529ad04, 0x5529ad04, 0xa0a133b1, 0xa0a133b1, 0x72f927da, 0x72f927da, 0x28de6d8e, 0x28de6d8e, 0xa5eb10fc, 0xa5eb10fc, 0x2d7ba4f5, 0x2d7ba4f5, 0xd832b228, 0xd832b228, 0x56f0351, 0x56f0351, 0xc6556c2e, 0xc6556c2e, 0x2ceecfa4, 0x2ceecfa4, 0x3d765fbd, 0x3d765fbd, 0x8da7887e, 0x8da7887e, 0xfc8209ea, 0xfc8209ea, 0x6e822767, 0x6e822767, 0xba5c0adf, 0xba5c0adf, 0x8e2af81a, 0x8e2af81a, 0x62c25eb4, 0x2ba315e0, 0x349b7b7d, 0x349b7b7d, }, 45 },
+ { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x361fdea5, 0x361fdea5, 0x89a3b488, 0x89a3b488, 0x37302fbe, 0x37302fbe, 0x4b9f20b8, 0x4b9f20b8, 0xc60cf5fe, 0xc60cf5fe, 0xf7b755aa, 0xf7b755aa, 0xcaba5d52, 0xcaba5d52, 0x4f793adf, 0x4f793adf, 0x4cd60722, 0x4cd60722, 0x13adbeec, 0x13adbeec, 0xdc2c109f, 0xdc2c109f, 0x444e465a, 0x444e465a, 0x7baac5fa, 0x7baac5fa, 0x8e746e7f, 0x8e746e7f, 0x7fea6e68, 0x7fea6e68, 0x1f6edf48, 0x1f6edf48, 0x23322506, 0x23322506, 0xbccd38ef, 0xbccd38ef, 0x1b1f1dd3, 0x1b1f1dd3, 0x9c901775, 0x9c901775, 0x78b8e355, 0x95034aa2, 0x4f00ee83, 0x4f00ee83, }, 45 },
+ { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xdf032925, 0xb9ccc5a6, 0xdf032925, 0x9cf5e462, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0x9cf5e462, 0x9cf5e462, 0x59c36f00, }, 20 },
+ { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa24e444d, 0x664c3f5, 0xa24e444d, 0x8c4bc132, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x8c4bc132, 0x8c4bc132, 0xaa4593fe, }, 20 },
+ { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6fa41086, 0xd5284f5e, 0x6fa41086, 0x32b37d02, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0x32b37d02, 0x32b37d02, 0xc9cbf769, }, 20 },
+ { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd084e37c, 0x6324ea4b, 0xd084e37c, 0x7ed2aaa4, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0x7ed2aaa4, 0x7ed2aaa4, 0x9813a416, }, 20 },
+ { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x451273fe, 0x55e4689f, 0x451273fe, 0x33b4464d, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x33b4464d, 0x33b4464d, 0x5fcf013d, }, 20 },
+ { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x93132338, 0xc76b87e6, 0x93132338, 0x8816f93f, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0x8816f93f, 0x8816f93f, 0xdd28f52b, }, 20 },
+ { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xae6a4ef5, 0x5fb9948, 0xae6a4ef5, 0x51d55575, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x51d55575, 0x51d55575, 0x43d1f34, }, 20 },
+ { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x60e56714, 0x14275a99, 0x60e56714, 0x35080c92, 0x9a2e0d26, 0xc53fe194, 0xc53fe194, 0xc53fe194, 0x99e71754, 0x99e71754, 0x99e71754, 0xb07fd9c6, 0xb07fd9c6, 0xb07fd9c6, 0x59c36f00, 0x35080c92, 0x35080c92, }, 18 },
+ { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x33d94a8c, 0x7b789e53, 0x33d94a8c, 0xe8b9b6bf, 0xa9d58ccd, 0x8cf0d333, 0x8cf0d333, 0x8cf0d333, 0xd9af7939, 0xd9af7939, 0xd9af7939, 0xb09cb170, 0xb09cb170, 0xb09cb170, 0xaa4593fe, 0xe8b9b6bf, 0xe8b9b6bf, }, 18 },
+ { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe4669404, 0x9afa8e99, 0xe4669404, 0xdd25167e, 0x5411be8b, 0x3589841c, 0x3589841c, 0x3589841c, 0x4a372288, 0x4a372288, 0x4a372288, 0x84342f0, 0x84342f0, 0x84342f0, 0xc9cbf769, 0xdd25167e, 0xdd25167e, }, 18 },
+ { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0x37ed1568, 0x12f55eef, 0x37ed1568, 0x8aa8ad16, 0x740d78cf, 0x1a9dc2bc, 0x1a9dc2bc, 0x1a9dc2bc, 0xf13828c0, 0xf13828c0, 0xf13828c0, 0xf7732830, 0xf7732830, 0xf7732830, 0x1c3742c9, 0x8aa8ad16, 0x8aa8ad16, }, 18 },
+ { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0xc5315ac9, 0x7dece9d3, 0xc5315ac9, 0xc84ef08b, 0xbcda144c, 0x321e548b, 0x321e548b, 0x321e548b, 0x5d57889a, 0x5d57889a, 0x5d57889a, 0x50a11699, 0x50a11699, 0x50a11699, 0xcc5a7bed, 0xc84ef08b, 0xc84ef08b, }, 18 },
+ { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0x40a72ecd, 0x2304571f, 0x40a72ecd, 0xd2de6d81, 0x5d55a141, 0x8ccafa03, 0x8ccafa03, 0x8ccafa03, 0x4a78be1d, 0x4a78be1d, 0x4a78be1d, 0x5e1d6ea2, 0x5e1d6ea2, 0x5e1d6ea2, 0xef4a3312, 0xd2de6d81, 0xd2de6d81, }, 18 },
+ { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0xe6143ead, 0x19816f75, 0xe6143ead, 0xe2db78c2, 0xa992f629, 0x5fefa0d1, 0x5fefa0d1, 0x5fefa0d1, 0xde1c5600, 0xde1c5600, 0xde1c5600, 0x48b8ef6f, 0x48b8ef6f, 0x48b8ef6f, 0x54e48d80, 0xe2db78c2, 0xe2db78c2, }, 18 },
+ { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x25ba43d4, 0x43fe620d, 0x25ba43d4, 0x664c8e93, 0x59c36f00, 0x59c36f00, 0xb2921a37, 0xb2921a37, 0xb2921a37, 0xcc127751, 0xcc127751, 0xcc127751, 0xaee46283, 0xaee46283, 0xaee46283, 0x59c36f00, 0x664c8e93, 0x664c8e93, 0x59c36f00, }, 20 },
+ { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2aa2a72b, 0x6d6df6e1, 0x2aa2a72b, 0x4a72254, 0xaa4593fe, 0xaa4593fe, 0xa3be9127, 0xa3be9127, 0xa3be9127, 0x54b9c40, 0x54b9c40, 0x54b9c40, 0x28733738, 0x28733738, 0x28733738, 0xaa4593fe, 0x4a72254, 0x4a72254, 0xaa4593fe, }, 20 },
+ { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9e799f98, 0xe21ad041, 0x9e799f98, 0xc36ef21c, 0xc9cbf769, 0xc9cbf769, 0x93d6c07d, 0x93d6c07d, 0x93d6c07d, 0x6d0e01b1, 0x6d0e01b1, 0x6d0e01b1, 0x8444beb9, 0x8444beb9, 0x8444beb9, 0xc9cbf769, 0xc36ef21c, 0xc36ef21c, 0xc9cbf769, }, 20 },
+ { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7ffc43fd, 0x64505961, 0x7ffc43fd, 0xd1aa0a25, 0x9813a416, 0x9813a416, 0x5b5f9bd5, 0x5b5f9bd5, 0x5b5f9bd5, 0xca841de6, 0xca841de6, 0xca841de6, 0xd33e2036, 0xd33e2036, 0xd33e2036, 0x9813a416, 0xd1aa0a25, 0xd1aa0a25, 0x9813a416, }, 20 },
+ { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x570ca3fc, 0x4f1cee0f, 0x570ca3fc, 0x21aa964f, 0x5fcf013d, 0x5fcf013d, 0xf2bc017e, 0xf2bc017e, 0xf2bc017e, 0x20ac1908, 0x20ac1908, 0x20ac1908, 0x36df2697, 0x36df2697, 0x36df2697, 0x5fcf013d, 0x21aa964f, 0x21aa964f, 0x5fcf013d, }, 20 },
+ { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcf9798d3, 0x5d39a7fa, 0xcf9798d3, 0xd49242d4, 0xdd28f52b, 0xdd28f52b, 0xe15747f0, 0xe15747f0, 0xe15747f0, 0xc06bbe14, 0xc06bbe14, 0xc06bbe14, 0xbdd37598, 0xbdd37598, 0xbdd37598, 0xdd28f52b, 0xd49242d4, 0xd49242d4, 0xdd28f52b, }, 20 },
+ { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xae6154e8, 0x59e627f7, 0xae6154e8, 0x51de4f68, 0x43d1f34, 0x43d1f34, 0x59a8eb9f, 0x59a8eb9f, 0x59a8eb9f, 0x26a24237, 0x26a24237, 0x26a24237, 0xbff347b1, 0xbff347b1, 0xbff347b1, 0x43d1f34, 0x51de4f68, 0x51de4f68, 0x43d1f34, }, 20 },
+ { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xb2b04aa3, 0xca81b845, 0xb2b04aa3, 0xf14687e4, 0x59c36f00, 0x59c36f00, 0xc01ee8bb, 0xc01ee8bb, 0xc01ee8bb, 0xbe9e85dd, 0xbe9e85dd, 0xbe9e85dd, 0xdc68900f, 0xdc68900f, 0xdc68900f, 0x59c36f00, 0xf14687e4, 0xf14687e4, 0x59c36f00, }, 20 },
+ { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x19a66482, 0xba12148e, 0x19a66482, 0x37a3e1fd, 0xaa4593fe, 0xaa4593fe, 0xfa4f54c9, 0xfa4f54c9, 0xfa4f54c9, 0x5cba59ae, 0x5cba59ae, 0x5cba59ae, 0x7182f2d6, 0x7182f2d6, 0x7182f2d6, 0xaa4593fe, 0x37a3e1fd, 0x37a3e1fd, 0xaa4593fe, }, 20 },
+ { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6a5ddfe7, 0xc898195a, 0x6a5ddfe7, 0x374ab263, 0xc9cbf769, 0xc9cbf769, 0x7a6a0afe, 0x7a6a0afe, 0x7a6a0afe, 0x84b2cb32, 0x84b2cb32, 0x84b2cb32, 0x6df8743a, 0x6df8743a, 0x6df8743a, 0xc9cbf769, 0x374ab263, 0x374ab263, 0xc9cbf769, }, 20 },
+ { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb6ca222a, 0x98e6c241, 0xb6ca222a, 0x189c6bf2, 0x9813a416, 0x9813a416, 0x7fad8eb7, 0x7fad8eb7, 0x7fad8eb7, 0xee760884, 0xee760884, 0xee760884, 0xf7cc3554, 0xf7cc3554, 0xf7cc3554, 0x9813a416, 0x189c6bf2, 0x189c6bf2, 0x9813a416, }, 20 },
+ { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x726d82d0, 0xe9c535bd, 0x726d82d0, 0x4cbb763, 0x5fcf013d, 0x5fcf013d, 0xf99de8d5, 0xf99de8d5, 0xf99de8d5, 0x2b8df0a3, 0x2b8df0a3, 0x2b8df0a3, 0x3dfecf3c, 0x3dfecf3c, 0x3dfecf3c, 0x5fcf013d, 0x4cbb763, 0x4cbb763, 0x5fcf013d, }, 20 },
+ { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfe26fef7, 0x6031c462, 0xfe26fef7, 0xe52324f0, 0xdd28f52b, 0xdd28f52b, 0x84ff6e38, 0x84ff6e38, 0x84ff6e38, 0xa5c397dc, 0xa5c397dc, 0xa5c397dc, 0xd87b5c50, 0xd87b5c50, 0xd87b5c50, 0xdd28f52b, 0xe52324f0, 0xe52324f0, 0xdd28f52b, }, 20 },
+ { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x25e34f8a, 0x67935e5e, 0x25e34f8a, 0xda5c540a, 0x43d1f34, 0x43d1f34, 0x7ebdd748, 0x7ebdd748, 0x7ebdd748, 0x1b77ee0, 0x1b77ee0, 0x1b77ee0, 0x98e67b66, 0x98e67b66, 0x98e67b66, 0x43d1f34, 0xda5c540a, 0xda5c540a, 0x43d1f34, }, 20 },
+ { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x67038f5e, 0x65d6007f, 0x67038f5e, 0x24f54219, 0x59c36f00, 0x59c36f00, 0xac294ffd, 0xac294ffd, 0xac294ffd, 0xd2a9229b, 0xd2a9229b, 0xd2a9229b, 0xb05f3749, 0xb05f3749, 0xb05f3749, 0x59c36f00, 0x24f54219, 0x24f54219, 0x59c36f00, }, 20 },
+ { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x944464c7, 0x27123864, 0x944464c7, 0xba41e1b8, 0xaa4593fe, 0xaa4593fe, 0xa521274, 0xa521274, 0xa521274, 0xaca71f13, 0xaca71f13, 0xaca71f13, 0x819fb46b, 0x819fb46b, 0x819fb46b, 0xaa4593fe, 0xba41e1b8, 0xba41e1b8, 0xaa4593fe, }, 20 },
+ { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xfe97adaf, 0x4f3307d4, 0xfe97adaf, 0xa380c02b, 0xc9cbf769, 0xc9cbf769, 0xd202ced6, 0xd202ced6, 0xd202ced6, 0x2cda0f1a, 0x2cda0f1a, 0x2cda0f1a, 0xc590b012, 0xc590b012, 0xc590b012, 0xc9cbf769, 0xa380c02b, 0xa380c02b, 0xc9cbf769, }, 20 },
+ { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x5b32a9ba, 0xaf93fd91, 0x5b32a9ba, 0xf564e062, 0x9813a416, 0x9813a416, 0xcfdbc809, 0xcfdbc809, 0xcfdbc809, 0x5e004e3a, 0x5e004e3a, 0x5e004e3a, 0x47ba73ea, 0x47ba73ea, 0x47ba73ea, 0x9813a416, 0xf564e062, 0xf564e062, 0x9813a416, }, 20 },
+ { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5e0e1ce8, 0x7ed1c9ee, 0x5e0e1ce8, 0x28a8295b, 0x5fcf013d, 0x5fcf013d, 0x615f5762, 0x615f5762, 0x615f5762, 0xb34f4f14, 0xb34f4f14, 0xb34f4f14, 0xa53c708b, 0xa53c708b, 0xa53c708b, 0x5fcf013d, 0x28a8295b, 0x28a8295b, 0x5fcf013d, }, 20 },
+ { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xa473184a, 0x93eaf325, 0xa473184a, 0xbf76c24d, 0xdd28f52b, 0xdd28f52b, 0x714dd1f7, 0x714dd1f7, 0x714dd1f7, 0x50712813, 0x50712813, 0x50712813, 0x2dc9e39f, 0x2dc9e39f, 0x2dc9e39f, 0xdd28f52b, 0xbf76c24d, 0xbf76c24d, 0xdd28f52b, }, 20 },
+ { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa725578b, 0x81889cf9, 0xa725578b, 0x589a4c0b, 0x43d1f34, 0x43d1f34, 0xf25ab3a8, 0xf25ab3a8, 0xf25ab3a8, 0x8d501a00, 0x8d501a00, 0x8d501a00, 0x14011f86, 0x14011f86, 0x14011f86, 0x43d1f34, 0x589a4c0b, 0x589a4c0b, 0x43d1f34, }, 20 },
+ { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd69cdcbf, 0x6ad9ce85, 0xd69cdcbf, 0x956a11f8, 0x59c36f00, 0x59c36f00, 0xc4c10e6a, 0xc4c10e6a, 0xc4c10e6a, 0xba41630c, 0xba41630c, 0xba41630c, 0xd8b776de, 0xd8b776de, 0xd8b776de, 0x59c36f00, 0x956a11f8, 0x956a11f8, 0x59c36f00, }, 20 },
+ { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1acffa1b, 0xecff2136, 0x1acffa1b, 0x34ca7f64, 0xaa4593fe, 0xaa4593fe, 0xb57c29cc, 0xb57c29cc, 0xb57c29cc, 0x138924ab, 0x138924ab, 0x138924ab, 0x3eb18fd3, 0x3eb18fd3, 0x3eb18fd3, 0xaa4593fe, 0x34ca7f64, 0x34ca7f64, 0xaa4593fe, }, 20 },
+ { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x1cf8992, 0xb2c51b4c, 0x1cf8992, 0x5cd8e416, 0xc9cbf769, 0xc9cbf769, 0xba7b2d22, 0xba7b2d22, 0xba7b2d22, 0x44a3ecee, 0x44a3ecee, 0x44a3ecee, 0xade953e6, 0xade953e6, 0xade953e6, 0xc9cbf769, 0x5cd8e416, 0x5cd8e416, 0xc9cbf769, }, 20 },
+ { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1f39da0b, 0x6a7f5378, 0x1f39da0b, 0xb16f93d3, 0x9813a416, 0x9813a416, 0x8e8a2ed7, 0x8e8a2ed7, 0x8e8a2ed7, 0x1f51a8e4, 0x1f51a8e4, 0x1f51a8e4, 0x6eb9534, 0x6eb9534, 0x6eb9534, 0x9813a416, 0xb16f93d3, 0xb16f93d3, 0x9813a416, }, 20 },
+ { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x27394d6b, 0x459337bf, 0x27394d6b, 0x519f78d8, 0x5fcf013d, 0x5fcf013d, 0x66ed4571, 0x66ed4571, 0x66ed4571, 0xb4fd5d07, 0xb4fd5d07, 0xb4fd5d07, 0xa28e6298, 0xa28e6298, 0xa28e6298, 0x5fcf013d, 0x519f78d8, 0x519f78d8, 0x5fcf013d, }, 20 },
+ { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x624e1f92, 0x4be3bd84, 0x624e1f92, 0x794bc595, 0xdd28f52b, 0xdd28f52b, 0xd33767c, 0xd33767c, 0xd33767c, 0x2c0f8f98, 0x2c0f8f98, 0x2c0f8f98, 0x51b74414, 0x51b74414, 0x51b74414, 0xdd28f52b, 0x794bc595, 0x794bc595, 0xdd28f52b, }, 20 },
+ { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbf5dab2e, 0x4747516, 0xbf5dab2e, 0x40e2b0ae, 0x43d1f34, 0x43d1f34, 0x3cc1d2dd, 0x3cc1d2dd, 0x3cc1d2dd, 0x43cb7b75, 0x43cb7b75, 0x43cb7b75, 0xda9a7ef3, 0xda9a7ef3, 0xda9a7ef3, 0x43d1f34, 0x40e2b0ae, 0x40e2b0ae, 0x43d1f34, }, 20 },
+ { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x2e284303, 0x169e4b98, 0x2e284303, 0x6dde8e44, 0x59c36f00, 0x59c36f00, 0xd2e0cf68, 0xd2e0cf68, 0xd2e0cf68, 0xac60a20e, 0xac60a20e, 0xac60a20e, 0xce96b7dc, 0xce96b7dc, 0xce96b7dc, 0x59c36f00, 0x6dde8e44, 0x6dde8e44, 0x59c36f00, }, 20 },
+ { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3a911f8f, 0xe5d171c6, 0x3a911f8f, 0x14949af0, 0xaa4593fe, 0xaa4593fe, 0xe7c628ac, 0xe7c628ac, 0xe7c628ac, 0x413325cb, 0x413325cb, 0x413325cb, 0x6c0b8eb3, 0x6c0b8eb3, 0x6c0b8eb3, 0xaa4593fe, 0x14949af0, 0x14949af0, 0xaa4593fe, }, 20 },
+ { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa4645fb3, 0x8af97df0, 0xa4645fb3, 0xf9733237, 0xc9cbf769, 0xc9cbf769, 0xef376611, 0xef376611, 0xef376611, 0x11efa7dd, 0x11efa7dd, 0x11efa7dd, 0xf8a518d5, 0xf8a518d5, 0xf8a518d5, 0xc9cbf769, 0xf9733237, 0xf9733237, 0xc9cbf769, }, 20 },
+ { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7c3a337b, 0xed3f1a6, 0x7c3a337b, 0xd26c7aa3, 0x9813a416, 0x9813a416, 0x86aa8146, 0x86aa8146, 0x86aa8146, 0x17710775, 0x17710775, 0x17710775, 0xecb3aa5, 0xecb3aa5, 0xecb3aa5, 0x9813a416, 0xd26c7aa3, 0xd26c7aa3, 0x9813a416, }, 20 },
+ { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9f31781b, 0xb6d3e547, 0x9f31781b, 0xe9974da8, 0x5fcf013d, 0x5fcf013d, 0x3781245e, 0x3781245e, 0x3781245e, 0xe5913c28, 0xe5913c28, 0xe5913c28, 0xf3e203b7, 0xf3e203b7, 0xf3e203b7, 0x5fcf013d, 0xe9974da8, 0xe9974da8, 0x5fcf013d, }, 20 },
+ { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfc18d24f, 0x70ed44c6, 0xfc18d24f, 0xe71d0848, 0xdd28f52b, 0xdd28f52b, 0xc847f61f, 0xc847f61f, 0xc847f61f, 0xe97b0ffb, 0xe97b0ffb, 0xe97b0ffb, 0x94c3c477, 0x94c3c477, 0x94c3c477, 0xdd28f52b, 0xe71d0848, 0xe71d0848, 0xdd28f52b, }, 20 },
+ { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x7bb91866, 0xc4777a1f, 0x7bb91866, 0x840603e6, 0x43d1f34, 0x43d1f34, 0x2a49c131, 0x2a49c131, 0x2a49c131, 0x55436899, 0x55436899, 0x55436899, 0xcc126d1f, 0xcc126d1f, 0xcc126d1f, 0x43d1f34, 0x840603e6, 0x840603e6, 0x43d1f34, }, 20 },
+ { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa0d0faff, 0x8b37dfcd, 0xa0d0faff, 0xe32637b8, 0x59c36f00, 0x59c36f00, 0x94e6a8c7, 0x94e6a8c7, 0x94e6a8c7, 0xea66c5a1, 0xea66c5a1, 0xea66c5a1, 0x8890d073, 0x8890d073, 0x8890d073, 0x59c36f00, 0xe32637b8, 0xe32637b8, 0x59c36f00, }, 20 },
+ { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x4436bcdb, 0xb3a12b62, 0x4436bcdb, 0x6a3339a4, 0xaa4593fe, 0xaa4593fe, 0x53ef9b82, 0x53ef9b82, 0x53ef9b82, 0xf51a96e5, 0xf51a96e5, 0xf51a96e5, 0xd8223d9d, 0xd8223d9d, 0xd8223d9d, 0xaa4593fe, 0x6a3339a4, 0x6a3339a4, 0xaa4593fe, }, 20 },
+ { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb8e59140, 0x2463e41f, 0xb8e59140, 0xe5f2fcc4, 0xc9cbf769, 0xc9cbf769, 0xc31681f4, 0xc31681f4, 0xc31681f4, 0x3dce4038, 0x3dce4038, 0x3dce4038, 0xd484ff30, 0xd484ff30, 0xd484ff30, 0xc9cbf769, 0xe5f2fcc4, 0xe5f2fcc4, 0xc9cbf769, }, 20 },
+ { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x438b3fcc, 0x7ebfbfd, 0x438b3fcc, 0xeddd7614, 0x9813a416, 0x9813a416, 0x8ac4ae20, 0x8ac4ae20, 0x8ac4ae20, 0x1b1f2813, 0x1b1f2813, 0x1b1f2813, 0x2a515c3, 0x2a515c3, 0x2a515c3, 0x9813a416, 0xeddd7614, 0xeddd7614, 0x9813a416, }, 20 },
+ { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf9eea896, 0x25a51233, 0xf9eea896, 0x8f489d25, 0x5fcf013d, 0x5fcf013d, 0x62e37cf8, 0x62e37cf8, 0x62e37cf8, 0xb0f3648e, 0xb0f3648e, 0xb0f3648e, 0xa6805b11, 0xa6805b11, 0xa6805b11, 0x5fcf013d, 0x8f489d25, 0x8f489d25, 0x5fcf013d, }, 20 },
+ { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x9b617752, 0xb06817b5, 0x9b617752, 0x8064ad55, 0xdd28f52b, 0xdd28f52b, 0x38159b7a, 0x38159b7a, 0x38159b7a, 0x1929629e, 0x1929629e, 0x1929629e, 0x6491a912, 0x6491a912, 0x6491a912, 0xdd28f52b, 0x8064ad55, 0x8064ad55, 0xdd28f52b, }, 20 },
+ { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x595e29e, 0xc043d961, 0x595e29e, 0xfa2af91e, 0x43d1f34, 0x43d1f34, 0x6d6b2915, 0x6d6b2915, 0x6d6b2915, 0x126180bd, 0x126180bd, 0x126180bd, 0x8b30853b, 0x8b30853b, 0x8b30853b, 0x43d1f34, 0xfa2af91e, 0xfa2af91e, 0x43d1f34, }, 20 },
+ { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x63e24d8a, 0x52da109, 0x63e24d8a, 0x201480cd, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0x201480cd, 0x201480cd, 0x59c36f00, }, 20 },
+ { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1b2e61c9, 0xbf04e671, 0x1b2e61c9, 0x352be4b6, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x352be4b6, 0x352be4b6, 0xaa4593fe, }, 20 },
+ { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xefcce0d0, 0x5540bf08, 0xefcce0d0, 0xb2db8d54, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0xb2db8d54, 0xb2db8d54, 0xc9cbf769, }, 20 },
+ { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x65a5505e, 0xd6055969, 0x65a5505e, 0xcbf31986, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0xcbf31986, 0xcbf31986, 0x9813a416, }, 20 },
+ { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7319d06, 0x17c78667, 0x7319d06, 0x7197a8b5, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x7197a8b5, 0x7197a8b5, 0x5fcf013d, }, 20 },
+ { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x723a247, 0x535b0699, 0x723a247, 0x1c267840, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0x1c267840, 0x1c267840, 0xdd28f52b, }, 20 },
+ { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xe3a20cf8, 0x4833db45, 0xe3a20cf8, 0x1c1d1778, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x1c1d1778, 0x1c1d1778, 0x43d1f34, }, 20 },
+ { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24b38cd5, 0x6b033831, 0x24b38cd5, 0x67454192, 0x59c36f00, 0x59c36f00, 0xc12f3297, 0xc12f3297, 0xc12f3297, 0xbfaf5ff1, 0xbfaf5ff1, 0xbfaf5ff1, 0xdd594a23, 0xdd594a23, 0xdd594a23, 0x59c36f00, 0x67454192, 0x67454192, 0x59c36f00, }, 20 },
+ { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x54f09885, 0x5d94ace6, 0x54f09885, 0x7af51dfa, 0xaa4593fe, 0xaa4593fe, 0xe3a05427, 0xe3a05427, 0xe3a05427, 0x45555940, 0x45555940, 0x45555940, 0x686df238, 0x686df238, 0x686df238, 0xaa4593fe, 0x7af51dfa, 0x7af51dfa, 0xaa4593fe, }, 20 },
+ { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x53c2ee74, 0x92931869, 0x53c2ee74, 0xed583f0, 0xc9cbf769, 0xc9cbf769, 0x76afdc1b, 0x76afdc1b, 0x76afdc1b, 0x88771dd7, 0x88771dd7, 0x88771dd7, 0x613da2df, 0x613da2df, 0x613da2df, 0xc9cbf769, 0xed583f0, 0xed583f0, 0xc9cbf769, }, 20 },
+ { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4e5ded6f, 0x12bf47c3, 0x4e5ded6f, 0xe00ba4b7, 0x9813a416, 0x9813a416, 0x72c4cb9c, 0x72c4cb9c, 0x72c4cb9c, 0xe31f4daf, 0xe31f4daf, 0xe31f4daf, 0xfaa5707f, 0xfaa5707f, 0xfaa5707f, 0x9813a416, 0xe00ba4b7, 0xe00ba4b7, 0x9813a416, }, 20 },
+ { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x3566adf6, 0x4c7649cf, 0x3566adf6, 0x43c09845, 0x5fcf013d, 0x5fcf013d, 0xc2b479f, 0xc2b479f, 0xc2b479f, 0xde3b5fe9, 0xde3b5fe9, 0xde3b5fe9, 0xc8486076, 0xc8486076, 0xc8486076, 0x5fcf013d, 0x43c09845, 0x43c09845, 0x5fcf013d, }, 20 },
+ { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xec1bda0d, 0x86636a33, 0xec1bda0d, 0xf71e000a, 0xdd28f52b, 0xdd28f52b, 0xda5ce270, 0xda5ce270, 0xda5ce270, 0xfb601b94, 0xfb601b94, 0xfb601b94, 0x86d8d018, 0x86d8d018, 0x86d8d018, 0xdd28f52b, 0xf71e000a, 0xf71e000a, 0xdd28f52b, }, 20 },
+ { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x619415be, 0x92024b97, 0x619415be, 0x9e2b0e3e, 0x43d1f34, 0x43d1f34, 0xfa2f329, 0xfa2f329, 0xfa2f329, 0x70a85a81, 0x70a85a81, 0x70a85a81, 0xe9f95f07, 0xe9f95f07, 0xe9f95f07, 0x43d1f34, 0x9e2b0e3e, 0x9e2b0e3e, 0x43d1f34, }, 20 },
+ { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x200688e1, 0x1274a595, 0x200688e1, 0x63f045a6, 0x59c36f00, 0x59c36f00, 0x2312e40c, 0x2312e40c, 0x2312e40c, 0x5d92896a, 0x5d92896a, 0x5d92896a, 0x3f649cb8, 0x3f649cb8, 0x3f649cb8, 0x59c36f00, 0x63f045a6, 0x63f045a6, 0x59c36f00, }, 20 },
+ { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa943b821, 0x8aa682a4, 0xa943b821, 0x87463d5e, 0xaa4593fe, 0xaa4593fe, 0xff049fb7, 0xff049fb7, 0xff049fb7, 0x59f192d0, 0x59f192d0, 0x59f192d0, 0x74c939a8, 0x74c939a8, 0x74c939a8, 0xaa4593fe, 0x87463d5e, 0x87463d5e, 0xaa4593fe, }, 20 },
+ { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x11b6367b, 0x27bbcfb4, 0x11b6367b, 0x4ca15bff, 0xc9cbf769, 0xc9cbf769, 0x51f424d6, 0x51f424d6, 0x51f424d6, 0xaf2ce51a, 0xaf2ce51a, 0xaf2ce51a, 0x46665a12, 0x46665a12, 0x46665a12, 0xc9cbf769, 0x4ca15bff, 0x4ca15bff, 0xc9cbf769, }, 20 },
+ { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7c16ec93, 0xe9d7d93f, 0x7c16ec93, 0xd240a54b, 0x9813a416, 0x9813a416, 0x9e5c75d9, 0x9e5c75d9, 0x9e5c75d9, 0xf87f3ea, 0xf87f3ea, 0xf87f3ea, 0x163dce3a, 0x163dce3a, 0x163dce3a, 0x9813a416, 0xd240a54b, 0xd240a54b, 0x9813a416, }, 20 },
+ { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xe28608ec, 0x3575a25f, 0xe28608ec, 0x94203d5f, 0x5fcf013d, 0x5fcf013d, 0x7c6f7c86, 0x7c6f7c86, 0x7c6f7c86, 0xae7f64f0, 0xae7f64f0, 0xae7f64f0, 0xb80c5b6f, 0xb80c5b6f, 0xb80c5b6f, 0x5fcf013d, 0x94203d5f, 0x94203d5f, 0x5fcf013d, }, 20 },
+ { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xb510e48, 0x9406b857, 0xb510e48, 0x1054d44f, 0xdd28f52b, 0xdd28f52b, 0x13c76182, 0x13c76182, 0x13c76182, 0x32fb9866, 0x32fb9866, 0x32fb9866, 0x4f4353ea, 0x4f4353ea, 0x4f4353ea, 0xdd28f52b, 0x1054d44f, 0x1054d44f, 0xdd28f52b, }, 20 },
+ { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf256eb36, 0xaed7d845, 0xf256eb36, 0xde9f0b6, 0x43d1f34, 0x43d1f34, 0xbe644e0c, 0xbe644e0c, 0xbe644e0c, 0xc16ee7a4, 0xc16ee7a4, 0xc16ee7a4, 0x583fe222, 0x583fe222, 0x583fe222, 0x43d1f34, 0xde9f0b6, 0xde9f0b6, 0x43d1f34, }, 20 },
+ { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe382dd9, 0x68f7c15a, 0xe382dd9, 0x59159307, 0x59c36f00, 0x59c36f00, 0xba01eaa9, 0xba01eaa9, 0xba01eaa9, 0xc48187cf, 0xc48187cf, 0xc48187cf, 0xa677921d, 0xa677921d, 0xa677921d, 0x59c36f00, 0x59159307, 0x59159307, 0x59c36f00, }, 20 },
+ { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3c908c, 0xa4161734, 0x3c908c, 0xb09b4ada, 0xaa4593fe, 0xaa4593fe, 0xdfbf1f3, 0xdfbf1f3, 0xdfbf1f3, 0xab0efc94, 0xab0efc94, 0xab0efc94, 0x863657ec, 0x863657ec, 0x863657ec, 0xaa4593fe, 0xb09b4ada, 0xb09b4ada, 0xaa4593fe, }, 20 },
+ { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd2e9527, 0xb7a2caff, 0xd2e9527, 0x1d0b8b89, 0xc9cbf769, 0xc9cbf769, 0x6684aa7f, 0x6684aa7f, 0x6684aa7f, 0x985c6bb3, 0x985c6bb3, 0x985c6bb3, 0x7116d4bb, 0x7116d4bb, 0x7116d4bb, 0xc9cbf769, 0x1d0b8b89, 0x1d0b8b89, 0xc9cbf769, }, 20 },
+ { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1639705d, 0xa599796a, 0x1639705d, 0x26488c72, 0x9813a416, 0x9813a416, 0x49b2de5c, 0x49b2de5c, 0x49b2de5c, 0xd869586f, 0xd869586f, 0xd869586f, 0xc1d365bf, 0xc1d365bf, 0xc1d365bf, 0x9813a416, 0x26488c72, 0x26488c72, 0x9813a416, }, 20 },
+ { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x10d0c422, 0x26df43, 0x10d0c422, 0xbed72bd7, 0x5fcf013d, 0x5fcf013d, 0x67d73911, 0x67d73911, 0x67d73911, 0xb5c72167, 0xb5c72167, 0xb5c72167, 0xa3b41ef8, 0xa3b41ef8, 0xa3b41ef8, 0x5fcf013d, 0xbed72bd7, 0xbed72bd7, 0x5fcf013d, }, 20 },
+ { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdd34e67a, 0x894c42a4, 0xdd34e67a, 0x53502da0, 0xdd28f52b, 0xdd28f52b, 0x886a111, 0x886a111, 0x886a111, 0x29ba58f5, 0x29ba58f5, 0x29ba58f5, 0x54029379, 0x54029379, 0x54029379, 0xdd28f52b, 0x53502da0, 0x53502da0, 0xdd28f52b, }, 20 },
+ { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x410b50fc, 0xea9a8741, 0x410b50fc, 0xd653d65c, 0x43d1f34, 0x43d1f34, 0xcdea4de5, 0xcdea4de5, 0xcdea4de5, 0xb2e0e44d, 0xb2e0e44d, 0xb2e0e44d, 0x2bb1e1cb, 0x2bb1e1cb, 0x2bb1e1cb, 0x43d1f34, 0xd653d65c, 0xd653d65c, 0x43d1f34, }, 20 },
+ { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4c09d761, 0x2ac63be2, 0x4c09d761, 0xf44378ab, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0xf44378ab, 0xf44378ab, 0x59c36f00, }, 20 },
+ { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd3c0fce6, 0x77ea7b5e, 0xd3c0fce6, 0x10463469, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x10463469, 0x10463469, 0xaa4593fe, }, 20 },
+ { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xabafd82f, 0x112387f7, 0xabafd82f, 0xe9ca2412, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0xe9ca2412, 0xe9ca2412, 0xc9cbf769, }, 20 },
+ { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2b138245, 0x98b38b72, 0x2b138245, 0x6500200c, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0x6500200c, 0x6500200c, 0x9813a416, }, 20 },
+ { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x87f97368, 0x970f6809, 0x87f97368, 0x149f7c5f, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x149f7c5f, 0x149f7c5f, 0x5fcf013d, }, 20 },
+ { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x12986e14, 0x46e0caca, 0x12986e14, 0xf51eaa4a, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0xf51eaa4a, 0xf51eaa4a, 0xdd28f52b, }, 20 },
+ { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf6aab2f6, 0x5d3b654b, 0xf6aab2f6, 0x8e22ec59, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x8e22ec59, 0x8e22ec59, 0x43d1f34, }, 20 },
+ { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 },
+ { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 },
+ { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x4c2cef83, 0x1b215a88, 0xe2378595, 0xb53a309e, 0x15f64d5e, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x758f388c, 0xd4442397, 0x33f5784b, 0x923e6350, 0xf97bb902, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xb9f6f52a, 0x4e24e8b7, 0x53beb8e1, 0xa46ca57c, 0x688a184d, }, 5 },
+ { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x5bd98ce3, 0x15df7962, 0xc7d467e1, 0x89d29260, 0x662e2c16, }, 5 },
+ { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, }, 5 },
+ { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, }, 5 },
+ { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x335fadcb, 0x1f517b5c, 0x6b4200e5, 0x474cd672, 0x8364f797, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0xcf9985f8, 0x1d92c7fc, 0x6e637701, 0xbc683505, 0x898016fb, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0xdb824190, 0x378d05dc, 0x670bff9, 0xea7ffbb5, 0x658bcbb3, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x157232bd, 0x5e6bdacd, 0x8341e25d, 0xc8580a2d, 0x3cf9e58c, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0xbfafd7cd, 0x51650951, 0x67d61c04, 0x891cc298, 0xab036ae, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x760580c9, 0xdc6d8205, 0x2739f3a0, 0x8d51f16c, 0xd47d661b, }, 5 },
+ { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0xada3b5f, 0x24cd61a6, 0x56f48ead, 0x78e3d454, 0xb28750bb, }, 5 },
+ { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x827694e2, 0x9d97c3dd, 0xbdb43a9c, 0xa2556da3, 0xfdf3c81e, }, 5 },
+ { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0x664534a5, 0xcd0979a0, 0x3531d85e, 0x9e7d955b, 0xc0aced53, }, 5 },
diff --git a/grub-core/tests/cmdline_cat_test.c b/grub-core/tests/cmdline_cat_test.c
index c3de5c464..f1e21439e 100644
--- a/grub-core/tests/cmdline_cat_test.c
+++ b/grub-core/tests/cmdline_cat_test.c
@@ -109,7 +109,7 @@ cmdline_cat_test (void)
grub_video_checksum ("cmdline_cat");
if (!grub_test_use_gfxterm ())
- grub_cmdline_run (1);
+ grub_cmdline_run (1, 0);
grub_test_use_gfxterm_end ();
diff --git a/grub-core/tests/cmp_test.c b/grub-core/tests/cmp_test.c
new file mode 100644
index 000000000..af5b39576
--- /dev/null
+++ b/grub-core/tests/cmp_test.c
@@ -0,0 +1,190 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2015 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/test.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_uint64_t vectors[][2] = {
+ { 0xffffffffffffffffULL, 1},
+ { 1, 0xffffffffffffffffULL},
+ { 0xffffffffffffffffULL, 0xffffffffffffffffULL},
+ { 1, 1 },
+ { 2, 1 }
+};
+
+/* Don't change those to use shift as shift may call to compile rt
+ functions and we're not testing them now.
+ */
+static int
+leading_bit64 (grub_uint64_t a)
+{
+ return !!(a & 0x8000000000000000LL);
+}
+
+static int
+leading_bit32 (grub_uint32_t a)
+{
+ return !!(a & 0x80000000);
+}
+
+/* Computes (a < b) without involving comparison operator. */
+static int
+is_less32 (grub_uint32_t a, grub_uint32_t b)
+{
+ if (leading_bit32(a) && !leading_bit32(b))
+ return 0;
+ if (!leading_bit32(a) && leading_bit32(b))
+ return 1;
+ return leading_bit32(a - b);
+}
+
+static void
+test32 (grub_uint32_t a, grub_uint32_t b)
+{
+ grub_test_assert ((a < b) == is_less32(a, b), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert ((a > b) == is_less32(b, a), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert ((b < a) == is_less32(b, a), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert ((b > a) == is_less32(a, b), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert (!(is_less32(a, b) && is_less32(b, a)), "comparison inconsistent: %lld, %lld",
+ (long long) a, (long long) b);
+}
+
+/* Computes (a > b) without involving comparison operator. */
+static int
+is_less32s (grub_int32_t a, grub_int32_t b)
+{
+ if (leading_bit32(a) && !leading_bit32(b))
+ return 1; /* a < 0 && b >= 0. */
+ if (!leading_bit32(a) && leading_bit32(b))
+ return 0; /* b < 0 && a >= 0. */
+ return leading_bit32(a - b);
+}
+
+static void
+test32s (grub_int32_t a, grub_int32_t b)
+{
+ grub_test_assert ((a < b) == is_less32s(a, b), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert ((a > b) == is_less32s(b, a), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert ((b < a) == is_less32s(b, a), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert ((b > a) == is_less32s(a, b), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert (!(is_less32s(a, b) && is_less32s(b, a)), "comparison inconsistent: %lld, %lld",
+ (long long) a, (long long) b);
+}
+
+/* Computes (a > b) without involving comparison operator. */
+static int
+is_less64 (grub_uint64_t a, grub_uint64_t b)
+{
+ if (leading_bit64(a) && !leading_bit64(b))
+ return 0;
+ if (!leading_bit64(a) && leading_bit64(b))
+ return 1;
+ return leading_bit64(a - b);
+}
+
+static void
+test64 (grub_uint64_t a, grub_uint64_t b)
+{
+ grub_test_assert ((a < b) == is_less64(a, b), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert ((a > b) == is_less64(b, a), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert ((b < a) == is_less64(b, a), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert ((b > a) == is_less64(a, b), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert (!(is_less64(a, b) && is_less64(b, a)), "comparison inconsistent: %lld, %lld",
+ (long long) a, (long long) b);
+}
+
+/* Computes (a > b) without involving comparison operator. */
+static int
+is_less64s (grub_int64_t a, grub_int64_t b)
+{
+ if (leading_bit64(a) && !leading_bit64(b))
+ return 1; /* a < 0 && b >= 0. */
+ if (!leading_bit64(a) && leading_bit64(b))
+ return 0; /* b < 0 && a >= 0. */
+ return leading_bit64(a - b);
+}
+
+static void
+test64s (grub_int64_t a, grub_int64_t b)
+{
+ grub_test_assert ((a < b) == is_less64s(a, b), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert ((a > b) == is_less64s(b, a), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert ((b < a) == is_less64s(b, a), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert ((b > a) == is_less64s(a, b), "comparison result mismatch: %lld, %lld",
+ (long long) a, (long long) b);
+ grub_test_assert (!(is_less64s(a, b) && is_less64s(b, a)), "comparison inconsistent: %lld, %lld",
+ (long long) a, (long long) b);
+}
+
+static void
+test_all(grub_uint64_t a, grub_uint64_t b)
+{
+ test64 (a, b);
+ test32 (a, b);
+ test64s (a, b);
+ test32s (a, b);
+ test64s (a, -b);
+ test32s (a, -b);
+ test64s (-a, b);
+ test32s (-a, b);
+ test64s (-a, -b);
+ test32s (-a, -b);
+}
+
+static void
+cmp_test (void)
+{
+ grub_uint64_t a = 404, b = 7;
+ grub_size_t i;
+
+ for (i = 0; i < ARRAY_SIZE (vectors); i++)
+ {
+ test_all (vectors[i][0], vectors[i][1]);
+ }
+ for (i = 0; i < 40000; i++)
+ {
+ a = 17 * a + 13 * b;
+ b = 23 * a + 29 * b;
+ if (b == 0)
+ b = 1;
+ if (a == 0)
+ a = 1;
+ test_all (a, b);
+ }
+}
+
+/* Register example_test method as a functional test. */
+GRUB_FUNCTIONAL_TEST (cmp_test, cmp_test);
diff --git a/grub-core/tests/ctz_test.c b/grub-core/tests/ctz_test.c
new file mode 100644
index 000000000..eb7a1df38
--- /dev/null
+++ b/grub-core/tests/ctz_test.c
@@ -0,0 +1,111 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2013 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/test.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+/* ull version is not used on i386 other than in this test.
+ Avoid requiring extra function.
+ */
+#if defined (__i386__)
+#define SKIP_ULL 1
+#endif
+
+static grub_uint64_t vectors[] = {
+ 0xffffffffffffffffULL, 1, 2, 0, 0x0102030405060708ULL
+};
+
+static void
+test_ui (unsigned int a)
+{
+ int i;
+ a |= 1;
+ for (i = 0; i < (int) (8 * sizeof (a)); i++)
+ {
+ grub_test_assert (__builtin_ctz(a << i) == i,
+ "ctz mismatch: ctz(0x%llx) != 0x%x",
+ (long long) (a << i), __builtin_ctz(a << i));
+ }
+}
+
+static void
+test_ul (unsigned long a)
+{
+ int i;
+ a |= 1;
+ for (i = 0; i < (int) (8 * sizeof (a)); i++)
+ {
+ grub_test_assert (__builtin_ctzl(a << i) == i,
+ "ctzl mismatch: ctzl(0x%llx) != 0x%x",
+ (long long) (a << i), __builtin_ctz(a << i));
+ }
+}
+
+#ifndef SKIP_ULL
+static void
+test_ull (unsigned long long a)
+{
+ int i;
+ a |= 1;
+ for (i = 0; i < (int) (8 * sizeof (a)); i++)
+ {
+ grub_test_assert (__builtin_ctzll(a << i) == i,
+ "ctzll mismatch: ctzll(0x%llx) != 0x%x",
+ (long long) (a << i), __builtin_ctz(a << i));
+ }
+}
+#endif
+
+static void
+test_all(grub_uint64_t a)
+{
+ test_ui (a);
+ test_ul (a);
+#ifndef SKIP_ULL
+ test_ull (a);
+#endif
+}
+
+static void
+ctz_test (void)
+{
+ grub_uint64_t a = 404, b = 7;
+ grub_size_t i;
+
+ for (i = 0; i < ARRAY_SIZE (vectors); i++)
+ {
+ test_all (vectors[i]);
+ }
+ for (i = 0; i < 40000; i++)
+ {
+ a = 17 * a + 13 * b;
+ b = 23 * a + 29 * b;
+ if (b == 0)
+ b = 1;
+ if (a == 0)
+ a = 1;
+ test_all (a);
+ test_all (b);
+ }
+}
+
+/* Register example_test method as a functional test. */
+GRUB_FUNCTIONAL_TEST (ctz_test, ctz_test);
diff --git a/grub-core/tests/div_test.c b/grub-core/tests/div_test.c
index 1928f8507..9abc6d5c4 100644
--- a/grub-core/tests/div_test.c
+++ b/grub-core/tests/div_test.c
@@ -34,6 +34,8 @@ static void
test32 (grub_uint32_t a, grub_uint32_t b)
{
grub_uint64_t q, r;
+ if (b == 0)
+ return;
q = grub_divmod64 (a, b, &r);
grub_test_assert (r < b, "remainder is larger than dividend: 0x%llx %% 0x%llx = 0x%llx",
(long long) a, (long long) b, (long long) r);
@@ -95,6 +97,72 @@ test64 (grub_uint64_t a, grub_uint64_t b)
#endif
}
+static grub_int64_t
+abs64(grub_int64_t a)
+{
+ return a > 0 ? a : -a;
+}
+
+static void
+test32s (grub_int32_t a, grub_int32_t b)
+{
+ grub_int64_t q, r;
+ if (b == 0)
+ return;
+
+ q = grub_divmod64s (a, b, &r);
+ grub_test_assert (a > 0 ? r >= 0 : r <= 0, "remainder sign mismatch: %lld %% %lld = %lld",
+ (long long) a, (long long) b, (long long) r);
+ grub_test_assert (((a > 0) == (b > 0)) ? q >= 0 : q <= 0, "quotient sign mismatch: %lld / %lld = %lld",
+ (long long) a, (long long) b, (long long) q);
+ grub_test_assert (abs64(r) < abs64(b), "remainder is larger than dividend: %lld %% %lld = %lld",
+ (long long) a, (long long) b, (long long) r);
+ grub_test_assert (q * b + r == a, "division doesn't satisfy base property: %lld * %lld + %lld != %lld", (long long) q, (long long) b, (long long) r,
+ (long long) a);
+ if (0) { grub_test_assert (q == (a / b),
+ "C compiler division failure in 0x%llx, 0x%llx", (long long) a, (long long) b);
+ grub_test_assert (r == (a % b),
+ "C compiler modulo failure in 0x%llx, 0x%llx", (long long) a, (long long) b);
+ }
+}
+
+static void
+test64s (grub_int64_t a, grub_int64_t b)
+{
+ grub_int64_t q, r;
+ q = grub_divmod64s (a, b, &r);
+
+ grub_test_assert (a > 0 ? r >= 0 : r <= 0, "remainder sign mismatch: %lld %% %lld = %lld",
+ (long long) a, (long long) b, (long long) r);
+ grub_test_assert (((a > 0) == (b > 0)) ? q >= 0 : q <= 0, "quotient sign mismatch: %lld / %lld = %lld",
+ (long long) a, (long long) b, (long long) q);
+ grub_test_assert (abs64(r) < abs64(b), "remainder is larger than dividend: %lld %% %lld = %lld",
+ (long long) a, (long long) b, (long long) r);
+ grub_test_assert (q * b + r == a, "division doesn't satisfy base property: 0x%llx * 0x%llx + 0x%llx != 0x%llx", (long long) q, (long long) b, (long long) r,
+ (long long) a);
+#if GRUB_TARGET_SIZEOF_VOID_P == 8
+ grub_test_assert (q == (a / b),
+ "C compiler division failure in 0x%llx, 0x%llx", (long long) a, (long long) b);
+ grub_test_assert (r == (a % b),
+ "C compiler modulo failure in 0x%llx, 0x%llx", (long long) a, (long long) b);
+#endif
+}
+
+static void
+test_all(grub_uint64_t a, grub_uint64_t b)
+{
+ test64 (a, b);
+ test32 (a, b);
+ test64s (a, b);
+ test32s (a, b);
+ test64s (a, -b);
+ test32s (a, -b);
+ test64s (-a, b);
+ test32s (-a, b);
+ test64s (-a, -b);
+ test32s (-a, -b);
+}
+
static void
div_test (void)
{
@@ -103,8 +171,7 @@ div_test (void)
for (i = 0; i < ARRAY_SIZE (vectors); i++)
{
- test64 (vectors[i][0], vectors[i][1]);
- test32 (vectors[i][0], vectors[i][1]);
+ test_all (vectors[i][0], vectors[i][1]);
}
for (i = 0; i < 40000; i++)
{
@@ -114,9 +181,7 @@ div_test (void)
b = 1;
if (a == 0)
a = 1;
- test64 (a, b);
- test32 (a, b);
-
+ test_all (a, b);
}
}
diff --git a/grub-core/tests/lib/functional_test.c b/grub-core/tests/lib/functional_test.c
index 5be7a58e5..d4822a124 100644
--- a/grub-core/tests/lib/functional_test.c
+++ b/grub-core/tests/lib/functional_test.c
@@ -65,6 +65,11 @@ grub_functional_all_tests (grub_extcmd_context_t ctxt __attribute__ ((unused)),
grub_dl_load ("pbkdf2_test");
grub_dl_load ("signature_test");
grub_dl_load ("sleep_test");
+ grub_dl_load ("bswap_test");
+ grub_dl_load ("ctz_test");
+ grub_dl_load ("cmp_test");
+ grub_dl_load ("mul_test");
+ grub_dl_load ("shift_test");
FOR_LIST_ELEMENTS (test, grub_test_list)
ok = !grub_test_run (test) && ok;
diff --git a/grub-core/tests/mul_test.c b/grub-core/tests/mul_test.c
new file mode 100644
index 000000000..cd6423192
--- /dev/null
+++ b/grub-core/tests/mul_test.c
@@ -0,0 +1,73 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2013 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/test.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_uint64_t vectors[][2] = {
+ { 0xffffffffffffffffULL, 1},
+ { 1, 0xffffffffffffffffULL},
+ { 0xffffffffffffffffULL, 0xffffffffffffffffULL},
+ { 1, 1 },
+ { 2, 1 }
+};
+
+static void
+test64(grub_uint64_t a, grub_uint64_t b)
+{
+ grub_uint64_t r1 = a * b, r2 = 0, r3;
+ int i;
+ for (i = 0; i < 64; i++)
+ if ((a & (1LL << i)))
+ r2 += b << i;
+ r3 = ((grub_int64_t) a) * ((grub_int64_t) b);
+ grub_test_assert (r1 == r2,
+ "multiplication mismatch (u): 0x%llx x 0x%llx = 0x%llx != 0x%llx",
+ (long long) a, (long long) b, (long long) r2, (long long) r1);
+ grub_test_assert (r3 == r2,
+ "multiplication mismatch (s): 0x%llx x 0x%llx = 0x%llx != 0x%llx",
+ (long long) a, (long long) b, (long long) r2, (long long) r3);
+}
+
+static void
+mul_test (void)
+{
+ grub_uint64_t a = 404, b = 7;
+ grub_size_t i;
+
+ for (i = 0; i < ARRAY_SIZE (vectors); i++)
+ {
+ test64 (vectors[i][0], vectors[i][1]);
+ }
+ for (i = 0; i < 40000; i++)
+ {
+ a = 17 * a + 13 * b;
+ b = 23 * a + 29 * b;
+ if (b == 0)
+ b = 1;
+ if (a == 0)
+ a = 1;
+ test64 (a, b);
+ }
+}
+
+/* Register example_test method as a functional test. */
+GRUB_FUNCTIONAL_TEST (mul_test, mul_test);
diff --git a/grub-core/tests/shift_test.c b/grub-core/tests/shift_test.c
new file mode 100644
index 000000000..4120f520a
--- /dev/null
+++ b/grub-core/tests/shift_test.c
@@ -0,0 +1,157 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2015 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/test.h>
+#include <grub/dl.h>
+#include <grub/misc.h>
+
+GRUB_MOD_LICENSE ("GPLv3+");
+
+static grub_uint64_t vectors[] = {
+ 0xffffffffffffffffULL, 1, 2, 0, 0x0102030405060708ULL
+};
+
+/* We're testing shifts, don't replace access to this with a shift. */
+static const grub_uint8_t bitmask[] =
+ { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
+
+typedef union {
+ grub_uint64_t v64;
+ grub_uint8_t v8[8];
+} grub_raw_u64_t;
+
+static int
+get_bit64 (grub_uint64_t v, int b)
+{
+ grub_raw_u64_t vr = { .v64 = v };
+ grub_uint8_t *p = vr.v8;
+ if (b >= 64)
+ return 0;
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ p += 7 - b / 8;
+#else
+ p += b / 8;
+#endif
+ return !!(*p & bitmask[b % 8]);
+}
+
+static grub_uint64_t
+set_bit64 (grub_uint64_t v, int b)
+{
+ grub_raw_u64_t vr = { .v64 = v };
+ grub_uint8_t *p = vr.v8;
+ if (b >= 64)
+ return v;
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
+ p += 7 - b / 8;
+#else
+ p += b / 8;
+#endif
+ *p |= bitmask[b % 8];
+ return vr.v64;
+}
+
+static grub_uint64_t
+left_shift64 (grub_uint64_t v, int s)
+{
+ grub_uint64_t r = 0;
+ int i;
+ for (i = 0; i + s < 64; i++)
+ if (get_bit64 (v, i))
+ r = set_bit64 (r, i + s);
+ return r;
+}
+
+static grub_uint64_t
+right_shift64 (grub_uint64_t v, int s)
+{
+ grub_uint64_t r = 0;
+ int i;
+ for (i = s; i < 64; i++)
+ if (get_bit64 (v, i))
+ r = set_bit64 (r, i - s);
+ return r;
+}
+
+static grub_uint64_t
+arithmetic_right_shift64 (grub_uint64_t v, int s)
+{
+ grub_uint64_t r = 0;
+ int i;
+ for (i = s; i < 64; i++)
+ if (get_bit64 (v, i))
+ r = set_bit64 (r, i - s);
+ if (get_bit64 (v, 63))
+ for (i -= s; i < 64; i++)
+ r = set_bit64 (r, i);
+
+ return r;
+}
+
+static void
+test64 (grub_uint64_t v)
+{
+ int i;
+ for (i = 0; i < 64; i++)
+ {
+ grub_test_assert ((v << i) == left_shift64 (v, i),
+ "lshift wrong: 0x%llx << %d: 0x%llx, 0x%llx",
+ (long long) v, i,
+ (long long) (v << i), (long long) left_shift64 (v, i));
+ grub_test_assert ((v >> i) == right_shift64 (v, i),
+ "rshift wrong: 0x%llx >> %d: 0x%llx, 0x%llx",
+ (long long) v, i,
+ (long long) (v >> i), (long long) right_shift64 (v, i));
+ grub_test_assert ((((grub_int64_t) v) >> i) == (grub_int64_t) arithmetic_right_shift64 (v, i),
+ "arithmetic rshift wrong: ((grub_int64_t) 0x%llx) >> %d: 0x%llx, 0x%llx",
+ (long long) v, i,
+ (long long) (((grub_int64_t) v) >> i), (long long) arithmetic_right_shift64 (v, i));
+ }
+}
+
+static void
+test_all(grub_uint64_t a)
+{
+ test64 (a);
+}
+
+static void
+shift_test (void)
+{
+ grub_uint64_t a = 404, b = 7;
+ grub_size_t i;
+
+ for (i = 0; i < ARRAY_SIZE (vectors); i++)
+ {
+ test_all (vectors[i]);
+ }
+ for (i = 0; i < 4000; i++)
+ {
+ a = 17 * a + 13 * b;
+ b = 23 * a + 29 * b;
+ if (b == 0)
+ b = 1;
+ if (a == 0)
+ a = 1;
+ test_all (a);
+ test_all (b);
+ }
+}
+
+/* Register example_test method as a functional test. */
+GRUB_FUNCTIONAL_TEST (shift_test, shift_test);
diff --git a/grub-core/tests/sleep_test.c b/grub-core/tests/sleep_test.c
index 3dda30312..3d11c717c 100644
--- a/grub-core/tests/sleep_test.c
+++ b/grub-core/tests/sleep_test.c
@@ -33,12 +33,19 @@ sleep_test (void)
{
struct grub_datetime st, en;
grub_int32_t stu = 0, enu = 0;
+ int is_delayok;
grub_test_assert (!grub_get_datetime (&st), "Couldn't retrieve start time");
grub_millisleep (10000);
grub_test_assert (!grub_get_datetime (&en), "Couldn't retrieve end time");
grub_test_assert (grub_datetime2unixtime (&st, &stu), "Invalid date");
grub_test_assert (grub_datetime2unixtime (&en, &enu), "Invalid date");
- grub_test_assert (enu - stu >= 9 && enu - stu <= 11, "Interval out of range: %d", enu-stu);
+ is_delayok = (enu - stu >= 9 && enu - stu <= 11);
+#ifdef __arm__
+ /* Ignore QEMU bug */
+ if (enu - stu >= 15 && enu - stu <= 17)
+ is_delayok = 1;
+#endif
+ grub_test_assert (is_delayok, "Interval out of range: %d", enu-stu);
}
diff --git a/grub-core/tests/video_checksum.c b/grub-core/tests/video_checksum.c
index 491bc5573..74d5b65e5 100644
--- a/grub-core/tests/video_checksum.c
+++ b/grub-core/tests/video_checksum.c
@@ -288,16 +288,16 @@ grub_video_capture_write_bmp (const char *fname,
if (mode_info->mode_type & GRUB_VIDEO_MODE_TYPE_RGB)
{
head.filesize = grub_cpu_to_le32 (sizeof (head) + mode_info->width * mode_info->height * 3);
- head.bmp_off = grub_cpu_to_le32 (sizeof (head));
+ head.bmp_off = grub_cpu_to_le32_compile_time (sizeof (head));
head.bpp = grub_cpu_to_le16_compile_time (24);
}
else
{
head.filesize = grub_cpu_to_le32 (sizeof (head) + 3 * 256 + mode_info->width * mode_info->height);
- head.bmp_off = grub_cpu_to_le32 (sizeof (head) + 3 * 256);
+ head.bmp_off = grub_cpu_to_le32_compile_time (sizeof (head) + 3 * 256);
head.bpp = grub_cpu_to_le16_compile_time (8);
}
- head.head_size = grub_cpu_to_le32 (sizeof (head) - 14);
+ head.head_size = grub_cpu_to_le32_compile_time (sizeof (head) - 14);
head.width = grub_cpu_to_le16 (mode_info->width);
head.height = grub_cpu_to_le16 (mode_info->height);
head.planes = grub_cpu_to_le16_compile_time (1);
diff --git a/grub-core/video/bitmap_scale.c b/grub-core/video/bitmap_scale.c
index 0b93d0206..70c32f029 100644
--- a/grub-core/video/bitmap_scale.c
+++ b/grub-core/video/bitmap_scale.c
@@ -361,35 +361,46 @@ scale_nn (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
unsigned dh = dst->mode_info.height;
unsigned sw = src->mode_info.width;
unsigned sh = src->mode_info.height;
- unsigned dstride = dst->mode_info.pitch;
- unsigned sstride = src->mode_info.pitch;
+ int dstride = dst->mode_info.pitch;
+ int sstride = src->mode_info.pitch;
/* bytes_per_pixel is the same for both src and dst. */
- unsigned bytes_per_pixel = dst->mode_info.bytes_per_pixel;
+ int bytes_per_pixel = dst->mode_info.bytes_per_pixel;
+ unsigned dy, sy, ystep, yfrac, yover;
+ unsigned sx, xstep, xfrac, xover;
+ grub_uint8_t *dptr, *dline_end, *sline;
- unsigned dy;
- for (dy = 0; dy < dh; dy++)
+ xstep = sw / dw;
+ xover = sw % dw;
+ ystep = sh / dh;
+ yover = sh % dh;
+
+ for (dy = 0, sy = 0, yfrac = 0; dy < dh; dy++, sy += ystep, yfrac += yover)
{
- unsigned dx;
- for (dx = 0; dx < dw; dx++)
+ if (yfrac >= dh)
+ {
+ yfrac -= dh;
+ sy++;
+ }
+ dptr = ddata + dy * dstride;
+ dline_end = dptr + dw * bytes_per_pixel;
+ sline = sdata + sy * sstride;
+ for (sx = 0, xfrac = 0; dptr < dline_end; sx += xstep, xfrac += xover, dptr += bytes_per_pixel)
{
- grub_uint8_t *dptr;
grub_uint8_t *sptr;
- unsigned sx;
- unsigned sy;
- unsigned comp;
+ int comp;
- /* Compute the source coordinate that the destination coordinate
- maps to. Note: sx/sw = dx/dw => sx = sw*dx/dw. */
- sx = sw * dx / dw;
- sy = sh * dy / dh;
+ if (xfrac >= dw)
+ {
+ xfrac -= dw;
+ sx++;
+ }
/* Get the address of the pixels in src and dst. */
- dptr = ddata + dy * dstride + dx * bytes_per_pixel;
- sptr = sdata + sy * sstride + sx * bytes_per_pixel;
+ sptr = sline + sx * bytes_per_pixel;
- /* Copy the pixel color value. */
- for (comp = 0; comp < bytes_per_pixel; comp++)
- dptr[comp] = sptr[comp];
+ /* Copy the pixel color value. */
+ for (comp = 0; comp < bytes_per_pixel; comp++)
+ dptr[comp] = sptr[comp];
}
}
return GRUB_ERR_NONE;
@@ -422,27 +433,40 @@ scale_bilinear (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
int sstride = src->mode_info.pitch;
/* bytes_per_pixel is the same for both src and dst. */
int bytes_per_pixel = dst->mode_info.bytes_per_pixel;
+ unsigned dy, syf, sy, ystep, yfrac, yover;
+ unsigned sxf, sx, xstep, xfrac, xover;
+ grub_uint8_t *dptr, *dline_end, *sline;
+
+ xstep = (sw << 8) / dw;
+ xover = (sw << 8) % dw;
+ ystep = (sh << 8) / dh;
+ yover = (sh << 8) % dh;
- unsigned dy;
- for (dy = 0; dy < dh; dy++)
+ for (dy = 0, syf = 0, yfrac = 0; dy < dh; dy++, syf += ystep, yfrac += yover)
{
- unsigned dx;
- for (dx = 0; dx < dw; dx++)
+ if (yfrac >= dh)
+ {
+ yfrac -= dh;
+ syf++;
+ }
+ sy = syf >> 8;
+ dptr = ddata + dy * dstride;
+ dline_end = dptr + dw * bytes_per_pixel;
+ sline = sdata + sy * sstride;
+ for (sxf = 0, xfrac = 0; dptr < dline_end; sxf += xstep, xfrac += xover, dptr += bytes_per_pixel)
{
- grub_uint8_t *dptr;
grub_uint8_t *sptr;
- unsigned sx;
- unsigned sy;
int comp;
- /* Compute the source coordinate that the destination coordinate
- maps to. Note: sx/sw = dx/dw => sx = sw*dx/dw. */
- sx = sw * dx / dw;
- sy = sh * dy / dh;
+ if (xfrac >= dw)
+ {
+ xfrac -= dw;
+ sxf++;
+ }
/* Get the address of the pixels in src and dst. */
- dptr = ddata + dy * dstride + dx * bytes_per_pixel;
- sptr = sdata + sy * sstride + sx * bytes_per_pixel;
+ sx = sxf >> 8;
+ sptr = sline + sx * bytes_per_pixel;
/* If we have enough space to do so, use bilinear interpolation.
Otherwise, fall back to nearest neighbor for this pixel. */
@@ -453,27 +477,27 @@ scale_bilinear (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
/* Fixed-point .8 numbers representing the fraction of the
distance in the x (u) and y (v) direction within the
box of 4 pixels in the source. */
- int u = (256 * sw * dx / dw) - (sx * 256);
- int v = (256 * sh * dy / dh) - (sy * 256);
+ unsigned u = sxf & 0xff;
+ unsigned v = syf & 0xff;
for (comp = 0; comp < bytes_per_pixel; comp++)
{
/* Get the component's values for the
four source corner pixels. */
- int f00 = sptr[comp];
- int f10 = sptr[comp + bytes_per_pixel];
- int f01 = sptr[comp + sstride];
- int f11 = sptr[comp + sstride + bytes_per_pixel];
+ unsigned f00 = sptr[comp];
+ unsigned f10 = sptr[comp + bytes_per_pixel];
+ unsigned f01 = sptr[comp + sstride];
+ unsigned f11 = sptr[comp + sstride + bytes_per_pixel];
/* Count coeffecients. */
- int c00 = (256 - u) * (256 - v);
- int c10 = u * (256 - v);
- int c01 = (256 - u) * v;
- int c11 = u * v;
+ unsigned c00 = (256 - u) * (256 - v);
+ unsigned c10 = u * (256 - v);
+ unsigned c01 = (256 - u) * v;
+ unsigned c11 = u * v;
/* Interpolate. */
- int fxy = c00 * f00 + c01 * f01 + c10 * f10 + c11 * f11;
- fxy = fxy / (256 * 256);
+ unsigned fxy = c00 * f00 + c01 * f01 + c10 * f10 + c11 * f11;
+ fxy = fxy >> 16;
dptr[comp] = fxy;
}
diff --git a/grub-core/video/bochs.c b/grub-core/video/bochs.c
index 9098f90d1..3bcfa53a9 100644
--- a/grub-core/video/bochs.c
+++ b/grub-core/video/bochs.c
@@ -359,6 +359,7 @@ grub_video_bochs_setup (unsigned int width, unsigned int height,
case 32:
framebuffer.mode_info.reserved_mask_size = 8;
framebuffer.mode_info.reserved_field_pos = 24;
+ /* Fallthrough. */
case 24:
framebuffer.mode_info.red_mask_size = 8;
diff --git a/grub-core/video/capture.c b/grub-core/video/capture.c
index 67c8edde8..4f83c7441 100644
--- a/grub-core/video/capture.c
+++ b/grub-core/video/capture.c
@@ -4,6 +4,7 @@
#include <grub/video.h>
#include <grub/video_fb.h>
#include <grub/mm.h>
+#include <grub/misc.h>
static struct
{
diff --git a/grub-core/video/cirrus.c b/grub-core/video/cirrus.c
index 4913084fa..e2149e8ce 100644
--- a/grub-core/video/cirrus.c
+++ b/grub-core/video/cirrus.c
@@ -440,6 +440,7 @@ grub_video_cirrus_setup (unsigned int width, unsigned int height,
case 32:
framebuffer.mode_info.reserved_mask_size = 8;
framebuffer.mode_info.reserved_field_pos = 24;
+ /* Fallthrough. */
case 24:
framebuffer.mode_info.red_mask_size = 8;
diff --git a/grub-core/video/fb/fbblit.c b/grub-core/video/fb/fbblit.c
index 3a073cea7..d55924837 100644
--- a/grub-core/video/fb/fbblit.c
+++ b/grub-core/video/fb/fbblit.c
@@ -1145,6 +1145,20 @@ grub_video_fbblit_replace_index_RGB888 (struct grub_video_fbblit_info *dst,
}
}
+static inline grub_uint8_t
+alpha_dilute (grub_uint8_t bg, grub_uint8_t fg, grub_uint8_t alpha)
+{
+ grub_uint16_t s;
+ grub_uint16_t h, l;
+ s = (fg * alpha) + (bg * (255 ^ alpha));
+ /* Optimised division by 255. */
+ h = s >> 8;
+ l = s & 0xff;
+ if (h + l >= 255)
+ h++;
+ return h;
+}
+
/* Generic blending blitter. Works for every supported format. */
static void
grub_video_fbblit_blend (struct grub_video_fbblit_info *dst,
@@ -1190,12 +1204,9 @@ grub_video_fbblit_blend (struct grub_video_fbblit_info *dst,
grub_video_fb_unmap_color_int (dst, dst_color, &dst_red,
&dst_green, &dst_blue, &dst_alpha);
- dst_red = (((src_red * src_alpha)
- + (dst_red * (255 ^ src_alpha))) / 255U);
- dst_green = (((src_green * src_alpha)
- + (dst_green * (255 ^ src_alpha))) / 255U);
- dst_blue = (((src_blue * src_alpha)
- + (dst_blue * (255 ^ src_alpha))) / 255U);
+ dst_red = alpha_dilute (dst_red, src_red, src_alpha);
+ dst_green = alpha_dilute (dst_green, src_green, src_alpha);
+ dst_blue = alpha_dilute (dst_blue, src_blue, src_alpha);
dst_alpha = src_alpha;
dst_color = grub_video_fb_map_rgba (dst_red, dst_green, dst_blue,
@@ -1270,11 +1281,11 @@ grub_video_fbblit_blend_BGRA8888_RGBA8888 (struct grub_video_fbblit_info *dst,
color = *dstptr;
dr = (color >> 16) & 0xFF;
- dr = (dr * (255 ^ a) + sr * a) / 255U;
+ dr = alpha_dilute (dr, sr, a);
dg = (color >> 8) & 0xFF;
- dg = (dg * (255 ^ a) + sg * a) / 255U;
+ dg = alpha_dilute (dg, sg, a);
db = (color >> 0) & 0xFF;
- db = (db * (255 ^ a) + sb * a) / 255U;
+ db = alpha_dilute (db, sb, a);
}
color = (a << 24) | (dr << 16) | (dg << 8) | db;
@@ -1360,9 +1371,9 @@ grub_video_fbblit_blend_BGR888_RGBA8888 (struct grub_video_fbblit_info *dst,
db = dstptr[2];
#endif
- db = (db * (255 ^ a) + sb * a) / 255U;
- dg = (dg * (255 ^ a) + sg * a) / 255U;
- dr = (dr * (255 ^ a) + sr * a) / 255U;
+ db = alpha_dilute (db, sb, a);
+ dg = alpha_dilute (dg, sg, a);
+ dr = alpha_dilute (dr, sr, a);
}
#ifndef GRUB_CPU_WORDS_BIGENDIAN
@@ -1440,9 +1451,9 @@ grub_video_fbblit_blend_RGBA8888_RGBA8888 (struct grub_video_fbblit_info *dst,
dg = (color >> 8) & 0xFF;
db = (color >> 16) & 0xFF;
- dr = (dr * (255 ^ a) + sr * a) / 255U;
- dg = (dg * (255 ^ a) + sg * a) / 255U;
- db = (db * (255 ^ a) + sb * a) / 255U;
+ dr = alpha_dilute (dr, sr, a);
+ dg = alpha_dilute (dg, sg, a);
+ db = alpha_dilute (db, sb, a);
color = (a << 24) | (db << 16) | (dg << 8) | dr;
@@ -1525,9 +1536,9 @@ grub_video_fbblit_blend_RGB888_RGBA8888 (struct grub_video_fbblit_info *dst,
dr = dstptr[2];
#endif
- dr = (dr * (255 ^ a) + sr * a) / 255U;
- dg = (dg * (255 ^ a) + sg * a) / 255U;
- db = (db * (255 ^ a) + sb * a) / 255U;
+ dr = alpha_dilute (dr, sr, a);
+ dg = alpha_dilute (dg, sg, a);
+ db = alpha_dilute (db, sb, a);
#ifndef GRUB_CPU_WORDS_BIGENDIAN
*dstptr++ = dr;
@@ -1601,9 +1612,9 @@ grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst,
grub_video_fb_unmap_color_int (dst, *dstptr, &dr, &dg, &db, &da);
- dr = (dr * (255 ^ a) + sr * a) / 255U;
- dg = (dg * (255 ^ a) + sg * a) / 255U;
- db = (db * (255 ^ a) + sb * a) / 255U;
+ dr = alpha_dilute (dr, sr, a);
+ dg = alpha_dilute (dg, sg, a);
+ db = alpha_dilute (db, sb, a);
color = grub_video_fb_map_rgb(dr, dg, db);
@@ -1683,9 +1694,9 @@ grub_video_fbblit_blend_XXXA8888_1bit (struct grub_video_fbblit_info *dst,
grub_uint8_t d2 = (*dstptr >> 8) & 0xFF;
grub_uint8_t d3 = (*dstptr >> 16) & 0xFF;
- d1 = (d1 * (255 ^ a) + s1 * a) / 255U;
- d2 = (d2 * (255 ^ a) + s2 * a) / 255U;
- d3 = (d3 * (255 ^ a) + s3 * a) / 255U;
+ d1 = alpha_dilute (d1, s1, a);
+ d2 = alpha_dilute (d2, s2, a);
+ d3 = alpha_dilute (d3, s3, a);
*dstptr = (a << 24) | (d3 << 16) | (d2 << 8) | d1;
}
@@ -1791,9 +1802,9 @@ grub_video_fbblit_blend_XXX888_1bit (struct grub_video_fbblit_info *dst,
grub_uint8_t d2 = (*(grub_uint32_t *) dstptr >> 8) & 0xFF;
grub_uint8_t d3 = (*(grub_uint32_t *) dstptr >> 16) & 0xFF;
- ((grub_uint8_t *) dstptr)[0] = (d1 * (255 ^ a) + s1 * a) / 255U;
- ((grub_uint8_t *) dstptr)[1] = (d2 * (255 ^ a) + s2 * a) / 255U;
- ((grub_uint8_t *) dstptr)[2] = (d3 * (255 ^ a) + s3 * a) / 255U;
+ ((grub_uint8_t *) dstptr)[0] = alpha_dilute (d1, s1, a);
+ ((grub_uint8_t *) dstptr)[1] = alpha_dilute (d2, s2, a);
+ ((grub_uint8_t *) dstptr)[2] = alpha_dilute (d3, s3, a);
}
srcmask >>= 1;
@@ -1887,9 +1898,9 @@ grub_video_fbblit_blend_XXX565_1bit (struct grub_video_fbblit_info *dst,
grub_uint8_t d2 = (*dstptr >> 5) & 0x3F;
grub_uint8_t d3 = (*dstptr >> 11) & 0x1F;
- d1 = (d1 * (255 ^ a) + s1 * a) / 255U;
- d2 = (d2 * (255 ^ a) + s2 * a) / 255U;
- d3 = (d3 * (255 ^ a) + s3 * a) / 255U;
+ d1 = alpha_dilute (d1, s1, a);
+ d2 = alpha_dilute (d2, s2, a);
+ d3 = alpha_dilute (d3, s3, a);
*dstptr = (d1 & 0x1f) | ((d2 & 0x3f) << 5) | ((d3 & 0x1f) << 11);
}
diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c
index 62b5c2245..b7f911926 100644
--- a/grub-core/video/i386/pc/vbe.c
+++ b/grub-core/video/i386/pc/vbe.c
@@ -304,8 +304,7 @@ grub_vbe_bios_getset_dac_palette_width (int set, int *dac_mask_size)
struct grub_bios_int_registers regs;
regs.eax = 0x4f08;
- regs.ebx = (*dac_mask_size & 0xff) >> 8;
- regs.ebx = set ? 1 : 0;
+ regs.ebx = ((*dac_mask_size & 0xff) << 8) | (set ? 1 : 0);
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x10, &regs);
*dac_mask_size = (regs.ebx >> 8) & 0xff;
@@ -875,6 +874,7 @@ vbe2videoinfo (grub_uint32_t mode,
/* CGA is basically 4-bit packed pixel. */
case GRUB_VBE_MEMORY_MODEL_CGA:
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_CGA;
+ /* Fallthrough. */
case GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL:
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
break;
@@ -887,6 +887,7 @@ vbe2videoinfo (grub_uint32_t mode,
/* Non chain 4 is a special case of planar. */
case GRUB_VBE_MEMORY_MODEL_NONCHAIN4_256:
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_NONCHAIN4;
+ /* Fallthrough. */
case GRUB_VBE_MEMORY_MODEL_PLANAR:
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_PLANAR
| GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c
index 2dc2ee10e..c3e0df240 100644
--- a/grub-core/video/readers/jpeg.c
+++ b/grub-core/video/readers/jpeg.c
@@ -94,7 +94,7 @@ struct grub_jpeg_data
jpeg_data_unit_t crdu;
jpeg_data_unit_t cbdu;
- unsigned vs, hs;
+ unsigned log_vs, log_hs;
int dri;
unsigned r1;
@@ -315,11 +315,14 @@ grub_jpeg_decode_sof (struct grub_jpeg_data *data)
ss = grub_jpeg_get_byte (data); /* Sampling factor. */
if (!id)
{
- data->vs = ss & 0xF; /* Vertical sampling. */
- data->hs = ss >> 4; /* Horizontal sampling. */
- if ((data->vs > 2) || (data->hs > 2))
+ grub_uint8_t vs, hs;
+ vs = ss & 0xF; /* Vertical sampling. */
+ hs = ss >> 4; /* Horizontal sampling. */
+ if ((vs > 2) || (hs > 2) || (vs == 0) || (hs == 0))
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: sampling method not supported");
+ data->log_vs = (vs == 2);
+ data->log_hs = (hs == 2);
}
else if (ss != JPEG_SAMPLING_1x1)
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
@@ -616,10 +619,10 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data)
unsigned c1, vb, hb, nr1, nc1;
int rst = data->dri;
- vb = data->vs * 8;
- hb = data->hs * 8;
- nr1 = (data->image_height + vb - 1) / vb;
- nc1 = (data->image_width + hb - 1) / hb;
+ vb = 8 << data->log_vs;
+ hb = 8 << data->log_hs;
+ nr1 = (data->image_height + vb - 1) >> (3 + data->log_vs);
+ nc1 = (data->image_width + hb - 1) >> (3 + data->log_hs);
for (; data->r1 < nr1 && (!data->dri || rst);
data->r1++, data->bitmap_ptr += (vb * data->image_width - hb * nc1) * 3)
@@ -629,8 +632,8 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data)
unsigned r2, c2, nr2, nc2;
grub_uint8_t *ptr2;
- for (r2 = 0; r2 < data->vs; r2++)
- for (c2 = 0; c2 < data->hs; c2++)
+ for (r2 = 0; r2 < (1U << data->log_vs); r2++)
+ for (c2 = 0; c2 < (1U << data->log_hs); c2++)
grub_jpeg_decode_du (data, 0, data->ydu[r2 * 2 + c2]);
if (data->color_components >= 3)
@@ -652,7 +655,7 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data)
unsigned i0;
int yy;
- i0 = (r2 / data->vs) * 8 + (c2 / data->hs);
+ i0 = (r2 >> data->log_vs) * 8 + (c2 >> data->log_hs);
yy = data->ydu[(r2 / 8) * 2 + (c2 / 8)][(r2 % 8) * 8 + (c2 % 8)];
if (data->color_components >= 3)
diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c
index 1f03f88d3..e1a01e99f 100644
--- a/grub-core/video/readers/png.c
+++ b/grub-core/video/readers/png.c
@@ -227,7 +227,7 @@ grub_png_decode_image_palette (struct grub_png_data *data,
{
unsigned i = 0, j;
- if (len == 0 || len % 3 != 0)
+ if (len == 0)
return GRUB_ERR_NONE;
for (i = 0; 3 * i < len && i < 256; i++)
@@ -851,15 +851,26 @@ grub_png_convert_image (struct grub_png_data *data)
int mask = (1 << data->color_bits) - 1;
unsigned j;
if (data->is_gray)
- for (i = 0; i < (1U << data->color_bits); i++)
- {
- grub_uint8_t col = (0xff * i) / ((1U << data->color_bits) - 1);
- palette[i][0] = col;
- palette[i][1] = col;
- palette[i][2] = col;
- }
+ {
+ /* Generic formula is
+ (0xff * i) / ((1U << data->color_bits) - 1)
+ but for allowed bit depth of 1, 2 and for it's
+ equivalent to
+ (0xff / ((1U << data->color_bits) - 1)) * i
+ Precompute the multipliers to avoid division.
+ */
+
+ const grub_uint8_t multipliers[5] = { 0xff, 0xff, 0x55, 0x24, 0x11 };
+ for (i = 0; i < (1U << data->color_bits); i++)
+ {
+ grub_uint8_t col = multipliers[data->color_bits] * i;
+ palette[i][0] = col;
+ palette[i][1] = col;
+ palette[i][2] = col;
+ }
+ }
else
- grub_memcpy (palette, data->palette, 16 * 3);
+ grub_memcpy (palette, data->palette, 3 << data->color_bits);
d1c = d1;
d2c = d2;
for (j = 0; j < data->image_height; j++, d1c += data->image_width * 3,
diff --git a/include/grub/acpi.h b/include/grub/acpi.h
index 2ac2bd6fd..66148f684 100644
--- a/include/grub/acpi.h
+++ b/include/grub/acpi.h
@@ -22,6 +22,8 @@
#ifndef GRUB_DSDT_TEST
#include <grub/types.h>
#include <grub/err.h>
+#else
+#define GRUB_PACKED __attribute__ ((packed))
#endif
#define GRUB_RSDP_SIGNATURE "RSD PTR "
@@ -67,10 +69,14 @@ struct grub_acpi_fadt
grub_uint32_t dsdt_addr;
grub_uint8_t somefields1[20];
grub_uint32_t pm1a;
- grub_uint8_t somefields2[64];
+ grub_uint8_t somefields2[8];
+ grub_uint32_t pmtimer;
+ grub_uint8_t somefields3[32];
+ grub_uint32_t flags;
+ grub_uint8_t somefields4[16];
grub_uint64_t facs_xaddr;
grub_uint64_t dsdt_xaddr;
- grub_uint8_t somefields3[96];
+ grub_uint8_t somefields5[96];
} GRUB_PACKED;
#define GRUB_ACPI_MADT_SIGNATURE "APIC"
@@ -176,9 +182,9 @@ enum
#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);
+struct grub_acpi_rsdp_v10 *EXPORT_FUNC(grub_machine_acpi_get_rsdpv1) (void);
+struct grub_acpi_rsdp_v20 *EXPORT_FUNC(grub_machine_acpi_get_rsdpv2) (void);
+grub_uint8_t EXPORT_FUNC(grub_byte_checksum) (void *base, grub_size_t size);
grub_err_t grub_acpi_create_ebda (void);
@@ -191,7 +197,8 @@ void grub_acpi_halt (void);
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_NAME = 8, GRUB_ACPI_OPCODE_ALIAS = 0x06,
+ GRUB_ACPI_OPCODE_BYTE_CONST = 0x0a,
GRUB_ACPI_OPCODE_WORD_CONST = 0x0b,
GRUB_ACPI_OPCODE_DWORD_CONST = 0x0c,
GRUB_ACPI_OPCODE_STRING_CONST = 0x0d,
@@ -199,8 +206,25 @@ enum
GRUB_ACPI_OPCODE_BUFFER = 0x11,
GRUB_ACPI_OPCODE_PACKAGE = 0x12,
GRUB_ACPI_OPCODE_METHOD = 0x14, GRUB_ACPI_OPCODE_EXTOP = 0x5b,
+ GRUB_ACPI_OPCODE_ADD = 0x72,
+ GRUB_ACPI_OPCODE_CONCAT = 0x73,
+ GRUB_ACPI_OPCODE_SUBTRACT = 0x74,
+ GRUB_ACPI_OPCODE_MULTIPLY = 0x77,
+ GRUB_ACPI_OPCODE_DIVIDE = 0x78,
+ GRUB_ACPI_OPCODE_LSHIFT = 0x79,
+ GRUB_ACPI_OPCODE_RSHIFT = 0x7a,
+ GRUB_ACPI_OPCODE_AND = 0x7b,
+ GRUB_ACPI_OPCODE_NAND = 0x7c,
+ GRUB_ACPI_OPCODE_OR = 0x7d,
+ GRUB_ACPI_OPCODE_NOR = 0x7e,
+ GRUB_ACPI_OPCODE_XOR = 0x7f,
+ GRUB_ACPI_OPCODE_CONCATRES = 0x84,
+ GRUB_ACPI_OPCODE_MOD = 0x85,
+ GRUB_ACPI_OPCODE_INDEX = 0x88,
+ GRUB_ACPI_OPCODE_CREATE_DWORD_FIELD = 0x8a,
GRUB_ACPI_OPCODE_CREATE_WORD_FIELD = 0x8b,
GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD = 0x8c,
+ GRUB_ACPI_OPCODE_TOSTRING = 0x9c,
GRUB_ACPI_OPCODE_IF = 0xa0, GRUB_ACPI_OPCODE_ONES = 0xff
};
enum
@@ -217,4 +241,7 @@ enum
GRUB_ACPI_EXTOPCODE_BANK_FIELD_OP = 0x87,
};
+struct grub_acpi_fadt *
+EXPORT_FUNC(grub_acpi_find_fadt) (void);
+
#endif /* ! GRUB_ACPI_HEADER */
diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
index 1f62d76ac..059dbba42 100644
--- a/include/grub/arm/linux.h
+++ b/include/grub/arm/linux.h
@@ -23,15 +23,15 @@
#define LINUX_ZIMAGE_OFFSET 0x24
#define LINUX_ZIMAGE_MAGIC 0x016f2818
-#define ARM_FDT_MACHINE_TYPE 0xFFFFFFFF
+#include "system.h"
#if defined GRUB_MACHINE_UBOOT
# include <grub/uboot/uboot.h>
# define LINUX_ADDRESS (start_of_ram + 0x8000)
# define LINUX_INITRD_ADDRESS (start_of_ram + 0x02000000)
# define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000)
-# define firmware_get_boot_data grub_uboot_get_boot_data
-# define firmware_get_machine_type grub_uboot_get_machine_type
+# define grub_arm_firmware_get_boot_data grub_uboot_get_boot_data
+# define grub_arm_firmware_get_machine_type grub_uboot_get_machine_type
#elif defined GRUB_MACHINE_EFI
# include <grub/efi/efi.h>
# include <grub/machine/loader.h>
@@ -41,19 +41,17 @@
# define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000)
# define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000)
static inline grub_addr_t
-firmware_get_boot_data (void)
+grub_arm_firmware_get_boot_data (void)
{
return 0;
}
static inline grub_uint32_t
-firmware_get_machine_type (void)
+grub_arm_firmware_get_machine_type (void)
{
- return ARM_FDT_MACHINE_TYPE;
+ return GRUB_ARM_MACHINE_TYPE_FDT;
}
#endif
#define FDT_ADDITIONAL_ENTRIES_SIZE 0x300
-typedef void (*kernel_entry_t) (int, unsigned long, void *);
-
#endif /* ! GRUB_LINUX_CPU_HEADER */
diff --git a/include/grub/arm/reloc.h b/include/grub/arm/reloc.h
index b938037a0..ae92e21f1 100644
--- a/include/grub/arm/reloc.h
+++ b/include/grub/arm/reloc.h
@@ -43,4 +43,9 @@ void
grub_arm_jump24_set_offset (grub_uint32_t *target,
grub_int32_t offset);
+grub_uint16_t
+grub_arm_thm_movw_movt_get_value (grub_uint16_t *target);
+void
+grub_arm_thm_movw_movt_set_value (grub_uint16_t *target, grub_uint16_t value);
+
#endif
diff --git a/include/grub/arm/system.h b/include/grub/arm/system.h
index e22060003..f62c18c13 100644
--- a/include/grub/arm/system.h
+++ b/include/grub/arm/system.h
@@ -1,7 +1,18 @@
#ifndef GRUB_SYSTEM_CPU_HEADER
#define GRUB_SYSTEM_CPU_HEADER
-void grub_arm_disable_caches_mmu (void);
+#include <grub/types.h>
+
+enum
+ {
+ GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI = 3138,
+ GRUB_ARM_MACHINE_TYPE_FDT = 0xFFFFFFFF
+ };
+
+void EXPORT_FUNC(grub_arm_disable_caches_mmu) (void);
+void grub_arm_enable_caches_mmu (void);
+void grub_arm_enable_mmu (grub_uint32_t *mmu_tables);
+void grub_arm_clear_mmu_v6 (void);
#endif /* ! GRUB_SYSTEM_CPU_HEADER */
diff --git a/include/grub/arm/uboot/kernel.h b/include/grub/arm/uboot/kernel.h
index c37a18d06..ce0b149cc 100644
--- a/include/grub/arm/uboot/kernel.h
+++ b/include/grub/arm/uboot/kernel.h
@@ -26,7 +26,7 @@
#endif /* ! ASM_FILE */
-#define GRUB_KERNEL_MACHINE_STACK_SIZE 0x40000
-#define GRUB_KERNEL_MACHINE_HEAP_SIZE (grub_size_t) (2 * 1024 * 1024)
+#define GRUB_KERNEL_MACHINE_STACK_SIZE GRUB_KERNEL_ARM_STACK_SIZE
+#define GRUB_KERNEL_MACHINE_HEAP_SIZE (grub_size_t) (16 * 1024 * 1024)
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
diff --git a/include/grub/libusb.h b/include/grub/arm64/fdtload.h
index 26548bccb..7b9ddba91 100644
--- a/include/grub/libusb.h
+++ b/include/grub/arm64/fdtload.h
@@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2010 Free Software Foundation, Inc.
+ * Copyright (C) 2013-2015 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,14 +16,20 @@
* 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);
+#ifndef GRUB_FDTLOAD_CPU_HEADER
+#define GRUB_FDTLOAD_CPU_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+
+void *
+grub_fdt_load (grub_size_t additional_size);
+void
+grub_fdt_unload (void);
+grub_err_t
+grub_fdt_install (void);
+
+#define GRUB_EFI_PAGE_SHIFT 12
+#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT)
+
+#endif
diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
new file mode 100644
index 000000000..1ea23696e
--- /dev/null
+++ b/include/grub/arm64/linux.h
@@ -0,0 +1,48 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2013 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_LINUX_CPU_HEADER
+#define GRUB_LINUX_CPU_HEADER 1
+
+#include <grub/efi/efi.h>
+
+#define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */
+
+#define GRUB_EFI_PE_MAGIC 0x5A4D
+
+/* From linux/Documentation/arm64/booting.txt */
+struct grub_arm64_linux_kernel_header
+{
+ grub_uint32_t code0; /* Executable code */
+ grub_uint32_t code1; /* Executable code */
+ grub_uint64_t text_offset; /* Image load offset */
+ grub_uint64_t res0; /* reserved */
+ grub_uint64_t res1; /* reserved */
+ grub_uint64_t res2; /* reserved */
+ grub_uint64_t res3; /* reserved */
+ grub_uint64_t res4; /* reserved */
+ grub_uint32_t magic; /* Magic number, little endian, "ARM\x64" */
+ grub_uint32_t hdr_offset; /* Offset of PE/COFF header */
+};
+
+grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header
+ *lh);
+grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size,
+ char *args);
+
+#endif /* ! GRUB_LINUX_CPU_HEADER */
diff --git a/include/grub/arm64/reloc.h b/include/grub/arm64/reloc.h
index 4aed3d715..452c14822 100644
--- a/include/grub/arm64/reloc.h
+++ b/include/grub/arm64/reloc.h
@@ -22,5 +22,13 @@
int grub_arm_64_check_xxxx26_offset (grub_int64_t offset);
void
grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset);
+int
+grub_arm64_check_hi21_signed (grub_int64_t offset);
+void
+grub_arm64_set_hi21 (grub_uint32_t *place, grub_int64_t offset);
+void
+grub_arm64_set_abs_lo12 (grub_uint32_t *place, grub_int64_t target);
+void
+grub_arm64_set_abs_lo12_ldst64 (grub_uint32_t *place, grub_int64_t target);
#endif
diff --git a/include/grub/cache.h b/include/grub/cache.h
index c6a0b0ba4..fc669dfd1 100644
--- a/include/grub/cache.h
+++ b/include/grub/cache.h
@@ -35,14 +35,20 @@ void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len);
#ifndef GRUB_MACHINE_EMU
#ifdef _mips
-void EXPORT_FUNC(grub_arch_sync_dma_caches) (void *address, grub_size_t len);
+void EXPORT_FUNC(grub_arch_sync_dma_caches) (volatile void *address,
+ grub_size_t len);
#else
static inline void
-grub_arch_sync_dma_caches (void *address __attribute__ ((unused)),
+grub_arch_sync_dma_caches (volatile void *address __attribute__ ((unused)),
grub_size_t len __attribute__ ((unused)))
{
}
#endif
#endif
+#ifdef __arm__
+void
+grub_arm_cache_enable (void);
+#endif
+
#endif /* ! GRUB_CACHE_HEADER */
diff --git a/include/grub/command.h b/include/grub/command.h
index 8705a6355..eee4e847e 100644
--- a/include/grub/command.h
+++ b/include/grub/command.h
@@ -22,6 +22,7 @@
#include <grub/symbol.h>
#include <grub/err.h>
#include <grub/list.h>
+#include <grub/misc.h>
typedef enum grub_command_flags
{
diff --git a/include/grub/compiler-rt-emu.h b/include/grub/compiler-rt-emu.h
new file mode 100644
index 000000000..b21425d9e
--- /dev/null
+++ b/include/grub/compiler-rt-emu.h
@@ -0,0 +1,260 @@
+/* compiler-rt-emu.h - prototypes for compiler helpers. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010-2014 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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_COMPILER_RT_HEADER
+#define GRUB_COMPILER_RT_HEADER 1
+
+#include <config-util.h>
+#include <grub/types.h>
+#include <grub/symbol.h>
+
+#ifdef HAVE___UDIVSI3
+grub_uint32_t
+EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b);
+#endif
+
+#ifdef HAVE___UMODSI3
+grub_uint32_t
+EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b);
+#endif
+
+#ifdef HAVE___DIVSI3
+grub_int32_t
+EXPORT_FUNC (__divsi3) (grub_int32_t a, grub_int32_t b);
+#endif
+
+#ifdef HAVE___MODSI3
+grub_int32_t
+EXPORT_FUNC (__modsi3) (grub_int32_t a, grub_int32_t b);
+#endif
+
+#ifdef HAVE___DIVDI3
+grub_int64_t
+EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b);
+#endif
+
+#ifdef HAVE___MODDI3
+grub_int64_t
+EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b);
+#endif
+
+#ifdef HAVE___UDIVDI3
+grub_uint64_t
+EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b);
+#endif
+
+#ifdef HAVE___UMODDI3
+grub_uint64_t
+EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b);
+#endif
+
+#ifdef HAVE___CTZDI2
+unsigned
+EXPORT_FUNC (__ctzdi2) (grub_uint64_t x);
+#endif
+
+#ifdef HAVE___CTZSI2
+unsigned
+EXPORT_FUNC (__ctzsi2) (grub_uint32_t x);
+#endif
+
+#ifdef HAVE___AEABI_UIDIV
+grub_uint32_t
+EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b);
+#endif
+
+#ifdef HAVE___AEABI_UIDIVMOD
+grub_uint32_t
+EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b);
+#endif
+
+#ifdef HAVE___AEABI_IDIV
+grub_int32_t
+EXPORT_FUNC (__aeabi_idiv) (grub_int32_t a, grub_int32_t b);
+#endif
+
+#ifdef HAVE___AEABI_IDIVMOD
+grub_int32_t
+EXPORT_FUNC (__aeabi_idivmod) (grub_int32_t a, grub_int32_t b);
+#endif
+
+#ifdef HAVE___AEABI_ULCMP
+int
+EXPORT_FUNC (__aeabi_ulcmp) (grub_uint64_t a, grub_uint64_t b);
+#endif
+
+/* Needed for allowing modules to be compiled as thumb. */
+#ifdef HAVE___MULDI3
+grub_uint64_t
+EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b);
+#endif
+
+#ifdef HAVE___AEABI_LMUL
+grub_uint64_t
+EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b);
+#endif
+
+#ifdef HAVE___AEABI_MEMCPY
+void *
+EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n);
+#endif
+
+#ifdef HAVE___AEABI_MEMCPY4
+void *
+EXPORT_FUNC (__aeabi_memcpy4) (void *dest, const void *src, grub_size_t n);
+#endif
+
+#ifdef HAVE___AEABI_MEMCPY8
+void *
+EXPORT_FUNC (__aeabi_memcpy8) (void *dest, const void *src, grub_size_t n);
+#endif
+
+#ifdef HAVE___AEABI_MEMSET
+void *
+EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n);
+#endif
+
+#ifdef HAVE___AEABI_MEMCLR
+void *
+EXPORT_FUNC(__aeabi_memclr) (void *s, grub_size_t n);
+#endif
+
+#ifdef HAVE___AEABI_MEMCLR4
+void *
+EXPORT_FUNC(__aeabi_memclr4) (void *s, grub_size_t n);
+#endif
+
+#ifdef HAVE___AEABI_MEMCLR8
+void *
+EXPORT_FUNC(__aeabi_memclr8) (void *s, grub_size_t n);
+#endif
+
+#ifdef HAVE___AEABI_LASR
+grub_uint64_t
+EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b);
+#endif
+
+#ifdef HAVE___AEABI_LLSL
+grub_uint64_t
+EXPORT_FUNC (__aeabi_llsl) (grub_uint64_t u, int b);
+#endif
+
+#ifdef HAVE___AEABI_LLSR
+grub_uint64_t
+EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b);
+#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
+
+#ifdef HAVE___UCMPDI2
+int
+EXPORT_FUNC(__ucmpdi2) (grub_uint64_t a, grub_uint64_t b);
+#endif
+
+#ifdef HAVE___ASHLDI3
+grub_uint64_t
+EXPORT_FUNC(__ashldi3) (grub_uint64_t u, int b);
+#endif
+
+#ifdef HAVE___ASHRDI3
+grub_uint64_t
+EXPORT_FUNC(__ashrdi3) (grub_uint64_t u, int b);
+#endif
+
+#ifdef HAVE___LSHRDI3
+grub_uint64_t
+EXPORT_FUNC (__lshrdi3) (grub_uint64_t u, int b);
+#endif
+
+#ifdef HAVE___BSWAPSI2
+grub_uint32_t
+EXPORT_FUNC(__bswapsi2) (grub_uint32_t u);
+#endif
+
+#ifdef HAVE___BSWAPDI2
+grub_uint64_t
+EXPORT_FUNC(__bswapdi2) (grub_uint64_t u);
+#endif
+
+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);
+
+#ifdef HAVE___BZERO
+void EXPORT_FUNC (__bzero) (void *s, grub_size_t n);
+#endif
+
+#ifdef HAVE___REGISTER_FRAME_INFO
+void EXPORT_FUNC (__register_frame_info) (void);
+#endif
+
+#ifdef HAVE___DEREGISTER_FRAME_INFO
+void EXPORT_FUNC (__deregister_frame_info) (void);
+#endif
+#ifdef HAVE____CHKSTK_MS
+void EXPORT_FUNC (___chkstk_ms) (void);
+#endif
+
+#ifdef HAVE___CHKSTK_MS
+void EXPORT_FUNC (__chkstk_ms) (void);
+#endif
+
+#endif
+
diff --git a/include/grub/compiler-rt.h b/include/grub/compiler-rt.h
new file mode 100644
index 000000000..dc73649a5
--- /dev/null
+++ b/include/grub/compiler-rt.h
@@ -0,0 +1,200 @@
+/* compiler-rt.h - prototypes for compiler helpers. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010-2014 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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_COMPILER_RT_HEADER
+#define GRUB_COMPILER_RT_HEADER 1
+
+#include <stdarg.h>
+#include <grub/types.h>
+#include <grub/symbol.h>
+#include <grub/misc.h>
+
+#if defined(GRUB_DIVISION_IN_SOFTWARE) && GRUB_DIVISION_IN_SOFTWARE
+
+grub_uint32_t
+EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b);
+
+grub_uint32_t
+EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b);
+
+grub_int32_t
+EXPORT_FUNC (__divsi3) (grub_int32_t a, grub_int32_t b);
+
+grub_int32_t
+EXPORT_FUNC (__modsi3) (grub_int32_t a, grub_int32_t b);
+
+grub_int64_t
+EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b);
+
+grub_int64_t
+EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b);
+
+grub_uint64_t
+EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b);
+
+grub_uint64_t
+EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b);
+
+#endif
+
+#if defined (__sparc__) || defined (__powerpc__) || defined (__mips__) || defined (__arm__)
+unsigned
+EXPORT_FUNC (__ctzdi2) (grub_uint64_t x);
+#define NEED_CTZDI2 1
+#endif
+
+#if defined (__mips__) || defined (__arm__)
+unsigned
+EXPORT_FUNC (__ctzsi2) (grub_uint32_t x);
+#define NEED_CTZSI2 1
+#endif
+
+#ifdef __arm__
+grub_uint32_t
+EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b);
+grub_uint32_t
+EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b);
+
+grub_int32_t
+EXPORT_FUNC (__aeabi_idiv) (grub_int32_t a, grub_int32_t b);
+grub_int32_t
+EXPORT_FUNC (__aeabi_idivmod) (grub_int32_t a, grub_int32_t b);
+
+int
+EXPORT_FUNC (__aeabi_ulcmp) (grub_uint64_t a, grub_uint64_t b);
+
+/* Needed for allowing modules to be compiled as thumb. */
+grub_uint64_t
+EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b);
+grub_uint64_t
+EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b);
+
+void *
+EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n);
+void *
+EXPORT_FUNC (__aeabi_memcpy4) (void *dest, const void *src, grub_size_t n);
+void *
+EXPORT_FUNC (__aeabi_memcpy8) (void *dest, const void *src, grub_size_t n);
+void *
+EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n);
+void EXPORT_FUNC(__aeabi_memclr) (void *s, grub_size_t n);
+void EXPORT_FUNC(__aeabi_memclr4) (void *s, grub_size_t n);
+void EXPORT_FUNC(__aeabi_memclr8) (void *s, grub_size_t n);
+
+grub_uint64_t
+EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b);
+
+grub_uint64_t
+EXPORT_FUNC (__aeabi_llsl) (grub_uint64_t u, int b);
+
+grub_uint64_t
+EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b);
+
+#endif
+
+
+#if defined (__powerpc__)
+
+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
+
+#if defined (__powerpc__) || defined(__mips__) || defined (__arm__)
+
+int
+EXPORT_FUNC(__ucmpdi2) (grub_uint64_t a, grub_uint64_t b);
+
+grub_uint64_t
+EXPORT_FUNC(__ashldi3) (grub_uint64_t u, int b);
+
+grub_uint64_t
+EXPORT_FUNC(__ashrdi3) (grub_uint64_t u, int b);
+
+grub_uint64_t
+EXPORT_FUNC (__lshrdi3) (grub_uint64_t u, int b);
+#endif
+
+#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || defined (__arm__)
+grub_uint32_t
+EXPORT_FUNC(__bswapsi2) (grub_uint32_t u);
+
+grub_uint64_t
+EXPORT_FUNC(__bswapdi2) (grub_uint64_t u);
+#endif
+
+#if defined (__APPLE__) && defined(__i386__)
+#define GRUB_BUILTIN_ATTR __attribute__ ((regparm(0)))
+#else
+#define GRUB_BUILTIN_ATTR
+#endif
+
+/* Prototypes for aliases. */
+int GRUB_BUILTIN_ATTR EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n);
+void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n);
+void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n);
+void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memset) (void *s, int c, grub_size_t n);
+
+#ifdef __APPLE__
+void GRUB_BUILTIN_ATTR EXPORT_FUNC (__bzero) (void *s, grub_size_t n);
+#endif
+
+#if defined (__MINGW32__) || defined (__CYGWIN__)
+void EXPORT_FUNC (__register_frame_info) (void);
+void EXPORT_FUNC (__deregister_frame_info) (void);
+void EXPORT_FUNC (___chkstk_ms) (void);
+void EXPORT_FUNC (__chkstk_ms) (void);
+#endif
+
+#endif
+
diff --git a/include/grub/compiler.h b/include/grub/compiler.h
new file mode 100644
index 000000000..c9e1d7a73
--- /dev/null
+++ b/include/grub/compiler.h
@@ -0,0 +1,51 @@
+/* compiler.h - macros for various compiler features */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010,2014 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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_COMPILER_HEADER
+#define GRUB_COMPILER_HEADER 1
+
+/* 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) __attribute__ ((noreturn))
+#endif
+
+#if GNUC_PREREQ(4,4)
+# define GNU_PRINTF gnu_printf
+#else
+# define GNU_PRINTF printf
+#endif
+
+#if GNUC_PREREQ(3,4)
+# define WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
+#else
+# define WARN_UNUSED_RESULT
+#endif
+
+#endif /* ! GRUB_COMPILER_HEADER */
diff --git a/include/grub/crypto.h b/include/grub/crypto.h
index 3739c6a4b..a24e89dd9 100644
--- a/include/grub/crypto.h
+++ b/include/grub/crypto.h
@@ -293,9 +293,10 @@ grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size)
}
while (size >= sizeof (grub_uint64_t))
{
+ /* We've already checked that all pointers are aligned. */
*(grub_uint64_t *) (void *) outptr
- = (*(grub_uint64_t *) (void *) in1ptr
- ^ *(grub_uint64_t *) (void *) in2ptr);
+ = (*(const grub_uint64_t *) (const void *) in1ptr
+ ^ *(const grub_uint64_t *) (const void *) in2ptr);
in1ptr += sizeof (grub_uint64_t);
in2ptr += sizeof (grub_uint64_t);
outptr += sizeof (grub_uint64_t);
@@ -320,7 +321,7 @@ grub_crypto_ecb_encrypt (grub_crypto_cipher_handle_t cipher,
void *out, const 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 *out, const void *in, grub_size_t size,
void *iv_in);
gcry_err_code_t
grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher,
@@ -407,7 +408,7 @@ void _gcry_assert_failed (const char *expr, const char *file, int line,
const char *func) __attribute__ ((noreturn));
void _gcry_burn_stack (int bytes);
-void _gcry_log_error( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2)));
+void _gcry_log_error( const char *fmt, ... ) __attribute__ ((format (__printf__, 1, 2)));
#ifdef GRUB_UTIL
diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h
index 66f3e1e22..32f564ae0 100644
--- a/include/grub/cryptodisk.h
+++ b/include/grub/cryptodisk.h
@@ -97,6 +97,7 @@ struct grub_cryptodisk
grub_uint8_t rekey_key[64];
grub_uint64_t last_rekey;
int rekey_derived_size;
+ grub_disk_addr_t partition_start;
};
typedef struct grub_cryptodisk *grub_cryptodisk_t;
@@ -145,7 +146,8 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
grub_disk_t source, const char *cheat);
void
grub_util_cryptodisk_get_abstraction (grub_disk_t disk,
- void (*cb) (const char *val));
+ void (*cb) (const char *val, void *data),
+ void *data);
char *
grub_util_get_geli_uuid (const char *dev);
diff --git a/include/grub/diskfilter.h b/include/grub/diskfilter.h
index 042fe04a5..d89273c1b 100644
--- a/include/grub/diskfilter.h
+++ b/include/grub/diskfilter.h
@@ -172,7 +172,7 @@ grub_diskfilter_unregister (grub_diskfilter_t diskfilter)
struct grub_diskfilter_vg *
grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
- char *name, grub_uint64_t disk_size,
+ const char *name, grub_uint64_t disk_size,
grub_uint64_t stripe_size,
int layout, int level);
@@ -202,7 +202,8 @@ grub_diskfilter_get_pv_from_disk (grub_disk_t disk,
struct grub_diskfilter_vg **vg);
void
grub_diskfilter_get_partmap (grub_disk_t disk,
- void (*cb) (const char *val));
+ void (*cb) (const char *val, void *data),
+ void *data);
#endif
#endif /* ! GRUB_RAID_H */
diff --git a/include/grub/dl.h b/include/grub/dl.h
index d29a899f5..9562fa663 100644
--- a/include/grub/dl.h
+++ b/include/grub/dl.h
@@ -26,6 +26,7 @@
#include <grub/types.h>
#include <grub/elf.h>
#include <grub/list.h>
+#include <grub/misc.h>
#endif
/*
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
index 5ebdd9f42..c7c9f0e1d 100644
--- a/include/grub/efi/api.h
+++ b/include/grub/efi/api.h
@@ -49,6 +49,9 @@
#define GRUB_EFI_MEMORY_WP 0x0000000000001000LL
#define GRUB_EFI_MEMORY_RP 0x0000000000002000LL
#define GRUB_EFI_MEMORY_XP 0x0000000000004000LL
+#define GRUB_EFI_MEMORY_NV 0x0000000000008000LL
+#define GRUB_EFI_MEMORY_MORE_RELIABLE 0x0000000000010000LL
+#define GRUB_EFI_MEMORY_RO 0x0000000000020000LL
#define GRUB_EFI_MEMORY_RUNTIME 0x8000000000000000LL
#define GRUB_EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
@@ -111,7 +114,7 @@
{ 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
}
-#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
+#define GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
{ 0xdd9e7534, 0x7762, 0x4698, \
{ 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } \
}
@@ -246,6 +249,51 @@
{ 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } \
}
+#define GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID \
+ { 0xa31280ad, 0x481e, 0x41b6, \
+ { 0x95, 0xe8, 0x12, 0x7f, 0x4c, 0x98, 0x47, 0x79 } \
+ }
+
+#define GRUB_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID \
+ { 0xfc1bcdb0, 0x7d31, 0x49aa, \
+ { 0x93, 0x6a, 0xa4, 0x60, 0x0d, 0x9d, 0xd0, 0x83 } \
+ }
+
+#define GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID \
+ { 0xee4e5898, 0x3914, 0x4259, \
+ { 0x9d, 0x6e, 0xdc, 0x7b, 0xd7, 0x94, 0x03, 0xcf } \
+ }
+
+#define GRUB_EFI_TSC_FREQUENCY_GUID \
+ { 0xdba6a7e3, 0xbb57, 0x4be7, \
+ { 0x8a, 0xf8, 0xd5, 0x78, 0xdb, 0x7e, 0x56, 0x87 } \
+ }
+
+#define GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID \
+ { 0xb122a263, 0x3661, 0x4f68, \
+ { 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 } \
+ }
+
+#define GRUB_EFI_DXE_SERVICES_TABLE_GUID \
+ { 0x05ad34ba, 0x6f02, 0x4214, \
+ { 0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } \
+ }
+
+#define GRUB_EFI_HOB_LIST_GUID \
+ { 0x7739f24c, 0x93d7, 0x11d4, \
+ { 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
+ }
+
+#define GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID \
+ { 0x4c19049f, 0x4137, 0x4dd3, \
+ { 0x9c, 0x10, 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa } \
+ }
+
+#define GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID \
+ { 0x49152e77, 0x1ada, 0x4764, \
+ { 0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b } \
+ }
+
#define GRUB_EFI_MPS_TABLE_GUID \
{ 0xeb9d2d2f, 0x2d88, 0x11d3, \
{ 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
@@ -276,6 +324,16 @@
{ 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 } \
}
+#define GRUB_EFI_DEVICE_TREE_GUID \
+ { 0xb1b621d5, 0xf19c, 0x41a5, \
+ { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } \
+ }
+
+#define GRUB_EFI_VENDOR_APPLE_GUID \
+ { 0x2B0585EB, 0xD8B8, 0x49A9, \
+ { 0x8B, 0x8C, 0xE2, 0x1B, 0x01, 0xAE, 0xF2, 0xB7 } \
+ }
+
struct grub_efi_sal_system_table
{
grub_uint32_t signature;
@@ -421,6 +479,7 @@ enum grub_efi_memory_type
GRUB_EFI_MEMORY_MAPPED_IO,
GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE,
GRUB_EFI_PAL_CODE,
+ GRUB_EFI_PERSISTENT_MEMORY,
GRUB_EFI_MAX_MEMORY_TYPE
};
typedef enum grub_efi_memory_type grub_efi_memory_type_t;
@@ -809,15 +868,18 @@ struct grub_efi_uart_device_path
} GRUB_PACKED;
typedef struct grub_efi_uart_device_path grub_efi_uart_device_path_t;
-#define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10
+#define GRUB_EFI_SATA_DEVICE_PATH_SUBTYPE 18
-struct grub_efi_vendor_messaging_device_path
+struct grub_efi_sata_device_path
{
grub_efi_device_path_t header;
- grub_efi_packed_guid_t vendor_guid;
- grub_efi_uint8_t vendor_defined_data[0];
+ grub_efi_uint16_t hba_port;
+ grub_efi_uint16_t multiplier_port;
+ grub_efi_uint16_t lun;
} GRUB_PACKED;
-typedef struct grub_efi_vendor_messaging_device_path grub_efi_vendor_messaging_device_path_t;
+typedef struct grub_efi_sata_device_path grub_efi_sata_device_path_t;
+
+#define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10
/* Media Device Path. */
#define GRUB_EFI_MEDIA_DEVICE_PATH_TYPE 4
@@ -939,6 +1001,32 @@ struct grub_efi_input_key
};
typedef struct grub_efi_input_key grub_efi_input_key_t;
+typedef grub_efi_uint8_t grub_efi_key_toggle_state_t;
+struct grub_efi_key_state
+{
+ grub_efi_uint32_t key_shift_state;
+ grub_efi_key_toggle_state_t key_toggle_state;
+};
+typedef struct grub_efi_key_state grub_efi_key_state_t;
+
+#define GRUB_EFI_SHIFT_STATE_VALID 0x80000000
+#define GRUB_EFI_RIGHT_SHIFT_PRESSED 0x00000001
+#define GRUB_EFI_LEFT_SHIFT_PRESSED 0x00000002
+#define GRUB_EFI_RIGHT_CONTROL_PRESSED 0x00000004
+#define GRUB_EFI_LEFT_CONTROL_PRESSED 0x00000008
+#define GRUB_EFI_RIGHT_ALT_PRESSED 0x00000010
+#define GRUB_EFI_LEFT_ALT_PRESSED 0x00000020
+#define GRUB_EFI_RIGHT_LOGO_PRESSED 0x00000040
+#define GRUB_EFI_LEFT_LOGO_PRESSED 0x00000080
+#define GRUB_EFI_MENU_KEY_PRESSED 0x00000100
+#define GRUB_EFI_SYS_REQ_PRESSED 0x00000200
+
+#define GRUB_EFI_TOGGLE_STATE_VALID 0x80
+#define GRUB_EFI_KEY_STATE_EXPOSED 0x40
+#define GRUB_EFI_SCROLL_LOCK_ACTIVE 0x01
+#define GRUB_EFI_NUM_LOCK_ACTIVE 0x02
+#define GRUB_EFI_CAPS_LOCK_ACTIVE 0x04
+
struct grub_efi_simple_text_output_mode
{
grub_efi_int32_t max_mode;
@@ -1281,6 +1369,43 @@ struct grub_efi_simple_input_interface
};
typedef struct grub_efi_simple_input_interface grub_efi_simple_input_interface_t;
+struct grub_efi_key_data {
+ grub_efi_input_key_t key;
+ grub_efi_key_state_t key_state;
+};
+typedef struct grub_efi_key_data grub_efi_key_data_t;
+
+typedef grub_efi_status_t (*grub_efi_key_notify_function_t) (
+ grub_efi_key_data_t *key_data
+ );
+
+struct grub_efi_simple_text_input_ex_interface
+{
+ grub_efi_status_t
+ (*reset) (struct grub_efi_simple_text_input_ex_interface *this,
+ grub_efi_boolean_t extended_verification);
+
+ grub_efi_status_t
+ (*read_key_stroke) (struct grub_efi_simple_text_input_ex_interface *this,
+ grub_efi_key_data_t *key_data);
+
+ grub_efi_event_t wait_for_key;
+
+ grub_efi_status_t
+ (*set_state) (struct grub_efi_simple_text_input_ex_interface *this,
+ grub_efi_key_toggle_state_t *key_toggle_state);
+
+ grub_efi_status_t
+ (*register_key_notify) (struct grub_efi_simple_text_input_ex_interface *this,
+ grub_efi_key_data_t *key_data,
+ grub_efi_key_notify_function_t key_notification_function);
+
+ grub_efi_status_t
+ (*unregister_key_notify) (struct grub_efi_simple_text_input_ex_interface *this,
+ void *notification_handle);
+};
+typedef struct grub_efi_simple_text_input_ex_interface grub_efi_simple_text_input_ex_interface_t;
+
struct grub_efi_simple_text_output_interface
{
grub_efi_status_t
@@ -1488,17 +1613,31 @@ enum
GRUB_EFI_NETWORK_INITIALIZED,
};
+enum
+ {
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST = 0x01,
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST = 0x02,
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST = 0x04,
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS = 0x08,
+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST = 0x10,
+ };
+
struct grub_efi_simple_network
{
grub_uint64_t revision;
grub_efi_status_t (*start) (struct grub_efi_simple_network *this);
- void (*stop) (void);
+ grub_efi_status_t (*stop) (struct grub_efi_simple_network *this);
grub_efi_status_t (*initialize) (struct grub_efi_simple_network *this,
grub_efi_uintn_t extra_rx,
grub_efi_uintn_t extra_tx);
void (*reset) (void);
- void (*shutdown) (void);
- void (*receive_filters) (void);
+ grub_efi_status_t (*shutdown) (struct grub_efi_simple_network *this);
+ grub_efi_status_t (*receive_filters) (struct grub_efi_simple_network *this,
+ grub_uint32_t enable,
+ grub_uint32_t disable,
+ grub_efi_boolean_t reset_mcast_filter,
+ grub_efi_uintn_t mcast_filter_count,
+ grub_efi_mac_address_t *mcast_filter);
void (*station_address) (void);
void (*statistics) (void);
void (*mcastiptomac) (void);
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index 489cf9e6d..0e6fd86b0 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -53,6 +53,10 @@ 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_efi_device_path_t *
+EXPORT_FUNC(grub_efi_find_last_device_path) (const grub_efi_device_path_t *dp);
+grub_efi_device_path_t *
+EXPORT_FUNC(grub_efi_duplicate_device_path) (const grub_efi_device_path_t *dp);
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,
diff --git a/include/grub/elf.h b/include/grub/elf.h
index caa796390..db15acecf 100644
--- a/include/grub/elf.h
+++ b/include/grub/elf.h
@@ -2068,6 +2068,9 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_AARCH64_NONE 0 /* No relocation. */
#define R_AARCH64_ABS64 257 /* Direct 64 bit. */
#define R_AARCH64_ABS32 258 /* Direct 32 bit. */
+#define R_AARCH64_ADR_PREL_PG_HI21 275
+#define R_AARCH64_ADD_ABS_LO12_NC 277
+#define R_AARCH64_LDST64_ABS_LO12_NC 286
#define R_AARCH64_JUMP26 282 /* 26-bit relative. */
#define R_AARCH64_CALL26 283 /* 26-bit relative. */
#define R_AARCH64_COPY 1024 /* Copy symbol at runtime. */
diff --git a/include/grub/emu/hostdisk.h b/include/grub/emu/hostdisk.h
index ba0034d5f..e006f0b38 100644
--- a/include/grub/emu/hostdisk.h
+++ b/include/grub/emu/hostdisk.h
@@ -61,7 +61,7 @@ char *
grub_util_get_os_disk (const char *os_dev);
int
-grub_util_get_dm_node_linear_info (const char *dev,
+grub_util_get_dm_node_linear_info (dev_t dev,
int *maj, int *min,
grub_disk_addr_t *st);
@@ -75,6 +75,12 @@ grub_hostdisk_find_partition_start_os (const char *dev);
void
grub_hostdisk_flush_initial_buffer (const char *os_dev);
+#ifdef __GNU__
+int
+grub_util_hurd_get_disk_info (const char *dev, grub_uint32_t *secsize, grub_disk_addr_t *offset,
+ grub_disk_addr_t *size, char **parent);
+#endif
+
struct grub_util_hostdisk_data
{
char *dev;
diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h
index dde48c192..df6085bcb 100644
--- a/include/grub/emu/misc.h
+++ b/include/grub/emu/misc.h
@@ -27,6 +27,7 @@
#include <grub/symbol.h>
#include <grub/types.h>
#include <grub/misc.h>
+#include <grub/util/misc.h>
extern int verbosity;
extern const char *program_name;
@@ -53,16 +54,14 @@ grub_util_device_is_mapped (const char *dev);
void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT;
void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT;
char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT;
-char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) WARN_UNUSED_RESULT;
+char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))) WARN_UNUSED_RESULT;
-void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2), noreturn));
+void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2)));
+void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2)));
+void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2), noreturn));
grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void);
-extern char * canonicalize_file_name (const char *path);
-
#ifdef HAVE_DEVICE_MAPPER
int grub_device_mapper_supported (void);
#endif
diff --git a/include/grub/err.h b/include/grub/err.h
index 9896fccf9..1590c688e 100644
--- a/include/grub/err.h
+++ b/include/grub/err.h
@@ -91,6 +91,6 @@ 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)));
+ __attribute__ ((format (__printf__, 1, 2)));
#endif /* ! GRUB_ERR_HEADER */
diff --git a/include/grub/fdt.h b/include/grub/fdt.h
index 2ad0536b6..fdfca75bf 100644
--- a/include/grub/fdt.h
+++ b/include/grub/fdt.h
@@ -36,6 +36,19 @@ typedef struct {
grub_uint32_t size_dt_struct;
} grub_fdt_header_t;
+struct grub_fdt_empty_tree {
+ grub_fdt_header_t header;
+ grub_uint64_t empty_rsvmap[2];
+ struct {
+ grub_uint32_t node_start;
+ grub_uint8_t name[1];
+ grub_uint32_t node_end;
+ grub_uint32_t tree_end;
+ } empty_node;
+};
+
+#define GRUB_FDT_EMPTY_TREE_SZ sizeof (struct grub_fdt_empty_tree)
+
#define grub_fdt_get_header(fdt, field) \
grub_be_to_cpu32(((const grub_fdt_header_t *)(fdt))->field)
#define grub_fdt_set_header(fdt, field, value) \
@@ -82,7 +95,9 @@ typedef struct {
#define grub_fdt_set_size_dt_struct(fdt, value) \
grub_fdt_set_header(fdt, size_dt_struct, value)
+int grub_fdt_create_empty_tree (void *fdt, unsigned int size);
int grub_fdt_check_header (void *fdt, unsigned int size);
+int grub_fdt_check_header_nosize (void *fdt);
int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset,
const char *name);
int grub_fdt_add_subnode (void *fdt, unsigned int parentoffset,
@@ -96,4 +111,22 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name,
grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 4); \
})
+#define grub_fdt_set_prop64(fdt, nodeoffset, name, val) \
+({ \
+ grub_uint64_t _val = grub_cpu_to_be64(val); \
+ grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 8); \
+})
+
+/* Setup "reg" property for
+ * #address-cells = <0x2>
+ * #size-cells = <0x2>
+ */
+#define grub_fdt_set_reg64(fdt, nodeoffset, addr, size) \
+({ \
+ grub_uint64_t reg_64[2]; \
+ reg_64[0] = grub_cpu_to_be64(addr); \
+ reg_64[1] = grub_cpu_to_be64(size); \
+ grub_fdt_set_prop ((fdt), (nodeoffset), "reg", reg_64, 16); \
+})
+
#endif /* ! GRUB_FDT_HEADER */
diff --git a/include/grub/fshelp.h b/include/grub/fshelp.h
index 38923044c..eb1ba4f6c 100644
--- a/include/grub/fshelp.h
+++ b/include/grub/fshelp.h
@@ -62,6 +62,17 @@ EXPORT_FUNC(grub_fshelp_find_file) (const char *path,
enum grub_fshelp_filetype expect);
+grub_err_t
+EXPORT_FUNC(grub_fshelp_find_file_lookup) (const char *path,
+ grub_fshelp_node_t rootnode,
+ grub_fshelp_node_t *foundnode,
+ grub_err_t (*lookup_file) (grub_fshelp_node_t dir,
+ const char *name,
+ grub_fshelp_node_t *foundnode,
+ enum grub_fshelp_filetype *foundtype),
+ 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
diff --git a/include/grub/hfsplus.h b/include/grub/hfsplus.h
index 75c9d18a3..117740ae2 100644
--- a/include/grub/hfsplus.h
+++ b/include/grub/hfsplus.h
@@ -171,7 +171,7 @@ struct grub_hfsplus_catkey
grub_uint16_t keylen;
grub_uint32_t parent;
grub_uint16_t namelen;
- grub_uint16_t name[30];
+ grub_uint16_t name[0];
} GRUB_PACKED;
/* The on disk layout of an extent overflow file key. */
@@ -207,12 +207,14 @@ struct grub_hfsplus_btnode
/* Return the offset of the record with the index INDEX, in the node
NODE which is part of the B+ tree BTREE. */
-static inline grub_off_t
+static inline grub_uint16_t
grub_hfsplus_btree_recoffset (struct grub_hfsplus_btree *btree,
- struct grub_hfsplus_btnode *node, int index)
+ struct grub_hfsplus_btnode *node, unsigned index)
{
char *cnode = (char *) node;
void *recptr;
+ if (btree->nodesize < index * sizeof (grub_uint16_t) + 2)
+ index = 0;
recptr = (&cnode[btree->nodesize - index * sizeof (grub_uint16_t) - 2]);
return grub_be_to_cpu16 (grub_get_unaligned16 (recptr));
}
@@ -221,11 +223,13 @@ grub_hfsplus_btree_recoffset (struct grub_hfsplus_btree *btree,
NODE which is part of the B+ tree BTREE. */
static inline struct grub_hfsplus_key *
grub_hfsplus_btree_recptr (struct grub_hfsplus_btree *btree,
- struct grub_hfsplus_btnode *node, int index)
+ struct grub_hfsplus_btnode *node, unsigned index)
{
char *cnode = (char *) node;
- grub_off_t offset;
+ grub_uint16_t offset;
offset = grub_hfsplus_btree_recoffset (btree, node, index);
+ if (offset > btree->nodesize - sizeof (struct grub_hfsplus_key))
+ offset = 0;
return (struct grub_hfsplus_key *) &cnode[offset];
}
@@ -247,7 +251,7 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
struct grub_hfsplus_btnode **matchnode,
grub_off_t *keyoffset);
grub_err_t
-grub_mac_bless_inode (grub_device_t dev, grub_uint64_t inode, int is_dir,
+grub_mac_bless_inode (grub_device_t dev, grub_uint32_t inode, int is_dir,
int intel);
grub_err_t
grub_mac_bless_file (grub_device_t dev, const char *path_in, int intel);
diff --git a/include/grub/i386/netbsd_bootinfo.h b/include/grub/i386/netbsd_bootinfo.h
index e48c19b40..9b4f46041 100644
--- a/include/grub/i386/netbsd_bootinfo.h
+++ b/include/grub/i386/netbsd_bootinfo.h
@@ -58,6 +58,8 @@
#define NETBSD_BTINFO_BOOTWEDGE 10
#define NETBSD_BTINFO_MODULES 11
#define NETBSD_BTINFO_FRAMEBUF 12
+#define NETBSD_BTINFO_USERCONFCOMMANDS 13
+#define NETBSD_BTINFO_EFI 14
struct grub_netbsd_bootinfo
{
@@ -146,4 +148,9 @@ struct grub_netbsd_btinfo_framebuf
#define GRUB_NETBSD_MAX_ROOTDEVICE_LEN 16
+struct grub_netbsd_btinfo_efi
+{
+ void *pa_systbl; /* Physical address of the EFI System Table */
+};
+
#endif
diff --git a/include/grub/i386/openbsd_bootarg.h b/include/grub/i386/openbsd_bootarg.h
index 01ca4868b..9ebe6b4e4 100644
--- a/include/grub/i386/openbsd_bootarg.h
+++ b/include/grub/i386/openbsd_bootarg.h
@@ -75,6 +75,8 @@ struct grub_openbsd_bootarg_console
{
grub_uint32_t device;
grub_uint32_t speed;
+ grub_uint32_t addr;
+ grub_uint32_t frequency;
};
struct grub_openbsd_bootarg_pcibios
diff --git a/include/grub/i386/pmtimer.h b/include/grub/i386/pmtimer.h
new file mode 100644
index 000000000..ac091806a
--- /dev/null
+++ b/include/grub/i386/pmtimer.h
@@ -0,0 +1,37 @@
+/*
+ * 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_PMTIMER_HEADER
+#define KERNEL_CPU_PMTIMER_HEADER 1
+
+#include <grub/i386/tsc.h>
+#include <grub/i386/io.h>
+
+/*
+ Preconditions:
+ * Caller has ensured that both pmtimer and tsc are supported
+ * 1 <= num_pm_ticks <= 3580
+ Return:
+ * Number of TSC ticks elapsed
+ * 0 on failure.
+*/
+grub_uint64_t
+EXPORT_FUNC(grub_pmtimer_wait_count_tsc) (grub_port_t pmtimer,
+ grub_uint16_t num_pm_ticks);
+
+#endif
diff --git a/include/grub/i386/tsc.h b/include/grub/i386/tsc.h
index 71b32e6b8..a0aa2c573 100644
--- a/include/grub/i386/tsc.h
+++ b/include/grub/i386/tsc.h
@@ -20,9 +20,51 @@
#define KERNEL_CPU_TSC_HEADER 1
#include <grub/types.h>
+#include <grub/i386/cpuid.h>
void grub_tsc_init (void);
/* In ms per 2^32 ticks. */
extern grub_uint32_t EXPORT_VAR(grub_tsc_rate);
+int
+grub_tsc_calibrate_from_xen (void);
+int
+grub_tsc_calibrate_from_efi (void);
+int
+grub_tsc_calibrate_from_pmtimer (void);
+int
+grub_tsc_calibrate_from_pit (void);
+
+/* 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;
+ grub_uint32_t a,b,c,d;
+
+ /* The CPUID instruction is a 'serializing' instruction, and
+ avoids out-of-order execution of the RDTSC instruction. */
+ grub_cpuid (0,a,b,c,d);
+ /* 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;
+}
+
+static __inline int
+grub_cpu_is_tsc_supported (void)
+{
+#ifndef GRUB_MACHINE_XEN
+ grub_uint32_t a,b,c,d;
+ if (! grub_cpu_is_cpuid_supported ())
+ return 0;
+
+ grub_cpuid(1,a,b,c,d);
+
+ return (d & (1 << 4)) != 0;
+#else
+ return 1;
+#endif
+}
#endif /* ! KERNEL_CPU_TSC_HEADER */
diff --git a/include/grub/i386/xnu.h b/include/grub/i386/xnu.h
index a076b8a97..062a7ddbe 100644
--- a/include/grub/i386/xnu.h
+++ b/include/grub/i386/xnu.h
@@ -89,7 +89,8 @@ struct grub_xnu_boot_params_v2
grub_uint64_t efi_runtime_first_page_virtual;
grub_uint32_t efi_system_table;
- grub_uint32_t unused2[11];
+ grub_uint32_t unused2[9];
+ grub_uint64_t ram_size;
grub_uint64_t fsbfreq;
grub_uint32_t unused3[734];
} GRUB_PACKED;
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
index dc54beabb..8e4251303 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -70,8 +70,9 @@ struct grub_ieee1275_devalias
};
extern void (*EXPORT_VAR(grub_ieee1275_net_config)) (const char *dev,
- char **device,
- char **path);
+ char **device,
+ char **path,
+ char *bootargs);
/* Maps a device alias to a pathname. */
extern grub_ieee1275_phandle_t EXPORT_VAR(grub_ieee1275_chosen);
diff --git a/include/grub/ieee1275/ofdisk.h b/include/grub/ieee1275/ofdisk.h
index 3f5831787..2f69e3f19 100644
--- a/include/grub/ieee1275/ofdisk.h
+++ b/include/grub/ieee1275/ofdisk.h
@@ -22,7 +22,4 @@
extern void grub_ofdisk_init (void);
extern void grub_ofdisk_fini (void);
-extern grub_err_t grub_ofdisk_get_block_size (const char *device,
- grub_uint32_t *block_size);
-
#endif /* ! GRUB_INIT_HEADER */
diff --git a/include/grub/libgcc.h b/include/grub/libgcc.h
deleted file mode 100644
index fdc6611a0..000000000
--- a/include/grub/libgcc.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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_*. */
-#ifndef __STDC_VERSION__
-#define __STDC_VERSION__ 0
-#endif
-#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
-# ifdef HAVE___CTZDI2
-void EXPORT_FUNC (__ctzdi2) (void);
-# endif
-# ifdef HAVE___CTZSI2
-void EXPORT_FUNC (__ctzsi2) (void);
-# endif
-#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
-
-#if defined (__arm__)
-void EXPORT_FUNC (__aeabi_lasr) (void);
-void EXPORT_FUNC (__aeabi_llsl) (void);
-void EXPORT_FUNC (__aeabi_llsr) (void);
-void EXPORT_FUNC (__aeabi_ulcmp) (void);
-#endif
diff --git a/include/grub/list.h b/include/grub/list.h
index edd20adfd..d170ff6da 100644
--- a/include/grub/list.h
+++ b/include/grub/list.h
@@ -21,8 +21,8 @@
#define GRUB_LIST_HEADER 1
#include <grub/symbol.h>
-#include <grub/types.h>
-#include <grub/misc.h>
+#include <grub/err.h>
+#include <grub/compiler.h>
struct grub_list
{
diff --git a/include/grub/memory.h b/include/grub/memory.h
index 083cfb680..6da114a1b 100644
--- a/include/grub/memory.h
+++ b/include/grub/memory.h
@@ -30,6 +30,8 @@ typedef enum grub_memory_type
GRUB_MEMORY_ACPI = 3,
GRUB_MEMORY_NVS = 4,
GRUB_MEMORY_BADRAM = 5,
+ GRUB_MEMORY_PERSISTENT = 7,
+ GRUB_MEMORY_PERSISTENT_LEGACY = 12,
GRUB_MEMORY_COREBOOT_TABLES = 16,
GRUB_MEMORY_CODE = 20,
/* This one is special: it's used internally but is never reported
diff --git a/include/grub/mips/asm.h b/include/grub/mips/asm.h
new file mode 100644
index 000000000..4c397f4a0
--- /dev/null
+++ b/include/grub/mips/asm.h
@@ -0,0 +1,18 @@
+#ifndef GRUB_MIPS_ASM_HEADER
+#define GRUB_MIPS_ASM_HEADER 1
+
+#if defined(_MIPS_SIM) && defined(_ABIN32) && _MIPS_SIM == _ABIN32
+#define GRUB_ASM_T4 $a4
+#define GRUB_ASM_T5 $a5
+#define GRUB_ASM_SZREG 8
+#define GRUB_ASM_REG_S sd
+#define GRUB_ASM_REG_L ld
+#else
+#define GRUB_ASM_T4 $t4
+#define GRUB_ASM_T5 $t5
+#define GRUB_ASM_SZREG 4
+#define GRUB_ASM_REG_S sw
+#define GRUB_ASM_REG_L lw
+#endif
+
+#endif
diff --git a/include/grub/mips/setjmp.h b/include/grub/mips/setjmp.h
index a99dde9ef..f8f6517ac 100644
--- a/include/grub/mips/setjmp.h
+++ b/include/grub/mips/setjmp.h
@@ -19,7 +19,7 @@
#ifndef GRUB_SETJMP_CPU_HEADER
#define GRUB_SETJMP_CPU_HEADER 1
-typedef unsigned long grub_jmp_buf[12];
+typedef grub_uint64_t grub_jmp_buf[12];
int grub_setjmp (grub_jmp_buf env) RETURNS_TWICE;
void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn));
diff --git a/include/grub/misc.h b/include/grub/misc.h
index af8e40480..2a9f87cc2 100644
--- a/include/grub/misc.h
+++ b/include/grub/misc.h
@@ -25,34 +25,7 @@
#include <grub/symbol.h>
#include <grub/err.h>
#include <grub/i18n.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) __attribute__ ((noreturn))
-#endif
-
-#if GNUC_PREREQ(4,4)
-# define GNU_PRINTF gnu_printf
-#else
-# define GNU_PRINTF printf
-#endif
-
-#if GNUC_PREREQ(3,4)
-# define WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
-#else
-# define WARN_UNUSED_RESULT
-#endif
+#include <grub/compiler.h>
#define ALIGN_UP(addr, align) \
((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1))
@@ -98,12 +71,6 @@ grub_memcpy (void *dest, const void *src, grub_size_t n)
return grub_memmove (dest, src, n);
}
-#if defined (__APPLE__) && defined(__i386__) && !defined (GRUB_UTIL)
-#define GRUB_BUILTIN_ATTR __attribute__ ((regparm(0)))
-#else
-#define GRUB_BUILTIN_ATTR
-#endif
-
#if defined(__x86_64__) && !defined (GRUB_UTIL)
#if defined (__MINGW32__) || defined (__CYGWIN__) || defined (__MINGW64__)
#define GRUB_ASM_ATTR __attribute__ ((sysv_abi))
@@ -112,19 +79,6 @@ grub_memcpy (void *dest, const void *src, grub_size_t n)
#endif
#endif
-/* Prototypes for aliases. */
-#ifndef GRUB_UTIL
-int GRUB_BUILTIN_ATTR EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n);
-void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n);
-void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n);
-void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memset) (void *s, int c, grub_size_t n);
-
-#ifdef __APPLE__
-void GRUB_BUILTIN_ATTR EXPORT_FUNC (__bzero) (void *s, grub_size_t n);
-#endif
-
-#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);
@@ -296,7 +250,7 @@ static inline long
grub_strtol (const char *str, char **end, int base)
{
int negative = 0;
- unsigned long magnitude;
+ unsigned long long magnitude;
while (*str && grub_isspace (*str))
str++;
@@ -385,13 +339,37 @@ grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
grub_uint64_t d,
grub_uint64_t *r);
-#if (defined (__MINGW32__) || defined (__CYGWIN__)) && !defined(GRUB_UTIL)
-void EXPORT_FUNC (__register_frame_info) (void);
-void EXPORT_FUNC (__deregister_frame_info) (void);
-void EXPORT_FUNC (___chkstk_ms) (void);
-void EXPORT_FUNC (__chkstk_ms) (void);
+/* Must match softdiv group in gentpl.py. */
+#if !defined(GRUB_MACHINE_EMU) && (defined(__arm__) || defined(__ia64__))
+#define GRUB_DIVISION_IN_SOFTWARE 1
+#else
+#define GRUB_DIVISION_IN_SOFTWARE 0
+#endif
+
+/* Some division functions need to be in kernel if compiler generates calls
+ to them. Otherwise we still need them for consistent tests but they go
+ into a separate module. */
+#if GRUB_DIVISION_IN_SOFTWARE
+#define EXPORT_FUNC_IF_SOFTDIV EXPORT_FUNC
+#else
+#define EXPORT_FUNC_IF_SOFTDIV(x) x
#endif
+grub_int64_t
+EXPORT_FUNC_IF_SOFTDIV(grub_divmod64s) (grub_int64_t n,
+ grub_int64_t d,
+ grub_int64_t *r);
+
+grub_uint32_t
+EXPORT_FUNC_IF_SOFTDIV (grub_divmod32) (grub_uint32_t n,
+ grub_uint32_t d,
+ grub_uint32_t *r);
+
+grub_int32_t
+EXPORT_FUNC_IF_SOFTDIV (grub_divmod32s) (grub_int32_t n,
+ grub_int32_t d,
+ grub_int32_t *r);
+
/* Inline functions. */
static inline char *
@@ -417,13 +395,6 @@ grub_abs (int x)
return (unsigned int) x;
}
-/* Rounded-up division */
-static inline unsigned int
-grub_div_roundup (unsigned int x, unsigned int y)
-{
- return (x + y - 1) / y;
-}
-
/* Reboot the machine. */
#if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS)
void EXPORT_FUNC(grub_reboot) (void) __attribute__ ((noreturn));
@@ -467,57 +438,6 @@ grub_error_load (const struct grub_error_saved *save)
grub_errno = save->grub_errno;
}
-#ifndef GRUB_UTIL
-
-#if defined (__arm__)
-
-grub_uint32_t
-EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b);
-
-grub_uint32_t
-EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b);
-
-#endif
-
-#if defined (__sparc__) || defined (__powerpc__)
-unsigned
-EXPORT_FUNC (__ctzdi2) (grub_uint64_t x);
-#define NEED_CTZDI2 1
-#endif
-
-#if defined (__mips__) || defined (__arm__)
-unsigned
-EXPORT_FUNC (__ctzsi2) (grub_uint32_t x);
-#define NEED_CTZSI2 1
-#endif
-
-#ifdef __arm__
-grub_uint32_t
-EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b);
-grub_uint32_t
-EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b);
-
-/* Needed for allowing modules to be compiled as thumb. */
-grub_uint64_t
-EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b);
-grub_uint64_t
-EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b);
-
-#endif
-
-#if defined (__ia64__)
-
-grub_uint64_t
-EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b);
-
-grub_uint64_t
-EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b);
-
-#endif
-
-#endif /* GRUB_UTIL */
-
-
#if BOOT_TIME_STATS
struct grub_boot_time
{
diff --git a/include/grub/module_verifier.h b/include/grub/module_verifier.h
new file mode 100644
index 000000000..6cddff30f
--- /dev/null
+++ b/include/grub/module_verifier.h
@@ -0,0 +1,20 @@
+#include <stdint.h>
+#include <stdlib.h>
+
+#include <grub/types.h>
+
+#define GRUB_MODULE_VERIFY_SUPPORTS_REL 1
+#define GRUB_MODULE_VERIFY_SUPPORTS_RELA 2
+
+struct grub_module_verifier_arch {
+ const char *name;
+ int voidp_sizeof;
+ int bigendian;
+ int machine;
+ int flags;
+ const int *supported_relocations;
+ const int *short_relocations;
+};
+
+void grub_module_verify64(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch);
+void grub_module_verify32(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch);
diff --git a/include/grub/net.h b/include/grub/net.h
index de6259ee1..2192fa186 100644
--- a/include/grub/net.h
+++ b/include/grub/net.h
@@ -191,6 +191,18 @@ typedef struct grub_net_network_level_netaddress
};
} grub_net_network_level_netaddress_t;
+struct grub_net_route
+{
+ struct grub_net_route *next;
+ struct grub_net_route **prev;
+ grub_net_network_level_netaddress_t target;
+ char *name;
+ struct grub_net_network_level_protocol *prot;
+ int is_gateway;
+ struct grub_net_network_level_interface *interface;
+ grub_net_network_level_address_t gw;
+};
+
#define FOR_PACKETS(cont,var) for (var = (cont).first; var; var = var->next)
static inline grub_err_t
@@ -367,6 +379,16 @@ grub_net_card_unregister (struct grub_net_card *card);
#define FOR_NET_CARDS_SAFE(var, next) for (var = grub_net_cards, next = (var ? var->next : 0); var; var = next, next = (var ? var->next : 0))
+extern struct grub_net_route *grub_net_routes;
+
+static inline void
+grub_net_route_register (struct grub_net_route *route)
+{
+ grub_list_push (GRUB_AS_LIST_P (&grub_net_routes),
+ GRUB_AS_LIST (route));
+}
+
+#define FOR_NET_ROUTES(var) for (var = grub_net_routes; var; var = var->next)
struct grub_net_session *
grub_net_open_tcp (char *address, grub_uint16_t port);
@@ -392,7 +414,8 @@ grub_net_add_route (const char *name,
grub_err_t
grub_net_add_route_gw (const char *name,
grub_net_network_level_netaddress_t target,
- grub_net_network_level_address_t gw);
+ grub_net_network_level_address_t gw,
+ struct grub_net_network_level_interface *inter);
#define GRUB_NET_BOOTP_MAC_ADDR_LEN 16
@@ -480,6 +503,10 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target,
void
grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str);
+grub_err_t
+grub_env_set_net_property (const char *intername, const char *suffix,
+ const char *value, grub_size_t len);
+
void
grub_net_poll_cards (unsigned time, int *stop_condition);
@@ -532,5 +559,6 @@ extern char *grub_net_default_server;
#define GRUB_NET_TRIES 40
#define GRUB_NET_INTERVAL 400
+#define GRUB_NET_INTERVAL_ADDITION 20
#endif /* ! GRUB_NET_HEADER */
diff --git a/include/grub/net/ip.h b/include/grub/net/ip.h
index 7a8e61479..dcceaa568 100644
--- a/include/grub/net/ip.h
+++ b/include/grub/net/ip.h
@@ -92,4 +92,6 @@ grub_err_t
grub_net_icmp6_send_request (struct grub_net_network_level_interface *inf,
const grub_net_network_level_address_t *proto_addr);
+grub_err_t
+grub_net_icmp6_send_router_solicit (struct grub_net_network_level_interface *inf);
#endif
diff --git a/include/grub/net/netbuff.h b/include/grub/net/netbuff.h
index 9ac168c89..1177c1220 100644
--- a/include/grub/net/netbuff.h
+++ b/include/grub/net/netbuff.h
@@ -25,6 +25,7 @@ grub_err_t grub_netbuff_pull (struct grub_net_buff *net_buff, grub_size_t len);
grub_err_t grub_netbuff_reserve (struct grub_net_buff *net_buff, grub_size_t len);
grub_err_t grub_netbuff_clear (struct grub_net_buff *net_buff);
struct grub_net_buff * grub_netbuff_alloc (grub_size_t len);
+struct grub_net_buff * grub_netbuff_make_pkt (grub_size_t len);
void grub_netbuff_free (struct grub_net_buff *net_buff);
#endif
diff --git a/include/grub/normal.h b/include/grub/normal.h
index c4ab193b3..218cbabcc 100644
--- a/include/grub/normal.h
+++ b/include/grub/normal.h
@@ -66,7 +66,7 @@ void grub_menu_init_page (int nested, int edit,
struct grub_term_output *term);
void grub_normal_init_page (struct grub_term_output *term, int y);
char *grub_file_getline (grub_file_t file);
-void grub_cmdline_run (int nested);
+void grub_cmdline_run (int nested, int force_auth);
/* Defined in `cmdline.c'. */
char *grub_cmdline_get (const char *prompt);
diff --git a/include/grub/offsets.h b/include/grub/offsets.h
index 85e7401ae..c88c86d4d 100644
--- a/include/grub/offsets.h
+++ b/include/grub/offsets.h
@@ -54,6 +54,7 @@
/* The offset of GRUB_TOTAL_MODULE_SIZE. */
#define GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE 0x8
+#define GRUB_KERNEL_ARM_STACK_SIZE 0x40000
#define GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE 12
@@ -120,7 +121,6 @@
#define GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN 0x8
#define GRUB_KERNEL_ARM_UBOOT_TOTAL_MODULE_SIZE 0x4
-#define GRUB_KERNEL_ARM_UBOOT_LINK_ADDR 0x08000000
/* 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
diff --git a/include/grub/osdep/hostfile_aros.h b/include/grub/osdep/hostfile_aros.h
index 4ec211b48..a059c0fa4 100644
--- a/include/grub/osdep/hostfile_aros.h
+++ b/include/grub/osdep/hostfile_aros.h
@@ -68,7 +68,7 @@ grub_util_rename (const char *from, const char *to)
return rename (from, to);
}
-#define grub_util_mkdir(a) mkdir (a, 0700)
+#define grub_util_mkdir(a) mkdir ((a), 0755)
struct grub_util_fd
{
diff --git a/include/grub/osdep/hostfile_unix.h b/include/grub/osdep/hostfile_unix.h
index e4e89398c..9ffe46fa3 100644
--- a/include/grub/osdep/hostfile_unix.h
+++ b/include/grub/osdep/hostfile_unix.h
@@ -71,7 +71,7 @@ grub_util_rename (const char *from, const char *to)
return rename (from, to);
}
-#define grub_util_mkdir(a) mkdir ((a), 0700)
+#define grub_util_mkdir(a) mkdir ((a), 0755)
#if defined (__NetBSD__)
/* NetBSD uses /boot for its boot block. */
diff --git a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h
index 36615b2c4..bf6451b6d 100644
--- a/include/grub/osdep/hostfile_windows.h
+++ b/include/grub/osdep/hostfile_windows.h
@@ -69,8 +69,11 @@ enum grub_util_fd_open_flags_t
#if defined (__MINGW32__) && !defined (__MINGW64__)
+/* 32 bit on Mingw-w64 already redefines them if _FILE_OFFSET_BITS=64 */
+#ifndef _W64
#define fseeko fseeko64
#define ftello ftello64
+#endif
#endif
diff --git a/include/grub/procfs.h b/include/grub/procfs.h
index d393da77f..8cc331d94 100644
--- a/include/grub/procfs.h
+++ b/include/grub/procfs.h
@@ -20,6 +20,7 @@
#define GRUB_PROCFS_HEADER 1
#include <grub/list.h>
+#include <grub/types.h>
struct grub_procfs_entry
{
diff --git a/include/grub/random.h b/include/grub/random.h
new file mode 100644
index 000000000..4b75c0e2b
--- /dev/null
+++ b/include/grub/random.h
@@ -0,0 +1,33 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2016 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more 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_RANDOM_HEADER
+#define GRUB_RANDOM_HEADER 1
+
+#include <grub/types.h>
+#include <grub/err.h>
+
+/* Not peer-reviewed. May not be any better than string of zeros. */
+grub_err_t
+grub_crypto_get_random (void *buffer, grub_size_t sz);
+
+/* Do not use directly. Use grub_crypto_get_random instead. */
+int
+grub_crypto_arch_get_random (void *buffer, grub_size_t sz);
+
+#endif
diff --git a/include/grub/term.h b/include/grub/term.h
index 528c53008..5ffb38f69 100644
--- a/include/grub/term.h
+++ b/include/grub/term.h
@@ -334,12 +334,12 @@ void grub_term_restore_pos (struct grub_term_coordinate *pos);
static inline unsigned grub_term_width (struct grub_term_output *term)
{
- return term->getwh(term).x;
+ return term->getwh(term).x ? : 80;
}
static inline unsigned grub_term_height (struct grub_term_output *term)
{
- return term->getwh(term).y;
+ return term->getwh(term).y ? : 24;
}
static inline struct grub_term_coordinate
@@ -405,7 +405,7 @@ grub_unicode_estimate_width (const struct grub_unicode_glyph *c);
#else
-static inline grub_ssize_t
+static inline grub_size_t
grub_unicode_estimate_width (const struct grub_unicode_glyph *c __attribute__ ((unused)))
{
if (grub_unicode_get_comb_type (c->base))
diff --git a/include/grub/time.h b/include/grub/time.h
index 64ac99a12..c919c1f0b 100644
--- a/include/grub/time.h
+++ b/include/grub/time.h
@@ -21,7 +21,7 @@
#include <grub/types.h>
#include <grub/symbol.h>
-#ifndef GRUB_MACHINE_EMU
+#if !defined(GRUB_MACHINE_EMU) && !defined(GRUB_UTIL)
#include <grub/cpu/time.h>
#else
static inline void
diff --git a/include/grub/types.h b/include/grub/types.h
index 79f765c62..b93e48201 100644
--- a/include/grub/types.h
+++ b/include/grub/types.h
@@ -179,7 +179,7 @@ static inline grub_uint16_t grub_swap_bytes16(grub_uint16_t _x)
| (_x >> 56)); \
})
-#if defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)
+#if (defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)) || defined(__clang__)
static inline grub_uint32_t grub_swap_bytes32(grub_uint32_t x)
{
return __builtin_bswap32(x);
@@ -254,55 +254,49 @@ static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t _x)
#endif /* ! WORDS_BIGENDIAN */
+struct grub_unaligned_uint16
+{
+ grub_uint16_t val;
+} GRUB_PACKED;
+struct grub_unaligned_uint32
+{
+ grub_uint32_t val;
+} GRUB_PACKED;
+struct grub_unaligned_uint64
+{
+ grub_uint64_t val;
+} GRUB_PACKED;
+
+typedef struct grub_unaligned_uint16 grub_unaligned_uint16_t;
+typedef struct grub_unaligned_uint32 grub_unaligned_uint32_t;
+typedef struct grub_unaligned_uint64 grub_unaligned_uint64_t;
+
static inline grub_uint16_t grub_get_unaligned16 (const void *ptr)
{
- struct grub_unaligned_uint16_t
- {
- grub_uint16_t d;
- } GRUB_PACKED;
- const struct grub_unaligned_uint16_t *dd
- = (const struct grub_unaligned_uint16_t *) ptr;
- return dd->d;
+ const struct grub_unaligned_uint16 *dd
+ = (const struct grub_unaligned_uint16 *) ptr;
+ return dd->val;
}
static inline void grub_set_unaligned16 (void *ptr, grub_uint16_t val)
{
- struct grub_unaligned_uint16_t
- {
- grub_uint16_t d;
- } GRUB_PACKED;
- struct grub_unaligned_uint16_t *dd = (struct grub_unaligned_uint16_t *) ptr;
- dd->d = val;
+ struct grub_unaligned_uint16 *dd = (struct grub_unaligned_uint16 *) ptr;
+ dd->val = val;
}
static inline grub_uint32_t grub_get_unaligned32 (const void *ptr)
{
- struct grub_unaligned_uint32_t
- {
- grub_uint32_t d;
- } GRUB_PACKED;
- const struct grub_unaligned_uint32_t *dd
- = (const struct grub_unaligned_uint32_t *) ptr;
- return dd->d;
+ const struct grub_unaligned_uint32 *dd
+ = (const struct grub_unaligned_uint32 *) ptr;
+ return dd->val;
}
static inline void grub_set_unaligned32 (void *ptr, grub_uint32_t val)
{
- struct grub_unaligned_uint32_t
- {
- grub_uint32_t d;
- } GRUB_PACKED;
- struct grub_unaligned_uint32_t *dd = (struct grub_unaligned_uint32_t *) ptr;
- dd->d = val;
+ struct grub_unaligned_uint32 *dd = (struct grub_unaligned_uint32 *) ptr;
+ dd->val = val;
}
-struct grub_unaligned_uint64
-{
- grub_uint64_t val;
-} GRUB_PACKED;
-
-typedef struct grub_unaligned_uint64 grub_unaligned_uint64_t;
-
static inline grub_uint64_t grub_get_unaligned64 (const void *ptr)
{
const struct grub_unaligned_uint64 *dd
diff --git a/include/grub/util/install.h b/include/grub/util/install.h
index bc987aadc..5ca4811cd 100644
--- a/include/grub/util/install.h
+++ b/include/grub/util/install.h
@@ -39,7 +39,7 @@
{ "locales", GRUB_INSTALL_OPTIONS_INSTALL_LOCALES, N_("LOCALES"),\
0, N_("install only LOCALES [default=all]"), 1 }, \
{ "compress", GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS, \
- "no,xz,gz,lzo", OPTION_ARG_OPTIONAL, \
+ "no|xz|gz|lzo", 0, \
N_("compress GRUB files [optional]"), 1 }, \
{"core-compress", GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS, \
"xz|none|auto", \
@@ -138,6 +138,8 @@ grub_install_get_platform_cpu (enum grub_install_plat platid);
const char *
grub_install_get_platform_platform (enum grub_install_plat platid);
+char *
+grub_install_get_platforms_string (void);
typedef enum {
GRUB_COMPRESSION_AUTO,
diff --git a/include/grub/util/misc.h b/include/grub/util/misc.h
index 192874d42..e9e0a6724 100644
--- a/include/grub/util/misc.h
+++ b/include/grub/util/misc.h
@@ -41,7 +41,7 @@ void grub_util_write_image_at (const void *img, size_t size, off_t offset,
char *make_system_path_relative_to_its_root (const char *path);
-char *canonicalize_file_name (const char *path);
+char *grub_canonicalize_file_name (const char *path);
void grub_util_init_nls (void);
diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h
new file mode 100644
index 000000000..2a4894213
--- /dev/null
+++ b/include/grub/util/mkimage.h
@@ -0,0 +1,185 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2013 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_UTIL_MKIMAGE_HEADER
+#define GRUB_UTIL_MKIMAGE_HEADER 1
+
+struct grub_mkimage_layout
+{
+ size_t exec_size;
+ size_t kernel_size;
+ size_t bss_size;
+ grub_uint64_t start_address;
+ void *reloc_section;
+ size_t reloc_size;
+ size_t align;
+ grub_size_t ia64jmp_off;
+ grub_size_t tramp_off;
+ grub_size_t ia64_got_off;
+ grub_size_t got_size;
+ unsigned ia64jmpnum;
+ grub_uint32_t bss_start;
+ grub_uint32_t end;
+};
+
+/* Private header. Use only in mkimage-related sources. */
+char *
+grub_mkimage_load_image32 (const char *kernel_path,
+ size_t total_module_size,
+ struct grub_mkimage_layout *layout,
+ const struct grub_install_image_target_desc *image_target);
+char *
+grub_mkimage_load_image64 (const char *kernel_path,
+ size_t total_module_size,
+ struct grub_mkimage_layout *layout,
+ const struct grub_install_image_target_desc *image_target);
+void
+grub_mkimage_generate_elf32 (const struct grub_install_image_target_desc *image_target,
+ int note, char **core_img, size_t *core_size,
+ Elf32_Addr target_addr, grub_size_t align,
+ size_t kernel_size, size_t bss_size);
+void
+grub_mkimage_generate_elf64 (const struct grub_install_image_target_desc *image_target,
+ int note, char **core_img, size_t *core_size,
+ Elf64_Addr target_addr, grub_size_t align,
+ size_t kernel_size, size_t bss_size);
+
+struct grub_install_image_target_desc
+{
+ const char *dirname;
+ const char *names[6];
+ grub_size_t voidp_sizeof;
+ int bigendian;
+ enum {
+ IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT,
+ IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_SPARC64_CDCORE,
+ IMAGE_I386_IEEE1275,
+ IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH,
+ IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC,
+ IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT, IMAGE_XEN, IMAGE_I386_PC_ELTORITO
+ } id;
+ enum
+ {
+ PLATFORM_FLAGS_NONE = 0,
+ PLATFORM_FLAGS_DECOMPRESSORS = 2,
+ PLATFORM_FLAGS_MODULES_BEFORE_KERNEL = 4,
+ } flags;
+ unsigned total_module_size;
+ unsigned decompressor_compressed_size;
+ unsigned decompressor_uncompressed_size;
+ unsigned decompressor_uncompressed_addr;
+ unsigned reloc_table_offset;
+ unsigned link_align;
+ grub_uint16_t elf_target;
+ unsigned section_align;
+ signed vaddr_offset;
+ grub_uint64_t link_addr;
+ unsigned mod_gap, mod_align;
+ grub_compression_t default_compression;
+ grub_uint16_t pe_target;
+};
+
+#define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x)))
+#define grub_host_to_target32(x) (grub_host_to_target32_real (image_target, (x)))
+#define grub_target_to_host64(x) (grub_target_to_host64_real (image_target, (x)))
+#define grub_host_to_target64(x) (grub_host_to_target64_real (image_target, (x)))
+#define grub_host_to_target_addr(x) (grub_host_to_target_addr_real (image_target, (x)))
+#define grub_target_to_host16(x) (grub_target_to_host16_real (image_target, (x)))
+#define grub_host_to_target16(x) (grub_host_to_target16_real (image_target, (x)))
+
+static inline grub_uint32_t
+grub_target_to_host32_real (const struct grub_install_image_target_desc *image_target,
+ grub_uint32_t in)
+{
+ if (image_target->bigendian)
+ return grub_be_to_cpu32 (in);
+ else
+ return grub_le_to_cpu32 (in);
+}
+
+static inline grub_uint64_t
+grub_target_to_host64_real (const struct grub_install_image_target_desc *image_target,
+ grub_uint64_t in)
+{
+ if (image_target->bigendian)
+ return grub_be_to_cpu64 (in);
+ else
+ return grub_le_to_cpu64 (in);
+}
+
+static inline grub_uint64_t
+grub_host_to_target64_real (const struct grub_install_image_target_desc *image_target,
+ grub_uint64_t in)
+{
+ if (image_target->bigendian)
+ return grub_cpu_to_be64 (in);
+ else
+ return grub_cpu_to_le64 (in);
+}
+
+static inline grub_uint32_t
+grub_host_to_target32_real (const struct grub_install_image_target_desc *image_target,
+ grub_uint32_t in)
+{
+ if (image_target->bigendian)
+ return grub_cpu_to_be32 (in);
+ else
+ return grub_cpu_to_le32 (in);
+}
+
+static inline grub_uint16_t
+grub_target_to_host16_real (const struct grub_install_image_target_desc *image_target,
+ grub_uint16_t in)
+{
+ if (image_target->bigendian)
+ return grub_be_to_cpu16 (in);
+ else
+ return grub_le_to_cpu16 (in);
+}
+
+static inline grub_uint16_t
+grub_host_to_target16_real (const struct grub_install_image_target_desc *image_target,
+ grub_uint16_t in)
+{
+ if (image_target->bigendian)
+ return grub_cpu_to_be16 (in);
+ else
+ return grub_cpu_to_le16 (in);
+}
+
+static inline grub_uint64_t
+grub_host_to_target_addr_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in)
+{
+ if (image_target->voidp_sizeof == 8)
+ return grub_host_to_target64_real (image_target, in);
+ else
+ return grub_host_to_target32_real (image_target, in);
+}
+
+static inline grub_uint64_t
+grub_target_to_host_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in)
+{
+ if (image_target->voidp_sizeof == 8)
+ return grub_target_to_host64_real (image_target, in);
+ else
+ return grub_target_to_host32_real (image_target, in);
+}
+
+#define grub_target_to_host(val) grub_target_to_host_real(image_target, (val))
+
+#endif
diff --git a/include/grub/util/resolve.h b/include/grub/util/resolve.h
index f42df32f9..8923a6e6c 100644
--- a/include/grub/util/resolve.h
+++ b/include/grub/util/resolve.h
@@ -31,5 +31,6 @@ struct grub_util_path_list *
grub_util_resolve_dependencies (const char *prefix,
const char *dep_list_file,
char *modules[]);
+void grub_util_free_path_list (struct grub_util_path_list *path_list);
#endif /* ! GRUB_UTIL_RESOLVE_HEADER */
diff --git a/include/grub/video.h b/include/grub/video.h
index 778012e08..52c3fd71e 100644
--- a/include/grub/video.h
+++ b/include/grub/video.h
@@ -552,7 +552,7 @@ grub_video_check_mode_flag (grub_video_mode_type_t flags,
grub_video_driver_id_t EXPORT_FUNC (grub_video_get_driver_id) (void);
static __inline grub_video_rgba_color_t
-grub_video_rgba_color_rgb (int r, int g, int b)
+grub_video_rgba_color_rgb (grub_uint8_t r, grub_uint8_t g, grub_uint8_t b)
{
grub_video_rgba_color_t c;
c.red = r;
diff --git a/include/grub/x86_64/types.h b/include/grub/x86_64/types.h
index fec910952..0bbdc6d01 100644
--- a/include/grub/x86_64/types.h
+++ b/include/grub/x86_64/types.h
@@ -20,10 +20,14 @@
#define GRUB_TYPES_CPU_HEADER 1
/* The size of void *. */
+#ifdef __ILP32__
+#define GRUB_TARGET_SIZEOF_VOID_P 4
+#else
#define GRUB_TARGET_SIZEOF_VOID_P 8
+#endif
/* The size of long. */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__ILP32__)
#define GRUB_TARGET_SIZEOF_LONG 4
#else
#define GRUB_TARGET_SIZEOF_LONG 8
diff --git a/include/grub/xen.h b/include/grub/xen.h
index 6035d1a10..c31cc10c7 100644
--- a/include/grub/xen.h
+++ b/include/grub/xen.h
@@ -21,6 +21,8 @@
#define __XEN_INTERFACE_VERSION__ 0x0003020a
+#define memset grub_memset
+
#ifdef ASM_FILE
#define __ASSEMBLY__
#include <xen/xen.h>
@@ -31,7 +33,12 @@
#include <grub/err.h>
#ifndef GRUB_SYMBOL_GENERATOR
-#include <stdint.h>
+typedef grub_int8_t int8_t;
+typedef grub_int16_t int16_t;
+typedef grub_uint8_t uint8_t;
+typedef grub_uint16_t uint16_t;
+typedef grub_uint32_t uint32_t;
+typedef grub_uint64_t uint64_t;
#include <xen/xen.h>
#include <xen/sched.h>
diff --git a/include/grub/zfs/spa.h b/include/grub/zfs/spa.h
index 7edb8ab7d..8dd1fa8e3 100644
--- a/include/grub/zfs/spa.h
+++ b/include/grub/zfs/spa.h
@@ -126,7 +126,7 @@ typedef struct zio_cksum {
* +-------+-------+-------+-------+-------+-------+-------+-------+
* 5 |G| offset3 |
* +-------+-------+-------+-------+-------+-------+-------+-------+
- * 6 |BDX|lvl| type | cksum | comp | PSIZE | LSIZE |
+ * 6 |BDX|lvl| type | cksum |E| comp| PSIZE | LSIZE |
* +-------+-------+-------+-------+-------+-------+-------+-------+
* 7 | padding |
* +-------+-------+-------+-------+-------+-------+-------+-------+
@@ -160,7 +160,8 @@ typedef struct zio_cksum {
* G gang block indicator
* B byteorder (endianness)
* D dedup
- * X unused
+ * X encryption
+ * E blkptr_t contains embedded data
* lvl level of indirection
* type DMU object type
* phys birth txg of block allocation; zero if same as logical birth txg
@@ -203,8 +204,8 @@ typedef struct blkptr {
#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_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 7)
+#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 7, 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)
@@ -215,6 +216,8 @@ typedef struct blkptr {
#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_IS_EMBEDDED(bp) BF64_GET((bp)->blk_prop, 39, 1)
+
#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)
@@ -277,9 +280,27 @@ typedef struct blkptr {
(zcp)->zc_word[3] = w3; \
}
+#define BPE_GET_ETYPE(bp) BP_GET_CHECKSUM(bp)
+#define BPE_GET_LSIZE(bp) \
+ BF64_GET_SB((bp)->blk_prop, 0, 25, 0, 1)
+#define BPE_GET_PSIZE(bp) \
+ BF64_GET_SB((bp)->blk_prop, 25, 7, 0, 1)
+
+typedef enum bp_embedded_type {
+ BP_EMBEDDED_TYPE_DATA,
+ NUM_BP_EMBEDDED_TYPES
+} bp_embedded_type_t;
+
+#define BPE_NUM_WORDS 14
+#define BPE_PAYLOAD_SIZE (BPE_NUM_WORDS * sizeof(grub_uint64_t))
+#define BPE_IS_PAYLOADWORD(bp, wp) \
+ ((wp) != &(bp)->blk_prop && (wp) != &(bp)->blk_birth)
+
#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)
+#define DVA_IS_EMPTY(dva) ((dva)->dva_word[0] == 0ULL && \
+ (dva)->dva_word[1] == 0ULL)
+#define BP_IS_HOLE(bp) DVA_IS_EMPTY(BP_IDENTITY(bp))
/* BP_IS_RAIDZ(bp) assumes no block compression */
#define BP_IS_RAIDZ(bp) (DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \
diff --git a/include/multiboot2.h b/include/multiboot2.h
index 3ccff15fc..8b8c1568a 100644
--- a/include/multiboot2.h
+++ b/include/multiboot2.h
@@ -156,9 +156,6 @@ 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
@@ -179,7 +176,7 @@ struct multiboot_mmap_entry
#define MULTIBOOT_MEMORY_BADRAM 5
multiboot_uint32_t type;
multiboot_uint32_t zero;
-} GRUB_PACKED;
+};
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
struct multiboot_tag
diff --git a/include/xen/arch-x86/xen-x86_32.h b/include/xen/arch-x86/xen-x86_32.h
new file mode 100644
index 000000000..15041911e
--- /dev/null
+++ b/include/xen/arch-x86/xen-x86_32.h
@@ -0,0 +1,171 @@
+/******************************************************************************
+ * xen-x86_32.h
+ *
+ * Guest OS interface to x86 32-bit Xen.
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright (c) 2004-2007, K A Fraser
+ */
+
+#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
+#define __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__
+
+/*
+ * Hypercall interface:
+ * Input: %ebx, %ecx, %edx, %esi, %edi, %ebp (arguments 1-6)
+ * Output: %eax
+ * Access is via hypercall page (set up by guest loader or via a Xen MSR):
+ * call hypercall_page + hypercall-number * 32
+ * Clobbered: Argument registers (e.g., 2-arg hypercall clobbers %ebx,%ecx)
+ */
+
+/*
+ * These flat segments are in the Xen-private section of every GDT. Since these
+ * are also present in the initial GDT, many OSes will be able to avoid
+ * installing their own GDT.
+ */
+#define FLAT_RING1_CS 0xe019 /* GDT index 259 */
+#define FLAT_RING1_DS 0xe021 /* GDT index 260 */
+#define FLAT_RING1_SS 0xe021 /* GDT index 260 */
+#define FLAT_RING3_CS 0xe02b /* GDT index 261 */
+#define FLAT_RING3_DS 0xe033 /* GDT index 262 */
+#define FLAT_RING3_SS 0xe033 /* GDT index 262 */
+
+#define FLAT_KERNEL_CS FLAT_RING1_CS
+#define FLAT_KERNEL_DS FLAT_RING1_DS
+#define FLAT_KERNEL_SS FLAT_RING1_SS
+#define FLAT_USER_CS FLAT_RING3_CS
+#define FLAT_USER_DS FLAT_RING3_DS
+#define FLAT_USER_SS FLAT_RING3_SS
+
+#define __HYPERVISOR_VIRT_START_PAE 0xF5800000
+#define __MACH2PHYS_VIRT_START_PAE 0xF5800000
+#define __MACH2PHYS_VIRT_END_PAE 0xF6800000
+#define HYPERVISOR_VIRT_START_PAE \
+ mk_unsigned_long(__HYPERVISOR_VIRT_START_PAE)
+#define MACH2PHYS_VIRT_START_PAE \
+ mk_unsigned_long(__MACH2PHYS_VIRT_START_PAE)
+#define MACH2PHYS_VIRT_END_PAE \
+ mk_unsigned_long(__MACH2PHYS_VIRT_END_PAE)
+
+/* Non-PAE bounds are obsolete. */
+#define __HYPERVISOR_VIRT_START_NONPAE 0xFC000000
+#define __MACH2PHYS_VIRT_START_NONPAE 0xFC000000
+#define __MACH2PHYS_VIRT_END_NONPAE 0xFC400000
+#define HYPERVISOR_VIRT_START_NONPAE \
+ mk_unsigned_long(__HYPERVISOR_VIRT_START_NONPAE)
+#define MACH2PHYS_VIRT_START_NONPAE \
+ mk_unsigned_long(__MACH2PHYS_VIRT_START_NONPAE)
+#define MACH2PHYS_VIRT_END_NONPAE \
+ mk_unsigned_long(__MACH2PHYS_VIRT_END_NONPAE)
+
+#define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_PAE
+#define __MACH2PHYS_VIRT_START __MACH2PHYS_VIRT_START_PAE
+#define __MACH2PHYS_VIRT_END __MACH2PHYS_VIRT_END_PAE
+
+#ifndef HYPERVISOR_VIRT_START
+#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
+#endif
+
+#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START)
+#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END)
+#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2)
+#ifndef machine_to_phys_mapping
+#define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)
+#endif
+
+/* 32-/64-bit invariability for control interfaces (domctl/sysctl). */
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
+#undef ___DEFINE_XEN_GUEST_HANDLE
+#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
+ typedef struct { type *p; } \
+ __guest_handle_ ## name; \
+ typedef struct { union { type *p; uint64_aligned_t q; }; } \
+ __guest_handle_64_ ## name
+#undef set_xen_guest_handle_raw
+#define set_xen_guest_handle_raw(hnd, val) \
+ do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0; \
+ (hnd).p = val; \
+ } while ( 0 )
+#define uint64_aligned_t uint64_t __attribute__((aligned(8)))
+#define __XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name
+#define XEN_GUEST_HANDLE_64(name) __XEN_GUEST_HANDLE_64(name)
+#endif
+
+#ifndef __ASSEMBLY__
+
+struct cpu_user_regs {
+ uint32_t ebx;
+ uint32_t ecx;
+ uint32_t edx;
+ uint32_t esi;
+ uint32_t edi;
+ uint32_t ebp;
+ uint32_t eax;
+ uint16_t error_code; /* private */
+ uint16_t entry_vector; /* private */
+ uint32_t eip;
+ uint16_t cs;
+ uint8_t saved_upcall_mask;
+ uint8_t _pad0;
+ uint32_t eflags; /* eflags.IF == !saved_upcall_mask */
+ uint32_t esp;
+ uint16_t ss, _pad1;
+ uint16_t es, _pad2;
+ uint16_t ds, _pad3;
+ uint16_t fs, _pad4;
+ uint16_t gs, _pad5;
+};
+typedef struct cpu_user_regs cpu_user_regs_t;
+DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
+
+/*
+ * Page-directory addresses above 4GB do not fit into architectural %cr3.
+ * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
+ * must use the following accessor macros to pack/unpack valid MFNs.
+ */
+#define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20))
+#define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20))
+
+struct arch_vcpu_info {
+ unsigned long cr2;
+ unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */
+};
+typedef struct arch_vcpu_info arch_vcpu_info_t;
+
+struct xen_callback {
+ unsigned long cs;
+ unsigned long eip;
+};
+typedef struct xen_callback xen_callback_t;
+
+#endif /* !__ASSEMBLY__ */
+
+#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/arch-x86/xen-x86_64.h b/include/xen/arch-x86/xen-x86_64.h
new file mode 100644
index 000000000..1c4e1590f
--- /dev/null
+++ b/include/xen/arch-x86/xen-x86_64.h
@@ -0,0 +1,202 @@
+/******************************************************************************
+ * xen-x86_64.h
+ *
+ * Guest OS interface to x86 64-bit Xen.
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright (c) 2004-2006, K A Fraser
+ */
+
+#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__
+#define __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__
+
+/*
+ * Hypercall interface:
+ * Input: %rdi, %rsi, %rdx, %r10, %r8, %r9 (arguments 1-6)
+ * Output: %rax
+ * Access is via hypercall page (set up by guest loader or via a Xen MSR):
+ * call hypercall_page + hypercall-number * 32
+ * Clobbered: argument registers (e.g., 2-arg hypercall clobbers %rdi,%rsi)
+ */
+
+/*
+ * 64-bit segment selectors
+ * These flat segments are in the Xen-private section of every GDT. Since these
+ * are also present in the initial GDT, many OSes will be able to avoid
+ * installing their own GDT.
+ */
+
+#define FLAT_RING3_CS32 0xe023 /* GDT index 260 */
+#define FLAT_RING3_CS64 0xe033 /* GDT index 261 */
+#define FLAT_RING3_DS32 0xe02b /* GDT index 262 */
+#define FLAT_RING3_DS64 0x0000 /* NULL selector */
+#define FLAT_RING3_SS32 0xe02b /* GDT index 262 */
+#define FLAT_RING3_SS64 0xe02b /* GDT index 262 */
+
+#define FLAT_KERNEL_DS64 FLAT_RING3_DS64
+#define FLAT_KERNEL_DS32 FLAT_RING3_DS32
+#define FLAT_KERNEL_DS FLAT_KERNEL_DS64
+#define FLAT_KERNEL_CS64 FLAT_RING3_CS64
+#define FLAT_KERNEL_CS32 FLAT_RING3_CS32
+#define FLAT_KERNEL_CS FLAT_KERNEL_CS64
+#define FLAT_KERNEL_SS64 FLAT_RING3_SS64
+#define FLAT_KERNEL_SS32 FLAT_RING3_SS32
+#define FLAT_KERNEL_SS FLAT_KERNEL_SS64
+
+#define FLAT_USER_DS64 FLAT_RING3_DS64
+#define FLAT_USER_DS32 FLAT_RING3_DS32
+#define FLAT_USER_DS FLAT_USER_DS64
+#define FLAT_USER_CS64 FLAT_RING3_CS64
+#define FLAT_USER_CS32 FLAT_RING3_CS32
+#define FLAT_USER_CS FLAT_USER_CS64
+#define FLAT_USER_SS64 FLAT_RING3_SS64
+#define FLAT_USER_SS32 FLAT_RING3_SS32
+#define FLAT_USER_SS FLAT_USER_SS64
+
+#define __HYPERVISOR_VIRT_START 0xFFFF800000000000
+#define __HYPERVISOR_VIRT_END 0xFFFF880000000000
+#define __MACH2PHYS_VIRT_START 0xFFFF800000000000
+#define __MACH2PHYS_VIRT_END 0xFFFF804000000000
+
+#ifndef HYPERVISOR_VIRT_START
+#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START)
+#define HYPERVISOR_VIRT_END mk_unsigned_long(__HYPERVISOR_VIRT_END)
+#endif
+
+#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START)
+#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END)
+#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>3)
+#ifndef machine_to_phys_mapping
+#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)
+#endif
+
+/*
+ * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base)
+ * @which == SEGBASE_* ; @base == 64-bit base address
+ * Returns 0 on success.
+ */
+#define SEGBASE_FS 0
+#define SEGBASE_GS_USER 1
+#define SEGBASE_GS_KERNEL 2
+#define SEGBASE_GS_USER_SEL 3 /* Set user %gs specified in base[15:0] */
+
+/*
+ * int HYPERVISOR_iret(void)
+ * All arguments are on the kernel stack, in the following format.
+ * Never returns if successful. Current kernel context is lost.
+ * The saved CS is mapped as follows:
+ * RING0 -> RING3 kernel mode.
+ * RING1 -> RING3 kernel mode.
+ * RING2 -> RING3 kernel mode.
+ * RING3 -> RING3 user mode.
+ * However RING0 indicates that the guest kernel should return to iteself
+ * directly with
+ * orb $3,1*8(%rsp)
+ * iretq
+ * If flags contains VGCF_in_syscall:
+ * Restore RAX, RIP, RFLAGS, RSP.
+ * Discard R11, RCX, CS, SS.
+ * Otherwise:
+ * Restore RAX, R11, RCX, CS:RIP, RFLAGS, SS:RSP.
+ * All other registers are saved on hypercall entry and restored to user.
+ */
+/* Guest exited in SYSCALL context? Return to guest with SYSRET? */
+#define _VGCF_in_syscall 8
+#define VGCF_in_syscall (1<<_VGCF_in_syscall)
+#define VGCF_IN_SYSCALL VGCF_in_syscall
+
+#ifndef __ASSEMBLY__
+
+struct iret_context {
+ /* Top of stack (%rsp at point of hypercall). */
+ uint64_t rax, r11, rcx, flags, rip, cs, rflags, rsp, ss;
+ /* Bottom of iret stack frame. */
+};
+
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+/* Anonymous union includes both 32- and 64-bit names (e.g., eax/rax). */
+#define __DECL_REG(name) union { \
+ uint64_t r ## name, e ## name; \
+ uint32_t _e ## name; \
+}
+#else
+/* Non-gcc sources must always use the proper 64-bit name (e.g., rax). */
+#define __DECL_REG(name) uint64_t r ## name
+#endif
+
+struct cpu_user_regs {
+ uint64_t r15;
+ uint64_t r14;
+ uint64_t r13;
+ uint64_t r12;
+ __DECL_REG(bp);
+ __DECL_REG(bx);
+ uint64_t r11;
+ uint64_t r10;
+ uint64_t r9;
+ uint64_t r8;
+ __DECL_REG(ax);
+ __DECL_REG(cx);
+ __DECL_REG(dx);
+ __DECL_REG(si);
+ __DECL_REG(di);
+ uint32_t error_code; /* private */
+ uint32_t entry_vector; /* private */
+ __DECL_REG(ip);
+ uint16_t cs, _pad0[1];
+ uint8_t saved_upcall_mask;
+ uint8_t _pad1[3];
+ __DECL_REG(flags); /* rflags.IF == !saved_upcall_mask */
+ __DECL_REG(sp);
+ uint16_t ss, _pad2[3];
+ uint16_t es, _pad3[3];
+ uint16_t ds, _pad4[3];
+ uint16_t fs, _pad5[3]; /* Non-zero => takes precedence over fs_base. */
+ uint16_t gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_usr. */
+};
+typedef struct cpu_user_regs cpu_user_regs_t;
+DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
+
+#undef __DECL_REG
+
+#define xen_pfn_to_cr3(pfn) ((unsigned long)(pfn) << 12)
+#define xen_cr3_to_pfn(cr3) ((unsigned long)(cr3) >> 12)
+
+struct arch_vcpu_info {
+ unsigned long cr2;
+ unsigned long pad; /* sizeof(vcpu_info_t) == 64 */
+};
+typedef struct arch_vcpu_info arch_vcpu_info_t;
+
+typedef unsigned long xen_callback_t;
+
+#endif /* !__ASSEMBLY__ */
+
+#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/arch-x86/xen.h b/include/xen/arch-x86/xen.h
new file mode 100644
index 000000000..f35804b88
--- /dev/null
+++ b/include/xen/arch-x86/xen.h
@@ -0,0 +1,273 @@
+/******************************************************************************
+ * arch-x86/xen.h
+ *
+ * Guest OS interface to x86 Xen.
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright (c) 2004-2006, K A Fraser
+ */
+
+#include "../xen.h"
+
+#ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__
+#define __XEN_PUBLIC_ARCH_X86_XEN_H__
+
+/* Structural guest handles introduced in 0x00030201. */
+#if __XEN_INTERFACE_VERSION__ >= 0x00030201
+#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
+ typedef struct { type *p; } __guest_handle_ ## name
+#else
+#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
+ typedef type * __guest_handle_ ## name
+#endif
+
+/*
+ * XEN_GUEST_HANDLE represents a guest pointer, when passed as a field
+ * in a struct in memory.
+ * XEN_GUEST_HANDLE_PARAM represent a guest pointer, when passed as an
+ * hypercall argument.
+ * XEN_GUEST_HANDLE_PARAM and XEN_GUEST_HANDLE are the same on X86 but
+ * they might not be on other architectures.
+ */
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
+ ___DEFINE_XEN_GUEST_HANDLE(name, type); \
+ ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type)
+#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name
+#define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name)
+#define XEN_GUEST_HANDLE_PARAM(name) XEN_GUEST_HANDLE(name)
+#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = val; } while (0)
+#ifdef __XEN_TOOLS__
+#define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0)
+#endif
+#define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val)
+
+#if defined(__i386__)
+#include "xen-x86_32.h"
+#elif defined(__x86_64__)
+#include "xen-x86_64.h"
+#endif
+
+#ifndef __ASSEMBLY__
+typedef unsigned long xen_pfn_t;
+#define PRI_xen_pfn "lx"
+#endif
+
+#define XEN_HAVE_PV_GUEST_ENTRY 1
+
+#define XEN_HAVE_PV_UPCALL_MASK 1
+
+/*
+ * `incontents 200 segdesc Segment Descriptor Tables
+ */
+/*
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_set_gdt(const xen_pfn_t frames[], unsigned int entries);
+ * `
+ */
+/*
+ * A number of GDT entries are reserved by Xen. These are not situated at the
+ * start of the GDT because some stupid OSes export hard-coded selector values
+ * in their ABI. These hard-coded values are always near the start of the GDT,
+ * so Xen places itself out of the way, at the far end of the GDT.
+ *
+ * NB The LDT is set using the MMUEXT_SET_LDT op of HYPERVISOR_mmuext_op
+ */
+#define FIRST_RESERVED_GDT_PAGE 14
+#define FIRST_RESERVED_GDT_BYTE (FIRST_RESERVED_GDT_PAGE * 4096)
+#define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
+
+
+/*
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_update_descriptor(u64 pa, u64 desc);
+ * `
+ * ` @pa The machine physical address of the descriptor to
+ * ` update. Must be either a descriptor page or writable.
+ * ` @desc The descriptor value to update, in the same format as a
+ * ` native descriptor table entry.
+ */
+
+/* Maximum number of virtual CPUs in legacy multi-processor guests. */
+#define XEN_LEGACY_MAX_VCPUS 32
+
+#ifndef __ASSEMBLY__
+
+typedef unsigned long xen_ulong_t;
+#define PRI_xen_ulong "lx"
+
+/*
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp);
+ * `
+ * Sets the stack segment and pointer for the current vcpu.
+ */
+
+/*
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_set_trap_table(const struct trap_info traps[]);
+ * `
+ */
+/*
+ * Send an array of these to HYPERVISOR_set_trap_table().
+ * Terminate the array with a sentinel entry, with traps[].address==0.
+ * The privilege level specifies which modes may enter a trap via a software
+ * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate
+ * privilege levels as follows:
+ * Level == 0: Noone may enter
+ * Level == 1: Kernel may enter
+ * Level == 2: Kernel may enter
+ * Level == 3: Everyone may enter
+ */
+#define TI_GET_DPL(_ti) ((_ti)->flags & 3)
+#define TI_GET_IF(_ti) ((_ti)->flags & 4)
+#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl))
+#define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2))
+struct trap_info {
+ uint8_t vector; /* exception vector */
+ uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */
+ uint16_t cs; /* code selector */
+ unsigned long address; /* code offset */
+};
+typedef struct trap_info trap_info_t;
+DEFINE_XEN_GUEST_HANDLE(trap_info_t);
+
+typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
+
+/*
+ * The following is all CPU context. Note that the fpu_ctxt block is filled
+ * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
+ *
+ * Also note that when calling DOMCTL_setvcpucontext and VCPU_initialise
+ * for HVM and PVH guests, not all information in this structure is updated:
+ *
+ * - For HVM guests, the structures read include: fpu_ctxt (if
+ * VGCT_I387_VALID is set), flags, user_regs, debugreg[*]
+ *
+ * - PVH guests are the same as HVM guests, but additionally use ctrlreg[3] to
+ * set cr3. All other fields not used should be set to 0.
+ */
+struct vcpu_guest_context {
+ /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */
+ struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */
+#define VGCF_I387_VALID (1<<0)
+#define VGCF_IN_KERNEL (1<<2)
+#define _VGCF_i387_valid 0
+#define VGCF_i387_valid (1<<_VGCF_i387_valid)
+#define _VGCF_in_kernel 2
+#define VGCF_in_kernel (1<<_VGCF_in_kernel)
+#define _VGCF_failsafe_disables_events 3
+#define VGCF_failsafe_disables_events (1<<_VGCF_failsafe_disables_events)
+#define _VGCF_syscall_disables_events 4
+#define VGCF_syscall_disables_events (1<<_VGCF_syscall_disables_events)
+#define _VGCF_online 5
+#define VGCF_online (1<<_VGCF_online)
+ unsigned long flags; /* VGCF_* flags */
+ struct cpu_user_regs user_regs; /* User-level CPU registers */
+ struct trap_info trap_ctxt[256]; /* Virtual IDT */
+ unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */
+ unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */
+ unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */
+ /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */
+ unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */
+ unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */
+#ifdef __i386__
+ unsigned long event_callback_cs; /* CS:EIP of event callback */
+ unsigned long event_callback_eip;
+ unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */
+ unsigned long failsafe_callback_eip;
+#else
+ unsigned long event_callback_eip;
+ unsigned long failsafe_callback_eip;
+#ifdef __XEN__
+ union {
+ unsigned long syscall_callback_eip;
+ struct {
+ unsigned int event_callback_cs; /* compat CS of event cb */
+ unsigned int failsafe_callback_cs; /* compat CS of failsafe cb */
+ };
+ };
+#else
+ unsigned long syscall_callback_eip;
+#endif
+#endif
+ unsigned long vm_assist; /* VMASST_TYPE_* bitmap */
+#ifdef __x86_64__
+ /* Segment base addresses. */
+ uint64_t fs_base;
+ uint64_t gs_base_kernel;
+ uint64_t gs_base_user;
+#endif
+};
+typedef struct vcpu_guest_context vcpu_guest_context_t;
+DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
+
+struct arch_shared_info {
+ unsigned long max_pfn; /* max pfn that appears in table */
+ /* Frame containing list of mfns containing list of mfns containing p2m. */
+ xen_pfn_t pfn_to_mfn_frame_list_list;
+ unsigned long nmi_reason;
+ uint64_t pad[32];
+};
+typedef struct arch_shared_info arch_shared_info_t;
+
+#endif /* !__ASSEMBLY__ */
+
+/*
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_fpu_taskswitch(int set);
+ * `
+ * Sets (if set!=0) or clears (if set==0) CR0.TS.
+ */
+
+/*
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_set_debugreg(int regno, unsigned long value);
+ *
+ * ` unsigned long
+ * ` HYPERVISOR_get_debugreg(int regno);
+ * For 0<=reg<=7, returns the debug register value.
+ * For other values of reg, returns ((unsigned long)-EINVAL).
+ * (Unfortunately, this interface is defective.)
+ */
+
+/*
+ * Prefix forces emulation of some non-trapping instructions.
+ * Currently only CPUID.
+ */
+#ifdef __ASSEMBLY__
+#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ;
+#define XEN_CPUID XEN_EMULATE_PREFIX cpuid
+#else
+#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; "
+#define XEN_CPUID XEN_EMULATE_PREFIX "cpuid"
+#endif
+
+#endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/event_channel.h b/include/xen/event_channel.h
new file mode 100644
index 000000000..49ac8cca5
--- /dev/null
+++ b/include/xen/event_channel.h
@@ -0,0 +1,381 @@
+/******************************************************************************
+ * event_channel.h
+ *
+ * Event channels between domains.
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright (c) 2003-2004, K A Fraser.
+ */
+
+#ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
+#define __XEN_PUBLIC_EVENT_CHANNEL_H__
+
+#include "xen.h"
+
+/*
+ * `incontents 150 evtchn Event Channels
+ *
+ * Event channels are the basic primitive provided by Xen for event
+ * notifications. An event is the Xen equivalent of a hardware
+ * interrupt. They essentially store one bit of information, the event
+ * of interest is signalled by transitioning this bit from 0 to 1.
+ *
+ * Notifications are received by a guest via an upcall from Xen,
+ * indicating when an event arrives (setting the bit). Further
+ * notifications are masked until the bit is cleared again (therefore,
+ * guests must check the value of the bit after re-enabling event
+ * delivery to ensure no missed notifications).
+ *
+ * Event notifications can be masked by setting a flag; this is
+ * equivalent to disabling interrupts and can be used to ensure
+ * atomicity of certain operations in the guest kernel.
+ *
+ * Event channels are represented by the evtchn_* fields in
+ * struct shared_info and struct vcpu_info.
+ */
+
+/*
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_event_channel_op(enum event_channel_op cmd, void *args)
+ * `
+ * @cmd == EVTCHNOP_* (event-channel operation).
+ * @args == struct evtchn_* Operation-specific extra arguments (NULL if none).
+ */
+
+/* ` enum event_channel_op { // EVTCHNOP_* => struct evtchn_* */
+#define EVTCHNOP_bind_interdomain 0
+#define EVTCHNOP_bind_virq 1
+#define EVTCHNOP_bind_pirq 2
+#define EVTCHNOP_close 3
+#define EVTCHNOP_send 4
+#define EVTCHNOP_status 5
+#define EVTCHNOP_alloc_unbound 6
+#define EVTCHNOP_bind_ipi 7
+#define EVTCHNOP_bind_vcpu 8
+#define EVTCHNOP_unmask 9
+#define EVTCHNOP_reset 10
+#define EVTCHNOP_init_control 11
+#define EVTCHNOP_expand_array 12
+#define EVTCHNOP_set_priority 13
+/* ` } */
+
+typedef uint32_t evtchn_port_t;
+DEFINE_XEN_GUEST_HANDLE(evtchn_port_t);
+
+/*
+ * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
+ * accepting interdomain bindings from domain <remote_dom>. A fresh port
+ * is allocated in <dom> and returned as <port>.
+ * NOTES:
+ * 1. If the caller is unprivileged then <dom> must be DOMID_SELF.
+ * 2. <rdom> may be DOMID_SELF, allowing loopback connections.
+ */
+struct evtchn_alloc_unbound {
+ /* IN parameters */
+ domid_t dom, remote_dom;
+ /* OUT parameters */
+ evtchn_port_t port;
+};
+typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t;
+
+/*
+ * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
+ * the calling domain and <remote_dom>. <remote_dom,remote_port> must identify
+ * a port that is unbound and marked as accepting bindings from the calling
+ * domain. A fresh port is allocated in the calling domain and returned as
+ * <local_port>.
+ *
+ * In case the peer domain has already tried to set our event channel
+ * pending, before it was bound, EVTCHNOP_bind_interdomain always sets
+ * the local event channel pending.
+ *
+ * The usual pattern of use, in the guest's upcall (or subsequent
+ * handler) is as follows: (Re-enable the event channel for subsequent
+ * signalling and then) check for the existence of whatever condition
+ * is being waited for by other means, and take whatever action is
+ * needed (if any).
+ *
+ * NOTES:
+ * 1. <remote_dom> may be DOMID_SELF, allowing loopback connections.
+ */
+struct evtchn_bind_interdomain {
+ /* IN parameters. */
+ domid_t remote_dom;
+ evtchn_port_t remote_port;
+ /* OUT parameters. */
+ evtchn_port_t local_port;
+};
+typedef struct evtchn_bind_interdomain evtchn_bind_interdomain_t;
+
+/*
+ * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ <irq> on specified
+ * vcpu.
+ * NOTES:
+ * 1. Virtual IRQs are classified as per-vcpu or global. See the VIRQ list
+ * in xen.h for the classification of each VIRQ.
+ * 2. Global VIRQs must be allocated on VCPU0 but can subsequently be
+ * re-bound via EVTCHNOP_bind_vcpu.
+ * 3. Per-vcpu VIRQs may be bound to at most one event channel per vcpu.
+ * The allocated event channel is bound to the specified vcpu and the
+ * binding cannot be changed.
+ */
+struct evtchn_bind_virq {
+ /* IN parameters. */
+ uint32_t virq; /* enum virq */
+ uint32_t vcpu;
+ /* OUT parameters. */
+ evtchn_port_t port;
+};
+typedef struct evtchn_bind_virq evtchn_bind_virq_t;
+
+/*
+ * EVTCHNOP_bind_pirq: Bind a local event channel to a real IRQ (PIRQ <irq>).
+ * NOTES:
+ * 1. A physical IRQ may be bound to at most one event channel per domain.
+ * 2. Only a sufficiently-privileged domain may bind to a physical IRQ.
+ */
+struct evtchn_bind_pirq {
+ /* IN parameters. */
+ uint32_t pirq;
+#define BIND_PIRQ__WILL_SHARE 1
+ uint32_t flags; /* BIND_PIRQ__* */
+ /* OUT parameters. */
+ evtchn_port_t port;
+};
+typedef struct evtchn_bind_pirq evtchn_bind_pirq_t;
+
+/*
+ * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
+ * NOTES:
+ * 1. The allocated event channel is bound to the specified vcpu. The binding
+ * may not be changed.
+ */
+struct evtchn_bind_ipi {
+ uint32_t vcpu;
+ /* OUT parameters. */
+ evtchn_port_t port;
+};
+typedef struct evtchn_bind_ipi evtchn_bind_ipi_t;
+
+/*
+ * EVTCHNOP_close: Close a local event channel <port>. If the channel is
+ * interdomain then the remote end is placed in the unbound state
+ * (EVTCHNSTAT_unbound), awaiting a new connection.
+ */
+struct evtchn_close {
+ /* IN parameters. */
+ evtchn_port_t port;
+};
+typedef struct evtchn_close evtchn_close_t;
+
+/*
+ * EVTCHNOP_send: Send an event to the remote end of the channel whose local
+ * endpoint is <port>.
+ */
+struct evtchn_send {
+ /* IN parameters. */
+ evtchn_port_t port;
+};
+typedef struct evtchn_send evtchn_send_t;
+
+/*
+ * EVTCHNOP_status: Get the current status of the communication channel which
+ * has an endpoint at <dom, port>.
+ * NOTES:
+ * 1. <dom> may be specified as DOMID_SELF.
+ * 2. Only a sufficiently-privileged domain may obtain the status of an event
+ * channel for which <dom> is not DOMID_SELF.
+ */
+struct evtchn_status {
+ /* IN parameters */
+ domid_t dom;
+ evtchn_port_t port;
+ /* OUT parameters */
+#define EVTCHNSTAT_closed 0 /* Channel is not in use. */
+#define EVTCHNSTAT_unbound 1 /* Channel is waiting interdom connection.*/
+#define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */
+#define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */
+#define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */
+#define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */
+ uint32_t status;
+ uint32_t vcpu; /* VCPU to which this channel is bound. */
+ union {
+ struct {
+ domid_t dom;
+ } unbound; /* EVTCHNSTAT_unbound */
+ struct {
+ domid_t dom;
+ evtchn_port_t port;
+ } interdomain; /* EVTCHNSTAT_interdomain */
+ uint32_t pirq; /* EVTCHNSTAT_pirq */
+ uint32_t virq; /* EVTCHNSTAT_virq */
+ } u;
+};
+typedef struct evtchn_status evtchn_status_t;
+
+/*
+ * EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an
+ * event is pending.
+ * NOTES:
+ * 1. IPI-bound channels always notify the vcpu specified at bind time.
+ * This binding cannot be changed.
+ * 2. Per-VCPU VIRQ channels always notify the vcpu specified at bind time.
+ * This binding cannot be changed.
+ * 3. All other channels notify vcpu0 by default. This default is set when
+ * the channel is allocated (a port that is freed and subsequently reused
+ * has its binding reset to vcpu0).
+ */
+struct evtchn_bind_vcpu {
+ /* IN parameters. */
+ evtchn_port_t port;
+ uint32_t vcpu;
+};
+typedef struct evtchn_bind_vcpu evtchn_bind_vcpu_t;
+
+/*
+ * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver
+ * a notification to the appropriate VCPU if an event is pending.
+ */
+struct evtchn_unmask {
+ /* IN parameters. */
+ evtchn_port_t port;
+};
+typedef struct evtchn_unmask evtchn_unmask_t;
+
+/*
+ * EVTCHNOP_reset: Close all event channels associated with specified domain.
+ * NOTES:
+ * 1. <dom> may be specified as DOMID_SELF.
+ * 2. Only a sufficiently-privileged domain may specify other than DOMID_SELF.
+ */
+struct evtchn_reset {
+ /* IN parameters. */
+ domid_t dom;
+};
+typedef struct evtchn_reset evtchn_reset_t;
+
+/*
+ * EVTCHNOP_init_control: initialize the control block for the FIFO ABI.
+ *
+ * Note: any events that are currently pending will not be resent and
+ * will be lost. Guests should call this before binding any event to
+ * avoid losing any events.
+ */
+struct evtchn_init_control {
+ /* IN parameters. */
+ uint64_t control_gfn;
+ uint32_t offset;
+ uint32_t vcpu;
+ /* OUT parameters. */
+ uint8_t link_bits;
+ uint8_t _pad[7];
+};
+typedef struct evtchn_init_control evtchn_init_control_t;
+
+/*
+ * EVTCHNOP_expand_array: add an additional page to the event array.
+ */
+struct evtchn_expand_array {
+ /* IN parameters. */
+ uint64_t array_gfn;
+};
+typedef struct evtchn_expand_array evtchn_expand_array_t;
+
+/*
+ * EVTCHNOP_set_priority: set the priority for an event channel.
+ */
+struct evtchn_set_priority {
+ /* IN parameters. */
+ uint32_t port;
+ uint32_t priority;
+};
+typedef struct evtchn_set_priority evtchn_set_priority_t;
+
+/*
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_event_channel_op_compat(struct evtchn_op *op)
+ * `
+ * Superceded by new event_channel_op() hypercall since 0x00030202.
+ */
+struct evtchn_op {
+ uint32_t cmd; /* enum event_channel_op */
+ union {
+ struct evtchn_alloc_unbound alloc_unbound;
+ struct evtchn_bind_interdomain bind_interdomain;
+ struct evtchn_bind_virq bind_virq;
+ struct evtchn_bind_pirq bind_pirq;
+ struct evtchn_bind_ipi bind_ipi;
+ struct evtchn_close close;
+ struct evtchn_send send;
+ struct evtchn_status status;
+ struct evtchn_bind_vcpu bind_vcpu;
+ struct evtchn_unmask unmask;
+ } u;
+};
+typedef struct evtchn_op evtchn_op_t;
+DEFINE_XEN_GUEST_HANDLE(evtchn_op_t);
+
+/*
+ * 2-level ABI
+ */
+
+#define EVTCHN_2L_NR_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)
+
+/*
+ * FIFO ABI
+ */
+
+/* Events may have priorities from 0 (highest) to 15 (lowest). */
+#define EVTCHN_FIFO_PRIORITY_MAX 0
+#define EVTCHN_FIFO_PRIORITY_DEFAULT 7
+#define EVTCHN_FIFO_PRIORITY_MIN 15
+
+#define EVTCHN_FIFO_MAX_QUEUES (EVTCHN_FIFO_PRIORITY_MIN + 1)
+
+typedef uint32_t event_word_t;
+
+#define EVTCHN_FIFO_PENDING 31
+#define EVTCHN_FIFO_MASKED 30
+#define EVTCHN_FIFO_LINKED 29
+#define EVTCHN_FIFO_BUSY 28
+
+#define EVTCHN_FIFO_LINK_BITS 17
+#define EVTCHN_FIFO_LINK_MASK ((1 << EVTCHN_FIFO_LINK_BITS) - 1)
+
+#define EVTCHN_FIFO_NR_CHANNELS (1 << EVTCHN_FIFO_LINK_BITS)
+
+struct evtchn_fifo_control_block {
+ uint32_t ready;
+ uint32_t _rsvd;
+ uint32_t head[EVTCHN_FIFO_MAX_QUEUES];
+};
+typedef struct evtchn_fifo_control_block evtchn_fifo_control_block_t;
+
+#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
new file mode 100644
index 000000000..b8a3d6ceb
--- /dev/null
+++ b/include/xen/grant_table.h
@@ -0,0 +1,662 @@
+/******************************************************************************
+ * grant_table.h
+ *
+ * Interface for granting foreign access to page frames, and receiving
+ * page-ownership transfers.
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright (c) 2004, K A Fraser
+ */
+
+#ifndef __XEN_PUBLIC_GRANT_TABLE_H__
+#define __XEN_PUBLIC_GRANT_TABLE_H__
+
+#include "xen.h"
+
+/*
+ * `incontents 150 gnttab Grant Tables
+ *
+ * Xen's grant tables provide a generic mechanism to memory sharing
+ * between domains. This shared memory interface underpins the split
+ * device drivers for block and network IO.
+ *
+ * Each domain has its own grant table. This is a data structure that
+ * is shared with Xen; it allows the domain to tell Xen what kind of
+ * permissions other domains have on its pages. Entries in the grant
+ * table are identified by grant references. A grant reference is an
+ * integer, which indexes into the grant table. It acts as a
+ * capability which the grantee can use to perform operations on the
+ * granter’s memory.
+ *
+ * This capability-based system allows shared-memory communications
+ * between unprivileged domains. A grant reference also encapsulates
+ * the details of a shared page, removing the need for a domain to
+ * know the real machine address of a page it is sharing. This makes
+ * it possible to share memory correctly with domains running in
+ * fully virtualised memory.
+ */
+
+/***********************************
+ * GRANT TABLE REPRESENTATION
+ */
+
+/* Some rough guidelines on accessing and updating grant-table entries
+ * in a concurrency-safe manner. For more information, Linux contains a
+ * reference implementation for guest OSes (drivers/xen/grant_table.c, see
+ * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/xen/grant-table.c;hb=HEAD
+ *
+ * NB. WMB is a no-op on current-generation x86 processors. However, a
+ * compiler barrier will still be required.
+ *
+ * Introducing a valid entry into the grant table:
+ * 1. Write ent->domid.
+ * 2. Write ent->frame:
+ * GTF_permit_access: Frame to which access is permitted.
+ * GTF_accept_transfer: Pseudo-phys frame slot being filled by new
+ * frame, or zero if none.
+ * 3. Write memory barrier (WMB).
+ * 4. Write ent->flags, inc. valid type.
+ *
+ * Invalidating an unused GTF_permit_access entry:
+ * 1. flags = ent->flags.
+ * 2. Observe that !(flags & (GTF_reading|GTF_writing)).
+ * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0).
+ * NB. No need for WMB as reuse of entry is control-dependent on success of
+ * step 3, and all architectures guarantee ordering of ctrl-dep writes.
+ *
+ * Invalidating an in-use GTF_permit_access entry:
+ * This cannot be done directly. Request assistance from the domain controller
+ * which can set a timeout on the use of a grant entry and take necessary
+ * action. (NB. This is not yet implemented!).
+ *
+ * Invalidating an unused GTF_accept_transfer entry:
+ * 1. flags = ent->flags.
+ * 2. Observe that !(flags & GTF_transfer_committed). [*]
+ * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0).
+ * NB. No need for WMB as reuse of entry is control-dependent on success of
+ * step 3, and all architectures guarantee ordering of ctrl-dep writes.
+ * [*] If GTF_transfer_committed is set then the grant entry is 'committed'.
+ * The guest must /not/ modify the grant entry until the address of the
+ * transferred frame is written. It is safe for the guest to spin waiting
+ * for this to occur (detect by observing GTF_transfer_completed in
+ * ent->flags).
+ *
+ * Invalidating a committed GTF_accept_transfer entry:
+ * 1. Wait for (ent->flags & GTF_transfer_completed).
+ *
+ * Changing a GTF_permit_access from writable to read-only:
+ * Use SMP-safe CMPXCHG to set GTF_readonly, while checking !GTF_writing.
+ *
+ * Changing a GTF_permit_access from read-only to writable:
+ * Use SMP-safe bit-setting instruction.
+ */
+
+/*
+ * Reference to a grant entry in a specified domain's grant table.
+ */
+typedef uint32_t grant_ref_t;
+
+/*
+ * A grant table comprises a packed array of grant entries in one or more
+ * page frames shared between Xen and a guest.
+ * [XEN]: This field is written by Xen and read by the sharing guest.
+ * [GST]: This field is written by the guest and read by Xen.
+ */
+
+/*
+ * Version 1 of the grant table entry structure is maintained purely
+ * for backwards compatibility. New guests should use version 2.
+ */
+#if __XEN_INTERFACE_VERSION__ < 0x0003020a
+#define grant_entry_v1 grant_entry
+#define grant_entry_v1_t grant_entry_t
+#endif
+struct grant_entry_v1 {
+ /* GTF_xxx: various type and flag information. [XEN,GST] */
+ uint16_t flags;
+ /* The domain being granted foreign privileges. [GST] */
+ domid_t domid;
+ /*
+ * GTF_permit_access: Frame that @domid is allowed to map and access. [GST]
+ * GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN]
+ */
+ uint32_t frame;
+};
+typedef struct grant_entry_v1 grant_entry_v1_t;
+
+/* The first few grant table entries will be preserved across grant table
+ * version changes and may be pre-populated at domain creation by tools.
+ */
+#define GNTTAB_NR_RESERVED_ENTRIES 8
+#define GNTTAB_RESERVED_CONSOLE 0
+#define GNTTAB_RESERVED_XENSTORE 1
+
+/*
+ * Type of grant entry.
+ * GTF_invalid: This grant entry grants no privileges.
+ * GTF_permit_access: Allow @domid to map/access @frame.
+ * GTF_accept_transfer: Allow @domid to transfer ownership of one page frame
+ * to this guest. Xen writes the page number to @frame.
+ * GTF_transitive: Allow @domid to transitively access a subrange of
+ * @trans_grant in @trans_domid. No mappings are allowed.
+ */
+#define GTF_invalid (0U<<0)
+#define GTF_permit_access (1U<<0)
+#define GTF_accept_transfer (2U<<0)
+#define GTF_transitive (3U<<0)
+#define GTF_type_mask (3U<<0)
+
+/*
+ * Subflags for GTF_permit_access.
+ * GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST]
+ * GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN]
+ * GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN]
+ * GTF_PAT, GTF_PWT, GTF_PCD: (x86) cache attribute flags for the grant [GST]
+ * GTF_sub_page: Grant access to only a subrange of the page. @domid
+ * will only be allowed to copy from the grant, and not
+ * map it. [GST]
+ */
+#define _GTF_readonly (2)
+#define GTF_readonly (1U<<_GTF_readonly)
+#define _GTF_reading (3)
+#define GTF_reading (1U<<_GTF_reading)
+#define _GTF_writing (4)
+#define GTF_writing (1U<<_GTF_writing)
+#define _GTF_PWT (5)
+#define GTF_PWT (1U<<_GTF_PWT)
+#define _GTF_PCD (6)
+#define GTF_PCD (1U<<_GTF_PCD)
+#define _GTF_PAT (7)
+#define GTF_PAT (1U<<_GTF_PAT)
+#define _GTF_sub_page (8)
+#define GTF_sub_page (1U<<_GTF_sub_page)
+
+/*
+ * Subflags for GTF_accept_transfer:
+ * GTF_transfer_committed: Xen sets this flag to indicate that it is committed
+ * to transferring ownership of a page frame. When a guest sees this flag
+ * it must /not/ modify the grant entry until GTF_transfer_completed is
+ * set by Xen.
+ * GTF_transfer_completed: It is safe for the guest to spin-wait on this flag
+ * after reading GTF_transfer_committed. Xen will always write the frame
+ * address, followed by ORing this flag, in a timely manner.
+ */
+#define _GTF_transfer_committed (2)
+#define GTF_transfer_committed (1U<<_GTF_transfer_committed)
+#define _GTF_transfer_completed (3)
+#define GTF_transfer_completed (1U<<_GTF_transfer_completed)
+
+/*
+ * Version 2 grant table entries. These fulfil the same role as
+ * version 1 entries, but can represent more complicated operations.
+ * Any given domain will have either a version 1 or a version 2 table,
+ * and every entry in the table will be the same version.
+ *
+ * The interface by which domains use grant references does not depend
+ * on the grant table version in use by the other domain.
+ */
+#if __XEN_INTERFACE_VERSION__ >= 0x0003020a
+/*
+ * Version 1 and version 2 grant entries share a common prefix. The
+ * fields of the prefix are documented as part of struct
+ * grant_entry_v1.
+ */
+struct grant_entry_header {
+ uint16_t flags;
+ domid_t domid;
+};
+typedef struct grant_entry_header grant_entry_header_t;
+
+/*
+ * Version 2 of the grant entry structure.
+ */
+union grant_entry_v2 {
+ grant_entry_header_t hdr;
+
+ /*
+ * This member is used for V1-style full page grants, where either:
+ *
+ * -- hdr.type is GTF_accept_transfer, or
+ * -- hdr.type is GTF_permit_access and GTF_sub_page is not set.
+ *
+ * In that case, the frame field has the same semantics as the
+ * field of the same name in the V1 entry structure.
+ */
+ struct {
+ grant_entry_header_t hdr;
+ uint32_t pad0;
+ uint64_t frame;
+ } full_page;
+
+ /*
+ * If the grant type is GTF_grant_access and GTF_sub_page is set,
+ * @domid is allowed to access bytes [@page_off,@page_off+@length)
+ * in frame @frame.
+ */
+ struct {
+ grant_entry_header_t hdr;
+ uint16_t page_off;
+ uint16_t length;
+ uint64_t frame;
+ } sub_page;
+
+ /*
+ * If the grant is GTF_transitive, @domid is allowed to use the
+ * grant @gref in domain @trans_domid, as if it was the local
+ * domain. Obviously, the transitive access must be compatible
+ * with the original grant.
+ *
+ * The current version of Xen does not allow transitive grants
+ * to be mapped.
+ */
+ struct {
+ grant_entry_header_t hdr;
+ domid_t trans_domid;
+ uint16_t pad0;
+ grant_ref_t gref;
+ } transitive;
+
+ uint32_t __spacer[4]; /* Pad to a power of two */
+};
+typedef union grant_entry_v2 grant_entry_v2_t;
+
+typedef uint16_t grant_status_t;
+
+#endif /* __XEN_INTERFACE_VERSION__ */
+
+/***********************************
+ * GRANT TABLE QUERIES AND USES
+ */
+
+/* ` enum neg_errnoval
+ * ` HYPERVISOR_grant_table_op(enum grant_table_op cmd,
+ * ` void *args,
+ * ` unsigned int count)
+ * `
+ *
+ * @args points to an array of a per-command data structure. The array
+ * has @count members
+ */
+
+/* ` enum grant_table_op { // GNTTABOP_* => struct gnttab_* */
+#define GNTTABOP_map_grant_ref 0
+#define GNTTABOP_unmap_grant_ref 1
+#define GNTTABOP_setup_table 2
+#define GNTTABOP_dump_table 3
+#define GNTTABOP_transfer 4
+#define GNTTABOP_copy 5
+#define GNTTABOP_query_size 6
+#define GNTTABOP_unmap_and_replace 7
+#if __XEN_INTERFACE_VERSION__ >= 0x0003020a
+#define GNTTABOP_set_version 8
+#define GNTTABOP_get_status_frames 9
+#define GNTTABOP_get_version 10
+#define GNTTABOP_swap_grant_ref 11
+#endif /* __XEN_INTERFACE_VERSION__ */
+/* ` } */
+
+/*
+ * Handle to track a mapping created via a grant reference.
+ */
+typedef uint32_t grant_handle_t;
+
+/*
+ * GNTTABOP_map_grant_ref: Map the grant entry (<dom>,<ref>) for access
+ * by devices and/or host CPUs. If successful, <handle> is a tracking number
+ * that must be presented later to destroy the mapping(s). On error, <handle>
+ * is a negative status code.
+ * NOTES:
+ * 1. If GNTMAP_device_map is specified then <dev_bus_addr> is the address
+ * via which I/O devices may access the granted frame.
+ * 2. If GNTMAP_host_map is specified then a mapping will be added at
+ * either a host virtual address in the current address space, or at
+ * a PTE at the specified machine address. The type of mapping to
+ * perform is selected through the GNTMAP_contains_pte flag, and the
+ * address is specified in <host_addr>.
+ * 3. Mappings should only be destroyed via GNTTABOP_unmap_grant_ref. If a
+ * host mapping is destroyed by other means then it is *NOT* guaranteed
+ * to be accounted to the correct grant reference!
+ */
+struct gnttab_map_grant_ref {
+ /* IN parameters. */
+ uint64_t host_addr;
+ uint32_t flags; /* GNTMAP_* */
+ grant_ref_t ref;
+ domid_t dom;
+ /* OUT parameters. */
+ int16_t status; /* => enum grant_status */
+ grant_handle_t handle;
+ uint64_t dev_bus_addr;
+};
+typedef struct gnttab_map_grant_ref gnttab_map_grant_ref_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t);
+
+/*
+ * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings
+ * tracked by <handle>. If <host_addr> or <dev_bus_addr> is zero, that
+ * field is ignored. If non-zero, they must refer to a device/host mapping
+ * that is tracked by <handle>
+ * NOTES:
+ * 1. The call may fail in an undefined manner if either mapping is not
+ * tracked by <handle>.
+ * 3. After executing a batch of unmaps, it is guaranteed that no stale
+ * mappings will remain in the device or host TLBs.
+ */
+struct gnttab_unmap_grant_ref {
+ /* IN parameters. */
+ uint64_t host_addr;
+ uint64_t dev_bus_addr;
+ grant_handle_t handle;
+ /* OUT parameters. */
+ int16_t status; /* => enum grant_status */
+};
+typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t);
+
+/*
+ * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least
+ * <nr_frames> pages. The frame addresses are written to the <frame_list>.
+ * Only <nr_frames> addresses are written, even if the table is larger.
+ * NOTES:
+ * 1. <dom> may be specified as DOMID_SELF.
+ * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF.
+ * 3. Xen may not support more than a single grant-table page per domain.
+ */
+struct gnttab_setup_table {
+ /* IN parameters. */
+ domid_t dom;
+ uint32_t nr_frames;
+ /* OUT parameters. */
+ int16_t status; /* => enum grant_status */
+#if __XEN_INTERFACE_VERSION__ < 0x00040300
+ XEN_GUEST_HANDLE(ulong) frame_list;
+#else
+ XEN_GUEST_HANDLE(xen_pfn_t) frame_list;
+#endif
+};
+typedef struct gnttab_setup_table gnttab_setup_table_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_setup_table_t);
+
+/*
+ * GNTTABOP_dump_table: Dump the contents of the grant table to the
+ * xen console. Debugging use only.
+ */
+struct gnttab_dump_table {
+ /* IN parameters. */
+ domid_t dom;
+ /* OUT parameters. */
+ int16_t status; /* => enum grant_status */
+};
+typedef struct gnttab_dump_table gnttab_dump_table_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_dump_table_t);
+
+/*
+ * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The
+ * foreign domain has previously registered its interest in the transfer via
+ * <domid, ref>.
+ *
+ * Note that, even if the transfer fails, the specified page no longer belongs
+ * to the calling domain *unless* the error is GNTST_bad_page.
+ */
+struct gnttab_transfer {
+ /* IN parameters. */
+ xen_pfn_t mfn;
+ domid_t domid;
+ grant_ref_t ref;
+ /* OUT parameters. */
+ int16_t status;
+};
+typedef struct gnttab_transfer gnttab_transfer_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_t);
+
+
+/*
+ * GNTTABOP_copy: Hypervisor based copy
+ * source and destinations can be eithers MFNs or, for foreign domains,
+ * grant references. the foreign domain has to grant read/write access
+ * in its grant table.
+ *
+ * The flags specify what type source and destinations are (either MFN
+ * or grant reference).
+ *
+ * Note that this can also be used to copy data between two domains
+ * via a third party if the source and destination domains had previously
+ * grant appropriate access to their pages to the third party.
+ *
+ * source_offset specifies an offset in the source frame, dest_offset
+ * the offset in the target frame and len specifies the number of
+ * bytes to be copied.
+ */
+
+#define _GNTCOPY_source_gref (0)
+#define GNTCOPY_source_gref (1<<_GNTCOPY_source_gref)
+#define _GNTCOPY_dest_gref (1)
+#define GNTCOPY_dest_gref (1<<_GNTCOPY_dest_gref)
+
+struct gnttab_copy {
+ /* IN parameters. */
+ struct {
+ union {
+ grant_ref_t ref;
+ xen_pfn_t gmfn;
+ } u;
+ domid_t domid;
+ uint16_t offset;
+ } source, dest;
+ uint16_t len;
+ uint16_t flags; /* GNTCOPY_* */
+ /* OUT parameters. */
+ int16_t status;
+};
+typedef struct gnttab_copy gnttab_copy_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_copy_t);
+
+/*
+ * GNTTABOP_query_size: Query the current and maximum sizes of the shared
+ * grant table.
+ * NOTES:
+ * 1. <dom> may be specified as DOMID_SELF.
+ * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF.
+ */
+struct gnttab_query_size {
+ /* IN parameters. */
+ domid_t dom;
+ /* OUT parameters. */
+ uint32_t nr_frames;
+ uint32_t max_nr_frames;
+ int16_t status; /* => enum grant_status */
+};
+typedef struct gnttab_query_size gnttab_query_size_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_query_size_t);
+
+/*
+ * GNTTABOP_unmap_and_replace: Destroy one or more grant-reference mappings
+ * tracked by <handle> but atomically replace the page table entry with one
+ * pointing to the machine address under <new_addr>. <new_addr> will be
+ * redirected to the null entry.
+ * NOTES:
+ * 1. The call may fail in an undefined manner if either mapping is not
+ * tracked by <handle>.
+ * 2. After executing a batch of unmaps, it is guaranteed that no stale
+ * mappings will remain in the device or host TLBs.
+ */
+struct gnttab_unmap_and_replace {
+ /* IN parameters. */
+ uint64_t host_addr;
+ uint64_t new_addr;
+ grant_handle_t handle;
+ /* OUT parameters. */
+ int16_t status; /* => enum grant_status */
+};
+typedef struct gnttab_unmap_and_replace gnttab_unmap_and_replace_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_and_replace_t);
+
+#if __XEN_INTERFACE_VERSION__ >= 0x0003020a
+/*
+ * GNTTABOP_set_version: Request a particular version of the grant
+ * table shared table structure. This operation can only be performed
+ * once in any given domain. It must be performed before any grants
+ * are activated; otherwise, the domain will be stuck with version 1.
+ * The only defined versions are 1 and 2.
+ */
+struct gnttab_set_version {
+ /* IN/OUT parameters */
+ uint32_t version;
+};
+typedef struct gnttab_set_version gnttab_set_version_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_set_version_t);
+
+
+/*
+ * GNTTABOP_get_status_frames: Get the list of frames used to store grant
+ * status for <dom>. In grant format version 2, the status is separated
+ * from the other shared grant fields to allow more efficient synchronization
+ * using barriers instead of atomic cmpexch operations.
+ * <nr_frames> specify the size of vector <frame_list>.
+ * The frame addresses are returned in the <frame_list>.
+ * Only <nr_frames> addresses are returned, even if the table is larger.
+ * NOTES:
+ * 1. <dom> may be specified as DOMID_SELF.
+ * 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF.
+ */
+struct gnttab_get_status_frames {
+ /* IN parameters. */
+ uint32_t nr_frames;
+ domid_t dom;
+ /* OUT parameters. */
+ int16_t status; /* => enum grant_status */
+ XEN_GUEST_HANDLE(uint64_t) frame_list;
+};
+typedef struct gnttab_get_status_frames gnttab_get_status_frames_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_get_status_frames_t);
+
+/*
+ * GNTTABOP_get_version: Get the grant table version which is in
+ * effect for domain <dom>.
+ */
+struct gnttab_get_version {
+ /* IN parameters */
+ domid_t dom;
+ uint16_t pad;
+ /* OUT parameters */
+ uint32_t version;
+};
+typedef struct gnttab_get_version gnttab_get_version_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_get_version_t);
+
+/*
+ * GNTTABOP_swap_grant_ref: Swap the contents of two grant entries.
+ */
+struct gnttab_swap_grant_ref {
+ /* IN parameters */
+ grant_ref_t ref_a;
+ grant_ref_t ref_b;
+ /* OUT parameters */
+ int16_t status; /* => enum grant_status */
+};
+typedef struct gnttab_swap_grant_ref gnttab_swap_grant_ref_t;
+DEFINE_XEN_GUEST_HANDLE(gnttab_swap_grant_ref_t);
+
+#endif /* __XEN_INTERFACE_VERSION__ */
+
+/*
+ * Bitfield values for gnttab_map_grant_ref.flags.
+ */
+ /* Map the grant entry for access by I/O devices. */
+#define _GNTMAP_device_map (0)
+#define GNTMAP_device_map (1<<_GNTMAP_device_map)
+ /* Map the grant entry for access by host CPUs. */
+#define _GNTMAP_host_map (1)
+#define GNTMAP_host_map (1<<_GNTMAP_host_map)
+ /* Accesses to the granted frame will be restricted to read-only access. */
+#define _GNTMAP_readonly (2)
+#define GNTMAP_readonly (1<<_GNTMAP_readonly)
+ /*
+ * GNTMAP_host_map subflag:
+ * 0 => The host mapping is usable only by the guest OS.
+ * 1 => The host mapping is usable by guest OS + current application.
+ */
+#define _GNTMAP_application_map (3)
+#define GNTMAP_application_map (1<<_GNTMAP_application_map)
+
+ /*
+ * GNTMAP_contains_pte subflag:
+ * 0 => This map request contains a host virtual address.
+ * 1 => This map request contains the machine addess of the PTE to update.
+ */
+#define _GNTMAP_contains_pte (4)
+#define GNTMAP_contains_pte (1<<_GNTMAP_contains_pte)
+
+#define _GNTMAP_can_fail (5)
+#define GNTMAP_can_fail (1<<_GNTMAP_can_fail)
+
+/*
+ * Bits to be placed in guest kernel available PTE bits (architecture
+ * dependent; only supported when XENFEAT_gnttab_map_avail_bits is set).
+ */
+#define _GNTMAP_guest_avail0 (16)
+#define GNTMAP_guest_avail_mask ((uint32_t)~0 << _GNTMAP_guest_avail0)
+
+/*
+ * Values for error status returns. All errors are -ve.
+ */
+/* ` enum grant_status { */
+#define GNTST_okay (0) /* Normal return. */
+#define GNTST_general_error (-1) /* General undefined error. */
+#define GNTST_bad_domain (-2) /* Unrecognsed domain id. */
+#define GNTST_bad_gntref (-3) /* Unrecognised or inappropriate gntref. */
+#define GNTST_bad_handle (-4) /* Unrecognised or inappropriate handle. */
+#define GNTST_bad_virt_addr (-5) /* Inappropriate virtual address to map. */
+#define GNTST_bad_dev_addr (-6) /* Inappropriate device address to unmap.*/
+#define GNTST_no_device_space (-7) /* Out of space in I/O MMU. */
+#define GNTST_permission_denied (-8) /* Not enough privilege for operation. */
+#define GNTST_bad_page (-9) /* Specified page was invalid for op. */
+#define GNTST_bad_copy_arg (-10) /* copy arguments cross page boundary. */
+#define GNTST_address_too_big (-11) /* transfer page address too large. */
+#define GNTST_eagain (-12) /* Operation not done; try again. */
+/* ` } */
+
+#define GNTTABOP_error_msgs { \
+ "okay", \
+ "undefined error", \
+ "unrecognised domain id", \
+ "invalid grant reference", \
+ "invalid mapping handle", \
+ "invalid virtual address", \
+ "invalid device address", \
+ "no spare translation slot in the I/O MMU", \
+ "permission denied", \
+ "bad page", \
+ "copy arguments cross page boundary", \
+ "page address size too large", \
+ "operation not done; try again" \
+}
+
+#endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/io/blkif.h b/include/xen/io/blkif.h
new file mode 100644
index 000000000..c3e169ce2
--- /dev/null
+++ b/include/xen/io/blkif.h
@@ -0,0 +1,608 @@
+/******************************************************************************
+ * blkif.h
+ *
+ * Unified block-device I/O interface for Xen guest OSes.
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright (c) 2003-2004, Keir Fraser
+ * Copyright (c) 2012, Spectra Logic Corporation
+ */
+
+#ifndef __XEN_PUBLIC_IO_BLKIF_H__
+#define __XEN_PUBLIC_IO_BLKIF_H__
+
+#include "ring.h"
+#include "../grant_table.h"
+
+/*
+ * Front->back notifications: When enqueuing a new request, sending a
+ * notification can be made conditional on req_event (i.e., the generic
+ * hold-off mechanism provided by the ring macros). Backends must set
+ * req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).
+ *
+ * Back->front notifications: When enqueuing a new response, sending a
+ * notification can be made conditional on rsp_event (i.e., the generic
+ * hold-off mechanism provided by the ring macros). Frontends must set
+ * rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).
+ */
+
+#ifndef blkif_vdev_t
+#define blkif_vdev_t uint16_t
+#endif
+#define blkif_sector_t uint64_t
+
+/*
+ * Feature and Parameter Negotiation
+ * =================================
+ * The two halves of a Xen block driver utilize nodes within the XenStore to
+ * communicate capabilities and to negotiate operating parameters. This
+ * section enumerates these nodes which reside in the respective front and
+ * backend portions of the XenStore, following the XenBus convention.
+ *
+ * All data in the XenStore is stored as strings. Nodes specifying numeric
+ * values are encoded in decimal. Integer value ranges listed below are
+ * expressed as fixed sized integer types capable of storing the conversion
+ * of a properly formated node string, without loss of information.
+ *
+ * Any specified default value is in effect if the corresponding XenBus node
+ * is not present in the XenStore.
+ *
+ * XenStore nodes in sections marked "PRIVATE" are solely for use by the
+ * driver side whose XenBus tree contains them.
+ *
+ * XenStore nodes marked "DEPRECATED" in their notes section should only be
+ * used to provide interoperability with legacy implementations.
+ *
+ * See the XenBus state transition diagram below for details on when XenBus
+ * nodes must be published and when they can be queried.
+ *
+ *****************************************************************************
+ * Backend XenBus Nodes
+ *****************************************************************************
+ *
+ *------------------ Backend Device Identification (PRIVATE) ------------------
+ *
+ * mode
+ * Values: "r" (read only), "w" (writable)
+ *
+ * The read or write access permissions to the backing store to be
+ * granted to the frontend.
+ *
+ * params
+ * Values: string
+ *
+ * A free formatted string providing sufficient information for the
+ * backend driver to open the backing device. (e.g. the path to the
+ * file or block device representing the backing store.)
+ *
+ * type
+ * Values: "file", "phy", "tap"
+ *
+ * The type of the backing device/object.
+ *
+ *--------------------------------- Features ---------------------------------
+ *
+ * feature-barrier
+ * Values: 0/1 (boolean)
+ * Default Value: 0
+ *
+ * A value of "1" indicates that the backend can process requests
+ * containing the BLKIF_OP_WRITE_BARRIER request opcode. Requests
+ * of this type may still be returned at any time with the
+ * BLKIF_RSP_EOPNOTSUPP result code.
+ *
+ * feature-flush-cache
+ * Values: 0/1 (boolean)
+ * Default Value: 0
+ *
+ * A value of "1" indicates that the backend can process requests
+ * containing the BLKIF_OP_FLUSH_DISKCACHE request opcode. Requests
+ * of this type may still be returned at any time with the
+ * BLKIF_RSP_EOPNOTSUPP result code.
+ *
+ * feature-discard
+ * Values: 0/1 (boolean)
+ * Default Value: 0
+ *
+ * A value of "1" indicates that the backend can process requests
+ * containing the BLKIF_OP_DISCARD request opcode. Requests
+ * of this type may still be returned at any time with the
+ * BLKIF_RSP_EOPNOTSUPP result code.
+ *
+ * feature-persistent
+ * Values: 0/1 (boolean)
+ * Default Value: 0
+ * Notes: 7
+ *
+ * A value of "1" indicates that the backend can keep the grants used
+ * by the frontend driver mapped, so the same set of grants should be
+ * used in all transactions. The maximum number of grants the backend
+ * can map persistently depends on the implementation, but ideally it
+ * should be RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST. Using this
+ * feature the backend doesn't need to unmap each grant, preventing
+ * costly TLB flushes. The backend driver should only map grants
+ * persistently if the frontend supports it. If a backend driver chooses
+ * to use the persistent protocol when the frontend doesn't support it,
+ * it will probably hit the maximum number of persistently mapped grants
+ * (due to the fact that the frontend won't be reusing the same grants),
+ * and fall back to non-persistent mode. Backend implementations may
+ * shrink or expand the number of persistently mapped grants without
+ * notifying the frontend depending on memory constraints (this might
+ * cause a performance degradation).
+ *
+ * If a backend driver wants to limit the maximum number of persistently
+ * mapped grants to a value less than RING_SIZE *
+ * BLKIF_MAX_SEGMENTS_PER_REQUEST a LRU strategy should be used to
+ * discard the grants that are less commonly used. Using a LRU in the
+ * backend driver paired with a LIFO queue in the frontend will
+ * allow us to have better performance in this scenario.
+ *
+ *----------------------- Request Transport Parameters ------------------------
+ *
+ * max-ring-page-order
+ * Values: <uint32_t>
+ * Default Value: 0
+ * Notes: 1, 3
+ *
+ * The maximum supported size of the request ring buffer in units of
+ * lb(machine pages). (e.g. 0 == 1 page, 1 = 2 pages, 2 == 4 pages,
+ * etc.).
+ *
+ * max-ring-pages
+ * Values: <uint32_t>
+ * Default Value: 1
+ * Notes: DEPRECATED, 2, 3
+ *
+ * The maximum supported size of the request ring buffer in units of
+ * machine pages. The value must be a power of 2.
+ *
+ *------------------------- Backend Device Properties -------------------------
+ *
+ * discard-alignment
+ * Values: <uint32_t>
+ * Default Value: 0
+ * Notes: 4, 5
+ *
+ * The offset, in bytes from the beginning of the virtual block device,
+ * to the first, addressable, discard extent on the underlying device.
+ *
+ * discard-granularity
+ * Values: <uint32_t>
+ * Default Value: <"sector-size">
+ * Notes: 4
+ *
+ * The size, in bytes, of the individually addressable discard extents
+ * of the underlying device.
+ *
+ * discard-secure
+ * Values: 0/1 (boolean)
+ * Default Value: 0
+ * Notes: 10
+ *
+ * A value of "1" indicates that the backend can process BLKIF_OP_DISCARD
+ * requests with the BLKIF_DISCARD_SECURE flag set.
+ *
+ * info
+ * Values: <uint32_t> (bitmap)
+ *
+ * A collection of bit flags describing attributes of the backing
+ * device. The VDISK_* macros define the meaning of each bit
+ * location.
+ *
+ * sector-size
+ * Values: <uint32_t>
+ *
+ * The logical sector size, in bytes, of the backend device.
+ *
+ * physical-sector-size
+ * Values: <uint32_t>
+ *
+ * The physical sector size, in bytes, of the backend device.
+ *
+ * sectors
+ * Values: <uint64_t>
+ *
+ * The size of the backend device, expressed in units of its logical
+ * sector size ("sector-size").
+ *
+ *****************************************************************************
+ * Frontend XenBus Nodes
+ *****************************************************************************
+ *
+ *----------------------- Request Transport Parameters -----------------------
+ *
+ * event-channel
+ * Values: <uint32_t>
+ *
+ * The identifier of the Xen event channel used to signal activity
+ * in the ring buffer.
+ *
+ * ring-ref
+ * Values: <uint32_t>
+ * Notes: 6
+ *
+ * The Xen grant reference granting permission for the backend to map
+ * the sole page in a single page sized ring buffer.
+ *
+ * ring-ref%u
+ * Values: <uint32_t>
+ * Notes: 6
+ *
+ * For a frontend providing a multi-page ring, a "number of ring pages"
+ * sized list of nodes, each containing a Xen grant reference granting
+ * permission for the backend to map the page of the ring located
+ * at page index "%u". Page indexes are zero based.
+ *
+ * protocol
+ * Values: string (XEN_IO_PROTO_ABI_*)
+ * Default Value: XEN_IO_PROTO_ABI_NATIVE
+ *
+ * The machine ABI rules governing the format of all ring request and
+ * response structures.
+ *
+ * ring-page-order
+ * Values: <uint32_t>
+ * Default Value: 0
+ * Maximum Value: MAX(ffs(max-ring-pages) - 1, max-ring-page-order)
+ * Notes: 1, 3
+ *
+ * The size of the frontend allocated request ring buffer in units
+ * of lb(machine pages). (e.g. 0 == 1 page, 1 = 2 pages, 2 == 4 pages,
+ * etc.).
+ *
+ * num-ring-pages
+ * Values: <uint32_t>
+ * Default Value: 1
+ * Maximum Value: MAX(max-ring-pages,(0x1 << max-ring-page-order))
+ * Notes: DEPRECATED, 2, 3
+ *
+ * The size of the frontend allocated request ring buffer in units of
+ * machine pages. The value must be a power of 2.
+ *
+ * feature-persistent
+ * Values: 0/1 (boolean)
+ * Default Value: 0
+ * Notes: 7, 8, 9
+ *
+ * A value of "1" indicates that the frontend will reuse the same grants
+ * for all transactions, allowing the backend to map them with write
+ * access (even when it should be read-only). If the frontend hits the
+ * maximum number of allowed persistently mapped grants, it can fallback
+ * to non persistent mode. This will cause a performance degradation,
+ * since the the backend driver will still try to map those grants
+ * persistently. Since the persistent grants protocol is compatible with
+ * the previous protocol, a frontend driver can choose to work in
+ * persistent mode even when the backend doesn't support it.
+ *
+ * It is recommended that the frontend driver stores the persistently
+ * mapped grants in a LIFO queue, so a subset of all persistently mapped
+ * grants gets used commonly. This is done in case the backend driver
+ * decides to limit the maximum number of persistently mapped grants
+ * to a value less than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST.
+ *
+ *------------------------- Virtual Device Properties -------------------------
+ *
+ * device-type
+ * Values: "disk", "cdrom", "floppy", etc.
+ *
+ * virtual-device
+ * Values: <uint32_t>
+ *
+ * A value indicating the physical device to virtualize within the
+ * frontend's domain. (e.g. "The first ATA disk", "The third SCSI
+ * disk", etc.)
+ *
+ * See docs/misc/vbd-interface.txt for details on the format of this
+ * value.
+ *
+ * Notes
+ * -----
+ * (1) Multi-page ring buffer scheme first developed in the Citrix XenServer
+ * PV drivers.
+ * (2) Multi-page ring buffer scheme first used in some RedHat distributions
+ * including a distribution deployed on certain nodes of the Amazon
+ * EC2 cluster.
+ * (3) Support for multi-page ring buffers was implemented independently,
+ * in slightly different forms, by both Citrix and RedHat/Amazon.
+ * For full interoperability, block front and backends should publish
+ * identical ring parameters, adjusted for unit differences, to the
+ * XenStore nodes used in both schemes.
+ * (4) Devices that support discard functionality may internally allocate space
+ * (discardable extents) in units that are larger than the exported logical
+ * block size. If the backing device has such discardable extents the
+ * backend should provide both discard-granularity and discard-alignment.
+ * Providing just one of the two may be considered an error by the frontend.
+ * Backends supporting discard should include discard-granularity and
+ * discard-alignment even if it supports discarding individual sectors.
+ * Frontends should assume discard-alignment == 0 and discard-granularity
+ * == sector size if these keys are missing.
+ * (5) The discard-alignment parameter allows a physical device to be
+ * partitioned into virtual devices that do not necessarily begin or
+ * end on a discardable extent boundary.
+ * (6) When there is only a single page allocated to the request ring,
+ * 'ring-ref' is used to communicate the grant reference for this
+ * page to the backend. When using a multi-page ring, the 'ring-ref'
+ * node is not created. Instead 'ring-ref0' - 'ring-refN' are used.
+ * (7) When using persistent grants data has to be copied from/to the page
+ * where the grant is currently mapped. The overhead of doing this copy
+ * however doesn't suppress the speed improvement of not having to unmap
+ * the grants.
+ * (8) The frontend driver has to allow the backend driver to map all grants
+ * with write access, even when they should be mapped read-only, since
+ * further requests may reuse these grants and require write permissions.
+ * (9) Linux implementation doesn't have a limit on the maximum number of
+ * grants that can be persistently mapped in the frontend driver, but
+ * due to the frontent driver implementation it should never be bigger
+ * than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST.
+ *(10) The discard-secure property may be present and will be set to 1 if the
+ * backing device supports secure discard.
+ */
+
+/*
+ * STATE DIAGRAMS
+ *
+ *****************************************************************************
+ * Startup *
+ *****************************************************************************
+ *
+ * Tool stack creates front and back nodes with state XenbusStateInitialising.
+ *
+ * Front Back
+ * ================================= =====================================
+ * XenbusStateInitialising XenbusStateInitialising
+ * o Query virtual device o Query backend device identification
+ * properties. data.
+ * o Setup OS device instance. o Open and validate backend device.
+ * o Publish backend features and
+ * transport parameters.
+ * |
+ * |
+ * V
+ * XenbusStateInitWait
+ *
+ * o Query backend features and
+ * transport parameters.
+ * o Allocate and initialize the
+ * request ring.
+ * o Publish transport parameters
+ * that will be in effect during
+ * this connection.
+ * |
+ * |
+ * V
+ * XenbusStateInitialised
+ *
+ * o Query frontend transport parameters.
+ * o Connect to the request ring and
+ * event channel.
+ * o Publish backend device properties.
+ * |
+ * |
+ * V
+ * XenbusStateConnected
+ *
+ * o Query backend device properties.
+ * o Finalize OS virtual device
+ * instance.
+ * |
+ * |
+ * V
+ * XenbusStateConnected
+ *
+ * Note: Drivers that do not support any optional features, or the negotiation
+ * of transport parameters, can skip certain states in the state machine:
+ *
+ * o A frontend may transition to XenbusStateInitialised without
+ * waiting for the backend to enter XenbusStateInitWait. In this
+ * case, default transport parameters are in effect and any
+ * transport parameters published by the frontend must contain
+ * their default values.
+ *
+ * o A backend may transition to XenbusStateInitialised, bypassing
+ * XenbusStateInitWait, without waiting for the frontend to first
+ * enter the XenbusStateInitialised state. In this case, default
+ * transport parameters are in effect and any transport parameters
+ * published by the backend must contain their default values.
+ *
+ * Drivers that support optional features and/or transport parameter
+ * negotiation must tolerate these additional state transition paths.
+ * In general this means performing the work of any skipped state
+ * transition, if it has not already been performed, in addition to the
+ * work associated with entry into the current state.
+ */
+
+/*
+ * REQUEST CODES.
+ */
+#define BLKIF_OP_READ 0
+#define BLKIF_OP_WRITE 1
+/*
+ * All writes issued prior to a request with the BLKIF_OP_WRITE_BARRIER
+ * operation code ("barrier request") must be completed prior to the
+ * execution of the barrier request. All writes issued after the barrier
+ * request must not execute until after the completion of the barrier request.
+ *
+ * Optional. See "feature-barrier" XenBus node documentation above.
+ */
+#define BLKIF_OP_WRITE_BARRIER 2
+/*
+ * Commit any uncommitted contents of the backing device's volatile cache
+ * to stable storage.
+ *
+ * Optional. See "feature-flush-cache" XenBus node documentation above.
+ */
+#define BLKIF_OP_FLUSH_DISKCACHE 3
+/*
+ * Used in SLES sources for device specific command packet
+ * contained within the request. Reserved for that purpose.
+ */
+#define BLKIF_OP_RESERVED_1 4
+/*
+ * Indicate to the backend device that a region of storage is no longer in
+ * use, and may be discarded at any time without impact to the client. If
+ * the BLKIF_DISCARD_SECURE flag is set on the request, all copies of the
+ * discarded region on the device must be rendered unrecoverable before the
+ * command returns.
+ *
+ * This operation is analogous to performing a trim (ATA) or unamp (SCSI),
+ * command on a native device.
+ *
+ * More information about trim/unmap operations can be found at:
+ * http://t13.org/Documents/UploadedDocuments/docs2008/
+ * e07154r6-Data_Set_Management_Proposal_for_ATA-ACS2.doc
+ * http://www.seagate.com/staticfiles/support/disc/manuals/
+ * Interface%20manuals/100293068c.pdf
+ *
+ * Optional. See "feature-discard", "discard-alignment",
+ * "discard-granularity", and "discard-secure" in the XenBus node
+ * documentation above.
+ */
+#define BLKIF_OP_DISCARD 5
+
+/*
+ * Recognized if "feature-max-indirect-segments" in present in the backend
+ * xenbus info. The "feature-max-indirect-segments" node contains the maximum
+ * number of segments allowed by the backend per request. If the node is
+ * present, the frontend might use blkif_request_indirect structs in order to
+ * issue requests with more than BLKIF_MAX_SEGMENTS_PER_REQUEST (11). The
+ * maximum number of indirect segments is fixed by the backend, but the
+ * frontend can issue requests with any number of indirect segments as long as
+ * it's less than the number provided by the backend. The indirect_grefs field
+ * in blkif_request_indirect should be filled by the frontend with the
+ * grant references of the pages that are holding the indirect segments.
+ * These pages are filled with an array of blkif_request_segment that hold the
+ * information about the segments. The number of indirect pages to use is
+ * determined by the number of segments an indirect request contains. Every
+ * indirect page can contain a maximum of
+ * (PAGE_SIZE / sizeof(struct blkif_request_segment)) segments, so to
+ * calculate the number of indirect pages to use we have to do
+ * ceil(indirect_segments / (PAGE_SIZE / sizeof(struct blkif_request_segment))).
+ *
+ * If a backend does not recognize BLKIF_OP_INDIRECT, it should *not*
+ * create the "feature-max-indirect-segments" node!
+ */
+#define BLKIF_OP_INDIRECT 6
+
+/*
+ * Maximum scatter/gather segments per request.
+ * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE.
+ * NB. This could be 12 if the ring indexes weren't stored in the same page.
+ */
+#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
+
+/*
+ * Maximum number of indirect pages to use per request.
+ */
+#define BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST 8
+
+/*
+ * NB. first_sect and last_sect in blkif_request_segment, as well as
+ * sector_number in blkif_request, are always expressed in 512-byte units.
+ * However they must be properly aligned to the real sector size of the
+ * physical disk, which is reported in the "physical-sector-size" node in
+ * the backend xenbus info. Also the xenbus "sectors" node is expressed in
+ * 512-byte units.
+ */
+struct blkif_request_segment {
+ grant_ref_t gref; /* reference to I/O buffer frame */
+ /* @first_sect: first sector in frame to transfer (inclusive). */
+ /* @last_sect: last sector in frame to transfer (inclusive). */
+ uint8_t first_sect, last_sect;
+};
+
+/*
+ * Starting ring element for any I/O request.
+ */
+struct blkif_request {
+ uint8_t operation; /* BLKIF_OP_??? */
+ uint8_t nr_segments; /* number of segments */
+ blkif_vdev_t handle; /* only for read/write requests */
+ uint64_t id; /* private guest value, echoed in resp */
+ blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
+ struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+};
+typedef struct blkif_request blkif_request_t;
+
+/*
+ * Cast to this structure when blkif_request.operation == BLKIF_OP_DISCARD
+ * sizeof(struct blkif_request_discard) <= sizeof(struct blkif_request)
+ */
+struct blkif_request_discard {
+ uint8_t operation; /* BLKIF_OP_DISCARD */
+ uint8_t flag; /* BLKIF_DISCARD_SECURE or zero */
+#define BLKIF_DISCARD_SECURE (1<<0) /* ignored if discard-secure=0 */
+ blkif_vdev_t handle; /* same as for read/write requests */
+ uint64_t id; /* private guest value, echoed in resp */
+ blkif_sector_t sector_number;/* start sector idx on disk */
+ uint64_t nr_sectors; /* number of contiguous sectors to discard*/
+};
+typedef struct blkif_request_discard blkif_request_discard_t;
+
+struct blkif_request_indirect {
+ uint8_t operation; /* BLKIF_OP_INDIRECT */
+ uint8_t indirect_op; /* BLKIF_OP_{READ/WRITE} */
+ uint16_t nr_segments; /* number of segments */
+ uint64_t id; /* private guest value, echoed in resp */
+ blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
+ blkif_vdev_t handle; /* same as for read/write requests */
+ grant_ref_t indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];
+#ifdef __i386__
+ uint64_t pad; /* Make it 64 byte aligned on i386 */
+#endif
+};
+typedef struct blkif_request_indirect blkif_request_indirect_t;
+
+struct blkif_response {
+ uint64_t id; /* copied from request */
+ uint8_t operation; /* copied from request */
+ int16_t status; /* BLKIF_RSP_??? */
+};
+typedef struct blkif_response blkif_response_t;
+
+/*
+ * STATUS RETURN CODES.
+ */
+ /* Operation not supported (only happens on barrier writes). */
+#define BLKIF_RSP_EOPNOTSUPP -2
+ /* Operation failed for some unspecified reason (-EIO). */
+#define BLKIF_RSP_ERROR -1
+ /* Operation completed successfully. */
+#define BLKIF_RSP_OKAY 0
+
+/*
+ * Generate blkif ring structures and types.
+ */
+DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response);
+
+#define VDISK_CDROM 0x1
+#define VDISK_REMOVABLE 0x2
+#define VDISK_READONLY 0x4
+
+#endif /* __XEN_PUBLIC_IO_BLKIF_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/io/console.h b/include/xen/io/console.h
new file mode 100644
index 000000000..e2cd97f77
--- /dev/null
+++ b/include/xen/io/console.h
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * console.h
+ *
+ * Console I/O interface for Xen guest OSes.
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright (c) 2005, Keir Fraser
+ */
+
+#ifndef __XEN_PUBLIC_IO_CONSOLE_H__
+#define __XEN_PUBLIC_IO_CONSOLE_H__
+
+typedef uint32_t XENCONS_RING_IDX;
+
+#define MASK_XENCONS_IDX(idx, ring) ((idx) & (sizeof(ring)-1))
+
+struct xencons_interface {
+ char in[1024];
+ char out[2048];
+ XENCONS_RING_IDX in_cons, in_prod;
+ XENCONS_RING_IDX out_cons, out_prod;
+};
+
+#endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/io/protocols.h b/include/xen/io/protocols.h
new file mode 100644
index 000000000..80b196bc3
--- /dev/null
+++ b/include/xen/io/protocols.h
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * protocols.h
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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 __XEN_PROTOCOLS_H__
+#define __XEN_PROTOCOLS_H__
+
+#define XEN_IO_PROTO_ABI_X86_32 "x86_32-abi"
+#define XEN_IO_PROTO_ABI_X86_64 "x86_64-abi"
+#define XEN_IO_PROTO_ABI_ARM "arm-abi"
+
+#if defined(__i386__)
+# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32
+#elif defined(__x86_64__)
+# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64
+#elif defined(__arm__) || defined(__aarch64__)
+# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_ARM
+#else
+# error arch fixup needed here
+#endif
+
+#endif
diff --git a/include/xen/io/ring.h b/include/xen/io/ring.h
new file mode 100644
index 000000000..73e13d7ae
--- /dev/null
+++ b/include/xen/io/ring.h
@@ -0,0 +1,312 @@
+/******************************************************************************
+ * ring.h
+ *
+ * Shared producer-consumer ring macros.
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Tim Deegan and Andrew Warfield November 2004.
+ */
+
+#ifndef __XEN_PUBLIC_IO_RING_H__
+#define __XEN_PUBLIC_IO_RING_H__
+
+#include "../xen-compat.h"
+
+#if __XEN_INTERFACE_VERSION__ < 0x00030208
+#define xen_mb() mb()
+#define xen_rmb() rmb()
+#define xen_wmb() wmb()
+#endif
+
+typedef unsigned int RING_IDX;
+
+/* Round a 32-bit unsigned constant down to the nearest power of two. */
+#define __RD2(_x) (((_x) & 0x00000002) ? 0x2 : ((_x) & 0x1))
+#define __RD4(_x) (((_x) & 0x0000000c) ? __RD2((_x)>>2)<<2 : __RD2(_x))
+#define __RD8(_x) (((_x) & 0x000000f0) ? __RD4((_x)>>4)<<4 : __RD4(_x))
+#define __RD16(_x) (((_x) & 0x0000ff00) ? __RD8((_x)>>8)<<8 : __RD8(_x))
+#define __RD32(_x) (((_x) & 0xffff0000) ? __RD16((_x)>>16)<<16 : __RD16(_x))
+
+/*
+ * Calculate size of a shared ring, given the total available space for the
+ * ring and indexes (_sz), and the name tag of the request/response structure.
+ * A ring contains as many entries as will fit, rounded down to the nearest
+ * power of two (so we can mask with (size-1) to loop around).
+ */
+#define __CONST_RING_SIZE(_s, _sz) \
+ (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \
+ sizeof(((struct _s##_sring *)0)->ring[0])))
+/*
+ * The same for passing in an actual pointer instead of a name tag.
+ */
+#define __RING_SIZE(_s, _sz) \
+ (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
+
+/*
+ * Macros to make the correct C datatypes for a new kind of ring.
+ *
+ * To make a new ring datatype, you need to have two message structures,
+ * let's say request_t, and response_t already defined.
+ *
+ * In a header where you want the ring datatype declared, you then do:
+ *
+ * DEFINE_RING_TYPES(mytag, request_t, response_t);
+ *
+ * These expand out to give you a set of types, as you can see below.
+ * The most important of these are:
+ *
+ * mytag_sring_t - The shared ring.
+ * mytag_front_ring_t - The 'front' half of the ring.
+ * mytag_back_ring_t - The 'back' half of the ring.
+ *
+ * To initialize a ring in your code you need to know the location and size
+ * of the shared memory area (PAGE_SIZE, for instance). To initialise
+ * the front half:
+ *
+ * mytag_front_ring_t front_ring;
+ * SHARED_RING_INIT((mytag_sring_t *)shared_page);
+ * FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
+ *
+ * Initializing the back follows similarly (note that only the front
+ * initializes the shared ring):
+ *
+ * mytag_back_ring_t back_ring;
+ * BACK_RING_INIT(&back_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
+ */
+
+#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t) \
+ \
+/* Shared ring entry */ \
+union __name##_sring_entry { \
+ __req_t req; \
+ __rsp_t rsp; \
+}; \
+ \
+/* Shared ring page */ \
+struct __name##_sring { \
+ RING_IDX req_prod, req_event; \
+ RING_IDX rsp_prod, rsp_event; \
+ union { \
+ struct { \
+ uint8_t smartpoll_active; \
+ } netif; \
+ struct { \
+ uint8_t msg; \
+ } tapif_user; \
+ uint8_t pvt_pad[4]; \
+ } private; \
+ uint8_t __pad[44]; \
+ union __name##_sring_entry ring[1]; /* variable-length */ \
+}; \
+ \
+/* "Front" end's private variables */ \
+struct __name##_front_ring { \
+ RING_IDX req_prod_pvt; \
+ RING_IDX rsp_cons; \
+ unsigned int nr_ents; \
+ struct __name##_sring *sring; \
+}; \
+ \
+/* "Back" end's private variables */ \
+struct __name##_back_ring { \
+ RING_IDX rsp_prod_pvt; \
+ RING_IDX req_cons; \
+ unsigned int nr_ents; \
+ struct __name##_sring *sring; \
+}; \
+ \
+/* Syntactic sugar */ \
+typedef struct __name##_sring __name##_sring_t; \
+typedef struct __name##_front_ring __name##_front_ring_t; \
+typedef struct __name##_back_ring __name##_back_ring_t
+
+/*
+ * Macros for manipulating rings.
+ *
+ * FRONT_RING_whatever works on the "front end" of a ring: here
+ * requests are pushed on to the ring and responses taken off it.
+ *
+ * BACK_RING_whatever works on the "back end" of a ring: here
+ * requests are taken off the ring and responses put on.
+ *
+ * N.B. these macros do NO INTERLOCKS OR FLOW CONTROL.
+ * This is OK in 1-for-1 request-response situations where the
+ * requestor (front end) never has more than RING_SIZE()-1
+ * outstanding requests.
+ */
+
+/* Initialising empty rings */
+#define SHARED_RING_INIT(_s) do { \
+ (_s)->req_prod = (_s)->rsp_prod = 0; \
+ (_s)->req_event = (_s)->rsp_event = 1; \
+ (void)memset((_s)->private.pvt_pad, 0, sizeof((_s)->private.pvt_pad)); \
+ (void)memset((_s)->__pad, 0, sizeof((_s)->__pad)); \
+} while(0)
+
+#define FRONT_RING_INIT(_r, _s, __size) do { \
+ (_r)->req_prod_pvt = 0; \
+ (_r)->rsp_cons = 0; \
+ (_r)->nr_ents = __RING_SIZE(_s, __size); \
+ (_r)->sring = (_s); \
+} while (0)
+
+#define BACK_RING_INIT(_r, _s, __size) do { \
+ (_r)->rsp_prod_pvt = 0; \
+ (_r)->req_cons = 0; \
+ (_r)->nr_ents = __RING_SIZE(_s, __size); \
+ (_r)->sring = (_s); \
+} while (0)
+
+/* How big is this ring? */
+#define RING_SIZE(_r) \
+ ((_r)->nr_ents)
+
+/* Number of free requests (for use on front side only). */
+#define RING_FREE_REQUESTS(_r) \
+ (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons))
+
+/* Test if there is an empty slot available on the front ring.
+ * (This is only meaningful from the front. )
+ */
+#define RING_FULL(_r) \
+ (RING_FREE_REQUESTS(_r) == 0)
+
+/* Test if there are outstanding messages to be processed on a ring. */
+#define RING_HAS_UNCONSUMED_RESPONSES(_r) \
+ ((_r)->sring->rsp_prod - (_r)->rsp_cons)
+
+#ifdef __GNUC__
+#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({ \
+ unsigned int req = (_r)->sring->req_prod - (_r)->req_cons; \
+ unsigned int rsp = RING_SIZE(_r) - \
+ ((_r)->req_cons - (_r)->rsp_prod_pvt); \
+ req < rsp ? req : rsp; \
+})
+#else
+/* Same as above, but without the nice GCC ({ ... }) syntax. */
+#define RING_HAS_UNCONSUMED_REQUESTS(_r) \
+ ((((_r)->sring->req_prod - (_r)->req_cons) < \
+ (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ? \
+ ((_r)->sring->req_prod - (_r)->req_cons) : \
+ (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt)))
+#endif
+
+/* Direct access to individual ring elements, by index. */
+#define RING_GET_REQUEST(_r, _idx) \
+ (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req))
+
+#define RING_GET_RESPONSE(_r, _idx) \
+ (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp))
+
+/* Loop termination condition: Would the specified index overflow the ring? */
+#define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \
+ (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
+
+/* Ill-behaved frontend determination: Can there be this many requests? */
+#define RING_REQUEST_PROD_OVERFLOW(_r, _prod) \
+ (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r))
+
+#define RING_PUSH_REQUESTS(_r) do { \
+ xen_wmb(); /* back sees requests /before/ updated producer index */ \
+ (_r)->sring->req_prod = (_r)->req_prod_pvt; \
+} while (0)
+
+#define RING_PUSH_RESPONSES(_r) do { \
+ xen_wmb(); /* front sees resps /before/ updated producer index */ \
+ (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt; \
+} while (0)
+
+/*
+ * Notification hold-off (req_event and rsp_event):
+ *
+ * When queueing requests or responses on a shared ring, it may not always be
+ * necessary to notify the remote end. For example, if requests are in flight
+ * in a backend, the front may be able to queue further requests without
+ * notifying the back (if the back checks for new requests when it queues
+ * responses).
+ *
+ * When enqueuing requests or responses:
+ *
+ * Use RING_PUSH_{REQUESTS,RESPONSES}_AND_CHECK_NOTIFY(). The second argument
+ * is a boolean return value. True indicates that the receiver requires an
+ * asynchronous notification.
+ *
+ * After dequeuing requests or responses (before sleeping the connection):
+ *
+ * Use RING_FINAL_CHECK_FOR_REQUESTS() or RING_FINAL_CHECK_FOR_RESPONSES().
+ * The second argument is a boolean return value. True indicates that there
+ * are pending messages on the ring (i.e., the connection should not be put
+ * to sleep).
+ *
+ * These macros will set the req_event/rsp_event field to trigger a
+ * notification on the very next message that is enqueued. If you want to
+ * create batches of work (i.e., only receive a notification after several
+ * messages have been enqueued) then you will need to create a customised
+ * version of the FINAL_CHECK macro in your own code, which sets the event
+ * field appropriately.
+ */
+
+#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do { \
+ RING_IDX __old = (_r)->sring->req_prod; \
+ RING_IDX __new = (_r)->req_prod_pvt; \
+ xen_wmb(); /* back sees requests /before/ updated producer index */ \
+ (_r)->sring->req_prod = __new; \
+ xen_mb(); /* back sees new requests /before/ we check req_event */ \
+ (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) < \
+ (RING_IDX)(__new - __old)); \
+} while (0)
+
+#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do { \
+ RING_IDX __old = (_r)->sring->rsp_prod; \
+ RING_IDX __new = (_r)->rsp_prod_pvt; \
+ xen_wmb(); /* front sees resps /before/ updated producer index */ \
+ (_r)->sring->rsp_prod = __new; \
+ xen_mb(); /* front sees new resps /before/ we check rsp_event */ \
+ (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) < \
+ (RING_IDX)(__new - __old)); \
+} while (0)
+
+#define RING_FINAL_CHECK_FOR_REQUESTS(_r, _work_to_do) do { \
+ (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \
+ if (_work_to_do) break; \
+ (_r)->sring->req_event = (_r)->req_cons + 1; \
+ xen_mb(); \
+ (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \
+} while (0)
+
+#define RING_FINAL_CHECK_FOR_RESPONSES(_r, _work_to_do) do { \
+ (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \
+ if (_work_to_do) break; \
+ (_r)->sring->rsp_event = (_r)->rsp_cons + 1; \
+ xen_mb(); \
+ (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \
+} while (0)
+
+#endif /* __XEN_PUBLIC_IO_RING_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/io/xenbus.h b/include/xen/io/xenbus.h
new file mode 100644
index 000000000..927f9db55
--- /dev/null
+++ b/include/xen/io/xenbus.h
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * xenbus.h
+ *
+ * Xenbus protocol details.
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright (C) 2005 XenSource Ltd.
+ */
+
+#ifndef _XEN_PUBLIC_IO_XENBUS_H
+#define _XEN_PUBLIC_IO_XENBUS_H
+
+/*
+ * The state of either end of the Xenbus, i.e. the current communication
+ * status of initialisation across the bus. States here imply nothing about
+ * the state of the connection between the driver and the kernel's device
+ * layers.
+ */
+enum xenbus_state {
+ XenbusStateUnknown = 0,
+
+ XenbusStateInitialising = 1,
+
+ /*
+ * InitWait: Finished early initialisation but waiting for information
+ * from the peer or hotplug scripts.
+ */
+ XenbusStateInitWait = 2,
+
+ /*
+ * Initialised: Waiting for a connection from the peer.
+ */
+ XenbusStateInitialised = 3,
+
+ XenbusStateConnected = 4,
+
+ /*
+ * Closing: The device is being closed due to an error or an unplug event.
+ */
+ XenbusStateClosing = 5,
+
+ XenbusStateClosed = 6,
+
+ /*
+ * Reconfiguring: The device is being reconfigured.
+ */
+ XenbusStateReconfiguring = 7,
+
+ XenbusStateReconfigured = 8
+};
+typedef enum xenbus_state XenbusState;
+
+#endif /* _XEN_PUBLIC_IO_XENBUS_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/io/xs_wire.h b/include/xen/io/xs_wire.h
new file mode 100644
index 000000000..585f0c8f5
--- /dev/null
+++ b/include/xen/io/xs_wire.h
@@ -0,0 +1,138 @@
+/*
+ * Details of the "wire" protocol between Xen Store Daemon and client
+ * library or guest kernel.
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright (C) 2005 Rusty Russell IBM Corporation
+ */
+
+#ifndef _XS_WIRE_H
+#define _XS_WIRE_H
+
+enum xsd_sockmsg_type
+{
+ XS_DEBUG,
+ XS_DIRECTORY,
+ XS_READ,
+ XS_GET_PERMS,
+ XS_WATCH,
+ XS_UNWATCH,
+ XS_TRANSACTION_START,
+ XS_TRANSACTION_END,
+ XS_INTRODUCE,
+ XS_RELEASE,
+ XS_GET_DOMAIN_PATH,
+ XS_WRITE,
+ XS_MKDIR,
+ XS_RM,
+ XS_SET_PERMS,
+ XS_WATCH_EVENT,
+ XS_ERROR,
+ XS_IS_DOMAIN_INTRODUCED,
+ XS_RESUME,
+ XS_SET_TARGET,
+ XS_RESTRICT,
+ XS_RESET_WATCHES
+};
+
+#define XS_WRITE_NONE "NONE"
+#define XS_WRITE_CREATE "CREATE"
+#define XS_WRITE_CREATE_EXCL "CREATE|EXCL"
+
+/* We hand errors as strings, for portability. */
+struct xsd_errors
+{
+ int errnum;
+ const char *errstring;
+};
+#ifdef EINVAL
+#define XSD_ERROR(x) { x, #x }
+/* LINTED: static unused */
+static struct xsd_errors xsd_errors[]
+#if defined(__GNUC__)
+__attribute__((unused))
+#endif
+ = {
+ XSD_ERROR(EINVAL),
+ XSD_ERROR(EACCES),
+ XSD_ERROR(EEXIST),
+ XSD_ERROR(EISDIR),
+ XSD_ERROR(ENOENT),
+ XSD_ERROR(ENOMEM),
+ XSD_ERROR(ENOSPC),
+ XSD_ERROR(EIO),
+ XSD_ERROR(ENOTEMPTY),
+ XSD_ERROR(ENOSYS),
+ XSD_ERROR(EROFS),
+ XSD_ERROR(EBUSY),
+ XSD_ERROR(EAGAIN),
+ XSD_ERROR(EISCONN),
+ XSD_ERROR(E2BIG)
+};
+#endif
+
+struct xsd_sockmsg
+{
+ uint32_t type; /* XS_??? */
+ uint32_t req_id;/* Request identifier, echoed in daemon's response. */
+ uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
+ uint32_t len; /* Length of data following this. */
+
+ /* Generally followed by nul-terminated string(s). */
+};
+
+enum xs_watch_type
+{
+ XS_WATCH_PATH = 0,
+ XS_WATCH_TOKEN
+};
+
+/*
+ * `incontents 150 xenstore_struct XenStore wire protocol.
+ *
+ * Inter-domain shared memory communications. */
+#define XENSTORE_RING_SIZE 1024
+typedef uint32_t XENSTORE_RING_IDX;
+#define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1))
+struct xenstore_domain_interface {
+ char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */
+ char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */
+ XENSTORE_RING_IDX req_cons, req_prod;
+ XENSTORE_RING_IDX rsp_cons, rsp_prod;
+};
+
+/* Violating this is very bad. See docs/misc/xenstore.txt. */
+#define XENSTORE_PAYLOAD_MAX 4096
+
+/* Violating these just gets you an error back */
+#define XENSTORE_ABS_PATH_MAX 3072
+#define XENSTORE_REL_PATH_MAX 2048
+
+#endif /* _XS_WIRE_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/sched.h b/include/xen/sched.h
new file mode 100644
index 000000000..a30b11d96
--- /dev/null
+++ b/include/xen/sched.h
@@ -0,0 +1,174 @@
+/******************************************************************************
+ * sched.h
+ *
+ * Scheduler state interactions
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
+ */
+
+#ifndef __XEN_PUBLIC_SCHED_H__
+#define __XEN_PUBLIC_SCHED_H__
+
+#include "event_channel.h"
+
+/*
+ * `incontents 150 sched Guest Scheduler Operations
+ *
+ * The SCHEDOP interface provides mechanisms for a guest to interact
+ * with the scheduler, including yield, blocking and shutting itself
+ * down.
+ */
+
+/*
+ * The prototype for this hypercall is:
+ * ` long HYPERVISOR_sched_op(enum sched_op cmd, void *arg, ...)
+ *
+ * @cmd == SCHEDOP_??? (scheduler operation).
+ * @arg == Operation-specific extra argument(s), as described below.
+ * ... == Additional Operation-specific extra arguments, described below.
+ *
+ * Versions of Xen prior to 3.0.2 provided only the following legacy version
+ * of this hypercall, supporting only the commands yield, block and shutdown:
+ * long sched_op(int cmd, unsigned long arg)
+ * @cmd == SCHEDOP_??? (scheduler operation).
+ * @arg == 0 (SCHEDOP_yield and SCHEDOP_block)
+ * == SHUTDOWN_* code (SCHEDOP_shutdown)
+ *
+ * This legacy version is available to new guests as:
+ * ` long HYPERVISOR_sched_op_compat(enum sched_op cmd, unsigned long arg)
+ */
+
+/* ` enum sched_op { // SCHEDOP_* => struct sched_* */
+/*
+ * Voluntarily yield the CPU.
+ * @arg == NULL.
+ */
+#define SCHEDOP_yield 0
+
+/*
+ * Block execution of this VCPU until an event is received for processing.
+ * If called with event upcalls masked, this operation will atomically
+ * reenable event delivery and check for pending events before blocking the
+ * VCPU. This avoids a "wakeup waiting" race.
+ * @arg == NULL.
+ */
+#define SCHEDOP_block 1
+
+/*
+ * Halt execution of this domain (all VCPUs) and notify the system controller.
+ * @arg == pointer to sched_shutdown_t structure.
+ *
+ * If the sched_shutdown_t reason is SHUTDOWN_suspend then this
+ * hypercall takes an additional extra argument which should be the
+ * MFN of the guest's start_info_t.
+ *
+ * In addition, which reason is SHUTDOWN_suspend this hypercall
+ * returns 1 if suspend was cancelled or the domain was merely
+ * checkpointed, and 0 if it is resuming in a new domain.
+ */
+#define SCHEDOP_shutdown 2
+
+/*
+ * Poll a set of event-channel ports. Return when one or more are pending. An
+ * optional timeout may be specified.
+ * @arg == pointer to sched_poll_t structure.
+ */
+#define SCHEDOP_poll 3
+
+/*
+ * Declare a shutdown for another domain. The main use of this function is
+ * in interpreting shutdown requests and reasons for fully-virtualized
+ * domains. A para-virtualized domain may use SCHEDOP_shutdown directly.
+ * @arg == pointer to sched_remote_shutdown_t structure.
+ */
+#define SCHEDOP_remote_shutdown 4
+
+/*
+ * Latch a shutdown code, so that when the domain later shuts down it
+ * reports this code to the control tools.
+ * @arg == sched_shutdown_t, as for SCHEDOP_shutdown.
+ */
+#define SCHEDOP_shutdown_code 5
+
+/*
+ * Setup, poke and destroy a domain watchdog timer.
+ * @arg == pointer to sched_watchdog_t structure.
+ * With id == 0, setup a domain watchdog timer to cause domain shutdown
+ * after timeout, returns watchdog id.
+ * With id != 0 and timeout == 0, destroy domain watchdog timer.
+ * With id != 0 and timeout != 0, poke watchdog timer and set new timeout.
+ */
+#define SCHEDOP_watchdog 6
+/* ` } */
+
+struct sched_shutdown {
+ unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */
+};
+typedef struct sched_shutdown sched_shutdown_t;
+DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t);
+
+struct sched_poll {
+ XEN_GUEST_HANDLE(evtchn_port_t) ports;
+ unsigned int nr_ports;
+ uint64_t timeout;
+};
+typedef struct sched_poll sched_poll_t;
+DEFINE_XEN_GUEST_HANDLE(sched_poll_t);
+
+struct sched_remote_shutdown {
+ domid_t domain_id; /* Remote domain ID */
+ unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */
+};
+typedef struct sched_remote_shutdown sched_remote_shutdown_t;
+DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t);
+
+struct sched_watchdog {
+ uint32_t id; /* watchdog ID */
+ uint32_t timeout; /* timeout */
+};
+typedef struct sched_watchdog sched_watchdog_t;
+DEFINE_XEN_GUEST_HANDLE(sched_watchdog_t);
+
+/*
+ * Reason codes for SCHEDOP_shutdown. These may be interpreted by control
+ * software to determine the appropriate action. For the most part, Xen does
+ * not care about the shutdown code.
+ */
+/* ` enum sched_shutdown_reason { */
+#define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */
+#define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */
+#define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */
+#define SHUTDOWN_crash 3 /* Tell controller we've crashed. */
+#define SHUTDOWN_watchdog 4 /* Restart because watchdog time expired. */
+#define SHUTDOWN_MAX 4 /* Maximum valid shutdown reason. */
+/* ` } */
+
+#endif /* __XEN_PUBLIC_SCHED_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/xen/xen-compat.h b/include/xen/xen-compat.h
new file mode 100644
index 000000000..3eb80a02d
--- /dev/null
+++ b/include/xen/xen-compat.h
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * xen-compat.h
+ *
+ * Guest OS interface to Xen. Compatibility layer.
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright (c) 2006, Christian Limpach
+ */
+
+#ifndef __XEN_PUBLIC_XEN_COMPAT_H__
+#define __XEN_PUBLIC_XEN_COMPAT_H__
+
+#define __XEN_LATEST_INTERFACE_VERSION__ 0x00040400
+
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
+/* Xen is built with matching headers and implements the latest interface. */
+#define __XEN_INTERFACE_VERSION__ __XEN_LATEST_INTERFACE_VERSION__
+#elif !defined(__XEN_INTERFACE_VERSION__)
+/* Guests which do not specify a version get the legacy interface. */
+#define __XEN_INTERFACE_VERSION__ 0x00000000
+#endif
+
+#if __XEN_INTERFACE_VERSION__ > __XEN_LATEST_INTERFACE_VERSION__
+#error "These header files do not support the requested interface version."
+#endif
+
+#endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */
diff --git a/include/xen/xen.h b/include/xen/xen.h
new file mode 100644
index 000000000..a6a20926a
--- /dev/null
+++ b/include/xen/xen.h
@@ -0,0 +1,899 @@
+/******************************************************************************
+ * xen.h
+ *
+ * Guest OS interface to Xen.
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Copyright (c) 2004, K A Fraser
+ */
+
+#ifndef __XEN_PUBLIC_XEN_H__
+#define __XEN_PUBLIC_XEN_H__
+
+#include "xen-compat.h"
+
+#if defined(__i386__) || defined(__x86_64__)
+#include "arch-x86/xen.h"
+#elif defined(__arm__) || defined (__aarch64__)
+#include "arch-arm.h"
+#else
+#error "Unsupported architecture"
+#endif
+
+#ifndef __ASSEMBLY__
+/* Guest handles for primitive C types. */
+DEFINE_XEN_GUEST_HANDLE(char);
+__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
+DEFINE_XEN_GUEST_HANDLE(int);
+__DEFINE_XEN_GUEST_HANDLE(uint, unsigned int);
+#if __XEN_INTERFACE_VERSION__ < 0x00040300
+DEFINE_XEN_GUEST_HANDLE(long);
+__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
+#endif
+DEFINE_XEN_GUEST_HANDLE(void);
+
+DEFINE_XEN_GUEST_HANDLE(uint64_t);
+DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
+DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
+#endif
+
+/*
+ * HYPERCALLS
+ */
+
+/* `incontents 100 hcalls List of hypercalls
+ * ` enum hypercall_num { // __HYPERVISOR_* => HYPERVISOR_*()
+ */
+
+#define __HYPERVISOR_set_trap_table 0
+#define __HYPERVISOR_mmu_update 1
+#define __HYPERVISOR_set_gdt 2
+#define __HYPERVISOR_stack_switch 3
+#define __HYPERVISOR_set_callbacks 4
+#define __HYPERVISOR_fpu_taskswitch 5
+#define __HYPERVISOR_sched_op_compat 6 /* compat since 0x00030101 */
+#define __HYPERVISOR_platform_op 7
+#define __HYPERVISOR_set_debugreg 8
+#define __HYPERVISOR_get_debugreg 9
+#define __HYPERVISOR_update_descriptor 10
+#define __HYPERVISOR_memory_op 12
+#define __HYPERVISOR_multicall 13
+#define __HYPERVISOR_update_va_mapping 14
+#define __HYPERVISOR_set_timer_op 15
+#define __HYPERVISOR_event_channel_op_compat 16 /* compat since 0x00030202 */
+#define __HYPERVISOR_xen_version 17
+#define __HYPERVISOR_console_io 18
+#define __HYPERVISOR_physdev_op_compat 19 /* compat since 0x00030202 */
+#define __HYPERVISOR_grant_table_op 20
+#define __HYPERVISOR_vm_assist 21
+#define __HYPERVISOR_update_va_mapping_otherdomain 22
+#define __HYPERVISOR_iret 23 /* x86 only */
+#define __HYPERVISOR_vcpu_op 24
+#define __HYPERVISOR_set_segment_base 25 /* x86/64 only */
+#define __HYPERVISOR_mmuext_op 26
+#define __HYPERVISOR_xsm_op 27
+#define __HYPERVISOR_nmi_op 28
+#define __HYPERVISOR_sched_op 29
+#define __HYPERVISOR_callback_op 30
+#define __HYPERVISOR_xenoprof_op 31
+#define __HYPERVISOR_event_channel_op 32
+#define __HYPERVISOR_physdev_op 33
+#define __HYPERVISOR_hvm_op 34
+#define __HYPERVISOR_sysctl 35
+#define __HYPERVISOR_domctl 36
+#define __HYPERVISOR_kexec_op 37
+#define __HYPERVISOR_tmem_op 38
+#define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */
+
+/* Architecture-specific hypercall definitions. */
+#define __HYPERVISOR_arch_0 48
+#define __HYPERVISOR_arch_1 49
+#define __HYPERVISOR_arch_2 50
+#define __HYPERVISOR_arch_3 51
+#define __HYPERVISOR_arch_4 52
+#define __HYPERVISOR_arch_5 53
+#define __HYPERVISOR_arch_6 54
+#define __HYPERVISOR_arch_7 55
+
+/* ` } */
+
+/*
+ * HYPERCALL COMPATIBILITY.
+ */
+
+/* New sched_op hypercall introduced in 0x00030101. */
+#if __XEN_INTERFACE_VERSION__ < 0x00030101
+#undef __HYPERVISOR_sched_op
+#define __HYPERVISOR_sched_op __HYPERVISOR_sched_op_compat
+#endif
+
+/* New event-channel and physdev hypercalls introduced in 0x00030202. */
+#if __XEN_INTERFACE_VERSION__ < 0x00030202
+#undef __HYPERVISOR_event_channel_op
+#define __HYPERVISOR_event_channel_op __HYPERVISOR_event_channel_op_compat
+#undef __HYPERVISOR_physdev_op
+#define __HYPERVISOR_physdev_op __HYPERVISOR_physdev_op_compat
+#endif
+
+/* New platform_op hypercall introduced in 0x00030204. */
+#if __XEN_INTERFACE_VERSION__ < 0x00030204
+#define __HYPERVISOR_dom0_op __HYPERVISOR_platform_op
+#endif
+
+/*
+ * VIRTUAL INTERRUPTS
+ *
+ * Virtual interrupts that a guest OS may receive from Xen.
+ *
+ * In the side comments, 'V.' denotes a per-VCPU VIRQ while 'G.' denotes a
+ * global VIRQ. The former can be bound once per VCPU and cannot be re-bound.
+ * The latter can be allocated only once per guest: they must initially be
+ * allocated to VCPU0 but can subsequently be re-bound.
+ */
+/* ` enum virq { */
+#define VIRQ_TIMER 0 /* V. Timebase update, and/or requested timeout. */
+#define VIRQ_DEBUG 1 /* V. Request guest to dump debug info. */
+#define VIRQ_CONSOLE 2 /* G. (DOM0) Bytes received on emergency console. */
+#define VIRQ_DOM_EXC 3 /* G. (DOM0) Exceptional event for some domain. */
+#define VIRQ_TBUF 4 /* G. (DOM0) Trace buffer has records available. */
+#define VIRQ_DEBUGGER 6 /* G. (DOM0) A domain has paused for debugging. */
+#define VIRQ_XENOPROF 7 /* V. XenOprofile interrupt: new sample available */
+#define VIRQ_CON_RING 8 /* G. (DOM0) Bytes received on console */
+#define VIRQ_PCPU_STATE 9 /* G. (DOM0) PCPU state changed */
+#define VIRQ_MEM_EVENT 10 /* G. (DOM0) A memory event has occured */
+#define VIRQ_XC_RESERVED 11 /* G. Reserved for XenClient */
+#define VIRQ_ENOMEM 12 /* G. (DOM0) Low on heap memory */
+
+/* Architecture-specific VIRQ definitions. */
+#define VIRQ_ARCH_0 16
+#define VIRQ_ARCH_1 17
+#define VIRQ_ARCH_2 18
+#define VIRQ_ARCH_3 19
+#define VIRQ_ARCH_4 20
+#define VIRQ_ARCH_5 21
+#define VIRQ_ARCH_6 22
+#define VIRQ_ARCH_7 23
+/* ` } */
+
+#define NR_VIRQS 24
+
+/*
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_mmu_update(const struct mmu_update reqs[],
+ * ` unsigned count, unsigned *done_out,
+ * ` unsigned foreigndom)
+ * `
+ * @reqs is an array of mmu_update_t structures ((ptr, val) pairs).
+ * @count is the length of the above array.
+ * @pdone is an output parameter indicating number of completed operations
+ * @foreigndom[15:0]: FD, the expected owner of data pages referenced in this
+ * hypercall invocation. Can be DOMID_SELF.
+ * @foreigndom[31:16]: PFD, the expected owner of pagetable pages referenced
+ * in this hypercall invocation. The value of this field
+ * (x) encodes the PFD as follows:
+ * x == 0 => PFD == DOMID_SELF
+ * x != 0 => PFD == x - 1
+ *
+ * Sub-commands: ptr[1:0] specifies the appropriate MMU_* command.
+ * -------------
+ * ptr[1:0] == MMU_NORMAL_PT_UPDATE:
+ * Updates an entry in a page table belonging to PFD. If updating an L1 table,
+ * and the new table entry is valid/present, the mapped frame must belong to
+ * FD. If attempting to map an I/O page then the caller assumes the privilege
+ * of the FD.
+ * FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the caller.
+ * FD == DOMID_XEN: Map restricted areas of Xen's heap space.
+ * ptr[:2] -- Machine address of the page-table entry to modify.
+ * val -- Value to write.
+ *
+ * There also certain implicit requirements when using this hypercall. The
+ * pages that make up a pagetable must be mapped read-only in the guest.
+ * This prevents uncontrolled guest updates to the pagetable. Xen strictly
+ * enforces this, and will disallow any pagetable update which will end up
+ * mapping pagetable page RW, and will disallow using any writable page as a
+ * pagetable. In practice it means that when constructing a page table for a
+ * process, thread, etc, we MUST be very dilligient in following these rules:
+ * 1). Start with top-level page (PGD or in Xen language: L4). Fill out
+ * the entries.
+ * 2). Keep on going, filling out the upper (PUD or L3), and middle (PMD
+ * or L2).
+ * 3). Start filling out the PTE table (L1) with the PTE entries. Once
+ * done, make sure to set each of those entries to RO (so writeable bit
+ * is unset). Once that has been completed, set the PMD (L2) for this
+ * PTE table as RO.
+ * 4). When completed with all of the PMD (L2) entries, and all of them have
+ * been set to RO, make sure to set RO the PUD (L3). Do the same
+ * operation on PGD (L4) pagetable entries that have a PUD (L3) entry.
+ * 5). Now before you can use those pages (so setting the cr3), you MUST also
+ * pin them so that the hypervisor can verify the entries. This is done
+ * via the HYPERVISOR_mmuext_op(MMUEXT_PIN_L4_TABLE, guest physical frame
+ * number of the PGD (L4)). And this point the HYPERVISOR_mmuext_op(
+ * MMUEXT_NEW_BASEPTR, guest physical frame number of the PGD (L4)) can be
+ * issued.
+ * For 32-bit guests, the L4 is not used (as there is less pagetables), so
+ * instead use L3.
+ * At this point the pagetables can be modified using the MMU_NORMAL_PT_UPDATE
+ * hypercall. Also if so desired the OS can also try to write to the PTE
+ * and be trapped by the hypervisor (as the PTE entry is RO).
+ *
+ * To deallocate the pages, the operations are the reverse of the steps
+ * mentioned above. The argument is MMUEXT_UNPIN_TABLE for all levels and the
+ * pagetable MUST not be in use (meaning that the cr3 is not set to it).
+ *
+ * ptr[1:0] == MMU_MACHPHYS_UPDATE:
+ * Updates an entry in the machine->pseudo-physical mapping table.
+ * ptr[:2] -- Machine address within the frame whose mapping to modify.
+ * The frame must belong to the FD, if one is specified.
+ * val -- Value to write into the mapping entry.
+ *
+ * ptr[1:0] == MMU_PT_UPDATE_PRESERVE_AD:
+ * As MMU_NORMAL_PT_UPDATE above, but A/D bits currently in the PTE are ORed
+ * with those in @val.
+ *
+ * @val is usually the machine frame number along with some attributes.
+ * The attributes by default follow the architecture defined bits. Meaning that
+ * if this is a X86_64 machine and four page table layout is used, the layout
+ * of val is:
+ * - 63 if set means No execute (NX)
+ * - 46-13 the machine frame number
+ * - 12 available for guest
+ * - 11 available for guest
+ * - 10 available for guest
+ * - 9 available for guest
+ * - 8 global
+ * - 7 PAT (PSE is disabled, must use hypercall to make 4MB or 2MB pages)
+ * - 6 dirty
+ * - 5 accessed
+ * - 4 page cached disabled
+ * - 3 page write through
+ * - 2 userspace accessible
+ * - 1 writeable
+ * - 0 present
+ *
+ * The one bits that does not fit with the default layout is the PAGE_PSE
+ * also called PAGE_PAT). The MMUEXT_[UN]MARK_SUPER arguments to the
+ * HYPERVISOR_mmuext_op serve as mechanism to set a pagetable to be 4MB
+ * (or 2MB) instead of using the PAGE_PSE bit.
+ *
+ * The reason that the PAGE_PSE (bit 7) is not being utilized is due to Xen
+ * using it as the Page Attribute Table (PAT) bit - for details on it please
+ * refer to Intel SDM 10.12. The PAT allows to set the caching attributes of
+ * pages instead of using MTRRs.
+ *
+ * The PAT MSR is as follows (it is a 64-bit value, each entry is 8 bits):
+ * PAT4 PAT0
+ * +-----+-----+----+----+----+-----+----+----+
+ * | UC | UC- | WC | WB | UC | UC- | WC | WB | <= Linux
+ * +-----+-----+----+----+----+-----+----+----+
+ * | UC | UC- | WT | WB | UC | UC- | WT | WB | <= BIOS (default when machine boots)
+ * +-----+-----+----+----+----+-----+----+----+
+ * | rsv | rsv | WP | WC | UC | UC- | WT | WB | <= Xen
+ * +-----+-----+----+----+----+-----+----+----+
+ *
+ * The lookup of this index table translates to looking up
+ * Bit 7, Bit 4, and Bit 3 of val entry:
+ *
+ * PAT/PSE (bit 7) ... PCD (bit 4) .. PWT (bit 3).
+ *
+ * If all bits are off, then we are using PAT0. If bit 3 turned on,
+ * then we are using PAT1, if bit 3 and bit 4, then PAT2..
+ *
+ * As you can see, the Linux PAT1 translates to PAT4 under Xen. Which means
+ * that if a guest that follows Linux's PAT setup and would like to set Write
+ * Combined on pages it MUST use PAT4 entry. Meaning that Bit 7 (PAGE_PAT) is
+ * set. For example, under Linux it only uses PAT0, PAT1, and PAT2 for the
+ * caching as:
+ *
+ * WB = none (so PAT0)
+ * WC = PWT (bit 3 on)
+ * UC = PWT | PCD (bit 3 and 4 are on).
+ *
+ * To make it work with Xen, it needs to translate the WC bit as so:
+ *
+ * PWT (so bit 3 on) --> PAT (so bit 7 is on) and clear bit 3
+ *
+ * And to translate back it would:
+ *
+ * PAT (bit 7 on) --> PWT (bit 3 on) and clear bit 7.
+ */
+#define MMU_NORMAL_PT_UPDATE 0 /* checked '*ptr = val'. ptr is MA. */
+#define MMU_MACHPHYS_UPDATE 1 /* ptr = MA of frame to modify entry for */
+#define MMU_PT_UPDATE_PRESERVE_AD 2 /* atomically: *ptr = val | (*ptr&(A|D)) */
+
+/*
+ * MMU EXTENDED OPERATIONS
+ *
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_mmuext_op(mmuext_op_t uops[],
+ * ` unsigned int count,
+ * ` unsigned int *pdone,
+ * ` unsigned int foreigndom)
+ */
+/* HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures.
+ * A foreigndom (FD) can be specified (or DOMID_SELF for none).
+ * Where the FD has some effect, it is described below.
+ *
+ * cmd: MMUEXT_(UN)PIN_*_TABLE
+ * mfn: Machine frame number to be (un)pinned as a p.t. page.
+ * The frame must belong to the FD, if one is specified.
+ *
+ * cmd: MMUEXT_NEW_BASEPTR
+ * mfn: Machine frame number of new page-table base to install in MMU.
+ *
+ * cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only]
+ * mfn: Machine frame number of new page-table base to install in MMU
+ * when in user space.
+ *
+ * cmd: MMUEXT_TLB_FLUSH_LOCAL
+ * No additional arguments. Flushes local TLB.
+ *
+ * cmd: MMUEXT_INVLPG_LOCAL
+ * linear_addr: Linear address to be flushed from the local TLB.
+ *
+ * cmd: MMUEXT_TLB_FLUSH_MULTI
+ * vcpumask: Pointer to bitmap of VCPUs to be flushed.
+ *
+ * cmd: MMUEXT_INVLPG_MULTI
+ * linear_addr: Linear address to be flushed.
+ * vcpumask: Pointer to bitmap of VCPUs to be flushed.
+ *
+ * cmd: MMUEXT_TLB_FLUSH_ALL
+ * No additional arguments. Flushes all VCPUs' TLBs.
+ *
+ * cmd: MMUEXT_INVLPG_ALL
+ * linear_addr: Linear address to be flushed from all VCPUs' TLBs.
+ *
+ * cmd: MMUEXT_FLUSH_CACHE
+ * No additional arguments. Writes back and flushes cache contents.
+ *
+ * cmd: MMUEXT_FLUSH_CACHE_GLOBAL
+ * No additional arguments. Writes back and flushes cache contents
+ * on all CPUs in the system.
+ *
+ * cmd: MMUEXT_SET_LDT
+ * linear_addr: Linear address of LDT base (NB. must be page-aligned).
+ * nr_ents: Number of entries in LDT.
+ *
+ * cmd: MMUEXT_CLEAR_PAGE
+ * mfn: Machine frame number to be cleared.
+ *
+ * cmd: MMUEXT_COPY_PAGE
+ * mfn: Machine frame number of the destination page.
+ * src_mfn: Machine frame number of the source page.
+ *
+ * cmd: MMUEXT_[UN]MARK_SUPER
+ * mfn: Machine frame number of head of superpage to be [un]marked.
+ */
+/* ` enum mmuext_cmd { */
+#define MMUEXT_PIN_L1_TABLE 0
+#define MMUEXT_PIN_L2_TABLE 1
+#define MMUEXT_PIN_L3_TABLE 2
+#define MMUEXT_PIN_L4_TABLE 3
+#define MMUEXT_UNPIN_TABLE 4
+#define MMUEXT_NEW_BASEPTR 5
+#define MMUEXT_TLB_FLUSH_LOCAL 6
+#define MMUEXT_INVLPG_LOCAL 7
+#define MMUEXT_TLB_FLUSH_MULTI 8
+#define MMUEXT_INVLPG_MULTI 9
+#define MMUEXT_TLB_FLUSH_ALL 10
+#define MMUEXT_INVLPG_ALL 11
+#define MMUEXT_FLUSH_CACHE 12
+#define MMUEXT_SET_LDT 13
+#define MMUEXT_NEW_USER_BASEPTR 15
+#define MMUEXT_CLEAR_PAGE 16
+#define MMUEXT_COPY_PAGE 17
+#define MMUEXT_FLUSH_CACHE_GLOBAL 18
+#define MMUEXT_MARK_SUPER 19
+#define MMUEXT_UNMARK_SUPER 20
+/* ` } */
+
+#ifndef __ASSEMBLY__
+struct mmuext_op {
+ unsigned int cmd; /* => enum mmuext_cmd */
+ union {
+ /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR
+ * CLEAR_PAGE, COPY_PAGE, [UN]MARK_SUPER */
+ xen_pfn_t mfn;
+ /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */
+ unsigned long linear_addr;
+ } arg1;
+ union {
+ /* SET_LDT */
+ unsigned int nr_ents;
+ /* TLB_FLUSH_MULTI, INVLPG_MULTI */
+#if __XEN_INTERFACE_VERSION__ >= 0x00030205
+ XEN_GUEST_HANDLE(const_void) vcpumask;
+#else
+ const void *vcpumask;
+#endif
+ /* COPY_PAGE */
+ xen_pfn_t src_mfn;
+ } arg2;
+};
+typedef struct mmuext_op mmuext_op_t;
+DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
+#endif
+
+/*
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_update_va_mapping(unsigned long va, u64 val,
+ * ` enum uvm_flags flags)
+ * `
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_update_va_mapping_otherdomain(unsigned long va, u64 val,
+ * ` enum uvm_flags flags,
+ * ` domid_t domid)
+ * `
+ * ` @va: The virtual address whose mapping we want to change
+ * ` @val: The new page table entry, must contain a machine address
+ * ` @flags: Control TLB flushes
+ */
+/* These are passed as 'flags' to update_va_mapping. They can be ORed. */
+/* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap. */
+/* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer. */
+/* ` enum uvm_flags { */
+#define UVMF_NONE (0UL<<0) /* No flushing at all. */
+#define UVMF_TLB_FLUSH (1UL<<0) /* Flush entire TLB(s). */
+#define UVMF_INVLPG (2UL<<0) /* Flush only one entry. */
+#define UVMF_FLUSHTYPE_MASK (3UL<<0)
+#define UVMF_MULTI (0UL<<2) /* Flush subset of TLBs. */
+#define UVMF_LOCAL (0UL<<2) /* Flush local TLB. */
+#define UVMF_ALL (1UL<<2) /* Flush all TLBs. */
+/* ` } */
+
+/*
+ * Commands to HYPERVISOR_console_io().
+ */
+#define CONSOLEIO_write 0
+#define CONSOLEIO_read 1
+
+/*
+ * Commands to HYPERVISOR_vm_assist().
+ */
+#define VMASST_CMD_enable 0
+#define VMASST_CMD_disable 1
+
+/* x86/32 guests: simulate full 4GB segment limits. */
+#define VMASST_TYPE_4gb_segments 0
+
+/* x86/32 guests: trap (vector 15) whenever above vmassist is used. */
+#define VMASST_TYPE_4gb_segments_notify 1
+
+/*
+ * x86 guests: support writes to bottom-level PTEs.
+ * NB1. Page-directory entries cannot be written.
+ * NB2. Guest must continue to remove all writable mappings of PTEs.
+ */
+#define VMASST_TYPE_writable_pagetables 2
+
+/* x86/PAE guests: support PDPTs above 4GB. */
+#define VMASST_TYPE_pae_extended_cr3 3
+
+#define MAX_VMASST_TYPE 3
+
+#ifndef __ASSEMBLY__
+
+typedef uint16_t domid_t;
+
+/* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */
+#define DOMID_FIRST_RESERVED (0x7FF0U)
+
+/* DOMID_SELF is used in certain contexts to refer to oneself. */
+#define DOMID_SELF (0x7FF0U)
+
+/*
+ * DOMID_IO is used to restrict page-table updates to mapping I/O memory.
+ * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO
+ * is useful to ensure that no mappings to the OS's own heap are accidentally
+ * installed. (e.g., in Linux this could cause havoc as reference counts
+ * aren't adjusted on the I/O-mapping code path).
+ * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can
+ * be specified by any calling domain.
+ */
+#define DOMID_IO (0x7FF1U)
+
+/*
+ * DOMID_XEN is used to allow privileged domains to map restricted parts of
+ * Xen's heap space (e.g., the machine_to_phys table).
+ * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if
+ * the caller is privileged.
+ */
+#define DOMID_XEN (0x7FF2U)
+
+/*
+ * DOMID_COW is used as the owner of sharable pages */
+#define DOMID_COW (0x7FF3U)
+
+/* DOMID_INVALID is used to identify pages with unknown owner. */
+#define DOMID_INVALID (0x7FF4U)
+
+/* Idle domain. */
+#define DOMID_IDLE (0x7FFFU)
+
+/*
+ * Send an array of these to HYPERVISOR_mmu_update().
+ * NB. The fields are natural pointer/address size for this architecture.
+ */
+struct mmu_update {
+ uint64_t ptr; /* Machine address of PTE. */
+ uint64_t val; /* New contents of PTE. */
+};
+typedef struct mmu_update mmu_update_t;
+DEFINE_XEN_GUEST_HANDLE(mmu_update_t);
+
+/*
+ * ` enum neg_errnoval
+ * ` HYPERVISOR_multicall(multicall_entry_t call_list[],
+ * ` uint32_t nr_calls);
+ *
+ * NB. The fields are logically the natural register size for this
+ * architecture. In cases where xen_ulong_t is larger than this then
+ * any unused bits in the upper portion must be zero.
+ */
+struct multicall_entry {
+ xen_ulong_t op, result;
+ xen_ulong_t args[6];
+};
+typedef struct multicall_entry multicall_entry_t;
+DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);
+
+#if __XEN_INTERFACE_VERSION__ < 0x00040400
+/*
+ * Event channel endpoints per domain (when using the 2-level ABI):
+ * 1024 if a long is 32 bits; 4096 if a long is 64 bits.
+ */
+#define NR_EVENT_CHANNELS EVTCHN_2L_NR_CHANNELS
+#endif
+
+struct vcpu_time_info {
+ /*
+ * Updates to the following values are preceded and followed by an
+ * increment of 'version'. The guest can therefore detect updates by
+ * looking for changes to 'version'. If the least-significant bit of
+ * the version number is set then an update is in progress and the guest
+ * must wait to read a consistent set of values.
+ * The correct way to interact with the version number is similar to
+ * Linux's seqlock: see the implementations of read_seqbegin/read_seqretry.
+ */
+ uint32_t version;
+ uint32_t pad0;
+ uint64_t tsc_timestamp; /* TSC at last update of time vals. */
+ uint64_t system_time; /* Time, in nanosecs, since boot. */
+ /*
+ * Current system time:
+ * system_time +
+ * ((((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul) >> 32)
+ * CPU frequency (Hz):
+ * ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift
+ */
+ uint32_t tsc_to_system_mul;
+ int8_t tsc_shift;
+ int8_t pad1[3];
+}; /* 32 bytes */
+typedef struct vcpu_time_info vcpu_time_info_t;
+
+struct vcpu_info {
+ /*
+ * 'evtchn_upcall_pending' is written non-zero by Xen to indicate
+ * a pending notification for a particular VCPU. It is then cleared
+ * by the guest OS /before/ checking for pending work, thus avoiding
+ * a set-and-check race. Note that the mask is only accessed by Xen
+ * on the CPU that is currently hosting the VCPU. This means that the
+ * pending and mask flags can be updated by the guest without special
+ * synchronisation (i.e., no need for the x86 LOCK prefix).
+ * This may seem suboptimal because if the pending flag is set by
+ * a different CPU then an IPI may be scheduled even when the mask
+ * is set. However, note:
+ * 1. The task of 'interrupt holdoff' is covered by the per-event-
+ * channel mask bits. A 'noisy' event that is continually being
+ * triggered can be masked at source at this very precise
+ * granularity.
+ * 2. The main purpose of the per-VCPU mask is therefore to restrict
+ * reentrant execution: whether for concurrency control, or to
+ * prevent unbounded stack usage. Whatever the purpose, we expect
+ * that the mask will be asserted only for short periods at a time,
+ * and so the likelihood of a 'spurious' IPI is suitably small.
+ * The mask is read before making an event upcall to the guest: a
+ * non-zero mask therefore guarantees that the VCPU will not receive
+ * an upcall activation. The mask is cleared when the VCPU requests
+ * to block: this avoids wakeup-waiting races.
+ */
+ uint8_t evtchn_upcall_pending;
+#ifdef XEN_HAVE_PV_UPCALL_MASK
+ uint8_t evtchn_upcall_mask;
+#else /* XEN_HAVE_PV_UPCALL_MASK */
+ uint8_t pad0;
+#endif /* XEN_HAVE_PV_UPCALL_MASK */
+ xen_ulong_t evtchn_pending_sel;
+ struct arch_vcpu_info arch;
+ struct vcpu_time_info time;
+}; /* 64 bytes (x86) */
+#ifndef __XEN__
+typedef struct vcpu_info vcpu_info_t;
+#endif
+
+/*
+ * `incontents 200 startofday_shared Start-of-day shared data structure
+ * Xen/kernel shared data -- pointer provided in start_info.
+ *
+ * This structure is defined to be both smaller than a page, and the
+ * only data on the shared page, but may vary in actual size even within
+ * compatible Xen versions; guests should not rely on the size
+ * of this structure remaining constant.
+ */
+struct shared_info {
+ struct vcpu_info vcpu_info[XEN_LEGACY_MAX_VCPUS];
+
+ /*
+ * A domain can create "event channels" on which it can send and receive
+ * asynchronous event notifications. There are three classes of event that
+ * are delivered by this mechanism:
+ * 1. Bi-directional inter- and intra-domain connections. Domains must
+ * arrange out-of-band to set up a connection (usually by allocating
+ * an unbound 'listener' port and avertising that via a storage service
+ * such as xenstore).
+ * 2. Physical interrupts. A domain with suitable hardware-access
+ * privileges can bind an event-channel port to a physical interrupt
+ * source.
+ * 3. Virtual interrupts ('events'). A domain can bind an event-channel
+ * port to a virtual interrupt source, such as the virtual-timer
+ * device or the emergency console.
+ *
+ * Event channels are addressed by a "port index". Each channel is
+ * associated with two bits of information:
+ * 1. PENDING -- notifies the domain that there is a pending notification
+ * to be processed. This bit is cleared by the guest.
+ * 2. MASK -- if this bit is clear then a 0->1 transition of PENDING
+ * will cause an asynchronous upcall to be scheduled. This bit is only
+ * updated by the guest. It is read-only within Xen. If a channel
+ * becomes pending while the channel is masked then the 'edge' is lost
+ * (i.e., when the channel is unmasked, the guest must manually handle
+ * pending notifications as no upcall will be scheduled by Xen).
+ *
+ * To expedite scanning of pending notifications, any 0->1 pending
+ * transition on an unmasked channel causes a corresponding bit in a
+ * per-vcpu selector word to be set. Each bit in the selector covers a
+ * 'C long' in the PENDING bitfield array.
+ */
+ xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) * 8];
+ xen_ulong_t evtchn_mask[sizeof(xen_ulong_t) * 8];
+
+ /*
+ * Wallclock time: updated only by control software. Guests should base
+ * their gettimeofday() syscall on this wallclock-base value.
+ */
+ uint32_t wc_version; /* Version counter: see vcpu_time_info_t. */
+ uint32_t wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */
+ uint32_t wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */
+
+ struct arch_shared_info arch;
+
+};
+#ifndef __XEN__
+typedef struct shared_info shared_info_t;
+#endif
+
+/*
+ * `incontents 200 startofday Start-of-day memory layout
+ *
+ * 1. The domain is started within contiguous virtual-memory region.
+ * 2. The contiguous region ends on an aligned 4MB boundary.
+ * 3. This the order of bootstrap elements in the initial virtual region:
+ * a. relocated kernel image
+ * b. initial ram disk [mod_start, mod_len]
+ * c. list of allocated page frames [mfn_list, nr_pages]
+ * (unless relocated due to XEN_ELFNOTE_INIT_P2M)
+ * d. start_info_t structure [register ESI (x86)]
+ * e. bootstrap page tables [pt_base and CR3 (x86)]
+ * f. bootstrap stack [register ESP (x86)]
+ * 4. Bootstrap elements are packed together, but each is 4kB-aligned.
+ * 5. The initial ram disk may be omitted.
+ * 6. The list of page frames forms a contiguous 'pseudo-physical' memory
+ * layout for the domain. In particular, the bootstrap virtual-memory
+ * region is a 1:1 mapping to the first section of the pseudo-physical map.
+ * 7. All bootstrap elements are mapped read-writable for the guest OS. The
+ * only exception is the bootstrap page table, which is mapped read-only.
+ * 8. There is guaranteed to be at least 512kB padding after the final
+ * bootstrap element. If necessary, the bootstrap virtual region is
+ * extended by an extra 4MB to ensure this.
+ *
+ * Note: Prior to 25833:bb85bbccb1c9. ("x86/32-on-64 adjust Dom0 initial page
+ * table layout") a bug caused the pt_base (3.e above) and cr3 to not point
+ * to the start of the guest page tables (it was offset by two pages).
+ * This only manifested itself on 32-on-64 dom0 kernels and not 32-on-64 domU
+ * or 64-bit kernels of any colour. The page tables for a 32-on-64 dom0 got
+ * allocated in the order: 'first L1','first L2', 'first L3', so the offset
+ * to the page table base is by two pages back. The initial domain if it is
+ * 32-bit and runs under a 64-bit hypervisor should _NOT_ use two of the
+ * pages preceding pt_base and mark them as reserved/unused.
+ */
+#ifdef XEN_HAVE_PV_GUEST_ENTRY
+struct start_info {
+ /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */
+ char magic[32]; /* "xen-<version>-<platform>". */
+ unsigned long nr_pages; /* Total pages allocated to this domain. */
+ unsigned long shared_info; /* MACHINE address of shared info struct. */
+ uint32_t flags; /* SIF_xxx flags. */
+ xen_pfn_t store_mfn; /* MACHINE page number of shared page. */
+ uint32_t store_evtchn; /* Event channel for store communication. */
+ union {
+ struct {
+ xen_pfn_t mfn; /* MACHINE page number of console page. */
+ uint32_t evtchn; /* Event channel for console page. */
+ } domU;
+ struct {
+ uint32_t info_off; /* Offset of console_info struct. */
+ uint32_t info_size; /* Size of console_info struct from start.*/
+ } dom0;
+ } console;
+ /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */
+ unsigned long pt_base; /* VIRTUAL address of page directory. */
+ unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames. */
+ unsigned long mfn_list; /* VIRTUAL address of page-frame list. */
+ unsigned long mod_start; /* VIRTUAL address of pre-loaded module */
+ /* (PFN of pre-loaded module if */
+ /* SIF_MOD_START_PFN set in flags). */
+ unsigned long mod_len; /* Size (bytes) of pre-loaded module. */
+#define MAX_GUEST_CMDLINE 1024
+ int8_t cmd_line[MAX_GUEST_CMDLINE];
+ /* The pfn range here covers both page table and p->m table frames. */
+ unsigned long first_p2m_pfn;/* 1st pfn forming initial P->M table. */
+ unsigned long nr_p2m_frames;/* # of pfns forming initial P->M table. */
+};
+typedef struct start_info start_info_t;
+
+/* New console union for dom0 introduced in 0x00030203. */
+#if __XEN_INTERFACE_VERSION__ < 0x00030203
+#define console_mfn console.domU.mfn
+#define console_evtchn console.domU.evtchn
+#endif
+#endif /* XEN_HAVE_PV_GUEST_ENTRY */
+
+/* These flags are passed in the 'flags' field of start_info_t. */
+#define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */
+#define SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? */
+#define SIF_MULTIBOOT_MOD (1<<2) /* Is mod_start a multiboot module? */
+#define SIF_MOD_START_PFN (1<<3) /* Is mod_start a PFN? */
+#define SIF_PM_MASK (0xFF<<8) /* reserve 1 byte for xen-pm options */
+
+/*
+ * A multiboot module is a package containing modules very similar to a
+ * multiboot module array. The only differences are:
+ * - the array of module descriptors is by convention simply at the beginning
+ * of the multiboot module,
+ * - addresses in the module descriptors are based on the beginning of the
+ * multiboot module,
+ * - the number of modules is determined by a termination descriptor that has
+ * mod_start == 0.
+ *
+ * This permits to both build it statically and reference it in a configuration
+ * file, and let the PV guest easily rebase the addresses to virtual addresses
+ * and at the same time count the number of modules.
+ */
+struct xen_multiboot_mod_list
+{
+ /* Address of first byte of the module */
+ uint32_t mod_start;
+ /* Address of last byte of the module (inclusive) */
+ uint32_t mod_end;
+ /* Address of zero-terminated command line */
+ uint32_t cmdline;
+ /* Unused, must be zero */
+ uint32_t pad;
+};
+/*
+ * `incontents 200 startofday_dom0_console Dom0_console
+ *
+ * The console structure in start_info.console.dom0
+ *
+ * This structure includes a variety of information required to
+ * have a working VGA/VESA console.
+ */
+typedef struct dom0_vga_console_info {
+ uint8_t video_type; /* DOM0_VGA_CONSOLE_??? */
+#define XEN_VGATYPE_TEXT_MODE_3 0x03
+#define XEN_VGATYPE_VESA_LFB 0x23
+#define XEN_VGATYPE_EFI_LFB 0x70
+
+ union {
+ struct {
+ /* Font height, in pixels. */
+ uint16_t font_height;
+ /* Cursor location (column, row). */
+ uint16_t cursor_x, cursor_y;
+ /* Number of rows and columns (dimensions in characters). */
+ uint16_t rows, columns;
+ } text_mode_3;
+
+ struct {
+ /* Width and height, in pixels. */
+ uint16_t width, height;
+ /* Bytes per scan line. */
+ uint16_t bytes_per_line;
+ /* Bits per pixel. */
+ uint16_t bits_per_pixel;
+ /* LFB physical address, and size (in units of 64kB). */
+ uint32_t lfb_base;
+ uint32_t lfb_size;
+ /* RGB mask offsets and sizes, as defined by VBE 1.2+ */
+ uint8_t red_pos, red_size;
+ uint8_t green_pos, green_size;
+ uint8_t blue_pos, blue_size;
+ uint8_t rsvd_pos, rsvd_size;
+#if __XEN_INTERFACE_VERSION__ >= 0x00030206
+ /* VESA capabilities (offset 0xa, VESA command 0x4f00). */
+ uint32_t gbl_caps;
+ /* Mode attributes (offset 0x0, VESA command 0x4f01). */
+ uint16_t mode_attrs;
+#endif
+ } vesa_lfb;
+ } u;
+} dom0_vga_console_info_t;
+#define xen_vga_console_info dom0_vga_console_info
+#define xen_vga_console_info_t dom0_vga_console_info_t
+
+typedef uint8_t xen_domain_handle_t[16];
+
+/* Turn a plain number into a C unsigned long constant. */
+#define __mk_unsigned_long(x) x ## UL
+#define mk_unsigned_long(x) __mk_unsigned_long(x)
+
+__DEFINE_XEN_GUEST_HANDLE(uint8, uint8_t);
+__DEFINE_XEN_GUEST_HANDLE(uint16, uint16_t);
+__DEFINE_XEN_GUEST_HANDLE(uint32, uint32_t);
+__DEFINE_XEN_GUEST_HANDLE(uint64, uint64_t);
+
+#else /* __ASSEMBLY__ */
+
+/* In assembly code we cannot use C numeric constant suffixes. */
+#define mk_unsigned_long(x) x
+
+#endif /* !__ASSEMBLY__ */
+
+/* Default definitions for macros used by domctl/sysctl. */
+#if defined(__XEN__) || defined(__XEN_TOOLS__)
+
+#ifndef uint64_aligned_t
+#define uint64_aligned_t uint64_t
+#endif
+#ifndef XEN_GUEST_HANDLE_64
+#define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name)
+#endif
+
+#ifndef __ASSEMBLY__
+struct xenctl_bitmap {
+ XEN_GUEST_HANDLE_64(uint8) bitmap;
+ uint32_t nr_bits;
+};
+#endif
+
+#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
+
+#endif /* __XEN_PUBLIC_XEN_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/linguas.sh b/linguas.sh
index 1de42ba2d..e57f50dc6 100755
--- a/linguas.sh
+++ b/linguas.sh
@@ -6,7 +6,7 @@ autogenerated="en@quot en@hebrew de@hebrew en@cyrillic en@greek en@arabic en@pig
for x in $autogenerated; do
- rm "po/$x.po";
+ rm -f "po/$x.po";
done
diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4
index 0152f2932..e74339a16 100644
--- a/m4/extern-inline.m4
+++ b/m4/extern-inline.m4
@@ -1,6 +1,6 @@
dnl 'extern inline' a la ISO C99.
-dnl Copyright 2012-2013 Free Software Foundation, Inc.
+dnl Copyright 2012-2015 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -8,42 +8,77 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_EXTERN_INLINE],
[
AH_VERBATIM([extern_inline],
-[/* _GL_INLINE is a portable alternative to ISO C99 plain 'inline'.
- _GL_EXTERN_INLINE is a portable alternative to 'extern inline'.
- _GL_INLINE_HEADER_BEGIN contains useful stuff to put
- in an include file, before uses of _GL_INLINE.
- It suppresses GCC's bogus "no previous prototype for 'FOO'" diagnostic,
- when FOO is an inline function in the header; see
- <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>.
- _GL_INLINE_HEADER_END contains useful stuff to put
- in the same include file, after uses of _GL_INLINE.
+[/* Please see the Gnulib manual for how to use these macros.
Suppress extern inline with HP-UX cc, as it appears to be broken; see
<http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>.
- Suppress the use of extern inline on Apple's platforms,
- as Libc-825.25 (2012-09-19) is incompatible with it; see
- <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
- Perhaps Apple will fix this some day. */
+ Suppress extern inline with Sun C in standards-conformance mode, as it
+ mishandles inline functions that call each other. E.g., for 'inline void f
+ (void) { } inline void g (void) { f (); }', c99 incorrectly complains
+ 'reference to static identifier "f" in extern inline function'.
+ This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16.
+
+ Suppress extern inline (with or without __attribute__ ((__gnu_inline__)))
+ on configurations that mistakenly use 'static inline' to implement
+ functions or macros in standard C headers like <ctype.h>. For example,
+ if isdigit is mistakenly implemented via a static inline function,
+ a program containing an extern inline function that calls isdigit
+ may not work since the C standard prohibits extern inline functions
+ from calling static functions. This bug is known to occur on:
+
+ OS X 10.8 and earlier; see:
+ http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html
+
+ DragonFly; see
+ http://muscles.dragonflybsd.org/bulk/bleeding-edge-potential/latest-per-pkg/ah-tty-0.3.12.log
+
+ FreeBSD; see:
+ http://lists.gnu.org/archive/html/bug-gnulib/2014-07/msg00104.html
+
+ OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
+ for clang but remains for g++; see <http://trac.macports.org/ticket/41033>.
+ Assume DragonFly and FreeBSD will be similar. */
+#if (((defined __APPLE__ && defined __MACH__) \
+ || defined __DragonFly__ || defined __FreeBSD__) \
+ && (defined __header_inline \
+ ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
+ && ! defined __clang__) \
+ : ((! defined _DONT_USE_CTYPE_INLINE_ \
+ && (defined __GNUC__ || defined __cplusplus)) \
+ || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
+ && defined __GNUC__ && ! defined __cplusplus))))
+# define _GL_EXTERN_INLINE_STDHEADER_BUG
+#endif
#if ((__GNUC__ \
? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
- : 199901L <= __STDC_VERSION__ && !defined __HP_cc) \
- && !defined __APPLE__)
+ : (199901L <= __STDC_VERSION__ \
+ && !defined __HP_cc \
+ && !(defined __SUNPRO_C && __STDC__))) \
+ && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
# define _GL_INLINE inline
# define _GL_EXTERN_INLINE extern inline
-#elif 2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __APPLE__
-# if __GNUC_GNU_INLINE__
+# define _GL_EXTERN_INLINE_IN_USE
+#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
+ && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
+# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
/* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
# else
# define _GL_INLINE extern inline
# endif
# define _GL_EXTERN_INLINE extern
+# define _GL_EXTERN_INLINE_IN_USE
#else
# define _GL_INLINE static _GL_UNUSED
# define _GL_EXTERN_INLINE static _GL_UNUSED
#endif
+/* In GCC, suppress bogus "no previous prototype for 'FOO'"
+ and "no previous declaration for 'FOO'" diagnostics,
+ when FOO is an inline function in the header; see
+ <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and
+ <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>. */
#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
# define _GL_INLINE_HEADER_CONST_PRAGMA
diff --git a/po/README b/po/README
index c9be27b52..aaf829267 100644
--- a/po/README
+++ b/po/README
@@ -1,6 +1,6 @@
-If you checked out this source tree directly from GRUB Bazaar, you might
-be wondering where are the POT and PO files. Here are some instructions
+If you checked out this source tree directly from GRUB Git, you might be
+wondering where are the POT and PO files. Here are some instructions
that will hopefully clarify the situation.
- If you're a user or a distributor, simply fill the po directory by
@@ -16,7 +16,7 @@ that will hopefully clarify the situation.
(http://translationproject.org/). The GRUB project doesn't interact
with translators directly (but we dearly appreciate your work!).
- - If you're a developer adding/removing/modifiing translatable strings,
+ - If you're a developer adding/removing/modifying translatable strings,
you can check that these turn into a sane POT file by using the
`po/grub.pot' make rule.
diff --git a/po/Rules-translit b/po/Rules-translit
index 4f9176d30..ab84a5f1f 100644
--- a/po/Rules-translit
+++ b/po/Rules-translit
@@ -1,16 +1,16 @@
DISTFILES.common.extra4 = hebrew.sed cyrillic.sed greek.sed arabic.sed Rules-translit
de@hebrew.po-create: de.po hebrew.sed
- LC_ALL=C.UTF-8 $(MSGFILTER) -i $< -o $(srcdir)/de@hebrew.po sed -f $(srcdir)/hebrew.sed
+ LC_ALL=C $(MSGFILTER) -i $< -o $(srcdir)/de@hebrew.po sed -f $(srcdir)/hebrew.sed
en@hebrew.po-create: $(DOMAIN).pot hebrew.sed
- LC_ALL=C.UTF-8 $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@hebrew -o - 2>/dev/null | LC_ALL=C.UTF-8 $(MSGCONV) -t UTF-8 | LC_ALL=C.UTF-8 $(MSGFILTER) -o $(srcdir)/en@hebrew.po -i - sed -f $(srcdir)/hebrew.sed
+ LC_ALL=C $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@hebrew -o - 2>/dev/null | LC_ALL=C $(MSGCONV) -t UTF-8 | LC_ALL=C $(MSGFILTER) -o $(srcdir)/en@hebrew.po -i - sed -f $(srcdir)/hebrew.sed
en@cyrillic.po-create: $(DOMAIN).pot cyrillic.sed
- LC_ALL=C.UTF-8 $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@cyrillic -o - 2>/dev/null | LC_ALL=C.UTF-8 $(MSGCONV) -t UTF-8 | LC_ALL=C.UTF-8 $(MSGFILTER) -o $(srcdir)/en@cyrillic.po -i - sed -f $(srcdir)/cyrillic.sed
+ LC_ALL=C $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@cyrillic -o - 2>/dev/null | LC_ALL=C $(MSGCONV) -t UTF-8 | LC_ALL=C $(MSGFILTER) -o $(srcdir)/en@cyrillic.po -i - sed -f $(srcdir)/cyrillic.sed
en@greek.po-create: $(DOMAIN).pot greek.sed
- LC_ALL=C.UTF-8 $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@greek -o - 2>/dev/null | LC_ALL=C.UTF-8 $(MSGCONV) -t UTF-8 | LC_ALL=C.UTF-8 $(MSGFILTER) -o $(srcdir)/en@greek.po -i - sed -f $(srcdir)/greek.sed
+ LC_ALL=C $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@greek -o - 2>/dev/null | LC_ALL=C $(MSGCONV) -t UTF-8 | LC_ALL=C $(MSGFILTER) -o $(srcdir)/en@greek.po -i - sed -f $(srcdir)/greek.sed
en@arabic.po-create: $(DOMAIN).pot arabic.sed
- LC_ALL=C.UTF-8 $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@arabic -o - 2>/dev/null | LC_ALL=C.UTF-8 $(MSGCONV) -t UTF-8 | LC_ALL=C.UTF-8 $(MSGFILTER) -o $(srcdir)/en@arabic.po -i - sed -f $(srcdir)/arabic.sed
+ LC_ALL=C $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@arabic -o - 2>/dev/null | LC_ALL=C $(MSGCONV) -t UTF-8 | LC_ALL=C $(MSGFILTER) -o $(srcdir)/en@arabic.po -i - sed -f $(srcdir)/arabic.sed
diff --git a/po/cyrillic.sed b/po/cyrillic.sed
index 46ddaec6e..ffad0ed8c 100644
--- a/po/cyrillic.sed
+++ b/po/cyrillic.sed
@@ -10,8 +10,84 @@
/^Content-Transfer-Encoding:/ b
/^Plural-Forms:/ b
-y,abcdefghijklmnopqrstuvwxyz,абцдефгхийклмнопќрстувўѯѝз,
-y,ABCDEFGHIJKLMNOPQRSTUVWXYZ,АБЦДЕФГХИЙКЛМНОПЌРСТУВЎѮЍЗ,
+s,a,а,g
+s,b,б,g
+s,c,ц,g
+s,d,д,g
+s,e,е,g
+s,f,ф,g
+s,g,г,g
+s,h,х,g
+s,i,и,g
+s,j,й,g
+s,k,к,g
+s,l,л,g
+s,m,м,g
+s,n,н,g
+s,o,о,g
+s,p,п,g
+s,q,ќ,g
+s,r,р,g
+s,s,с,g
+s,t,т,g
+s,u,у,g
+s,v,в,g
+s,w,ў,g
+s,x,ѯ,g
+s,y,ѝ,g
+s,z,з,g
+s,A,А,g
+s,B,Б,g
+s,C,Ц,g
+s,D,Д,g
+s,E,Е,g
+s,F,Ф,g
+s,G,Г,g
+s,H,Х,g
+s,I,И,g
+s,J,Й,g
+s,K,К,g
+s,L,Л,g
+s,M,М,g
+s,N,Н,g
+s,O,О,g
+s,P,П,g
+s,Q,Ќ,g
+s,R,Р,g
+s,S,С,g
+s,T,Т,g
+s,U,У,g
+s,V,В,g
+s,W,Ў,g
+s,X,Ѯ,g
+s,Y,Ѝ,g
+s,Z,З,g
+s,А,А,g
+s,Б,Б,g
+s,Ц,Ц,g
+s,Д,Д,g
+s,Е,Е,g
+s,Ф,Ф,g
+s,Г,Г,g
+s,Х,Х,g
+s,И,И,g
+s,Й,Й,g
+s,К,К,g
+s,Л,Л,g
+s,М,М,g
+s,Н,Н,g
+s,О,О,g
+s,П,П,g
+s,Ќ,Ќ,g
+s,Р,Р,g
+s,С,С,g
+s,Т,Т,g
+s,У,У,g
+s,В,В,g
+s,Ў,Ў,g
+s,Ѯ,Ѯ,g
+s,Ѝ,Ѝ,g
+s,З,З,g
s,%\([0-9]*\)Ц,%\1C,g
s,%\([0-9]*\)ц,%\1c,g
diff --git a/po/exclude.pot b/po/exclude.pot
index 1659eb01b..0a9b215ea 100644
--- a/po/exclude.pot
+++ b/po/exclude.pot
@@ -2296,10 +2296,6 @@ msgstr ""
msgid "WEEKDAY"
msgstr ""
-#: grub-core/io/lzopio.c:30
-msgid "�LZO"
-msgstr ""
-
#: grub-core/kern/dl.c:412
msgid "grub_mod_init"
msgstr ""
@@ -4215,22 +4211,10 @@ msgstr ""
msgid "ext*"
msgstr ""
-#: grub-core/partmap/msdos.c:74
-msgid "�A��"
-msgstr ""
-
-#: grub-core/partmap/msdos.c:80
-msgid "�A��"
-msgstr ""
-
#: grub-core/partmap/msdos.c:86
msgid "HP Backup and Recovery Manager (?)"
msgstr ""
-#: grub-core/partmap/msdos.c:87
-msgid "p�]F5���=���U>�"
-msgstr ""
-
#: grub-core/partmap/msdos.c:94
msgid "ycgl"
msgstr ""
@@ -4574,10 +4558,6 @@ msgstr ""
msgid " failed: %ld\n"
msgstr ""
-#: grub-core/lib/xzembed/xz_stream.h:35
-msgid "�7zXZ"
-msgstr ""
-
#: grub-core/lib/xzembed/xz_stream.h:38
msgid "YZ"
msgstr ""
@@ -7173,3 +7153,344 @@ msgstr ""
#: util/grub-mkimagexx.c:845
msgid "CALL26 Relocation out of range"
msgstr ""
+
+#: grub-core/commands/verify.c:313
+msgid "\x99"
+msgstr ""
+
+#: grub-core/commands/videotest.c:122
+msgid "Unicode test: happy\xE2\x98\xBA \xC2\xA3 5.00"
+ " \xC2\xA1\xCF\x84\xC3\xA4u! "
+ " \xE2\x84\xA4\xE2\x8A\x86\xE2\x84\x9D"
+msgstr ""
+
+#: grub-core/disk/luks.c:40
+msgid "LUKS\xBA\xBE"
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:67 grub-core/disk/lvmparse.c:69
+msgid " = ["
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:115 grub-core/disk/lvmparse.c:123
+#: grub-core/disk/lvmparse.c:167 grub-core/disk/lvmparse.c:170
+msgid "id = \""
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:127
+msgid "extent_size = "
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:143 grub-core/disk/lvmparse.c:146
+msgid "physical_volumes {"
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:174
+msgid "pe_start = "
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:199
+msgid "logical_volumes"
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:202
+msgid "logical_volumes = "
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:226 grub-core/disk/lvmparse.c:227
+msgid "status"
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:226
+msgid "VISIBLE"
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:227
+msgid "PVMOVE"
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:228
+msgid "segment_count = "
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:246
+msgid "segment"
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:255
+msgid "start_extent = "
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:263
+msgid "extent_count = "
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:272 grub-core/disk/lvmparse.c:275
+msgid "type = \""
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:277 grub-core/disk/lvmparse.c:278
+msgid "striped\""
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:282
+msgid "stripe_count = "
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:292 grub-core/disk/lvmparse.c:396
+msgid "stripe_size = "
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:299 grub-core/disk/lvmparse.c:307
+msgid "stripes = ["
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:332
+msgid "mirror\""
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:336
+msgid "mirror_count = "
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:350 grub-core/disk/lvmparse.c:358
+msgid "mirrors = ["
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:375 grub-core/disk/lvmparse.c:376
+#: grub-core/disk/lvmparse.c:377 grub-core/disk/lvmparse.c:384
+msgid "raid"
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:378
+msgid "raidX"
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:386
+msgid "device_count = "
+msgstr ""
+
+#: grub-core/disk/lvmparse.c:410 grub-core/disk/lvmparse.c:418
+msgid "raids = ["
+msgstr ""
+
+#: grub-core/fs/cpio.c:24
+msgid "\xc7\x71"
+msgstr ""
+
+#: grub-core/fs/cpio_be.c:23
+msgid "\x71\xc7"
+msgstr ""
+
+#: grub-core/gfxmenu/gui_circular_progress.c:244
+msgid "\xc2\xb0"
+msgstr ""
+
+#: grub-core/kern/ieee1275/cmain.c:88
+msgid "IBM pSeries (emulated by qemu)"
+msgstr ""
+
+#: grub-core/lib/all_video.c:36
+msgid "/video.lst"
+msgstr ""
+
+#: grub-core/osdep/unix/config.c:108
+#, c-format
+msgid ""
+"'; printf \"GRUB_ENABLE_CRYPTODISK=%s\\nGRUB_DISTRIBUTOR=%s\\n\" "
+"\"$GRUB_ENABLE_CRYPTODISK\" \"$GRUB_DISTRIBUTOR\""
+msgstr ""
+
+#: include/grub/dl.h:141
+msgid "license"
+msgstr ""
+
+#: util/grub-install.c:1106
+msgid "BOOTAA64.EFI"
+msgstr ""
+
+#: util/grub-install.c:1133
+msgid "grubaa64.efi"
+msgstr ""
+
+#: util/grub-install.c:1274
+msgid "GRUB_ENABLE_CRYPTODISK=y"
+msgstr ""
+
+#: util/grub-mkrescue.c:656
+msgid "part_gpt"
+msgstr ""
+
+#: util/grub-mkrescue.c:657
+msgid "part_msdos"
+msgstr ""
+
+#: util/grub-mkrescue.c:663 util/grub-mkrescue.c:668 util/grub-mkrescue.c:723
+msgid "part_apple"
+msgstr ""
+
+#: util/grub-mkrescue.c:677
+msgid "bootaa64.efi"
+msgstr ""
+
+#: util/grub-probe.c:136 util/grub-probe.c:151 util/grub-probe.c:190
+#: util/grub-probe.c:247
+#, c-format
+msgid "%s%c"
+msgstr ""
+
+#: util/grub-probe.c:233
+#, c-format
+msgid "lvm%c"
+msgstr ""
+
+#: util/grub-probe.c:237
+#, c-format
+msgid "ldm%c"
+msgstr ""
+
+#: util/grub-probe.c:245
+#, c-format
+msgid "diskfilter%c"
+msgstr ""
+
+#: util/grub-probe.c:250
+#, c-format
+msgid "raid5rec%c"
+msgstr ""
+
+#: util/grub-probe.c:252
+#, c-format
+msgid "raid6rec%c"
+msgstr ""
+
+#: util/grub-mkrescue.c:136
+#, c-format
+msgid "%s\n\n%s\n\n%s"
+msgstr ""
+
+#: grub-core/kern/arm/cache.c:133
+msgid "couldn't get memory map, not enabling caches"
+msgstr ""
+
+#: grub-core/kern/arm/cache.c:149
+#, c-format
+msgid "%d crossers\n"
+msgstr ""
+
+#: grub-core/kern/arm/cache.c:154
+msgid "couldn't allocate place for MMU table, not enabling caches"
+msgstr ""
+
+#: grub-core/kern/arm/cache.c:212
+msgid "MMU tables generated\n"
+msgstr ""
+
+#: grub-core/kern/arm/cache.c:216
+msgid "enabling MMU\n"
+msgstr ""
+
+#: grub-core/kern/arm/cache.c:218
+msgid "MMU enabled\n"
+msgstr ""
+
+#: grub-core/commands/verify.c:313
+msgid "™"
+msgstr ""
+
+#: grub-core/commands/videotest.c:122
+msgid "Unicode test: happy☺ £ 5.00 ¡τäu! ℤ⊆ℝ"
+msgstr ""
+
+#: grub-core/disk/luks.c:40
+msgid "LUKSº¾"
+msgstr ""
+
+#: grub-core/fs/cpio.c:24
+msgid "Çq"
+msgstr ""
+
+#: grub-core/fs/cpio_be.c:23
+msgid "qÇ"
+msgstr ""
+
+#: grub-core/gfxmenu/gui_circular_progress.c:244
+msgid "°"
+msgstr ""
+
+#: grub-core/lib/xzembed/xz_stream.h:35
+msgid "ý7zXZ"
+msgstr ""
+
+#: grub-core/partmap/msdos.c:74
+msgid "ÔA õ"
+msgstr ""
+
+#: grub-core/partmap/msdos.c:80
+msgid "ØA õ"
+msgstr ""
+
+#: grub-core/partmap/msdos.c:87
+msgid "pŠ]F5Å“®=†ý±U>à"
+msgstr ""
+
+#: grub-core/io/lzopio.c:30
+msgid ""
+"‰LZO\n"
+"\n"
+msgstr ""
+
+#: grub-core/bus/emu/pci.c:58
+#, c-format
+msgid "mapping 0x%llx failed (error %d)"
+msgstr ""
+
+#: grub-core/disk/dmraid_nvidia.c:175
+msgid "nv"
+msgstr ""
+
+#: grub-core/fs/xfs.c:478
+msgid ") - %"
+msgstr ""
+
+#: grub-core/fs/xfs.c:478
+#, c-format
+msgid ", %d
+"
+msgstr ""
+
+#: grub-core/fs/xfs.c:550
+msgid "BMA3"
+msgstr ""
+
+#: grub-core/fs/zfs/zfs.c:284
+msgid "com.delphix:hole_birth"
+msgstr ""
+
+#: grub-core/fs/zfs/zfs.c:285
+msgid "com.delphix:embedded_data"
+msgstr ""
+
+#: grub-core/fs/zfs/zfs.c:286
+msgid "com.delphix:extensible_dataset"
+msgstr ""
+
+#: grub-core/fs/zfs/zfs.c:287
+msgid "org.open-zfs:large_blocks"
+msgstr ""
+
+#: grub-core/fs/zfs/zfs.c:1877
+msgid "/%"
+msgstr ""
+
+#: grub-core/osdep/linux/platform.c:73
+msgid "/sys/firmware/efi/fw_platform_size"
+msgstr ""
+
+#: util/grub-mkrescue.c:454
+msgid "-output"
+msgstr ""
+
+#: util/grub-mkrescue.c:455
+msgid "--output"
+msgstr ""
diff --git a/po/greek.sed b/po/greek.sed
index 17e4b0468..93556c386 100644
--- a/po/greek.sed
+++ b/po/greek.sed
@@ -12,8 +12,84 @@
s,%\([0-9]*\)C,%\1#,g
-y,abcdefghijklmnopqrstuvwxyz,αϭϲδεφγχιϊκλμνοπϗρστυβωξϋζ,
-y,ABCDEFGHIJKLMNOPQRSTUVWXYZ,ΑϬϲΔΕΦΓΧΙΪΚΛΜΝΟΠϏΡΣΤΥΒΩΞΫΖ,
+s,a,α,g
+s,b,ϭ,g
+s,c,ϲ,g
+s,d,δ,g
+s,e,ε,g
+s,f,φ,g
+s,g,γ,g
+s,h,χ,g
+s,i,ι,g
+s,j,ϊ,g
+s,k,κ,g
+s,l,λ,g
+s,m,μ,g
+s,n,ν,g
+s,o,ο,g
+s,p,π,g
+s,q,ϗ,g
+s,r,ρ,g
+s,s,σ,g
+s,t,τ,g
+s,u,υ,g
+s,v,β,g
+s,w,ω,g
+s,x,ξ,g
+s,y,ϋ,g
+s,z,ζ,g
+s,A,Α,g
+s,B,Ϭ,g
+s,C,ϲ,g
+s,D,Δ,g
+s,E,Ε,g
+s,F,Φ,g
+s,G,Γ,g
+s,H,Χ,g
+s,I,Ι,g
+s,J,Ϊ,g
+s,K,Κ,g
+s,L,Λ,g
+s,M,Μ,g
+s,N,Ν,g
+s,O,Ο,g
+s,P,Π,g
+s,Q,Ϗ,g
+s,R,Ρ,g
+s,S,Σ,g
+s,T,Τ,g
+s,U,Υ,g
+s,V,Β,g
+s,W,Ω,g
+s,X,Ξ,g
+s,Y,Ϋ,g
+s,Z,Ζ,g
+s,А,А,g
+s,Б,Б,g
+s,Ц,Ц,g
+s,Д,Д,g
+s,Е,Е,g
+s,Ф,Ф,g
+s,Г,Г,g
+s,Х,Х,g
+s,И,И,g
+s,Й,Й,g
+s,К,К,g
+s,Л,Л,g
+s,М,М,g
+s,Н,Н,g
+s,О,О,g
+s,П,П,g
+s,Ќ,Ќ,g
+s,Р,Р,g
+s,С,С,g
+s,Т,Т,g
+s,У,У,g
+s,В,В,g
+s,Ў,Ў,g
+s,Ѯ,Ѯ,g
+s,Ѝ,Ѝ,g
+s,З,З,g
s,%\([0-9]*\)#,%\1C,g
s,%\([0-9]*\)ϲ,%\1c,g
diff --git a/tests/ahci_test.in b/tests/ahci_test.in
index e7d26ac07..1d01d1f59 100644
--- a/tests/ahci_test.in
+++ b/tests/ahci_test.in
@@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
mips*-arc | mips*-qemu_mips)
exit 0;;
# FIXME: No native drivers are available for those
- powerpc-ieee1275 | sparc64-ieee1275)
+ powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
exit 0;;
esac
diff --git a/tests/ehci_test.in b/tests/ehci_test.in
index 5cfe726df..7dd8d3e8f 100644
--- a/tests/ehci_test.in
+++ b/tests/ehci_test.in
@@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
mips*-arc | mips*-qemu_mips)
exit 0;;
# FIXME: No native drivers are available for those
- powerpc-ieee1275 | sparc64-ieee1275)
+ powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
exit 0;;
esac
diff --git a/tests/ext234_test.in b/tests/ext234_test.in
index 8910b716f..c986960a8 100644
--- a/tests/ext234_test.in
+++ b/tests/ext234_test.in
@@ -29,3 +29,4 @@ fi
"@builddir@/grub-fs-tester" ext2
"@builddir@/grub-fs-tester" ext3
"@builddir@/grub-fs-tester" ext4
+"@builddir@/grub-fs-tester" ext4_metabg
diff --git a/tests/fddboot_test.in b/tests/fddboot_test.in
index a05eb3e75..a59645b7f 100644
--- a/tests/fddboot_test.in
+++ b/tests/fddboot_test.in
@@ -46,6 +46,6 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
exit 0;;
esac
-if [ "$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes=")" != "Hello World" ]; then
+if [ "$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes= -no-pad")" != "Hello World" ]; then
exit 1
fi
diff --git a/tests/file_filter/file b/tests/file_filter/file
new file mode 100644
index 000000000..64650ac58
--- /dev/null
+++ b/tests/file_filter/file
@@ -0,0 +1 @@
+Hello, user!
diff --git a/tests/file_filter/file.gz b/tests/file_filter/file.gz
new file mode 100644
index 000000000..a07ffcbe0
--- /dev/null
+++ b/tests/file_filter/file.gz
Binary files differ
diff --git a/tests/file_filter/file.gz.sig b/tests/file_filter/file.gz.sig
new file mode 100644
index 000000000..602e6187e
--- /dev/null
+++ b/tests/file_filter/file.gz.sig
Binary files differ
diff --git a/tests/file_filter/file.lzop b/tests/file_filter/file.lzop
new file mode 100644
index 000000000..5f5a97171
--- /dev/null
+++ b/tests/file_filter/file.lzop
Binary files differ
diff --git a/tests/file_filter/file.lzop.sig b/tests/file_filter/file.lzop.sig
new file mode 100644
index 000000000..7c68dcf93
--- /dev/null
+++ b/tests/file_filter/file.lzop.sig
Binary files differ
diff --git a/tests/file_filter/file.xz b/tests/file_filter/file.xz
new file mode 100644
index 000000000..151a98029
--- /dev/null
+++ b/tests/file_filter/file.xz
Binary files differ
diff --git a/tests/file_filter/file.xz.sig b/tests/file_filter/file.xz.sig
new file mode 100644
index 000000000..57569242e
--- /dev/null
+++ b/tests/file_filter/file.xz.sig
Binary files differ
diff --git a/tests/file_filter/keys b/tests/file_filter/keys
new file mode 100644
index 000000000..1afa71382
--- /dev/null
+++ b/tests/file_filter/keys
Binary files differ
diff --git a/tests/file_filter/keys.pub b/tests/file_filter/keys.pub
new file mode 100644
index 000000000..61d4e7a7b
--- /dev/null
+++ b/tests/file_filter/keys.pub
Binary files differ
diff --git a/tests/file_filter/test.cfg b/tests/file_filter/test.cfg
new file mode 100644
index 000000000..4308aaca5
--- /dev/null
+++ b/tests/file_filter/test.cfg
@@ -0,0 +1,6 @@
+trust /keys.pub
+set check_signatures=enforce
+cat /file.gz
+cat /file.xz
+cat /file.lzop
+set check_signatures=
diff --git a/tests/file_filter_test.in b/tests/file_filter_test.in
new file mode 100644
index 000000000..8909e4021
--- /dev/null
+++ b/tests/file_filter_test.in
@@ -0,0 +1,76 @@
+#! /bin/sh
+# Copyright (C) 2014 Free Software Foundation, Inc.
+#
+# GRUB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GRUB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+grubshell=@builddir@/grub-shell
+
+. "@builddir@/grub-core/modinfo.sh"
+
+filters="gzio xzio lzopio verify"
+modules="cat mpi"
+
+for mod in $(cut -d ' ' -f 2 "@builddir@/grub-core/crypto.lst" | sort -u); do
+ modules="$modules $mod"
+done
+
+for file in file.gz file.xz file.lzop file.gz.sig file.xz.sig file.lzop.sig keys.pub; do
+ files="$files /$file=@srcdir@/tests/file_filter/$file"
+done
+
+# GRUB cat command adds extra newline after file
+result="Hello, user!
+
+Hello, user!
+
+Hello, user!"
+
+out="$("${grubshell}" --modules="$modules $filters" --files="$files" "@srcdir@/tests/file_filter/test.cfg")"
+if [ "$out" != "$result" ]; then
+ echo LOCAL FAIL
+ echo "$out"
+ exit 1
+fi
+
+# Taken from netboot_test
+case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
+ # PLATFORM: emu is different
+ *-emu)
+ exit 0;;
+ # PLATFORM: Flash targets
+ i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
+ exit 0;;
+ # FIXME: currently grub-shell uses only -kernel for loongson
+ mipsel-loongson)
+ exit 0;;
+ # FIXME: no rtl8139 support
+ i386-multiboot)
+ exit 0;;
+ # FIXME: We don't fully support netboot on ARC
+ *-arc)
+ exit 0;;
+ # FIXME: Many QEMU firmware have no netboot capability
+ *-efi | i386-ieee1275 | powerpc-ieee1275 | sparc64-ieee1275)
+ exit 0;;
+esac
+
+out="$("${grubshell}" --boot=net --modules="$modules $filters" --files="$files" "@srcdir@/tests/file_filter/test.cfg")"
+if [ "$out" != "$result" ]; then
+ echo NET FAIL
+ echo "$out"
+ exit 1
+fi
+
+exit 0
diff --git a/tests/grub_cmd_sleep.in b/tests/grub_cmd_sleep.in
index 1c84fbfbb..eb362aa24 100644
--- a/tests/grub_cmd_sleep.in
+++ b/tests/grub_cmd_sleep.in
@@ -14,6 +14,11 @@ dt=`echo 'date; sleep 10; date' | @builddir@/grub-shell`
dt1="$(date -u -d "$(echo "$dt" | head -n 1)" +%s)"
dt2="$(date -u -d "$(echo "$dt" | tail -n 1)" +%s)"
+# Ignore QEMU bug
+if [ "${grub_modinfo_target_cpu}" = arm ] && [ $((dt2 - dt1)) -ge 15 ] && [ $((dt2 - dt1)) -le 17 ]; then
+ exit 0;
+fi
+
if [ $((dt2 - dt1)) -gt 11 ] || [ $((dt2 - dt1)) -lt 9 ]; then
echo "Interval not in range $dt2-$dt1 != 10"
exit 1
diff --git a/tests/grub_cmd_test.in b/tests/grub_cmd_test.in
new file mode 100644
index 000000000..6269891c9
--- /dev/null
+++ b/tests/grub_cmd_test.in
@@ -0,0 +1,67 @@
+#! /bin/bash
+
+# create a randome file
+empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+non_empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+cat >$non_empty <<EOF
+hello world!
+EOF
+
+. "@builddir@/grub-core/modinfo.sh"
+
+if [ x"${grub_modinfo_platform}" = xemu ]; then
+ grub_empty="(host)$empty"
+ grub_non_empty="(host)$non_empty"
+ grub_dir="(host)${TMPDIR:-/tmp}"
+else
+ grub_empty="/boot/empty"
+ grub_non_empty="/boot/non_empty"
+ grub_dir="/boot/grub"
+fi
+
+
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+@builddir@/grub-shell --files=$grub_empty=$empty --files=$grub_non_empty=$non_empty>$outfile <<EOF
+if ! test -f $grub_empty; then
+ echo FAIL1
+fi
+if ! test -e $grub_empty; then
+ echo FAIL2
+fi
+if test -d $grub_empty; then
+ echo FAIL3
+fi
+if ! test -d $grub_dir; then
+ echo FAIL4
+fi
+if test -s $grub_empty; then
+ echo FAIL5
+fi
+if ! test -s $grub_non_empty; then
+ echo FAIL6
+fi
+if test -f $grub_empty -a foo = bar; then
+ echo FAIL7
+fi
+if test -e $grub_empty -a foo = bar; then
+ echo FAIL8
+fi
+if test -s $grub_non_empty -a foo = bar; then
+ echo FAIL9
+fi
+if test -d $grub_dir -a foo = bar; then
+ echo FAIL10
+fi
+
+EOF
+
+rm -f "$empty" "$non_empty"
+
+if grep FAIL "$outfile" > /dev/null 2>&1; then
+ echo "GRUB test command file tests failed."
+ cat "$outfile"
+ exit 1
+else
+ rm -f "${outfile}"
+ exit 0
+fi
diff --git a/tests/hddboot_test.in b/tests/hddboot_test.in
index 2cbbf97ec..c229716a6 100644
--- a/tests/hddboot_test.in
+++ b/tests/hddboot_test.in
@@ -29,9 +29,6 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# FIXME: currently grub-shell uses only -kernel for loongson
mipsel-loongson)
exit 0;;
- # FIXME: OVMF skips HDDs for automatic boot and has no USB support
- *-efi)
- exit 0;;
esac
if [ "$(echo hello | "${grubshell}" --boot=hd)" != "Hello World" ]; then
diff --git a/tests/minixfs_test.in b/tests/minixfs_test.in
index 8075ba890..1784b1261 100644
--- a/tests/minixfs_test.in
+++ b/tests/minixfs_test.in
@@ -16,10 +16,20 @@ if ! which mkfs.minix >/dev/null 2>&1; then
fi
if ! mkfs.minix -h | grep -- -v > /dev/null; then
+ echo "mkfs.minix doesn't support minix2fs; cannot test minix*fs."
+ exit 77
+fi
+
+if ! mkfs.minix -h | grep -- -3 > /dev/null; then
echo "mkfs.minix doesn't support minix3fs; cannot test minix*fs."
exit 77
fi
+if ! mkfs.minix -h | grep -- -B > /dev/null; then
+ echo "mkfs.minix doesn't support variable block size; cannot test minix*fs."
+ exit 77
+fi
+
"@builddir@/grub-fs-tester" minix
"@builddir@/grub-fs-tester" minix2
"@builddir@/grub-fs-tester" minix3
diff --git a/tests/ntfs_test.in b/tests/ntfs_test.in
index 6bf09e691..e25c6384a 100644
--- a/tests/ntfs_test.in
+++ b/tests/ntfs_test.in
@@ -15,5 +15,10 @@ if ! which mkfs.ntfs >/dev/null 2>&1; then
exit 77
fi
+if ! which setfattr >/dev/null 2>&1; then
+ echo "setfattr not installed; cannot test ntfs."
+ exit 77
+fi
+
"@builddir@/grub-fs-tester" ntfs
-"@builddir@/grub-fs-tester" ntfscomp \ No newline at end of file
+"@builddir@/grub-fs-tester" ntfscomp
diff --git a/tests/ohci_test.in b/tests/ohci_test.in
index f841bd25c..7fede6f26 100644
--- a/tests/ohci_test.in
+++ b/tests/ohci_test.in
@@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
mips*-arc | mips*-qemu_mips)
exit 0;;
# FIXME: No native drivers are available for those
- powerpc-ieee1275 | sparc64-ieee1275)
+ powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
exit 0;;
esac
diff --git a/tests/partmap_test.in b/tests/partmap_test.in
index 7786ccfbc..f8dc456fb 100644
--- a/tests/partmap_test.in
+++ b/tests/partmap_test.in
@@ -88,10 +88,19 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
mipsel-arc)
disk=arc/scsi0/disk0/rdisk0
;;
+ arm*-efi)
+ disk=hd3
+ ;;
*)
disk=hd0
;;
esac
+
+if ! which parted >/dev/null 2>&1; then
+ echo "parted not installed; cannot test partmap"
+ exit 77
+fi
+
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
diff --git a/tests/pata_test.in b/tests/pata_test.in
index 07d17b781..c1d0f63ea 100644
--- a/tests/pata_test.in
+++ b/tests/pata_test.in
@@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
*-arc)
exit 0;;
# FIXME: No native drivers are available for those
- powerpc-ieee1275 | sparc64-ieee1275)
+ powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
exit 0;;
i386-ieee1275)
disk=hdb
diff --git a/tests/printf_unit_test.c b/tests/printf_unit_test.c
index eb76bd002..d7b12c6db 100644
--- a/tests/printf_unit_test.c
+++ b/tests/printf_unit_test.c
@@ -66,6 +66,9 @@ printf_test (void)
grub_snprintf (real, sizeof (real), "%3$d %2$lld %1$d", 1, 2LL, 3);
snprintf (expected, sizeof (expected), "%3$d %2$lld %1$d", 1, 2LL, 3);
grub_test_assert (strcmp (real, expected) == 0, MSG);
+ grub_snprintf (real, sizeof (real), "%%0%dd ", 1);
+ snprintf (expected, sizeof (expected), "%%0%dd ", 1);
+ grub_test_assert (strcmp (real, expected) == 0, MSG);
}
GRUB_UNIT_TEST ("printf_unit_test", printf_test);
diff --git a/grub-core/gfxmenu/model.c b/tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg
index e69de29bb..e69de29bb 100644
--- a/grub-core/gfxmenu/model.c
+++ b/tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg
diff --git a/tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg b/tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg
new file mode 100644
index 000000000..2e107fade
--- /dev/null
+++ b/tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg
@@ -0,0 +1,52 @@
+menu hshift 9
+menu width 58
+
+menu begin desktop
+ include stdmenu.cfg
+ menu hshift 13
+ menu width 49
+ menu label Alternative desktop environments
+ menu title Desktop environment menu
+ label mainmenu-kde
+ menu label ^Back..
+ text help
+ Higher level options install the GNOME desktop environment
+ endtext
+ menu exit
+ menu begin kde-desktop
+ include stdmenu.cfg
+ menu label ^KDE
+ menu title KDE desktop boot menu
+ text help
+ Select the 'K Desktop Environment' for the Desktop task
+ endtext
+ label mainmenu-kde
+ menu label ^Back..
+ menu exit
+ include kde/menu.cfg
+ menu end
+ menu begin lxde-desktop
+ include stdmenu.cfg
+ menu label ^LXDE
+ menu title LXDE desktop boot menu
+ text help
+ Select the 'Lightweight X11 Desktop Environment' for the Desktop task
+ endtext
+ label mainmenu-lxde
+ menu label ^Back..
+ menu exit
+ include lxde/menu.cfg
+ menu end
+ menu begin xfce-desktop
+ include stdmenu.cfg
+ menu label ^Xfce
+ menu title Xfce desktop boot menu
+ text help
+ Select the 'Xfce lightweight desktop environment' for the Desktop task
+ endtext
+ label mainmenu-xfce
+ menu label ^Back..
+ menu exit
+ include xfce/menu.cfg
+ menu end
+menu end
diff --git a/tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg b/tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg
new file mode 100644
index 000000000..3119e654a
--- /dev/null
+++ b/tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg
@@ -0,0 +1,3 @@
+label menu
+ kernel vesamenu.c32
+ config isolinux.cfg
diff --git a/tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg b/tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg
new file mode 100644
index 000000000..b799cb5cb
--- /dev/null
+++ b/tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg
@@ -0,0 +1,12 @@
+foreground=0xFFFFFF
+background=0x958490
+screen-colour=0x270A1E
+hidden-timeout=2
+label normal=Normal
+append normal=
+label driverupdates=Use driver update disc
+append driverupdates=debian-installer/driver-update=true
+applies driverupdates=live live-install
+label oem=OEM install (for manufacturers)
+append oem=oem-config/enable=true
+applies oem=live live-install install
diff --git a/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg b/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg
new file mode 100644
index 000000000..fd9c333b2
--- /dev/null
+++ b/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg
@@ -0,0 +1,6 @@
+# D-I config version 2.0
+include menu.cfg
+default vesamenu.c32
+prompt 0
+timeout 50
+ui gfxboot bootlogo
diff --git a/tests/syslinux/ubuntu10.04/isolinux/menu.cfg b/tests/syslinux/ubuntu10.04/isolinux/menu.cfg
new file mode 100644
index 000000000..9f5607dea
--- /dev/null
+++ b/tests/syslinux/ubuntu10.04/isolinux/menu.cfg
@@ -0,0 +1,23 @@
+menu hshift 13
+menu width 49
+menu margin 8
+
+menu title Installer boot menu
+include stdmenu.cfg
+include txt.cfg
+include gtk.cfg
+menu begin advanced
+ menu title Advanced options
+ include stdmenu.cfg
+ label mainmenu
+ menu label ^Back..
+ menu exit
+ include adtxt.cfg
+ include adgtk.cfg
+menu end
+label help
+ menu label ^Help
+ text help
+ Display help screens; type 'menu' at boot prompt to return to this menu
+ endtext
+ config prompt.cfg
diff --git a/tests/syslinux/ubuntu10.04/isolinux/po4a.cfg b/tests/syslinux/ubuntu10.04/isolinux/po4a.cfg
new file mode 100644
index 000000000..75f67881c
--- /dev/null
+++ b/tests/syslinux/ubuntu10.04/isolinux/po4a.cfg
@@ -0,0 +1,3 @@
+[po4a_langs] ar bn ca cs da de es eu fi fr gl hu id it ja ka ko ku lv nb nl pl pt pt_BR ru sk sv ta tr vi zh_CN zh_TW
+[po4a_paths] po/help.pot $lang:po/$lang.po
+[type:docbook] help.xml
diff --git a/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg b/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg
new file mode 100644
index 000000000..f9984aedc
--- /dev/null
+++ b/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg
@@ -0,0 +1,16 @@
+prompt 1
+display f1.txt
+timeout 50
+include menu.cfg
+include exithelp.cfg
+
+f1 f1.txt
+f2 f2.txt
+f3 f3.txt
+f4 f4.txt
+f5 f5.txt
+f6 f6.txt
+f7 f7.txt
+f8 f8.txt
+f9 f9.txt
+f0 f10.txt
diff --git a/tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg b/tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg
new file mode 100644
index 000000000..bdf6231ae
--- /dev/null
+++ b/tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg
@@ -0,0 +1,4 @@
+label rescue
+ menu label ^Rescue mode
+ kernel /install/vmlinuz
+ append vga=788 initrd=/install/initrd.gz rescue/enable=true -- quiet
diff --git a/tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg b/tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg
new file mode 100644
index 000000000..671b16f78
--- /dev/null
+++ b/tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg
@@ -0,0 +1,15 @@
+menu background splash.png
+menu color title * #FFFFFFFF *
+menu color border * #00000000 #00000000 none
+menu color sel * #ffffffff #76a1d0ff *
+menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *
+menu color tabmsg * #ffffffff #00000000 *
+menu color help 37;40 #ffdddd00 #00000000 none
+menu vshift 12
+menu rows 10
+menu helpmsgrow 15
+# The command line must be at least one line from the bottom.
+menu cmdlinerow 16
+menu timeoutrow 16
+menu tabmsgrow 18
+menu tabmsg Press ENTER to boot or TAB to edit a menu entry
diff --git a/tests/syslinux/ubuntu10.04/isolinux/txt.cfg b/tests/syslinux/ubuntu10.04/isolinux/txt.cfg
new file mode 100644
index 000000000..860daad80
--- /dev/null
+++ b/tests/syslinux/ubuntu10.04/isolinux/txt.cfg
@@ -0,0 +1,19 @@
+default live
+label live
+ menu label ^Try Ubuntu without installing
+ kernel /casper/vmlinuz
+ append file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash --
+label live-install
+ menu label ^Install Ubuntu
+ kernel /casper/vmlinuz
+ append file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash --
+label check
+ menu label ^Check disc for defects
+ kernel /casper/vmlinuz
+ append boot=casper integrity-check initrd=/casper/initrd.lz quiet splash --
+label memtest
+ menu label Test ^memory
+ kernel /install/mt86plus
+label hd
+ menu label ^Boot from first hard disk
+ localboot 0x80
diff --git a/tests/syslinux/ubuntu10.04_grub.cfg.in b/tests/syslinux/ubuntu10.04_grub.cfg.in
new file mode 100644
index 000000000..846e4acf0
--- /dev/null
+++ b/tests/syslinux/ubuntu10.04_grub.cfg.in
@@ -0,0 +1,236 @@
+ background_image '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux'/'splash.png'
+# D-I config version 2.0
+ # UNSUPPORTED command 'menu hshift 13'
+ # UNSUPPORTED command 'menu width 49'
+ # UNSUPPORTED command 'menu margin 8'
+
+ # UNSUPPORTED command 'menu title Installer boot menu'
+ # UNSUPPORTED command 'menu color title * #FFFFFFFF *'
+ # UNSUPPORTED command 'menu color border * #00000000 #00000000 none'
+ # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *'
+ # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *'
+ # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *'
+ # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none'
+ # UNSUPPORTED command 'menu vshift 12'
+ # UNSUPPORTED command 'menu rows 10'
+ # UNSUPPORTED command 'menu helpmsgrow 15'
+# The command line must be at least one line from the bottom.
+ # UNSUPPORTED command 'menu cmdlinerow 16'
+ # UNSUPPORTED command 'menu timeoutrow 16'
+ # UNSUPPORTED command 'menu tabmsgrow 18'
+ # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry'
+set timeout=5
+ default='vesamenu.c32'
+menuentry 'Try Ubuntu without installing' --hotkey 't' --id 'live' {
+ if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi
+ linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash --
+ initrd$linux_suffix '/'/'/casper/initrd.lz'
+}
+menuentry 'Install Ubuntu' --hotkey 'i' --id 'live-install' {
+ if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi
+ linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash --
+ initrd$linux_suffix '/'/'/casper/initrd.lz'
+}
+menuentry 'Check disc for defects' --hotkey 'c' --id 'check' {
+ if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi
+ linux$linux_suffix '/'/'/casper/vmlinuz' boot=casper integrity-check initrd=/casper/initrd.lz quiet splash --
+ initrd$linux_suffix '/'/'/casper/initrd.lz'
+}
+menuentry 'Test memory' --hotkey 'm' --id 'memtest' {
+ if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi
+ linux$linux_suffix '/'/'/install/mt86plus'
+}
+menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' {
+# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/gtk.cfg not found
+ # UNSUPPORTED command 'menu begin advanced'
+ # UNSUPPORTED command 'menu title Advanced options'
+ # UNSUPPORTED command 'menu color title * #FFFFFFFF *'
+ # UNSUPPORTED command 'menu color border * #00000000 #00000000 none'
+ # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *'
+ # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *'
+ # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *'
+ # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none'
+ # UNSUPPORTED command 'menu vshift 12'
+ # UNSUPPORTED command 'menu rows 10'
+ # UNSUPPORTED command 'menu helpmsgrow 15'
+# The command line must be at least one line from the bottom.
+ # UNSUPPORTED command 'menu cmdlinerow 16'
+ # UNSUPPORTED command 'menu timeoutrow 16'
+ # UNSUPPORTED command 'menu tabmsgrow 18'
+ # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry'
+ root=hd0;
+ chainloader +1;
+}
+menuentry 'Back..' --hotkey 'b' --id 'mainmenu' {
+ # UNSUPPORTED command 'menu exit'
+# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/adgtk.cfg not found
+ # UNSUPPORTED command 'menu end'
+ # UNSUPPORTED entry type 0
+true;
+}
+menuentry 'Help' --hotkey 'h' --id 'help' {
+ # UNSUPPORTED command 'ui gfxboot bootlogo'
+#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux'/'prompt.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg:
+ background_image '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'splash.png'
+ # UNSUPPORTED command 'display f1.txt'
+ # UNSUPPORTED command 'menu hshift 13'
+ # UNSUPPORTED command 'menu width 49'
+ # UNSUPPORTED command 'menu margin 8'
+
+ # UNSUPPORTED command 'menu title Installer boot menu'
+ # UNSUPPORTED command 'menu color title * #FFFFFFFF *'
+ # UNSUPPORTED command 'menu color border * #00000000 #00000000 none'
+ # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *'
+ # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *'
+ # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *'
+ # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none'
+ # UNSUPPORTED command 'menu vshift 12'
+ # UNSUPPORTED command 'menu rows 10'
+ # UNSUPPORTED command 'menu helpmsgrow 15'
+# The command line must be at least one line from the bottom.
+ # UNSUPPORTED command 'menu cmdlinerow 16'
+ # UNSUPPORTED command 'menu timeoutrow 16'
+ # UNSUPPORTED command 'menu tabmsgrow 18'
+ # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry'
+set timeout=5
+ default='live'
+menuentry 'Try Ubuntu without installing' --hotkey 't' --id 'live' {
+ if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi
+ linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash --
+ initrd$linux_suffix '/'/'/casper/initrd.lz'
+}
+menuentry 'Install Ubuntu' --hotkey 'i' --id 'live-install' {
+ if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi
+ linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash --
+ initrd$linux_suffix '/'/'/casper/initrd.lz'
+}
+menuentry 'Check disc for defects' --hotkey 'c' --id 'check' {
+ if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi
+ linux$linux_suffix '/'/'/casper/vmlinuz' boot=casper integrity-check initrd=/casper/initrd.lz quiet splash --
+ initrd$linux_suffix '/'/'/casper/initrd.lz'
+}
+menuentry 'Test memory' --hotkey 'm' --id 'memtest' {
+ if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi
+ linux$linux_suffix '/'/'/install/mt86plus'
+}
+menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' {
+# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//gtk.cfg not found
+ # UNSUPPORTED command 'menu begin advanced'
+ # UNSUPPORTED command 'menu title Advanced options'
+ # UNSUPPORTED command 'menu color title * #FFFFFFFF *'
+ # UNSUPPORTED command 'menu color border * #00000000 #00000000 none'
+ # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *'
+ # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *'
+ # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *'
+ # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none'
+ # UNSUPPORTED command 'menu vshift 12'
+ # UNSUPPORTED command 'menu rows 10'
+ # UNSUPPORTED command 'menu helpmsgrow 15'
+# The command line must be at least one line from the bottom.
+ # UNSUPPORTED command 'menu cmdlinerow 16'
+ # UNSUPPORTED command 'menu timeoutrow 16'
+ # UNSUPPORTED command 'menu tabmsgrow 18'
+ # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry'
+ root=hd0;
+ chainloader +1;
+}
+menuentry 'Back..' --hotkey 'b' --id 'mainmenu' {
+ # UNSUPPORTED command 'menu exit'
+# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//adgtk.cfg not found
+ # UNSUPPORTED command 'menu end'
+ # UNSUPPORTED entry type 0
+true;
+}
+menuentry 'Help' --hotkey 'h' --id 'help' {
+#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg:
+ syslinux_configfile -r '/'/'/' -c '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'' '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg'
+}
+menuentry 'menu' --id 'menu' {
+ # UNSUPPORTED command 'f1 f1.txt'
+ # UNSUPPORTED command 'f2 f2.txt'
+ # UNSUPPORTED command 'f3 f3.txt'
+ # UNSUPPORTED command 'f4 f4.txt'
+ # UNSUPPORTED command 'f5 f5.txt'
+ # UNSUPPORTED command 'f6 f6.txt'
+ # UNSUPPORTED command 'f7 f7.txt'
+ # UNSUPPORTED command 'f8 f8.txt'
+ # UNSUPPORTED command 'f9 f9.txt'
+ # UNSUPPORTED command 'f0 f10.txt'
+#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'isolinux.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg:
+ background_image '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'splash.png'
+# D-I config version 2.0
+ # UNSUPPORTED command 'menu hshift 13'
+ # UNSUPPORTED command 'menu width 49'
+ # UNSUPPORTED command 'menu margin 8'
+
+ # UNSUPPORTED command 'menu title Installer boot menu'
+ # UNSUPPORTED command 'menu color title * #FFFFFFFF *'
+ # UNSUPPORTED command 'menu color border * #00000000 #00000000 none'
+ # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *'
+ # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *'
+ # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *'
+ # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none'
+ # UNSUPPORTED command 'menu vshift 12'
+ # UNSUPPORTED command 'menu rows 10'
+ # UNSUPPORTED command 'menu helpmsgrow 15'
+# The command line must be at least one line from the bottom.
+ # UNSUPPORTED command 'menu cmdlinerow 16'
+ # UNSUPPORTED command 'menu timeoutrow 16'
+ # UNSUPPORTED command 'menu tabmsgrow 18'
+ # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry'
+set timeout=5
+ default='vesamenu.c32'
+menuentry 'Try Ubuntu without installing' --hotkey 't' --id 'live' {
+ if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi
+ linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash --
+ initrd$linux_suffix '/'/'/casper/initrd.lz'
+}
+menuentry 'Install Ubuntu' --hotkey 'i' --id 'live-install' {
+ if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi
+ linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash --
+ initrd$linux_suffix '/'/'/casper/initrd.lz'
+}
+menuentry 'Check disc for defects' --hotkey 'c' --id 'check' {
+ if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi
+ linux$linux_suffix '/'/'/casper/vmlinuz' boot=casper integrity-check initrd=/casper/initrd.lz quiet splash --
+ initrd$linux_suffix '/'/'/casper/initrd.lz'
+}
+menuentry 'Test memory' --hotkey 'm' --id 'memtest' {
+ if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi
+ linux$linux_suffix '/'/'/install/mt86plus'
+}
+menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' {
+# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux///gtk.cfg not found
+ # UNSUPPORTED command 'menu begin advanced'
+ # UNSUPPORTED command 'menu title Advanced options'
+ # UNSUPPORTED command 'menu color title * #FFFFFFFF *'
+ # UNSUPPORTED command 'menu color border * #00000000 #00000000 none'
+ # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *'
+ # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *'
+ # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *'
+ # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none'
+ # UNSUPPORTED command 'menu vshift 12'
+ # UNSUPPORTED command 'menu rows 10'
+ # UNSUPPORTED command 'menu helpmsgrow 15'
+# The command line must be at least one line from the bottom.
+ # UNSUPPORTED command 'menu cmdlinerow 16'
+ # UNSUPPORTED command 'menu timeoutrow 16'
+ # UNSUPPORTED command 'menu tabmsgrow 18'
+ # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry'
+ root=hd0;
+ chainloader +1;
+}
+menuentry 'Back..' --hotkey 'b' --id 'mainmenu' {
+ # UNSUPPORTED command 'menu exit'
+# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux///adgtk.cfg not found
+ # UNSUPPORTED command 'menu end'
+ # UNSUPPORTED entry type 0
+true;
+}
+menuentry 'Help' --hotkey 'h' --id 'help' {
+ # UNSUPPORTED command 'ui gfxboot bootlogo'
+#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg:
+ syslinux_configfile -r '/'/'/' -c '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'' '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg'
+}
+}
+}
diff --git a/tests/syslinux_test.in b/tests/syslinux_test.in
new file mode 100644
index 000000000..fc4edd8ef
--- /dev/null
+++ b/tests/syslinux_test.in
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+
+"@builddir@/grub-syslinux2cfg" -r "@abs_top_srcdir@/tests/syslinux/ubuntu10.04" "@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg" -o "$outfile"
+
+echo "$outfile"
+
+if ! diff -u "$outfile" "@builddir@/tests/syslinux/ubuntu10.04_grub.cfg"; then
+ echo "Mismatch in ubuntu10.04"
+ exit 1;
+fi
+
+exit 0
diff --git a/tests/test_sha512sum.in b/tests/test_sha512sum.in
index 524c1d1c0..d5ef7f9ea 100644
--- a/tests/test_sha512sum.in
+++ b/tests/test_sha512sum.in
@@ -1,7 +1,7 @@
#! /bin/bash
# create a randome file
-file=`mktemp`
+file="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
cat >$file <<EOF
hello world!
EOF
@@ -15,12 +15,12 @@ else
fi
-outfile1=`mktemp`
+outfile1="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
@builddir@/grub-shell --files=/boot/grub/file=$file >$outfile1 <<EOF
sha512sum $grub_file
EOF
-outfile2=`mktemp`
+outfile2="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
sha512sum $file >$outfile2
SHA1=`cat $outfile1 | tr -d '\n' | cut -f1 -d\ `
diff --git a/tests/uhci_test.in b/tests/uhci_test.in
index 3dea51c01..89e2c1805 100644
--- a/tests/uhci_test.in
+++ b/tests/uhci_test.in
@@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
mips*-arc | mips*-qemu_mips)
exit 0;;
# FIXME: No native drivers are available for those
- powerpc-ieee1275 | sparc64-ieee1275)
+ powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
exit 0;;
esac
diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in
index 669527a90..424de2267 100644
--- a/tests/util/grub-fs-tester.in
+++ b/tests/util/grub-fs-tester.in
@@ -10,7 +10,7 @@ tempdir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
# This wrapper is to ease insertion of valgrind or time statistics
run_it () {
- "$GRUBFSTEST" "$@"
+ LC_ALL=C "$GRUBFSTEST" "$@"
}
run_grubfstest () {
@@ -40,6 +40,10 @@ case x"$fs" in
MINLOGSECSIZE=9
# OS LIMITATION: GNU/Linux doesn't accept > 4096
MAXLOGSECSIZE=12;;
+ xxfs_crc)
+ MINLOGSECSIZE=9
+ # OS LIMITATION: GNU/Linux doesn't accept > 1024
+ MAXLOGSECSIZE=10;;
xzfs*)
# OS LIMITATION: zfs-fuse hangs when creating zpool with sectors <=256B.
MINLOGSECSIZE=9
@@ -102,7 +106,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
# OS LIMITATION: Linux oopses with >=32768K
MAXBLKSIZE=$((16384*1024))
;;
- x"lvm_raid4" | x"lvm_raid5" | x"lvm_raid6")
+ x"lvm_raid1"* | x"lvm_raid4" | x"lvm_raid5" | x"lvm_raid6")
# OS LIMITATION: Linux crashes with less than 16384
MINBLKSIZE=16384
# Could go further but what's the point?
@@ -142,6 +146,10 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
MINBLKSIZE=$SECSIZE
# OS Limitation: GNU/Linux doesn't accept > 4096
MAXBLKSIZE=4096;;
+ xxfs_crc)
+ # OS Limitation: GNU/Linux doesn't accept != 1024
+ MINBLKSIZE=1024
+ MAXBLKSIZE=1024;;
xudf)
MINBLKSIZE=1024
MAXBLKSIZE=4096;;
@@ -166,7 +174,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
x"zfs_raidz" | x"zfs_stripe" | x"zfs_mirror" | xbtrfs_raid0 \
| xbtrfs_raid1 | x"mdraid"*"_raid4" | x"mdraid"*"_raid5" \
| x"mdraid"*"_linear" \
- | x"mdraid"*"_raid10" | xlvm_mirror1 | xlvm_mirrorall)
+ | x"mdraid"*"_raid10" | xlvm_raid1* | xlvm_mirror1 | xlvm_mirrorall)
MINDEVICES=2
MAXDEVICES=7
;;
@@ -199,7 +207,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
case x$fs in
# RAID 1 has to work with even one device of the set.
- xzfs_mirror | x"mdraid"*"_raid1" | xlvm_mirrorall)
+ xzfs_mirror | x"mdraid"*"_raid1" | xlvm_mirrorall | xlvm_raid1all)
NEED_IMAGES_N=1;;
# Degrade raidz by removing 3 devices
xzfs_raidz3)
@@ -210,7 +218,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
# Degrade raidz and btrfs RAID1 by removing one device
xbtrfs_raid1 | xbtrfs_raid10 | xzfs_raidz | x"mdraid"*"_raid4" \
| x"mdraid"*"_raid5" | x"mdraid"*"_raid10" | xlvm_mirror1 \
- | x"lvm_raid4" | x"lvm_raid5")
+ | x"lvm_raid1" | x"lvm_raid4" | x"lvm_raid5")
NEED_IMAGES_N=$((NDEVICES-1));;
*)
NEED_IMAGES_N=$NDEVICES;;
@@ -281,13 +289,13 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
#FSLABEL="g;/_é莭莽😁кит u"
;;
# FS LIMITATION: reiserfs, extN and jfs label is at most 16 UTF-8 characters
- x"reiserfs_old" | x"reiserfs" | x"ext2" | xext2_old | x"ext3" | x"ext4" | x"lvm"* | x"mdraid"* | x"jfs" | x"jfs_caseins")
+ x"reiserfs_old" | x"reiserfs" | x"ext"* | x"lvm"* | x"mdraid"* | x"jfs" | x"jfs_caseins")
FSLABEL="g;/éт 莭😁";;
# FS LIMITATION: No underscore, space, semicolon, slash or international characters in UFS* in label. Limited to 32 UTF-8 characters
x"ufs1" | x"ufs1_sun" | x"ufs2")
FSLABEL="grubtest""ieurrucnenreeiurueurewf";;
# FS LIMITATION: XFS label is at most 12 UTF-8 characters
- x"xfs")
+ x"xfs"|x"xfs_crc")
FSLABEL="géт 😁к";;
# FS LIMITATION: FAT labels limited to 11 characters, no international characters or lowercase
x"vfat"* | xmsdos*)
@@ -465,7 +473,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
case x"$fs" in
# FIXME: Not sure about BtrFS, NTFS, JFS, AFS, UDF and SFS. Check it.
# FS LIMITATION: as far as I know those FS don't store their last modification date.
- x"jfs_caseins" | x"jfs" | x"xfs"| x"btrfs"* | x"reiserfs_old" | x"reiserfs" \
+ x"jfs_caseins" | x"jfs" | x"xfs" | x"xfs_crc" | x"btrfs"* | x"reiserfs_old" | x"reiserfs" \
| x"bfs" | x"afs" \
| x"tarfs" | x"cpio_"* | x"minix" | x"minix2" \
| x"minix3" | x"ntfs"* | x"udf" | x"sfs"*)
@@ -728,10 +736,15 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
lvcreate -l "$((NDEVICES*7*LVMBLKMUL))" -n testvol grub_test
elif [ x$fs = xlvm_stripe ] ; then
lvcreate -l "$((NDEVICES*7*LVMBLKMUL))" -i "$NDEVICES" -n testvol grub_test
- elif [ x$fs = xlvm_mirror1 ] ; then
- lvcreate -m 1 -l "$((NDEVICES*2*LVMBLKMUL))" -n testvol grub_test
+ elif [ x$fs = xlvm_mirror1 ] || [ x$fs = xlvm_raid1 ] ; then
+ lvcreate -m 1 -l "$((NDEVICES*2*LVMBLKMUL))" --type "${fs/lvm_/}" -n testvol grub_test
elif [ x$fs = xlvm_mirrorall ] ; then
- lvcreate -m "$((NDEVICES-1))" -l "$((6*LVMBLKMUL))" -n testvol grub_test
+ lvcreate -m "$((NDEVICES-1))" -l "$((6*LVMBLKMUL))" --type mirror -n testvol grub_test
+ elif [ x$fs = xlvm_raid1all ] ; then
+ # Until version 2.02.103 LVM counts metadata segments
+ # twice when checking available space. Reduce segment
+ # count to work around it.
+ lvcreate -m "$((NDEVICES-1))" -l "$((6*LVMBLKMUL - 1))" --type raid1 -n testvol grub_test
elif [ x$fs = xlvm_raid4 ] || [ x$fs = xlvm_raid5 ]; then
lvcreate -l "$(((NDEVICES-1) * 5*LVMBLKMUL))" -i "$((NDEVICES-1))" --type "${fs/lvm_/}" -n testvol grub_test
elif [ x$fs = xlvm_raid6 ]; then
@@ -746,10 +759,17 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.ext2" -r 0 -b $BLKSIZE -L "$FSLABEL" -q "${LODEVICES[0]}"
MOUNTFS=ext2
;;
+ xext4_metabg)
+ MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.ext4" -O meta_bg,^resize_inode -b $BLKSIZE -L "$FSLABEL" -q "${LODEVICES[0]}"
+ MOUNTFS=ext4
+ ;;
xext*)
MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.$fs" -b $BLKSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;;
xxfs)
- "mkfs.xfs" -b size=$BLKSIZE -s size=$SECSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;;
+ "mkfs.xfs" -m crc=0 -b size=$BLKSIZE -s size=$SECSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;;
+ xxfs_crc)
+ MOUNTFS="xfs"
+ "mkfs.xfs" -m crc=1 -b size=$BLKSIZE -s size=$SECSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;;
*)
echo "Add appropriate mkfs command here"
exit 1
@@ -989,6 +1009,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
fi
sleep 1;
done
+ UMOUNT_TIME=$(date -u "+%Y-%m-%d %H:%M:%S")
sleep 1
vgchange -a n grub_test
;;
@@ -1000,6 +1021,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
fi
sleep 1;
done
+ UMOUNT_TIME=$(date -u "+%Y-%m-%d %H:%M:%S")
sleep 1
mdadm --stop /dev/md/"${fs}_$NDEVICES"
;;
@@ -1065,6 +1087,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
:
else
echo NLIST FAIL
+ echo "$LSROUT"
TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -lA "$MNTPOINTRO"
exit 1
fi
@@ -1082,6 +1105,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
:
else
echo LONG LIST FAIL
+ echo "$LSROUT"
TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO"
exit 1
fi
@@ -1110,6 +1134,37 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
case x"$fs" in
x"zfs"*)
+ LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/grub fs@/.");;
+ *)
+ LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/.");;
+ esac
+ if echo "$LSROUT" | grep -F " $BASEFILE" | grep "$BLOCKCNT" > /dev/null; then
+ :
+ else
+ echo DOT IN ROOTDIR FAIL
+ echo "$LSROUT"
+ TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO"
+ exit 1
+ fi
+
+ case x"$fs" in
+ x"zfs"*)
+ ;;
+ *)
+ LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/..");
+ if echo "$LSROUT" | grep -F " $BASEFILE" | grep "$BLOCKCNT" > /dev/null; then
+ :
+ else
+ echo DOTDOT IN ROOTDIR FAIL
+ echo "$LSROUT"
+ TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO"
+ exit 1
+ fi
+ ;;
+ esac
+
+ case x"$fs" in
+ x"zfs"*)
LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/grub fs@/////sdir");;
*)
LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/////sdir");;
@@ -1138,6 +1193,36 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
exit 1
fi
+ case x"$fs" in
+ x"zfs"*)
+ LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/grub fs@/sdir/.");;
+ *)
+ LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/sdir/.");;
+ esac
+ if echo "$LSROUT" | grep -F " 2.img" | grep $BLOCKCNT > /dev/null; then
+ :
+ else
+ echo DOT IN SUBDIR FAIL
+ echo "$LSROUT"
+ TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/$OSDIR/sdir"
+ exit 1
+ fi
+
+ case x"$fs" in
+ x"zfs"*)
+ LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/grub fs@/sdir/../sdir");;
+ *)
+ LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/sdir/../sdir");;
+ esac
+ if echo "$LSROUT" | grep -F " 2.img" | grep $BLOCKCNT > /dev/null; then
+ :
+ else
+ echo DOTDOT IN SUBDIR FAIL
+ echo "$LSROUT"
+ TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/$OSDIR/ssdir"
+ exit 1
+ fi
+
LSOUT=`run_grubfstest ls -- -l "($GRUBDEVICE)"`
if [ x"$NOFSLABEL" = xy ]; then
:
@@ -1208,10 +1293,15 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE +
case x$fs in
xiso9660 | xziso9660 | xrockridge | xjoliet | xrockridge_joliet | xiso9660_1999 | xrockridge_1999 | xjoliet_1999 | xrockridge_joliet_1999)
FSTIME="$(date -d "$(echo ${FSUUID} | awk -F - '{ print $1"-"$2"-"$3" "$4":"$5":"$6 ;}')" '+%Y-%m-%d %H:%M:%S')";;
+ xlvm*|xmdraid*)
+ # With some abstractions like mdraid flushing to disk
+ # may be delayed for a long time.
+ FSTIME="$UMOUNT_TIME";;
*)
FSTIME="$(TZ=UTC ls --time-style="+%Y-%m-%d_%H:%M:%S" -l -d "${FSIMAGES[0]}"|awk '{print $6; }'|sed 's,_, ,g')";;
esac
- # With some abstractions like mdraid it may take up to 2 seconds for the data to reach the disks after it was flushed by FS in these tests.
+ # With some abstractions like mdraid computing of UMOUNT_TIME
+ # is not precise. Account for small difference here.
FSTIMEM1="$(date -d "$FSTIME UTC -1 second" -u "+%Y-%m-%d %H:%M:%S")"
FSTIMEM2="$(date -d "$FSTIME UTC -2 second" -u "+%Y-%m-%d %H:%M:%S")"
diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in
index d9a5253e2..ab19dbbf5 100644
--- a/tests/util/grub-shell.in
+++ b/tests/util/grub-shell.in
@@ -65,7 +65,7 @@ serial_port=com0
serial_null=
halt_cmd=halt
pseries=n
-disk=hda
+disk="hda "
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
*-emu)
device_map=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
@@ -74,6 +74,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
disk=0
# To skip "Welcome to GRUB" and color setttings
trim=1
+ serial_port=
;;
powerpc-ieee1275)
boot=hd
@@ -82,6 +83,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
serial_port=escc-ch-b
serial_null="-serial null"
netbootext=elf
+ trim=1
;;
sparc64-ieee1275)
@@ -97,13 +99,13 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
mips-qemu_mips)
boot=mips_qemu
qemu=qemu-system-mips
- qemuopts="$qemuopts -M mips"
+ qemuopts="-M mips $qemuopts"
console=vga_text
;;
mips-arc)
boot=cd
qemu=qemu-system-mips64
- qemuopts="$qemuopts -M indy"
+ qemuopts="-M indy $qemuopts"
serial_port=arc/serial0/line0
console=
trim=1
@@ -111,7 +113,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
mipsel-arc)
boot=cd
qemu=qemu-system-mips64el
- qemuopts="$qemuopts -M magnum -no-reboot"
+ qemuopts="-M magnum $qemuopts -no-reboot"
serial_port=arc/multi0/serial0
console=console
halt_cmd=reboot
@@ -120,13 +122,13 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
mipsel-qemu_mips)
boot=mipsel_qemu
qemu=qemu-system-mipsel
- qemuopts="$qemuopts -M mips"
+ qemuopts="-M mips $qemuopts"
console=vga_text
;;
mipsel-loongson)
boot=mipsel_fulong2e
qemu=qemu-system-mips64el
- qemuopts="$qemuopts -M fulong2e"
+ qemuopts="-M fulong2e $qemuopts"
console=
trim=1
;;
@@ -145,7 +147,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
qemu=qemu-system-i386
console=console
trim=1
- disk=hdb
+ disk="hdb "
;;
i386-qemu)
boot=qemu
@@ -164,12 +166,32 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
boot=cd
console=console
trim=1
+ qemuopts="-bios OVMF-ia32.fd $qemuopts"
;;
x86_64-efi)
qemu=qemu-system-x86_64
boot=cd
console=console
trim=1
+ qemuopts="-bios OVMF.fd $qemuopts"
+ ;;
+ arm64-efi)
+ qemu=qemu-system-aarch64
+ boot=hd
+ console=console
+ trim=1
+ qemuopts="-machine virt -cpu cortex-a57 -bios /usr/share/qemu-efi/QEMU_EFI.fd $qemuopts"
+ disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file="
+ serial_port=
+ ;;
+ arm-efi)
+ qemu=qemu-system-arm
+ boot=hd
+ console=console
+ trim=1
+ qemuopts="-machine virt -bios /usr/share/ovmf-arm/QEMU_EFI.fd $qemuopts"
+ disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file="
+ serial_port=efi0
;;
*)
boot=hd
@@ -222,17 +244,17 @@ for option in "$@"; do
echo "(hd$disk) $dsk" >> "$device_map"
disk="$((disk+1))"
else
- if [ $disk = error ]; then
+ if [ "$disk" = error ]; then
echo "Too many disks" 1>&2
exit 1;
fi
- qemuopts="$qemuopts -$disk $dsk"
- if [ "$disk" = hda ]; then
- disk=hdb;
- elif [ "$disk" = hdb ]; then
+ qemuopts="$qemuopts -$disk$dsk"
+ if [ "$disk" = "hda " ]; then
+ disk="hdb ";
+ elif [ "$disk" = "hdb " ]; then
# CDROM is hdc
- disk=hdd
- elif [ "$disk" = hdd ]; then
+ disk="hdd "
+ elif [ "$disk" = "hdd " ]; then
# CDROM is hdc
disk=error
fi
@@ -289,6 +311,8 @@ fi
cfgfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
cat <<EOF >${cfgfile}
grubshell=yes
+enable_progress_indicator=0
+export enable_progress_indicator
EOF
@@ -299,7 +323,7 @@ fi
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = powerpc-ieee1275 ]; then
echo insmod escc >>${cfgfile}
fi
-if [ "${grub_modinfo_platform}" != emu ]; then
+if [ "${serial_port}" != "" ]; then
echo "serial ${serial_port}" >>${cfgfile}
term="serial_${serial_port}"
else
@@ -329,7 +353,8 @@ cat <<EOF >>${cfgfile}
source "\$prefix/testcase.cfg"
# Stop serial output to suppress "ACPI shutdown failed" error.
EOF
-if [ x$console != x ]; then
+# Attempt to switch to console on i386-ieee1275 causes "screen not found" message
+if [ x$console != x ] && [ x"${grub_modinfo_target_cpu}-${grub_modinfo_platform}" != xi386-ieee1275 ]; then
echo "terminal_output $console" >>${cfgfile}
fi
echo "${halt_cmd}" >>${cfgfile}
@@ -349,13 +374,16 @@ fi
if [ x$boot != xnet ] && [ x$boot != xemu ]; then
pkgdatadir="@builddir@" "@builddir@/grub-mkrescue" "--output=${isofile}" "--override-directory=${builddir}/grub-core" \
--rom-directory="${rom_directory}" \
+ --locale-directory="@srcdir@/po" \
--themes-directory="@srcdir@/themes" \
$mkimage_extra_arg ${mkrescue_args} \
"/boot/grub/grub.cfg=${cfgfile}" "/boot/grub/testcase.cfg=${source}" \
${files} >/dev/null 2>&1
fi
if [ x$boot = xhd ]; then
- if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = mips-arc ]; then
+ if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm-efi ]; then
+ device="device virtio-blk-device,drive=hd0 -drive if=none,id=hd0,file="
+ elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = mips-arc ]; then
device="hdb "
else
device="hda "
@@ -363,7 +391,9 @@ if [ x$boot = xhd ]; then
bootdev="-boot c"
fi
if [ x$boot = xcd ]; then
- if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = powerpc-ieee1275 ] && [ x$pseries != xy ] ; then
+ if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm-efi ]; then
+ device="device virtio-blk-device,drive=cd0 -drive if=none,id=cd0,media=cdrom,file="
+ elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = powerpc-ieee1275 ] && [ x$pseries != xy ] ; then
device="-drive if=ide,media=cdrom,file="
else
device="cdrom "
@@ -398,7 +428,7 @@ fi
if [ x$boot = xcoreboot ]; then
imgfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
cp "${GRUB_COREBOOT_ROM}" "${imgfile}"
- "${GRUB_CBFSTOOL}" "${imgfile}" add-payload "${rom_directory}/coreboot.elf" fallback/payload
+ "${GRUB_CBFSTOOL}" "${imgfile}" add-payload -f "${rom_directory}/coreboot.elf" -n fallback/payload
bootdev="-bios ${imgfile}"
device="cdrom "
test -z "$debug" || echo "Coreboot image: ${imgfile}" >&2
@@ -422,14 +452,32 @@ do_trim ()
fi
}
+copy_extra_files() {
+ _destdir="$1"
+ shift
+
+ # FIXME support '=' in file names
+ for _file in "$@"; do
+ _target="${_file%=*}"
+ _source="${_file#*=}"
+ [ -n "$_source" ] || _source="$_target"
+ _target="$_destdir/$_target"
+ _targetdir="$(dirname "$_target")"
+ [ -d "$_targetdir" ] || mkdir -p "$_targetdir"
+ cp "$_source" "$_target"
+ done
+}
+
if [ x$boot = xnet ]; then
netdir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
pkgdatadir="@builddir@" "@builddir@/grub-mknetdir" "--grub-mkimage=${builddir}/grub-mkimage" "--directory=${builddir}/grub-core" "--net-directory=$netdir" ${mkrescue_args} > /dev/null
cp "${cfgfile}" "$netdir/boot/grub/grub.cfg"
cp "${source}" "$netdir/boot/grub/testcase.cfg"
+ [ -z "$files" ] || copy_extra_files "$netdir" $files
timeout -s KILL $timeout "${qemu}" ${qemuopts} ${serial_null} -serial file:/dev/stdout -boot n -net "user,tftp=$netdir,bootfile=/boot/grub/${grub_modinfo_target_cpu}-${grub_modinfo_platform}/core.$netbootext" -net nic | cat | tr -d "\r" | do_trim
elif [ x$boot = xemu ]; then
- grubdir="$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")"
+ rootdir="$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")"
+ grubdir="$rootdir/boot/grub"
mkdir -p "$grubdir/fonts"
mkdir -p "$grubdir/themes"
mkdir -p "$grubdir/locale"
@@ -442,8 +490,12 @@ elif [ x$boot = xemu ]; then
done
cp "${cfgfile}" "$grubdir/grub.cfg"
cp "${source}" "$grubdir/testcase.cfg"
- @builddir@/grub-core/grub-emu -m "$device_map" -d "$grubdir" | tr -d "\r" | do_trim
- rm -rf "$grubdir"
+ [ -z "$files" ] || copy_extra_files "$rootdir" $files
+ roottar="$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")"
+ (cd "$rootdir"; tar cf "$roottar" .)
+ @builddir@/grub-core/grub-emu -m "$device_map" --memdisk "$roottar" -r memdisk -d "/boot/grub" | tr -d "\r" | do_trim
+ test -n "$debug" || rm -rf "$rootdir"
+ test -n "$debug" || rm -f "$roottar"
else
timeout -s KILL $timeout "${qemu}" ${qemuopts} ${serial_null} -serial file:/dev/stdout -${device}"${isofile}" ${bootdev} | cat | tr -d "\r" | do_trim
fi
diff --git a/tests/xfs_test.in b/tests/xfs_test.in
index 173b1cfe6..3807e2e5c 100644
--- a/tests/xfs_test.in
+++ b/tests/xfs_test.in
@@ -16,4 +16,5 @@ if ! which mkfs.xfs >/dev/null 2>&1; then
fi
+"@builddir@/grub-fs-tester" xfs_crc
"@builddir@/grub-fs-tester" xfs
diff --git a/util/editenv.c b/util/editenv.c
index f79e405d7..c6f8d2298 100644
--- a/util/editenv.c
+++ b/util/editenv.c
@@ -21,6 +21,7 @@
#include <grub/types.h>
#include <grub/emu/misc.h>
#include <grub/util/misc.h>
+#include <grub/util/install.h>
#include <grub/lib/envblk.h>
#include <grub/i18n.h>
#include <grub/emu/hostfile.h>
diff --git a/util/getroot.c b/util/getroot.c
index d71c9e858..92c0d709b 100644
--- a/util/getroot.c
+++ b/util/getroot.c
@@ -77,10 +77,15 @@
grub_disk_addr_t
grub_util_find_partition_start (const char *dev)
{
+#if GRUB_UTIL_FD_STAT_IS_FUNCTIONAL
+ struct stat st;
grub_disk_addr_t partition_start;
- if (grub_util_device_is_mapped (dev)
- && grub_util_get_dm_node_linear_info (dev, 0, 0, &partition_start))
+
+ if (stat (dev, &st) >= 0
+ && grub_util_device_is_mapped_stat (&st)
+ && grub_util_get_dm_node_linear_info (st.st_rdev, 0, 0, &partition_start))
return partition_start;
+#endif
return grub_util_find_partition_start_os (dev);
}
@@ -102,6 +107,7 @@ grub_util_pull_device (const char *os_dev)
default:
if (grub_util_pull_device_os (os_dev, ab))
return;
+ /* Fallthrough. */
case GRUB_DEV_ABSTRACTION_NONE:
free (grub_util_biosdisk_get_grub_dev (os_dev));
return;
@@ -363,9 +369,9 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
char *t;
t = dri;
if (*q >= 'a' && *q <= 'g')
- dri = xasprintf ("%s,%d,%d", t, n, *q - 'a' + 1);
+ dri = xasprintf ("%s,%ld,%d", t, n, *q - 'a' + 1);
else
- dri = xasprintf ("%s,%d", t, n);
+ dri = xasprintf ("%s,%ld", t, n);
free (t);
}
}
@@ -377,9 +383,6 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
grub_util_info ("%s starts from %" GRUB_HOST_PRIuLONG_LONG,
os_dev, (unsigned long long) ctx.start);
- if (ctx.start == 0 && !is_part)
- return name;
-
grub_util_info ("opening the device %s", name);
disk = grub_disk_open (name);
free (name);
@@ -400,7 +403,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
os_dev);
grub_errno = GRUB_ERR_NONE;
- canon = canonicalize_file_name (os_dev);
+ canon = grub_canonicalize_file_name (os_dev);
drive = grub_hostdisk_os_dev_to_grub_drive (canon ? : os_dev, 1);
if (canon)
free (canon);
@@ -412,7 +415,10 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
name = grub_util_get_ldm (disk, ctx.start);
if (name)
- return name;
+ {
+ grub_disk_close (disk);
+ return name;
+ }
ctx.partname = NULL;
diff --git a/util/glue-efi.c b/util/glue-efi.c
index c75f4759d..68f53168b 100644
--- a/util/glue-efi.c
+++ b/util/glue-efi.c
@@ -19,6 +19,7 @@
#include <config.h>
#include <grub/util/misc.h>
+#include <grub/util/install.h>
#include <grub/i18n.h>
#include <grub/term.h>
#include <grub/macho.h>
@@ -28,7 +29,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <argp.h>
#include <unistd.h>
#include <errno.h>
diff --git a/util/grub-editenv.c b/util/grub-editenv.c
index 540495b45..118e89fe5 100644
--- a/util/grub-editenv.c
+++ b/util/grub-editenv.c
@@ -30,7 +30,12 @@
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
+
#include "progname.h"
@@ -87,6 +92,8 @@ static error_t argp_parser (int key, char *arg, struct argp_state *state)
return 0;
}
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static char *
help_filter (int key, const char *text, void *input __attribute__ ((unused)))
{
@@ -100,6 +107,8 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
}
}
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
struct argp argp = {
options, argp_parser, N_("FILENAME COMMAND"),
"\n"N_("\
diff --git a/util/grub-file.c b/util/grub-file.c
index 7b7290133..50c18b683 100644
--- a/util/grub-file.c
+++ b/util/grub-file.c
@@ -34,7 +34,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <argp.h>
#include <unistd.h>
#include <errno.h>
@@ -78,7 +77,7 @@ main (int argc, char *argv[])
}
if (had_file)
grub_util_error ("one argument expected");
- argv2[i - 1] = canonicalize_file_name (argv[i]);
+ argv2[i - 1] = grub_canonicalize_file_name (argv[i]);
if (!argv2[i - 1])
{
grub_util_error (_("cannot open `%s': %s"), argv[i],
diff --git a/util/grub-fstest.c b/util/grub-fstest.c
index 4ff723c51..a358ae471 100644
--- a/util/grub-fstest.c
+++ b/util/grub-fstest.c
@@ -41,7 +41,11 @@
#include <string.h>
#include "progname.h"
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
#include "argp.h"
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
static grub_err_t
execute_command (const char *name, int n, char **args)
@@ -566,12 +570,12 @@ argp_parser (int key, char *arg, struct argp_state *state)
return 0;
}
real_size = fread (buf, 1, 1024, f);
+ fclose (f);
if (real_size < 0)
{
printf (_("%s: error:"), program_name);
printf (_("cannot read `%s': %s"), arg, strerror (errno));
printf ("\n");
- fclose (f);
return 0;
}
grub_zfs_add_key (buf, real_size, 0);
@@ -647,7 +651,7 @@ argp_parser (int key, char *arg, struct argp_state *state)
{
if (args_count == 0)
images = xmalloc (num_disks * sizeof (images[0]));
- images[args_count] = canonicalize_file_name (arg);
+ images[args_count] = grub_canonicalize_file_name (arg);
args_count++;
return 0;
}
diff --git a/util/grub-gen-asciih.c b/util/grub-gen-asciih.c
index e01447ae9..e35dcb78f 100644
--- a/util/grub-gen-asciih.c
+++ b/util/grub-gen-asciih.c
@@ -81,14 +81,14 @@ add_glyph (FT_UInt glyph_idx, FT_Face face,
err = FT_Load_Glyph (face, glyph_idx, flag);
if (err)
{
- printf ("Freetype Error %d loading glyph 0x%x for U+0x%x",
+ fprintf (stderr, "Freetype Error %d loading glyph 0x%x for U+0x%x",
err, glyph_idx, char_code);
if (err > 0 && err < (signed) ARRAY_SIZE (ft_errmsgs))
- printf (": %s\n", ft_errmsgs[err]);
+ fprintf (stderr, ": %s\n", ft_errmsgs[err]);
else
- printf ("\n");
- return;
+ fprintf (stderr, "\n");
+ exit (1);
}
glyph = face->glyph;
@@ -128,7 +128,6 @@ add_glyph (FT_UInt glyph_idx, FT_Face face,
static void
write_font_ascii_bitmap (FILE *file, FT_Face face)
{
- struct grub_glyph_info glyph;
int char_code;
fprintf (file, "/* THIS CHUNK OF BYTES IS AUTOMATICALLY GENERATED */\n");
@@ -138,10 +137,14 @@ write_font_ascii_bitmap (FILE *file, FT_Face face)
for (char_code = 0; char_code <= 0x7f; char_code++)
{
FT_UInt glyph_idx;
-
+ struct grub_glyph_info glyph;
+
glyph_idx = FT_Get_Char_Index (face, char_code);
if (!glyph_idx)
return;
+
+ memset (&glyph, 0, sizeof(glyph));
+
add_glyph (glyph_idx, face, char_code, &glyph);
if (glyph.width == 8 && glyph.height == 16
diff --git a/util/grub-glue-efi.c b/util/grub-glue-efi.c
index bd8240ca1..07fa43030 100644
--- a/util/grub-glue-efi.c
+++ b/util/grub-glue-efi.c
@@ -29,10 +29,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <argp.h>
#include <unistd.h>
#include <errno.h>
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
+#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
+
#include "progname.h"
struct arguments
@@ -87,7 +92,7 @@ argp_parser (int key, char *arg, struct argp_state *state)
static struct argp argp = {
options, argp_parser, N_("[OPTIONS]"),
- N_("Glue 32-bit and 64-binary into Apple fat one."),
+ N_("Glue 32-bit and 64-bit binary into Apple universal one."),
NULL, NULL, NULL
};
diff --git a/util/grub-install-common.c b/util/grub-install-common.c
index b34b8dcf2..452b230da 100644
--- a/util/grub-install-common.c
+++ b/util/grub-install-common.c
@@ -45,6 +45,8 @@
#include <stdlib.h>
#include <errno.h>
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
char *
grub_install_help_filter (int key, const char *text,
void *input __attribute__ ((unused)))
@@ -67,6 +69,8 @@ grub_install_help_filter (int key, const char *text,
}
}
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
static int (*compress_func) (const char *src, const char *dest) = NULL;
char *grub_install_copy_buffer;
@@ -120,7 +124,7 @@ grub_install_copy_file (const char *src,
return 1;
}
-int
+static int
grub_install_compress_file (const char *in_name,
const char *out_name,
int is_needed)
@@ -234,7 +238,7 @@ grub_install_push_module (const char *val)
if (modules.n_alloc < 16)
modules.n_alloc = 16;
modules.entries = xrealloc (modules.entries,
- modules.n_alloc * sizeof (modules.entries));
+ modules.n_alloc * sizeof (*modules.entries));
}
modules.entries[modules.n_entries++] = xstrdup (val);
modules.entries[modules.n_entries] = NULL;
@@ -486,10 +490,11 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix,
dir, prefix,
outname, mkimage_target,
compnames[compression], note ? "--note" : "", s);
+ free (s);
tgt = grub_install_get_image_target (mkimage_target);
if (!tgt)
- grub_util_error (_("unknown target format %s\n"), mkimage_target);
+ grub_util_error (_("unknown target format %s"), mkimage_target);
grub_install_generate_image (dir, prefix, fp, outname,
modules.entries, memdisk_path,
@@ -664,6 +669,36 @@ static struct
};
char *
+grub_install_get_platforms_string (void)
+{
+ char **arr = xmalloc (sizeof (char *) * ARRAY_SIZE (platforms));
+ int platform_strins_len = 0;
+ char *platforms_string;
+ char *ptr;
+ unsigned i;
+ for (i = 0; i < ARRAY_SIZE (platforms); i++)
+ {
+ arr[i] = xasprintf ("%s-%s", platforms[i].cpu,
+ platforms[i].platform);
+ platform_strins_len += strlen (arr[i]) + 2;
+ }
+ ptr = platforms_string = xmalloc (platform_strins_len);
+ qsort (arr, ARRAY_SIZE (platforms), sizeof (char *), grub_qsort_strcmp);
+ for (i = 0; i < ARRAY_SIZE (platforms); i++)
+ {
+ strcpy (ptr, arr[i]);
+ ptr += strlen (arr[i]);
+ *ptr++ = ',';
+ *ptr++ = ' ';
+ free (arr[i]);
+ }
+ ptr[-2] = 0;
+ free (arr);
+
+ return platforms_string;
+}
+
+char *
grub_install_get_platform_name (enum grub_install_plat platid)
{
return xasprintf ("%s-%s", platforms[platid].cpu,
@@ -730,6 +765,8 @@ grub_install_copy_files (const char *src,
grub_install_compress_file (srcf, dstf, 1);
free (dstf);
}
+
+ grub_util_free_path_list (path_list);
}
const char *pkglib_DATA[] = {"efiemu32.o", "efiemu64.o",
@@ -737,7 +774,7 @@ grub_install_copy_files (const char *src,
"fs.lst", "partmap.lst",
"parttool.lst",
"video.lst", "crypto.lst",
- "terminal.lst" };
+ "terminal.lst", "modinfo.sh" };
size_t i;
for (i = 0; i < ARRAY_SIZE (pkglib_DATA); i++)
@@ -867,8 +904,8 @@ grub_install_get_target (const char *src)
{
char *fn;
grub_util_fd_t f;
- char buf[2048];
- size_t r;
+ char buf[8192];
+ ssize_t r;
char *c, *pl, *p;
size_t i;
fn = grub_util_path_concat (2, src, "modinfo.sh");
@@ -877,6 +914,8 @@ grub_install_get_target (const char *src)
grub_util_error (_("%s doesn't exist. Please specify --target or --directory"),
fn);
r = grub_util_fd_read (f, buf, sizeof (buf) - 1);
+ if (r < 0)
+ grub_util_error (_("cannot read `%s': %s"), fn, strerror (errno));
grub_util_fd_close (f);
buf[r] = '\0';
c = strstr (buf, "grub_modinfo_target_cpu=");
diff --git a/util/grub-install.c b/util/grub-install.c
index c6cfc4968..6c89c2b0c 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -45,7 +45,11 @@
#include <string.h>
-#include "argp.h"
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
+#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
#include "progname.h"
@@ -90,7 +94,6 @@ enum
OPTION_RECHECK,
OPTION_FORCE,
OPTION_FORCE_FILE_ID,
- OPTION_MODULE,
OPTION_NO_NVRAM,
OPTION_REMOVABLE,
OPTION_BOOTLOADER_ID,
@@ -252,7 +255,7 @@ static struct argp_option options[] = {
OPTION_HIDDEN, 0, 2},
{"target", OPTION_TARGET, N_("TARGET"),
/* TRANSLATORS: "TARGET" as in "target platform". */
- 0, N_("install GRUB for TARGET platform [default=%s]"), 2},
+ 0, N_("install GRUB for TARGET platform [default=%s]; available targets: %s"), 2},
{"grub-setup", OPTION_SETUP, "FILE", OPTION_HIDDEN, 0, 2},
{"grub-mkrelpath", OPTION_MKRELPATH, "FILE", OPTION_HIDDEN, 0, 2},
{"grub-mkdevicemap", OPTION_MKDEVICEMAP, "FILE", OPTION_HIDDEN, 0, 2},
@@ -269,7 +272,7 @@ static struct argp_option options[] = {
N_("install even if problems are detected"), 2},
{"force-file-id", OPTION_FORCE_FILE_ID, 0, 0,
N_("use identifier file even if UUID is available"), 2},
- {"disk-module", OPTION_MODULE, N_("MODULE"), 0,
+ {"disk-module", OPTION_DISK_MODULE, N_("MODULE"), 0,
N_("disk module to use (biosdisk or native). "
"This option is only available on BIOS target."), 2},
{"no-nvram", OPTION_NO_NVRAM, 0, 0,
@@ -326,6 +329,8 @@ get_default_platform (void)
#endif
}
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static char *
help_filter (int key, const char *text, void *input __attribute__ ((unused)))
{
@@ -334,7 +339,13 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
case OPTION_BOOT_DIRECTORY:
return xasprintf (text, GRUB_DIR_NAME, GRUB_BOOT_DIR_NAME "/" GRUB_DIR_NAME);
case OPTION_TARGET:
- return xasprintf (text, get_default_platform ());
+ {
+ char *plats = grub_install_get_platforms_string ();
+ char *ret;
+ ret = xasprintf (text, get_default_platform (), plats);
+ free (plats);
+ return ret;
+ }
case ARGP_KEY_HELP_POST_DOC:
return xasprintf (text, program_name, GRUB_BOOT_DIR_NAME "/" GRUB_DIR_NAME);
default:
@@ -342,6 +353,8 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
}
}
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
/* TRANSLATORS: INSTALL_DEVICE isn't an identifier and is the DEVICE you
install to. */
struct argp argp = {
@@ -373,7 +386,7 @@ probe_raid_level (grub_disk_t disk)
}
static void
-push_partmap_module (const char *map)
+push_partmap_module (const char *map, void *data __attribute__ ((unused)))
{
char buf[50];
@@ -388,6 +401,12 @@ push_partmap_module (const char *map)
}
static void
+push_cryptodisk_module (const char *mod, void *data __attribute__ ((unused)))
+{
+ grub_install_push_module (mod);
+}
+
+static void
probe_mods (grub_disk_t disk)
{
grub_partition_t part;
@@ -398,11 +417,11 @@ probe_mods (grub_disk_t disk)
grub_util_info ("no partition map found for %s", disk->name);
for (part = disk->partition; part; part = part->parent)
- push_partmap_module (part->partmap->name);
+ push_partmap_module (part->partmap->name, NULL);
if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID)
{
- grub_diskfilter_get_partmap (disk, push_partmap_module);
+ grub_diskfilter_get_partmap (disk, push_partmap_module, NULL);
have_abstractions = 1;
}
@@ -418,7 +437,7 @@ probe_mods (grub_disk_t disk)
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
{
grub_util_cryptodisk_get_abstraction (disk,
- grub_install_push_module);
+ push_cryptodisk_module, NULL);
have_abstractions = 1;
have_cryptodisk = 1;
}
@@ -536,7 +555,7 @@ is_same_disk (const char *a, const char *b)
}
}
-char *
+static char *
get_rndstr (void)
{
grub_uint8_t rnd[15];
@@ -596,8 +615,6 @@ device_map_check_duplicates (const char *dev_map)
char **d;
size_t i;
- d = xmalloc (alloced * sizeof (d[0]));
-
if (dev_map[0] == '\0')
return;
@@ -605,6 +622,8 @@ device_map_check_duplicates (const char *dev_map)
if (! fp)
return;
+ d = xmalloc (alloced * sizeof (d[0]));
+
while (fgets (buf, sizeof (buf), fp))
{
char *p = buf;
@@ -667,6 +686,7 @@ write_to_disk (grub_device_t dev, const char *fn)
core_img = grub_util_read_image (fn);
+ grub_util_info ("writing `%s' to `%s'", fn, dev->disk->name);
err = grub_disk_write (dev->disk, 0, 0,
core_size, core_img);
free (core_img);
@@ -753,7 +773,7 @@ bless (grub_device_t dev, const char *path, int x86)
err = grub_mac_bless_inode (dev, st.st_ino, S_ISDIR (st.st_mode), x86);
if (err)
grub_util_error ("%s", grub_errmsg);
- grub_util_info ("blessed\n");
+ grub_util_info ("blessed");
}
static void
@@ -862,6 +882,12 @@ main (int argc, char *argv[])
platform = grub_install_get_target (grub_install_source_directory);
+ {
+ char *platname = grub_install_get_platform_name (platform);
+ fprintf (stderr, _("Installing for %s platform.\n"), platname);
+ free (platname);
+ }
+
switch (platform)
{
case GRUB_INSTALL_PLATFORM_I386_PC:
@@ -941,7 +967,7 @@ main (int argc, char *argv[])
{
char * t = grub_util_path_concat (2, bootdir, GRUB_DIR_NAME);
grub_install_mkdir_p (t);
- grubdir = canonicalize_file_name (t);
+ grubdir = grub_canonicalize_file_name (t);
if (!grubdir)
grub_util_error (_("failed to get canonical path of `%s'"), t);
free (t);
@@ -1044,7 +1070,7 @@ main (int argc, char *argv[])
efidir_is_mac = 1;
if (!efidir_is_mac && grub_strcmp (fs->name, "fat") != 0)
- grub_util_error (_("%s doesn't look like an EFI partition.\n"), efidir);
+ grub_util_error (_("%s doesn't look like an EFI partition"), efidir);
/* The EFI specification requires that an EFI System Partition must
contain an "EFI" subdirectory, and that OS loaders are stored in
@@ -1077,7 +1103,7 @@ main (int argc, char *argv[])
efi_file = "BOOTARM.EFI";
break;
case GRUB_INSTALL_PLATFORM_ARM64_EFI:
- efi_file = "BOOTAARCH64.EFI";
+ efi_file = "BOOTAA64.EFI";
break;
default:
grub_util_error ("%s", _("You've found a bug"));
@@ -1104,7 +1130,7 @@ main (int argc, char *argv[])
efi_file = "grubarm.efi";
break;
case GRUB_INSTALL_PLATFORM_ARM64_EFI:
- efi_file = "grubarm64.efi";
+ efi_file = "grubaa64.efi";
break;
default:
efi_file = "grub.efi";
@@ -1176,7 +1202,7 @@ main (int argc, char *argv[])
if (grub_strcmp (fs->name, "hfs") != 0
&& grub_strcmp (fs->name, "hfsplus") != 0
&& !is_guess)
- grub_util_error (_("%s is neither hfs nor hfsplus"),
+ grub_util_error (_("filesystem on %s is neither HFS nor HFS+"),
macppcdir);
if (grub_strcmp (fs->name, "hfs") == 0
|| grub_strcmp (fs->name, "hfsplus") == 0)
@@ -1244,8 +1270,8 @@ main (int argc, char *argv[])
}
if (!config.is_cryptodisk_enabled && have_cryptodisk)
- grub_util_error (_("attempt to install to cryptodisk without cryptodisk enabled. "
- "Set `%s' in file `%s'."), "GRUB_ENABLE_CRYPTODISK=1",
+ grub_util_error (_("attempt to install to encrypted disk without cryptodisk enabled. "
+ "Set `%s' in file `%s'"), "GRUB_ENABLE_CRYPTODISK=y",
grub_util_get_config_filename ());
if (disk_module && grub_strcmp (disk_module, "ata") == 0)
@@ -1256,6 +1282,7 @@ main (int argc, char *argv[])
grub_install_push_module ("ahci");
grub_install_push_module ("ohci");
grub_install_push_module ("uhci");
+ grub_install_push_module ("ehci");
grub_install_push_module ("usbms");
}
else if (disk_module && disk_module[0])
@@ -1273,7 +1300,7 @@ main (int argc, char *argv[])
{
char *t = grub_util_path_concat (2, grubdir,
platname);
- platdir = canonicalize_file_name (t);
+ platdir = grub_canonicalize_file_name (t);
if (!platdir)
grub_util_error (_("failed to get canonical path of `%s'"),
t);
@@ -1672,7 +1699,7 @@ main (int argc, char *argv[])
/* Now perform the installation. */
if (install_bootsector)
grub_util_sparc_setup (platdir, "boot.img", "core.img",
- install_device, force,
+ install_drive, force,
fs_probe, allow_floppy,
0 /* unused */ );
break;
@@ -1701,7 +1728,7 @@ main (int argc, char *argv[])
grub_elf = grub_util_path_concat (2, core_services, "grub.elf");
grub_install_copy_file (imgfile, grub_elf, 1);
- f = grub_util_fopen (mach_kernel, "r+");
+ f = grub_util_fopen (mach_kernel, "a+");
if (!f)
grub_util_error (_("Can't create file: %s"), strerror (errno));
fclose (f);
@@ -1783,7 +1810,7 @@ main (int argc, char *argv[])
grub_install_copy_file (imgfile, dst, 1);
free (dst);
}
-
+ /* Fallthrough. */
case GRUB_INSTALL_PLATFORM_X86_64_EFI:
if (efidir_is_mac)
{
@@ -1839,7 +1866,7 @@ main (int argc, char *argv[])
/* Try to make this image bootable using the EFI Boot Manager, if available. */
if (!efi_distributor || efi_distributor[0] == '\0')
- grub_util_error ("%s", _("EFI distributor id isn't specified."));
+ grub_util_error ("%s", _("EFI bootloader id isn't specified."));
efifile_path = xasprintf ("\\EFI\\%s\\%s",
efi_distributor,
efi_file);
diff --git a/util/grub-kbdcomp.in b/util/grub-kbdcomp.in
index 715c483af..a15ec24e5 100644
--- a/util/grub-kbdcomp.in
+++ b/util/grub-kbdcomp.in
@@ -25,7 +25,7 @@ usage () {
gettext "Make GRUB keyboard layout file."; echo
echo
print_option_help "-h, --help" "$(gettext "print this message and exit")"
- print_option_help "-v, --version" "$(gettext "print the version information and exit")"
+ print_option_help "-V, --version" "$(gettext "print the version information and exit")"
print_option_help "-o, --output=$(gettext FILE)" "$(gettext "save output in FILE [required]")"
echo
gettext_printf "%s generates a keyboard layout for GRUB using ckbcomp\n" "$self"
@@ -54,7 +54,7 @@ do
-h | --help)
usage
exit 0 ;;
- -v | --version)
+ -V | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
-o | --output)
diff --git a/util/grub-macbless.c b/util/grub-macbless.c
index 9869d0bbd..e9b15a053 100644
--- a/util/grub-macbless.c
+++ b/util/grub-macbless.c
@@ -45,7 +45,11 @@
#include <sys/stat.h>
#define _GNU_SOURCE 1
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
#include "progname.h"
@@ -60,7 +64,7 @@ bless (const char *path, int x86)
grub_err_t err;
struct stat st;
- grub_path = canonicalize_file_name (path);
+ grub_path = grub_canonicalize_file_name (path);
if (stat (grub_path, &st) < 0)
grub_util_error (N_("cannot stat `%s': %s"),
@@ -88,6 +92,8 @@ bless (const char *path, int x86)
free (filebuf_via_grub);
free (filebuf_via_sys);
free (drive_name);
+ free (devices);
+ grub_device_close (dev);
}
static struct argp_option options[] = {
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index 0ca0db189..f8496d28b 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -33,6 +33,9 @@ datadir="@datadir@"
if [ "x$pkgdatadir" = x ]; then
pkgdatadir="${datadir}/@PACKAGE@"
fi
+# export it for scripts
+export pkgdatadir
+
grub_cfg=""
grub_mkconfig_dir="${sysconfdir}"/grub.d
@@ -55,7 +58,6 @@ usage () {
gettext "Generate a grub config file"; echo
echo
print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")"
- print_option_help "-r, --root-directory=$(gettext DIR)" "$(gettext "use DIR as root directory [default=/]")"
print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
echo
@@ -73,8 +75,6 @@ argument () {
echo $1
}
-GRUB_ROOT=
-
# Check the arguments.
while test $# -gt 0
do
@@ -85,7 +85,7 @@ do
-h | --help)
usage
exit 0 ;;
- -v | --version)
+ -V | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
-o | --output)
@@ -93,11 +93,6 @@ do
--output=*)
grub_cfg=`echo "$option" | sed 's/--output=//'`
;;
- -r | --root-directory)
- GRUB_ROOT=`argument $option "$@"`; shift;;
- --root-directory=*)
- GRUB_ROOT=`echo "$option" | sed 's/--output=//'`
- ;;
-*)
gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2
usage
@@ -132,24 +127,24 @@ set $grub_probe dummy
if test -f "$1"; then
:
else
- gettext_print "%s: Not found.\n" "$1" 1>&2
+ gettext_printf "%s: Not found.\n" "$1" 1>&2
exit 1
fi
# Device containing our userland. Typically used for root= parameter.
-GRUB_DEVICE="`${grub_probe} --target=device "$GRUB_ROOT"/`"
+GRUB_DEVICE="`${grub_probe} --target=device /`"
GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
# Device containing our /boot partition. Usually the same as GRUB_DEVICE.
-GRUB_DEVICE_BOOT="`${grub_probe} --target=device "$GRUB_ROOT"/boot`"
+GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
# Filesystem for the device containing our userland. Used for stuff like
# choosing Hurd filesystem module.
GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
-if [ x"$GRUB_FS" = x ] || [ x"$GRUB_FS" = xunknown ]; then
- GRUB_FS="$(stat -f --printf=%T "$GRUB_ROOT"/ || echo unknown)"
+if [ x"$GRUB_FS" = xunknown ]; then
+ GRUB_FS="$(stat -f --printf=%T / || echo unknown)"
fi
if test -f ${sysconfdir}/default/grub ; then
@@ -186,7 +181,6 @@ if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub
# These are defined in this script, export them here so that user can
# override them.
export GRUB_DEVICE \
- GRUB_ROOT \
GRUB_DEVICE_UUID \
GRUB_DEVICE_BOOT \
GRUB_DEVICE_BOOT_UUID \
@@ -256,43 +250,16 @@ EOF
for i in "${grub_mkconfig_dir}"/* ; do
case "$i" in
- "${grub_mkconfig_dir}"/00_header \
- | "${grub_mkconfig_dir}"/30_os-prober \
- | "${grub_mkconfig_dir}"/40_custom \
- | "${grub_mkconfig_dir}"/41_custom)
- echo
- echo "### BEGIN $i ###"
- "$i"
- echo "### END $i ###"
- ;;
# emacsen backup files. FIXME: support other editors
*~) ;;
# emacsen autosave files. FIXME: support other editors
*/\#*\#) ;;
*)
if grub_file_is_not_garbage "$i" && test -x "$i" ; then
- for platform in x86 i386-xen-pae x86_64-xen mips mipsel sparc64 powerpc ia64 arm; do
- GRUB_PLATFORM=$platform
- export GRUB_PLATFORM
- buf="$($i)"
- if [ x"$buf" != x ]; then
- echo
- echo "### BEGIN $i ($platform) ###"
- case x$platform in
- xx86)
- echo "if [ x\"\$grub_platform\" != xxen \\( x\"\$grub_cpu\" = xi386 -o x\"\$grub_cpu\" = xx86_64 -o x\"\$grub_platform\" = x \\) ]; then" ;;
- xi386-xen-pae)
- echo "if [ x\"\$grub_cpu-\$grub_platform\" = xi386-xen -o x\"\$grub_cpu-\$grub_platform\" = x ]; then" ;;
- xx86_64-xen)
- echo "if [ x\"\$grub_cpu-\$grub_platform\" = xx86_64-xen -o x\"\$grub_cpu-\$grub_platform\" = x ]; then" ;;
- *)
- echo "if [ x\"\$grub_cpu\" = x$platform -o x\"\$grub_platform\" = x ]; then" ;;
- esac
- echo "$buf"
- echo "fi"
- echo "### END $i ($platform) ###"
- fi
- done
+ echo
+ echo "### BEGIN $i ###"
+ "$i"
+ echo "### END $i ###"
fi
;;
esac
@@ -306,6 +273,7 @@ Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
%s file attached." "${grub_cfg}.new" >&2
echo >&2
+ exit 1
else
# none of the children aborted with error, install the new grub.cfg
mv -f ${grub_cfg}.new ${grub_cfg}
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
index 14fadbcbb..60b31cadd 100644
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -145,7 +145,7 @@ prepare_grub_to_access_device ()
done
if [ x$GRUB_ENABLE_CRYPTODISK = xy ]; then
- for uuid in "`"${grub_probe}" --device $@ --target=cryptodisk_uuid`"; do
+ for uuid in `"${grub_probe}" --device $@ --target=cryptodisk_uuid`; do
echo "cryptomount -u $uuid"
done
fi
@@ -246,8 +246,8 @@ version_test_gt ()
fi
case "$version_test_gt_a:$version_test_gt_b" in
*.old:*.old) ;;
- *.old:*) version_test_gt_a="`echo -n "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;;
- *:*.old) version_test_gt_b="`echo -n "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;;
+ *.old:*) version_test_gt_a="`echo "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;;
+ *:*.old) version_test_gt_b="`echo "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;;
esac
version_test_numeric "$version_test_gt_a" "$version_test_gt_cmp" "$version_test_gt_b"
return "$?"
diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c
index 3cb02ad5c..a0cab3a93 100644
--- a/util/grub-mkfont.c
+++ b/util/grub-mkfont.c
@@ -33,7 +33,11 @@
#ifndef GRUB_BUILD
#define _GNU_SOURCE 1
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
#endif
#include <assert.h>
@@ -516,8 +520,8 @@ process_cursive (struct gsub_feature *feature,
}
if (grub_be_to_cpu16 (lookup->flag) & ~GSUB_RTL_CHAR)
{
- printf (_("Unsupported substitution flag: 0x%x\n"),
- grub_be_to_cpu16 (lookup->flag));
+ grub_util_info ("unsupported substitution flag: 0x%x",
+ grub_be_to_cpu16 (lookup->flag));
}
switch (feattag)
{
@@ -577,7 +581,8 @@ process_cursive (struct gsub_feature *feature,
There are 2 coverage specifications: list and range.
This warning is thrown when another coverage specification
is detected. */
- printf (_("Unsupported coverage specification: %d\n"), covertype);
+ fprintf (stderr,
+ _("Unsupported coverage specification: %d\n"), covertype);
}
}
}
@@ -616,7 +621,8 @@ add_font (struct grub_font_info *font_info, FT_Face face, int nocut)
grub_uint32_t feattag
= grub_be_to_cpu32 (features->features[i].feature_tag);
if (feature->params)
- printf (_("WARNING: unsupported font feature parameters: %x\n"),
+ fprintf (stderr,
+ _("WARNING: unsupported font feature parameters: %x\n"),
grub_be_to_cpu16 (feature->params));
switch (feattag)
{
@@ -647,8 +653,8 @@ add_font (struct grub_font_info *font_info, FT_Face face, int nocut)
if (!grub_isgraph (str[j]))
str[j] = '?';
/* TRANSLATORS: It's gsub feature, not gsub font. */
- printf (_("Unknown gsub font feature 0x%x (%s)\n"),
- feattag, str);
+ grub_util_info ("Unknown gsub font feature 0x%x (%s)",
+ feattag, str);
}
}
}
@@ -698,7 +704,7 @@ write_be16_section (const char *name, grub_uint16_t data, int* offset,
{
grub_uint32_t leng;
- leng = grub_cpu_to_be32 (2);
+ leng = grub_cpu_to_be32_compile_time (2);
data = grub_cpu_to_be16 (data);
grub_util_write_image (name, 4, file, filename);
grub_util_write_image ((char *) &leng, 4, file, filename);
@@ -795,7 +801,7 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
offset = 0;
- leng = grub_cpu_to_be32 (4);
+ leng = grub_cpu_to_be32_compile_time (4);
grub_util_write_image (FONT_FORMAT_SECTION_NAMES_FILE,
sizeof(FONT_FORMAT_SECTION_NAMES_FILE) - 1, file,
output_file);
diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c
index 02437417d..10375f4d2 100644
--- a/util/grub-mkimage.c
+++ b/util/grub-mkimage.c
@@ -48,7 +48,13 @@
#include <grub/emu/config.h>
#define _GNU_SOURCE 1
+
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
+
#include "progname.h"
@@ -58,13 +64,13 @@ static struct argp_option options[] = {
{"directory", 'd', N_("DIR"), 0,
/* TRANSLATORS: platform here isn't identifier. It can be translated. */
N_("use images and modules under DIR [default=%s/<platform>]"), 0},
- {"prefix", 'p', N_("DIR"), 0, N_("set prefix directory [default=%s]"), 0},
+ {"prefix", 'p', N_("DIR"), 0, N_("set prefix directory"), 0},
{"memdisk", 'm', N_("FILE"), 0,
/* TRANSLATORS: "memdisk" here isn't an identifier, it can be translated.
"embed" is a verb (command description). "*/
N_("embed FILE as a memdisk image\n"
- "Implies `-p (memdisk)/boot/grub' but prefix can be overridden by "
- "later options"), 0},
+ "Implies `-p (memdisk)/boot/grub' and overrides any prefix supplied previously,"
+ " but the prefix itself can be overridden by later options"), 0},
/* TRANSLATORS: "embed" is a verb (command description). "*/
{"config", 'c', N_("FILE"), 0, N_("embed FILE as an early config"), 0},
/* TRANSLATORS: "embed" is a verb (command description). "*/
@@ -78,6 +84,8 @@ static struct argp_option options[] = {
{ 0, 0, 0, 0, 0, 0 }
};
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static char *
help_filter (int key, const char *text, void *input __attribute__ ((unused)))
{
@@ -85,8 +93,6 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
{
case 'd':
return xasprintf (text, grub_util_get_pkglibdir ());
- case 'p':
- return xasprintf (text, DEFAULT_DIRECTORY);
case 'O':
{
char *formats = grub_install_get_image_targets_string (), *ret;
@@ -100,6 +106,8 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
}
}
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
struct arguments
{
size_t nmodules;
@@ -258,6 +266,15 @@ main (int argc, char *argv[])
exit(1);
}
+ if (!arguments.prefix)
+ {
+ char *program = xstrdup(program_name);
+ printf ("%s\n", _("Prefix not specified (use the -p option)."));
+ argp_help (&argp, stderr, ARGP_HELP_STD_USAGE, program);
+ free (program);
+ exit(1);
+ }
+
if (arguments.output)
{
fp = grub_util_fopen (arguments.output, "wb");
@@ -277,8 +294,7 @@ main (int argc, char *argv[])
strcpy (ptr, dn);
}
- grub_install_generate_image (arguments.dir,
- arguments.prefix ? : DEFAULT_DIRECTORY, fp,
+ grub_install_generate_image (arguments.dir, arguments.prefix, fp,
arguments.output, arguments.modules,
arguments.memdisk, arguments.pubkeys,
arguments.npubkeys, arguments.config,
@@ -288,8 +304,7 @@ main (int argc, char *argv[])
grub_util_file_sync (fp);
fclose (fp);
- if (arguments.dir)
- free (arguments.dir);
+ free (arguments.dir);
if (arguments.output)
free (arguments.output);
diff --git a/util/grub-mkimage32.c b/util/grub-mkimage32.c
new file mode 100644
index 000000000..9b31397bc
--- /dev/null
+++ b/util/grub-mkimage32.c
@@ -0,0 +1,22 @@
+#define MKIMAGE_ELF32 1
+
+# define SUFFIX(x) x ## 32
+# define ELFCLASSXX ELFCLASS32
+# define Elf_Ehdr Elf32_Ehdr
+# define Elf_Phdr Elf32_Phdr
+# define Elf_Nhdr Elf32_Nhdr
+# define Elf_Addr Elf32_Addr
+# define Elf_Sym Elf32_Sym
+# define Elf_Off Elf32_Off
+# define Elf_Shdr Elf32_Shdr
+# define Elf_Rela Elf32_Rela
+# define Elf_Rel Elf32_Rel
+# define Elf_Word Elf32_Word
+# define Elf_Half Elf32_Half
+# define Elf_Section Elf32_Section
+# define ELF_R_SYM(val) ELF32_R_SYM(val)
+# define ELF_R_TYPE(val) ELF32_R_TYPE(val)
+# define ELF_ST_TYPE(val) ELF32_ST_TYPE(val)
+#define XEN_NOTE_SIZE 132
+
+#include "grub-mkimagexx.c"
diff --git a/util/grub-mkimage64.c b/util/grub-mkimage64.c
new file mode 100644
index 000000000..d83345924
--- /dev/null
+++ b/util/grub-mkimage64.c
@@ -0,0 +1,22 @@
+#define MKIMAGE_ELF64 1
+
+# define SUFFIX(x) x ## 64
+# define ELFCLASSXX ELFCLASS64
+# define Elf_Ehdr Elf64_Ehdr
+# define Elf_Phdr Elf64_Phdr
+# define Elf_Nhdr Elf64_Nhdr
+# define Elf_Addr Elf64_Addr
+# define Elf_Sym Elf64_Sym
+# define Elf_Off Elf64_Off
+# define Elf_Shdr Elf64_Shdr
+# define Elf_Rela Elf64_Rela
+# define Elf_Rel Elf64_Rel
+# define Elf_Word Elf64_Word
+# define Elf_Half Elf64_Half
+# define Elf_Section Elf64_Section
+# define ELF_R_SYM(val) ELF64_R_SYM(val)
+# define ELF_R_TYPE(val) ELF64_R_TYPE(val)
+# define ELF_ST_TYPE(val) ELF64_ST_TYPE(val)
+#define XEN_NOTE_SIZE 120
+
+#include "grub-mkimagexx.c"
diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
index 7eb10deb3..353a9407a 100644
--- a/util/grub-mkimagexx.c
+++ b/util/grub-mkimagexx.c
@@ -17,58 +17,178 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
-#undef ELF_R_SYM
-#undef ELF_R_TYPE
-
-#if defined(MKIMAGE_ELF32)
-# define SUFFIX(x) x ## 32
-# define ELFCLASSXX ELFCLASS32
-# define Elf_Ehdr Elf32_Ehdr
-# define Elf_Phdr Elf32_Phdr
-# define Elf_Nhdr Elf32_Nhdr
-# define Elf_Addr Elf32_Addr
-# define Elf_Sym Elf32_Sym
-# define Elf_Off Elf32_Off
-# define Elf_Shdr Elf32_Shdr
-# define Elf_Rela Elf32_Rela
-# define Elf_Rel Elf32_Rel
-# define Elf_Word Elf32_Word
-# define Elf_Half Elf32_Half
-# define Elf_Section Elf32_Section
-# define ELF_R_SYM(val) ELF32_R_SYM(val)
-# define ELF_R_TYPE(val) ELF32_R_TYPE(val)
-# define ELF_ST_TYPE(val) ELF32_ST_TYPE(val)
-#define XEN_NOTE_SIZE 132
-#elif defined(MKIMAGE_ELF64)
-# define SUFFIX(x) x ## 64
-# define ELFCLASSXX ELFCLASS64
-# define Elf_Ehdr Elf64_Ehdr
-# define Elf_Phdr Elf64_Phdr
-# define Elf_Nhdr Elf64_Nhdr
-# define Elf_Addr Elf64_Addr
-# define Elf_Sym Elf64_Sym
-# define Elf_Off Elf64_Off
-# define Elf_Shdr Elf64_Shdr
-# define Elf_Rela Elf64_Rela
-# define Elf_Rel Elf64_Rel
-# define Elf_Word Elf64_Word
-# define Elf_Half Elf64_Half
-# define Elf_Section Elf64_Section
-# define ELF_R_SYM(val) ELF64_R_SYM(val)
-# define ELF_R_TYPE(val) ELF64_R_TYPE(val)
-# define ELF_ST_TYPE(val) ELF64_ST_TYPE(val)
-#define XEN_NOTE_SIZE 120
-#else
-#error "I'm confused"
-#endif
+#include <config.h>
+#include <grub/types.h>
+#include <grub/elf.h>
+#include <grub/aout.h>
+#include <grub/i18n.h>
+#include <grub/kernel.h>
+#include <grub/disk.h>
+#include <grub/emu/misc.h>
+#include <grub/util/misc.h>
+#include <grub/util/resolve.h>
+#include <grub/misc.h>
+#include <grub/offsets.h>
+#include <grub/crypto.h>
+#include <grub/dl.h>
+#include <time.h>
+#include <multiboot.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <grub/efi/pe32.h>
+#include <grub/uboot/image.h>
+#include <grub/arm/reloc.h>
+#include <grub/arm64/reloc.h>
+#include <grub/ia64/reloc.h>
+#include <grub/osdep/hostfile.h>
+#include <grub/util/install.h>
+#include <grub/util/mkimage.h>
+
+#pragma GCC diagnostic ignored "-Wcast-align"
static Elf_Addr SUFFIX (entry_point);
-static void
-SUFFIX (generate_elf) (const struct grub_install_image_target_desc *image_target,
- int note, char **core_img, size_t *core_size,
- Elf_Addr target_addr, grub_size_t align,
- size_t kernel_size, size_t bss_size)
+/* These structures are defined according to the CHRP binding to IEEE1275,
+ "Client Program Format" section. */
+
+struct grub_ieee1275_note_desc
+{
+ grub_uint32_t real_mode;
+ grub_uint32_t real_base;
+ grub_uint32_t real_size;
+ grub_uint32_t virt_base;
+ grub_uint32_t virt_size;
+ grub_uint32_t load_base;
+};
+
+#define GRUB_IEEE1275_NOTE_NAME "PowerPC"
+#define GRUB_IEEE1275_NOTE_TYPE 0x1275
+
+struct grub_ieee1275_note
+{
+ Elf32_Nhdr header;
+ char name[ALIGN_UP(sizeof (GRUB_IEEE1275_NOTE_NAME), 4)];
+ struct grub_ieee1275_note_desc descriptor;
+};
+
+#define GRUB_XEN_NOTE_NAME "Xen"
+
+struct fixup_block_list
+{
+ struct fixup_block_list *next;
+ int state;
+ struct grub_pe32_fixup_block b;
+};
+
+#define ALIGN_ADDR(x) (ALIGN_UP((x), image_target->voidp_sizeof))
+
+static int
+is_relocatable (const struct grub_install_image_target_desc *image_target)
+{
+ return image_target->id == IMAGE_EFI || image_target->id == IMAGE_UBOOT;
+}
+
+#ifdef MKIMAGE_ELF32
+
+/*
+ * R_ARM_THM_CALL/THM_JUMP24
+ *
+ * Relocate Thumb (T32) instruction set relative branches:
+ * B.W, BL and BLX
+ */
+static grub_err_t
+grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
+{
+ grub_int32_t offset;
+
+ offset = grub_arm_thm_call_get_offset (target);
+
+ grub_dprintf ("dl", " sym_addr = 0x%08x", sym_addr);
+
+ offset += sym_addr;
+
+ grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n",
+ target, sym_addr, offset);
+
+ /* Keep traditional (pre-Thumb2) limits on blx. In any case if the kernel
+ is bigger than 2M (currently under 150K) then we probably have a problem
+ somewhere else. */
+ if (offset < -0x200000 || offset >= 0x200000)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "THM_CALL Relocation out of range.");
+
+ grub_dprintf ("dl", " relative destination = %p",
+ (char *) target + offset);
+
+ return grub_arm_thm_call_set_offset (target, offset);
+}
+
+/*
+ * R_ARM_THM_JUMP19
+ *
+ * Relocate conditional Thumb (T32) B<c>.W
+ */
+static grub_err_t
+grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
+{
+ grub_int32_t offset;
+
+ if (!(sym_addr & 1))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "Relocation targeting wrong execution state");
+
+ offset = grub_arm_thm_jump19_get_offset (target);
+
+ /* Adjust and re-truncate offset */
+ offset += sym_addr;
+
+ if (!grub_arm_thm_jump19_check_offset (offset))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "THM_JUMP19 Relocation out of range.");
+
+ grub_arm_thm_jump19_set_offset (target, offset);
+
+ return GRUB_ERR_NONE;
+}
+
+/*
+ * R_ARM_JUMP24
+ *
+ * Relocate ARM (A32) B
+ */
+static grub_err_t
+grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr)
+{
+ grub_int32_t offset;
+
+ if (sym_addr & 1)
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "Relocation targeting wrong execution state");
+
+ offset = grub_arm_jump24_get_offset (target);
+ offset += sym_addr;
+
+ if (!grub_arm_jump24_check_offset (offset))
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "JUMP24 Relocation out of range.");
+
+
+ grub_arm_jump24_set_offset (target, offset);
+
+ return GRUB_ERR_NONE;
+}
+
+#endif
+
+void
+SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc *image_target,
+ int note, char **core_img, size_t *core_size,
+ Elf_Addr target_addr, grub_size_t align,
+ size_t kernel_size, size_t bss_size)
{
char *elf_img;
size_t program_size;
@@ -101,7 +221,7 @@ SUFFIX (generate_elf) (const struct grub_install_image_target_desc *image_target
program_size = ALIGN_ADDR (*core_size);
elf_img = xmalloc (program_size + header_size + footer_size);
- memset (elf_img, 0, program_size + header_size);
+ memset (elf_img, 0, program_size + header_size + footer_size);
memcpy (elf_img + header_size, *core_img, *core_size);
ehdr = (void *) elf_img;
phdr = (void *) (elf_img + sizeof (*ehdr));
@@ -376,11 +496,12 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections,
Elf_Shdr *symtab_section, Elf_Addr *section_addresses,
Elf_Half section_entsize, Elf_Half num_sections,
void *jumpers, Elf_Addr jumpers_addr,
+ Elf_Addr bss_start, Elf_Addr end,
const struct grub_install_image_target_desc *image_target)
{
Elf_Word symtab_size, sym_size, num_syms;
Elf_Off symtab_offset;
- Elf_Addr start_address = 0;
+ Elf_Addr start_address = (Elf_Addr) -1;
Elf_Sym *sym;
Elf_Word i;
Elf_Shdr *strtab_section;
@@ -414,16 +535,22 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections,
}
else if (cur_index == STN_UNDEF)
{
- if (sym->st_name)
+ if (sym->st_name && grub_strcmp (name, "__bss_start") == 0)
+ sym->st_value = bss_start;
+ else if (sym->st_name && grub_strcmp (name, "_end") == 0)
+ sym->st_value = end;
+ else if (sym->st_name)
grub_util_error ("undefined symbol %s", name);
else
continue;
}
else if (cur_index >= num_sections)
grub_util_error ("section %d does not exist", cur_index);
-
- sym->st_value = (grub_target_to_host (sym->st_value)
- + section_addresses[cur_index]);
+ else
+ {
+ sym->st_value = (grub_target_to_host (sym->st_value)
+ + section_addresses[cur_index]);
+ }
if (image_target->elf_target == EM_IA_64 && ELF_ST_TYPE (sym->st_info)
== STT_FUNC)
@@ -439,7 +566,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections,
(unsigned long long) sym->st_value,
(unsigned long long) section_addresses[cur_index]);
- if (! start_address)
+ if (start_address == (Elf_Addr)-1)
if (strcmp (name, "_start") == 0 || strcmp (name, "start") == 0)
start_address = sym->st_value;
}
@@ -836,6 +963,14 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
*target = grub_host_to_target64 (grub_target_to_host64 (*target) + sym_addr);
}
break;
+ case R_AARCH64_ADD_ABS_LO12_NC:
+ grub_arm64_set_abs_lo12 ((grub_uint32_t *) target,
+ sym_addr);
+ break;
+ case R_AARCH64_LDST64_ABS_LO12_NC:
+ grub_arm64_set_abs_lo12_ldst64 ((grub_uint32_t *) target,
+ sym_addr);
+ break;
case R_AARCH64_JUMP26:
case R_AARCH64_CALL26:
{
@@ -848,6 +983,17 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
sym_addr);
}
break;
+ case R_AARCH64_ADR_PREL_PG_HI21:
+ {
+ sym_addr &= ~0xfffULL;
+ sym_addr -= (offset + SUFFIX (entry_point)) & ~0xfffULL;
+ if (!grub_arm64_check_hi21_signed (sym_addr))
+ grub_util_error ("%s", "CALL26 Relocation out of range");
+
+ grub_arm64_set_hi21((grub_uint32_t *)target,
+ sym_addr);
+ }
+ break;
default:
grub_util_error (_("relocation 0x%x is not implemented yet"),
(unsigned int) ELF_R_TYPE (info));
@@ -868,7 +1014,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
grub_util_info (" ABS32:\toffset=%d\t(0x%08x)",
(int) sym_addr, (int) sym_addr);
/* Data will be naturally aligned */
- sym_addr += 0x400;
+ if (image_target->id == IMAGE_EFI)
+ sym_addr += 0x400;
*target = grub_host_to_target32 (grub_target_to_host32 (*target) + sym_addr);
}
break;
@@ -962,9 +1109,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
/* Add a PE32's fixup entry for a relocation. Return the resulting address
after having written to the file OUT. */
static Elf_Addr
-SUFFIX (add_fixup_entry) (struct fixup_block_list **cblock, grub_uint16_t type,
- Elf_Addr addr, int flush, Elf_Addr current_address,
- const struct grub_install_image_target_desc *image_target)
+add_fixup_entry (struct fixup_block_list **cblock, grub_uint16_t type,
+ Elf_Addr addr, int flush, Elf_Addr current_address,
+ const struct grub_install_image_target_desc *image_target)
{
struct grub_pe32_fixup_block *b;
@@ -1054,22 +1201,376 @@ SUFFIX (add_fixup_entry) (struct fixup_block_list **cblock, grub_uint16_t type,
return current_address;
}
-/* Make a .reloc section. */
-static Elf_Addr
-SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
- Elf_Addr *section_addresses, Elf_Shdr *sections,
- Elf_Half section_entsize, Elf_Half num_sections,
- const char *strtab,
- Elf_Addr jumpers, grub_size_t njumpers,
+struct raw_reloc
+{
+ struct raw_reloc *next;
+ grub_uint32_t offset;
+ enum raw_reloc_type {
+ RAW_RELOC_NONE = -1,
+ RAW_RELOC_32 = 0,
+ RAW_RELOC_MAX = 1,
+ } type;
+};
+
+struct translate_context
+{
+ /* PE */
+ struct fixup_block_list *lst, *lst0;
+ Elf_Addr current_address;
+
+ /* Raw */
+ struct raw_reloc *raw_relocs;
+};
+
+static void
+translate_reloc_start (struct translate_context *ctx,
+ const struct grub_install_image_target_desc *image_target)
+{
+ grub_memset (ctx, 0, sizeof (*ctx));
+ if (image_target->id == IMAGE_EFI)
+ {
+ ctx->lst = ctx->lst0 = xmalloc (sizeof (*ctx->lst) + 2 * 0x1000);
+ memset (ctx->lst, 0, sizeof (*ctx->lst) + 2 * 0x1000);
+ ctx->current_address = 0;
+ }
+}
+
+static void
+translate_relocation_pe (struct translate_context *ctx,
+ Elf_Addr addr,
+ Elf_Addr info,
+ const struct grub_install_image_target_desc *image_target)
+{
+ /* Necessary to relocate only absolute addresses. */
+ switch (image_target->elf_target)
+ {
+ case EM_386:
+ if (ELF_R_TYPE (info) == R_386_32)
+ {
+ grub_util_info ("adding a relocation entry for 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ (unsigned long long) addr);
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_HIGHLOW,
+ addr, 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ case EM_X86_64:
+ if ((ELF_R_TYPE (info) == R_X86_64_32) ||
+ (ELF_R_TYPE (info) == R_X86_64_32S))
+ {
+ grub_util_error ("can\'t add fixup entry for R_X86_64_32(S)");
+ }
+ else if (ELF_R_TYPE (info) == R_X86_64_64)
+ {
+ grub_util_info ("adding a relocation entry for 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ (unsigned long long) addr);
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_DIR64,
+ addr,
+ 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ case EM_IA_64:
+ switch (ELF_R_TYPE (info))
+ {
+ case R_IA64_PCREL64LSB:
+ case R_IA64_LDXMOV:
+ case R_IA64_PCREL21B:
+ case R_IA64_LTOFF_FPTR22:
+ case R_IA64_LTOFF22X:
+ case R_IA64_LTOFF22:
+ case R_IA64_GPREL22:
+ case R_IA64_SEGREL64LSB:
+ break;
+
+ case R_IA64_FPTR64LSB:
+ case R_IA64_DIR64LSB:
+#if 1
+ {
+ grub_util_info ("adding a relocation entry for 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ (unsigned long long) addr);
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_DIR64,
+ addr,
+ 0, ctx->current_address,
+ image_target);
+ }
+#endif
+ break;
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+ case EM_AARCH64:
+ switch (ELF_R_TYPE (info))
+ {
+ case R_AARCH64_ABS64:
+ {
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_DIR64,
+ addr, 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ /* Relative relocations do not require fixup entries. */
+ case R_AARCH64_CALL26:
+ case R_AARCH64_JUMP26:
+ break;
+ /* Page-relative relocations do not require fixup entries. */
+ case R_AARCH64_ADR_PREL_PG_HI21:
+ /* We page-align the whole kernel, so no need
+ for fixup entries.
+ */
+ case R_AARCH64_ADD_ABS_LO12_NC:
+ case R_AARCH64_LDST64_ABS_LO12_NC:
+ break;
+
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+ break;
+#if defined(MKIMAGE_ELF32)
+ case EM_ARM:
+ switch (ELF_R_TYPE (info))
+ {
+ case R_ARM_V4BX:
+ /* Relative relocations do not require fixup entries. */
+ case R_ARM_JUMP24:
+ case R_ARM_THM_CALL:
+ case R_ARM_THM_JUMP19:
+ case R_ARM_THM_JUMP24:
+ case R_ARM_CALL:
+ {
+ grub_util_info (" %s: not adding fixup: 0x%08x : 0x%08x", __FUNCTION__, (unsigned int) addr, (unsigned int) ctx->current_address);
+ }
+ break;
+ /* Create fixup entry for PE/COFF loader */
+ case R_ARM_ABS32:
+ {
+ ctx->current_address
+ = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_HIGHLOW,
+ addr, 0, ctx->current_address,
+ image_target);
+ }
+ break;
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+#endif /* defined(MKIMAGE_ELF32) */
+ default:
+ grub_util_error ("unknown machine type 0x%x", image_target->elf_target);
+ }
+}
+
+static enum raw_reloc_type
+classify_raw_reloc (Elf_Addr info,
+ const struct grub_install_image_target_desc *image_target)
+{
+ /* Necessary to relocate only absolute addresses. */
+ switch (image_target->elf_target)
+ {
+ case EM_ARM:
+ switch (ELF_R_TYPE (info))
+ {
+ case R_ARM_V4BX:
+ case R_ARM_JUMP24:
+ case R_ARM_THM_CALL:
+ case R_ARM_THM_JUMP19:
+ case R_ARM_THM_JUMP24:
+ case R_ARM_CALL:
+ return RAW_RELOC_NONE;
+ case R_ARM_ABS32:
+ return RAW_RELOC_32;
+ default:
+ grub_util_error (_("relocation 0x%x is not implemented yet"),
+ (unsigned int) ELF_R_TYPE (info));
+ break;
+ }
+ break;
+ default:
+ grub_util_error ("unknown machine type 0x%x", image_target->elf_target);
+ }
+}
+
+static void
+translate_relocation_raw (struct translate_context *ctx,
+ Elf_Addr addr,
+ Elf_Addr info,
+ const struct grub_install_image_target_desc *image_target)
+{
+ enum raw_reloc_type class = classify_raw_reloc (info, image_target);
+ struct raw_reloc *rel;
+ if (class == RAW_RELOC_NONE)
+ return;
+ rel = xmalloc (sizeof (*rel));
+ rel->next = ctx->raw_relocs;
+ rel->type = class;
+ rel->offset = addr;
+ ctx->raw_relocs = rel;
+}
+
+static void
+translate_relocation (struct translate_context *ctx,
+ Elf_Addr addr,
+ Elf_Addr info,
+ const struct grub_install_image_target_desc *image_target)
+{
+ if (image_target->id == IMAGE_EFI)
+ translate_relocation_pe (ctx, addr, info, image_target);
+ else
+ translate_relocation_raw (ctx, addr, info, image_target);
+}
+
+static void
+finish_reloc_translation_pe (struct translate_context *ctx, struct grub_mkimage_layout *layout,
const struct grub_install_image_target_desc *image_target)
{
+ ctx->current_address = add_fixup_entry (&ctx->lst, 0, 0, 1, ctx->current_address, image_target);
+
+ {
+ grub_uint8_t *ptr;
+ layout->reloc_section = ptr = xmalloc (ctx->current_address);
+ for (ctx->lst = ctx->lst0; ctx->lst; ctx->lst = ctx->lst->next)
+ if (ctx->lst->state)
+ {
+ memcpy (ptr, &ctx->lst->b, grub_target_to_host32 (ctx->lst->b.block_size));
+ ptr += grub_target_to_host32 (ctx->lst->b.block_size);
+ }
+ assert ((ctx->current_address + (grub_uint8_t *) layout->reloc_section) == ptr);
+ }
+
+ for (ctx->lst = ctx->lst0; ctx->lst; )
+ {
+ struct fixup_block_list *next;
+ next = ctx->lst->next;
+ free (ctx->lst);
+ ctx->lst = next;
+ }
+
+ layout->reloc_size = ctx->current_address;
+ if (image_target->elf_target == EM_ARM && layout->reloc_size > GRUB_KERNEL_ARM_STACK_SIZE)
+ grub_util_error ("Reloc section (%d) is bigger than stack size (%d). "
+ "This breaks assembly assumptions. Please increase stack size",
+ (int) layout->reloc_size,
+ (int) GRUB_KERNEL_ARM_STACK_SIZE);
+}
+
+/*
+ Layout:
+ <type 0 relocations>
+ <fffffffe>
+ <type 1 relocations>
+ <fffffffe>
+ ...
+ <type n relocations>
+ <ffffffff>
+ each relocation starts with 32-bit offset. Rest depends on relocation.
+ mkimage stops when it sees first unknown type or end marker.
+ This allows images to be created with mismatched mkimage and
+ kernel as long as no relocations are present in kernel that mkimage
+ isn't aware of (in which case mkimage aborts).
+ This also allows simple assembly to do the relocs.
+*/
+
+#define RAW_SEPARATOR 0xfffffffe
+#define RAW_END_MARKER 0xffffffff
+
+static void
+finish_reloc_translation_raw (struct translate_context *ctx, struct grub_mkimage_layout *layout,
+ const struct grub_install_image_target_desc *image_target)
+{
+ size_t count = 0, sz;
+ enum raw_reloc_type highest = RAW_RELOC_NONE;
+ enum raw_reloc_type curtype;
+ struct raw_reloc *cur;
+ grub_uint32_t *p;
+ if (!ctx->raw_relocs)
+ {
+ layout->reloc_section = p = xmalloc (sizeof (grub_uint32_t));
+ p[0] = RAW_END_MARKER;
+ layout->reloc_size = sizeof (grub_uint32_t);
+ return;
+ }
+ for (cur = ctx->raw_relocs; cur; cur = cur->next)
+ {
+ count++;
+ if (cur->type > highest)
+ highest = cur->type;
+ }
+ /* highest separators, count relocations and one end marker. */
+ sz = (highest + count + 1) * sizeof (grub_uint32_t);
+ layout->reloc_section = p = xmalloc (sz);
+ for (curtype = 0; curtype <= highest; curtype++)
+ {
+ /* Support for special cases would go here. */
+ for (cur = ctx->raw_relocs; cur; cur = cur->next)
+ if (cur->type == curtype)
+ {
+ *p++ = cur->offset;
+ }
+ *p++ = RAW_SEPARATOR;
+ }
+ *--p = RAW_END_MARKER;
+ layout->reloc_size = sz;
+}
+
+static void
+finish_reloc_translation (struct translate_context *ctx, struct grub_mkimage_layout *layout,
+ const struct grub_install_image_target_desc *image_target)
+{
+ if (image_target->id == IMAGE_EFI)
+ finish_reloc_translation_pe (ctx, layout, image_target);
+ else
+ finish_reloc_translation_raw (ctx, layout, image_target);
+}
+
+
+static void
+translate_reloc_jumpers (struct translate_context *ctx,
+ Elf_Addr jumpers, grub_size_t njumpers,
+ const struct grub_install_image_target_desc *image_target)
+{
+ unsigned i;
+ assert (image_target->id == IMAGE_EFI);
+ for (i = 0; i < njumpers; i++)
+ ctx->current_address = add_fixup_entry (&ctx->lst,
+ GRUB_PE32_REL_BASED_DIR64,
+ jumpers + 8 * i,
+ 0, ctx->current_address,
+ image_target);
+}
+
+/* Make a .reloc section. */
+static void
+make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout,
+ Elf_Addr *section_addresses, Elf_Shdr *sections,
+ Elf_Half section_entsize, Elf_Half num_sections,
+ const char *strtab,
+ const struct grub_install_image_target_desc *image_target)
+{
unsigned i;
Elf_Shdr *s;
- struct fixup_block_list *lst, *lst0;
- Elf_Addr current_address = 0;
+ struct translate_context ctx;
- lst = lst0 = xmalloc (sizeof (*lst) + 2 * 0x1000);
- memset (lst, 0, sizeof (*lst) + 2 * 0x1000);
+ translate_reloc_start (&ctx, image_target);
for (i = 0, s = sections; i < num_sections;
i++, s = (Elf_Shdr *) ((char *) s + section_entsize))
@@ -1098,190 +1599,25 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
{
Elf_Addr info;
Elf_Addr offset;
+ Elf_Addr addr;
offset = grub_target_to_host (r->r_offset);
info = grub_target_to_host (r->r_info);
- /* Necessary to relocate only absolute addresses. */
- switch (image_target->elf_target)
- {
- case EM_386:
- if (ELF_R_TYPE (info) == R_386_32)
- {
- Elf_Addr addr;
-
- addr = section_address + offset;
- grub_util_info ("adding a relocation entry for 0x%"
- GRUB_HOST_PRIxLONG_LONG,
- (unsigned long long) addr);
- current_address
- = SUFFIX (add_fixup_entry) (&lst,
- GRUB_PE32_REL_BASED_HIGHLOW,
- addr, 0, current_address,
- image_target);
- }
- break;
- case EM_X86_64:
- if ((ELF_R_TYPE (info) == R_X86_64_32) ||
- (ELF_R_TYPE (info) == R_X86_64_32S))
- {
- grub_util_error ("can\'t add fixup entry for R_X86_64_32(S)");
- }
- else if (ELF_R_TYPE (info) == R_X86_64_64)
- {
- Elf_Addr addr;
-
- addr = section_address + offset;
- grub_util_info ("adding a relocation entry for 0x%"
- GRUB_HOST_PRIxLONG_LONG,
- (unsigned long long) addr);
- current_address
- = SUFFIX (add_fixup_entry) (&lst,
- GRUB_PE32_REL_BASED_DIR64,
- addr,
- 0, current_address,
- image_target);
- }
- break;
- case EM_IA_64:
- switch (ELF_R_TYPE (info))
- {
- case R_IA64_PCREL64LSB:
- case R_IA64_LDXMOV:
- case R_IA64_PCREL21B:
- case R_IA64_LTOFF_FPTR22:
- case R_IA64_LTOFF22X:
- case R_IA64_LTOFF22:
- case R_IA64_GPREL22:
- case R_IA64_SEGREL64LSB:
- break;
-
- case R_IA64_FPTR64LSB:
- case R_IA64_DIR64LSB:
-#if 1
- {
- Elf_Addr addr;
+ addr = section_address + offset;
- addr = section_address + offset;
- grub_util_info ("adding a relocation entry for 0x%"
- GRUB_HOST_PRIxLONG_LONG,
- (unsigned long long) addr);
- current_address
- = SUFFIX (add_fixup_entry) (&lst,
- GRUB_PE32_REL_BASED_DIR64,
- addr,
- 0, current_address,
- image_target);
- }
-#endif
- break;
- default:
- grub_util_error (_("relocation 0x%x is not implemented yet"),
- (unsigned int) ELF_R_TYPE (info));
- break;
- }
- break;
- case EM_AARCH64:
- switch (ELF_R_TYPE (info))
- {
- case R_AARCH64_ABS64:
- {
- Elf_Addr addr;
-
- addr = section_address + offset;
- current_address
- = SUFFIX (add_fixup_entry) (&lst,
- GRUB_PE32_REL_BASED_DIR64,
- addr, 0, current_address,
- image_target);
- }
- break;
- /* Relative relocations do not require fixup entries. */
- case R_AARCH64_CALL26:
- case R_AARCH64_JUMP26:
- break;
- default:
- grub_util_error (_("relocation 0x%x is not implemented yet"),
- (unsigned int) ELF_R_TYPE (info));
- break;
- }
- break;
- break;
-#if defined(MKIMAGE_ELF32)
- case EM_ARM:
- switch (ELF_R_TYPE (info))
- {
- case R_ARM_V4BX:
- /* Relative relocations do not require fixup entries. */
- case R_ARM_JUMP24:
- case R_ARM_THM_CALL:
- case R_ARM_THM_JUMP19:
- case R_ARM_THM_JUMP24:
- case R_ARM_CALL:
- {
- Elf_Addr addr;
-
- addr = section_address + offset;
- grub_util_info (" %s: not adding fixup: 0x%08x : 0x%08x", __FUNCTION__, (unsigned int) addr, (unsigned int) current_address);
- }
- break;
- /* Create fixup entry for PE/COFF loader */
- case R_ARM_ABS32:
- {
- Elf_Addr addr;
-
- addr = section_address + offset;
- current_address
- = SUFFIX (add_fixup_entry) (&lst,
- GRUB_PE32_REL_BASED_HIGHLOW,
- addr, 0, current_address,
- image_target);
- }
- break;
- default:
- grub_util_error (_("relocation 0x%x is not implemented yet"),
- (unsigned int) ELF_R_TYPE (info));
- break;
- }
- break;
-#endif /* defined(MKIMAGE_ELF32) */
- default:
- grub_util_error ("unknown machine type 0x%x", image_target->elf_target);
- }
+ translate_relocation (&ctx, addr, info, image_target);
}
}
if (image_target->elf_target == EM_IA_64)
- for (i = 0; i < njumpers; i++)
- current_address = SUFFIX (add_fixup_entry) (&lst,
- GRUB_PE32_REL_BASED_DIR64,
- jumpers + 8 * i,
- 0, current_address,
- image_target);
+ translate_reloc_jumpers (&ctx,
+ layout->ia64jmp_off
+ + image_target->vaddr_offset,
+ 2 * layout->ia64jmpnum + (layout->got_size / 8),
+ image_target);
- current_address = SUFFIX (add_fixup_entry) (&lst, 0, 0, 1, current_address, image_target);
-
- {
- grub_uint8_t *ptr;
- ptr = *out = xmalloc (current_address);
- for (lst = lst0; lst; lst = lst->next)
- if (lst->state)
- {
- memcpy (ptr, &lst->b, grub_target_to_host32 (lst->b.block_size));
- ptr += grub_target_to_host32 (lst->b.block_size);
- }
- assert ((current_address + (grub_uint8_t *) *out) == ptr);
- }
-
- for (lst = lst0; lst; )
- {
- struct fixup_block_list *next;
- next = lst->next;
- free (lst);
- lst = next;
- }
-
- return current_address;
+ finish_reloc_translation (&ctx, layout, image_target);
}
/* Determine if this section is a text section. Return false if this
@@ -1289,24 +1625,31 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
static int
SUFFIX (is_text_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target)
{
- if (image_target->id != IMAGE_EFI
+ if (!is_relocatable (image_target)
&& grub_target_to_host32 (s->sh_type) != SHT_PROGBITS)
return 0;
return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC))
== (SHF_EXECINSTR | SHF_ALLOC));
}
-/* Determine if this section is a data section. This assumes that
- BSS is also a data section, since the converter initializes BSS
- when producing PE32 to avoid a bug in EFI implementations. */
+/* Determine if this section is a data section. */
static int
SUFFIX (is_data_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target)
{
- if (image_target->id != IMAGE_EFI
+ if (!is_relocatable (image_target)
&& grub_target_to_host32 (s->sh_type) != SHT_PROGBITS)
return 0;
return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC))
- == SHF_ALLOC);
+ == SHF_ALLOC) && !(grub_target_to_host32 (s->sh_type) == SHT_NOBITS);
+}
+
+static int
+SUFFIX (is_bss_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target)
+{
+ if (!is_relocatable (image_target))
+ return 0;
+ return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC))
+ == SHF_ALLOC) && (grub_target_to_host32 (s->sh_type) == SHT_NOBITS);
}
/* Return if the ELF header is valid. */
@@ -1326,35 +1669,62 @@ SUFFIX (check_elf_header) (Elf_Ehdr *e, size_t size, const struct grub_install_i
return 1;
}
+static Elf_Addr
+SUFFIX (put_section) (Elf_Shdr *s, int i,
+ Elf_Addr current_address,
+ Elf_Addr *section_addresses,
+ const char *strtab,
+ const struct grub_install_image_target_desc *image_target)
+{
+ Elf_Word align = grub_host_to_target_addr (s->sh_addralign);
+ const char *name = strtab + grub_host_to_target32 (s->sh_name);
+
+ if (align)
+ current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
+ align)
+ - image_target->vaddr_offset;
+
+ grub_util_info ("locating the section %s at 0x%"
+ GRUB_HOST_PRIxLONG_LONG,
+ name, (unsigned long long) current_address);
+ if (!is_relocatable (image_target))
+ current_address = grub_host_to_target_addr (s->sh_addr)
+ - image_target->link_addr;
+ section_addresses[i] = current_address;
+ current_address += grub_host_to_target_addr (s->sh_size);
+ return current_address;
+}
+
/* Locate section addresses by merging code sections and data sections
into .text and .data, respectively. Return the array of section
addresses. */
static Elf_Addr *
-SUFFIX (locate_sections) (const char *kernel_path,
+SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path,
Elf_Shdr *sections, Elf_Half section_entsize,
Elf_Half num_sections, const char *strtab,
- size_t *exec_size, size_t *kernel_sz,
- size_t *all_align,
+ struct grub_mkimage_layout *layout,
const struct grub_install_image_target_desc *image_target)
{
int i;
- Elf_Addr current_address;
Elf_Addr *section_addresses;
Elf_Shdr *s;
- *all_align = 1;
+ layout->align = 1;
+ /* Page-aligning simplifies relocation handling. */
+ if (image_target->elf_target == EM_AARCH64)
+ layout->align = 4096;
section_addresses = xmalloc (sizeof (*section_addresses) * num_sections);
memset (section_addresses, 0, sizeof (*section_addresses) * num_sections);
- current_address = 0;
+ layout->kernel_size = 0;
for (i = 0, s = sections;
i < num_sections;
i++, s = (Elf_Shdr *) ((char *) s + section_entsize))
if ((grub_target_to_host (s->sh_flags) & SHF_ALLOC)
- && grub_host_to_target32 (s->sh_addralign) > *all_align)
- *all_align = grub_host_to_target32 (s->sh_addralign);
+ && grub_host_to_target32 (s->sh_addralign) > layout->align)
+ layout->align = grub_host_to_target32 (s->sh_addralign);
/* .text */
@@ -1363,76 +1733,89 @@ SUFFIX (locate_sections) (const char *kernel_path,
i++, s = (Elf_Shdr *) ((char *) s + section_entsize))
if (SUFFIX (is_text_section) (s, image_target))
{
- Elf_Word align = grub_host_to_target_addr (s->sh_addralign);
- const char *name = strtab + grub_host_to_target32 (s->sh_name);
- if (align)
- current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
- align) - image_target->vaddr_offset;
- grub_util_info ("locating the section %s at 0x%"
- GRUB_HOST_PRIxLONG_LONG,
- name, (unsigned long long) current_address);
- if (image_target->id != IMAGE_EFI)
+ layout->kernel_size = SUFFIX (put_section) (s, i,
+ layout->kernel_size,
+ section_addresses,
+ strtab,
+ image_target);
+ if (!is_relocatable (image_target) &&
+ grub_host_to_target_addr (s->sh_addr) != image_target->link_addr)
{
- current_address = grub_host_to_target_addr (s->sh_addr)
- - image_target->link_addr;
- if (grub_host_to_target_addr (s->sh_addr)
- != image_target->link_addr)
- {
- char *msg
- = grub_xasprintf (_("`%s' is miscompiled: it's start address is 0x%llx"
- " instead of 0x%llx: ld.gold bug?"),
- kernel_path,
- (unsigned long long) grub_host_to_target_addr (s->sh_addr),
- (unsigned long long) image_target->link_addr);
- grub_util_error ("%s", msg);
- }
+ char *msg
+ = grub_xasprintf (_("`%s' is miscompiled: its start address is 0x%llx"
+ " instead of 0x%llx: ld.gold bug?"),
+ kernel_path,
+ (unsigned long long) grub_host_to_target_addr (s->sh_addr),
+ (unsigned long long) image_target->link_addr);
+ grub_util_error ("%s", msg);
}
- section_addresses[i] = current_address;
- current_address += grub_host_to_target_addr (s->sh_size);
}
- current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
+ layout->kernel_size = ALIGN_UP (layout->kernel_size + image_target->vaddr_offset,
image_target->section_align)
- image_target->vaddr_offset;
- *exec_size = current_address;
+ layout->exec_size = layout->kernel_size;
/* .data */
for (i = 0, s = sections;
i < num_sections;
i++, s = (Elf_Shdr *) ((char *) s + section_entsize))
if (SUFFIX (is_data_section) (s, image_target))
- {
- Elf_Word align = grub_host_to_target_addr (s->sh_addralign);
- const char *name = strtab + grub_host_to_target32 (s->sh_name);
+ layout->kernel_size = SUFFIX (put_section) (s, i,
+ layout->kernel_size,
+ section_addresses,
+ strtab,
+ image_target);
- if (align)
- current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
- align)
- - image_target->vaddr_offset;
+#ifdef MKIMAGE_ELF32
+ if (image_target->elf_target == EM_ARM)
+ {
+ grub_size_t tramp;
+ layout->kernel_size = ALIGN_UP (layout->kernel_size + image_target->vaddr_offset,
+ image_target->section_align) - image_target->vaddr_offset;
- grub_util_info ("locating the section %s at 0x%"
- GRUB_HOST_PRIxLONG_LONG,
- name, (unsigned long long) current_address);
- if (image_target->id != IMAGE_EFI)
- current_address = grub_host_to_target_addr (s->sh_addr)
- - image_target->link_addr;
- section_addresses[i] = current_address;
- current_address += grub_host_to_target_addr (s->sh_size);
- }
+ layout->kernel_size = ALIGN_UP (layout->kernel_size, 16);
+
+ tramp = arm_get_trampoline_size (e, sections, section_entsize,
+ num_sections, image_target);
- current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
+ layout->tramp_off = layout->kernel_size;
+ layout->kernel_size += ALIGN_UP (tramp, 16);
+ }
+#endif
+
+ layout->bss_start = layout->kernel_size;
+ layout->end = layout->kernel_size;
+
+ /* .bss */
+ for (i = 0, s = sections;
+ i < num_sections;
+ i++, s = (Elf_Shdr *) ((char *) s + section_entsize))
+ if (SUFFIX (is_bss_section) (s, image_target))
+ layout->end = SUFFIX (put_section) (s, i,
+ layout->end,
+ section_addresses,
+ strtab,
+ image_target);
+
+ layout->end = ALIGN_UP (layout->end + image_target->vaddr_offset,
image_target->section_align) - image_target->vaddr_offset;
- *kernel_sz = current_address;
+ /* Explicitly initialize BSS
+ when producing PE32 to avoid a bug in EFI implementations.
+ Platforms other than EFI and U-boot shouldn't have .bss in
+ their binaries as we build with -Wl,-Ttext.
+ */
+ if (image_target->id != IMAGE_UBOOT)
+ layout->kernel_size = layout->end;
+
return section_addresses;
}
-static char *
-SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
- size_t *kernel_sz, size_t *bss_size,
- size_t total_module_size, grub_uint64_t *start,
- void **reloc_section, size_t *reloc_size,
- size_t *align,
- const struct grub_install_image_target_desc *image_target)
+char *
+SUFFIX (grub_mkimage_load_image) (const char *kernel_path,
+ size_t total_module_size,
+ struct grub_mkimage_layout *layout,
+ const struct grub_install_image_target_desc *image_target)
{
char *kernel_img, *out_img;
const char *strtab;
@@ -1446,12 +1829,11 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
Elf_Off section_offset;
Elf_Half section_entsize;
grub_size_t kernel_size;
- grub_size_t ia64jmp_off = 0, tramp_off = 0, ia64_got_off = 0;
- unsigned ia64jmpnum = 0;
Elf_Shdr *symtab_section = 0;
- grub_size_t got = 0;
- *start = 0;
+ grub_memset (layout, 0, sizeof (*layout));
+
+ layout->start_address = 0;
kernel_size = grub_util_get_image_size (kernel_path);
kernel_img = xmalloc (kernel_size);
@@ -1465,7 +1847,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
section_entsize = grub_target_to_host16 (e->e_shentsize);
num_sections = grub_target_to_host16 (e->e_shnum);
- if (kernel_size < section_offset + section_entsize * num_sections)
+ if (kernel_size < section_offset + (grub_uint32_t) section_entsize * num_sections)
grub_util_error (_("premature end of file %s"), kernel_path);
sections = (Elf_Shdr *) (kernel_img + section_offset);
@@ -1475,10 +1857,10 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
+ grub_host_to_target16 (e->e_shstrndx) * section_entsize);
strtab = (char *) e + grub_host_to_target_addr (s->sh_offset);
- section_addresses = SUFFIX (locate_sections) (kernel_path,
+ section_addresses = SUFFIX (locate_sections) (e, kernel_path,
sections, section_entsize,
num_sections, strtab,
- exec_size, kernel_sz, align,
+ layout,
image_target);
section_vaddresses = xmalloc (sizeof (*section_addresses) * num_sections);
@@ -1486,9 +1868,9 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
for (i = 0; i < num_sections; i++)
section_vaddresses[i] = section_addresses[i] + image_target->vaddr_offset;
- if (image_target->id != IMAGE_EFI)
+ if (!is_relocatable (image_target))
{
- Elf_Addr current_address = *kernel_sz;
+ Elf_Addr current_address = layout->kernel_size;
for (i = 0, s = sections;
i < num_sections;
@@ -1507,7 +1889,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
grub_util_info ("locating the section %s at 0x%"
GRUB_HOST_PRIxLONG_LONG,
name, (unsigned long long) current_address);
- if (image_target->id != IMAGE_EFI)
+ if (!is_relocatable (image_target))
current_address = grub_host_to_target_addr (s->sh_addr)
- image_target->link_addr;
@@ -1518,17 +1900,18 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
image_target->section_align)
- image_target->vaddr_offset;
- *bss_size = current_address - *kernel_sz;
+ layout->bss_size = current_address - layout->kernel_size;
}
else
- *bss_size = 0;
+ layout->bss_size = 0;
if (image_target->id == IMAGE_SPARC64_AOUT
|| image_target->id == IMAGE_SPARC64_RAW
+ || image_target->id == IMAGE_UBOOT
|| image_target->id == IMAGE_SPARC64_CDCORE)
- *kernel_sz = ALIGN_UP (*kernel_sz, image_target->mod_align);
+ layout->kernel_size = ALIGN_UP (layout->kernel_size, image_target->mod_align);
- if (image_target->id == IMAGE_EFI)
+ if (is_relocatable (image_target))
{
symtab_section = NULL;
for (i = 0, s = sections;
@@ -1539,89 +1922,89 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
symtab_section = s;
break;
}
-
-#ifdef MKIMAGE_ELF32
- if (image_target->elf_target == EM_ARM)
- {
- grub_size_t tramp;
-
- *kernel_sz = ALIGN_UP (*kernel_sz, 16);
-
- tramp = arm_get_trampoline_size (e, sections, section_entsize,
- num_sections, image_target);
-
- tramp_off = *kernel_sz;
- *kernel_sz += ALIGN_UP (tramp, 16);
- }
-#endif
-
+ if (! symtab_section)
+ grub_util_error ("%s", _("no symbol table"));
#ifdef MKIMAGE_ELF64
if (image_target->elf_target == EM_IA_64)
{
grub_size_t tramp;
- *kernel_sz = ALIGN_UP (*kernel_sz, 16);
+ layout->kernel_size = ALIGN_UP (layout->kernel_size, 16);
- grub_ia64_dl_get_tramp_got_size (e, &tramp, &got);
+ grub_ia64_dl_get_tramp_got_size (e, &tramp, &layout->got_size);
- tramp_off = *kernel_sz;
- *kernel_sz += ALIGN_UP (tramp, 16);
+ layout->tramp_off = layout->kernel_size;
+ layout->kernel_size += ALIGN_UP (tramp, 16);
- ia64jmp_off = *kernel_sz;
- ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section,
- image_target);
- *kernel_sz += 16 * ia64jmpnum;
+ layout->ia64jmp_off = layout->kernel_size;
+ layout->ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section,
+ image_target);
+ layout->kernel_size += 16 * layout->ia64jmpnum;
- ia64_got_off = *kernel_sz;
- *kernel_sz += ALIGN_UP (got, 16);
+ layout->ia64_got_off = layout->kernel_size;
+ layout->kernel_size += ALIGN_UP (layout->got_size, 16);
}
#endif
-
- if (! symtab_section)
- grub_util_error ("%s", _("no symbol table"));
}
else
{
- *reloc_size = 0;
- *reloc_section = NULL;
+ layout->reloc_size = 0;
+ layout->reloc_section = NULL;
}
- out_img = xmalloc (*kernel_sz + total_module_size);
+ out_img = xmalloc (layout->kernel_size + total_module_size);
+ memset (out_img, 0, layout->kernel_size + total_module_size);
- if (image_target->id == IMAGE_EFI)
+ if (is_relocatable (image_target))
{
- *start = SUFFIX (relocate_symbols) (e, sections, symtab_section,
+ layout->start_address = SUFFIX (relocate_symbols) (e, sections, symtab_section,
section_vaddresses, section_entsize,
num_sections,
- (char *) out_img + ia64jmp_off,
- ia64jmp_off
+ (char *) out_img + layout->ia64jmp_off,
+ layout->ia64jmp_off
+ image_target->vaddr_offset,
+ layout->bss_start,
+ layout->end,
image_target);
- if (*start == 0)
+ if (layout->start_address == (Elf_Addr) -1)
grub_util_error ("start symbol is not defined");
- SUFFIX (entry_point) = (Elf_Addr) *start;
+ SUFFIX (entry_point) = (Elf_Addr) layout->start_address;
/* Resolve addresses in the virtual address space. */
SUFFIX (relocate_addresses) (e, sections, section_addresses,
section_entsize,
num_sections, strtab,
- out_img, tramp_off, ia64_got_off,
+ out_img, layout->tramp_off,
+ layout->ia64_got_off,
image_target);
- *reloc_size = SUFFIX (make_reloc_section) (e, reloc_section,
- section_vaddresses, sections,
- section_entsize, num_sections,
- strtab, ia64jmp_off
- + image_target->vaddr_offset,
- 2 * ia64jmpnum + (got / 8),
- image_target);
+ make_reloc_section (e, layout,
+ section_vaddresses, sections,
+ section_entsize, num_sections,
+ strtab,
+ image_target);
+ if (image_target->id != IMAGE_EFI)
+ {
+ out_img = xrealloc (out_img, layout->kernel_size + total_module_size
+ + ALIGN_UP (layout->reloc_size, image_target->mod_align));
+ memcpy (out_img + layout->kernel_size, layout->reloc_section, layout->reloc_size);
+ memset (out_img + layout->kernel_size + layout->reloc_size, 0,
+ total_module_size + ALIGN_UP (layout->reloc_size, image_target->mod_align) - layout->reloc_size);
+ layout->kernel_size += ALIGN_UP (layout->reloc_size, image_target->mod_align);
+ }
}
for (i = 0, s = sections;
i < num_sections;
i++, s = (Elf_Shdr *) ((char *) s + section_entsize))
if (SUFFIX (is_data_section) (s, image_target)
+ /* Explicitly initialize BSS
+ when producing PE32 to avoid a bug in EFI implementations.
+ Platforms other than EFI and U-boot shouldn't have .bss in
+ their binaries as we build with -Wl,-Ttext.
+ */
+ || (SUFFIX (is_bss_section) (s, image_target) && (image_target->id != IMAGE_UBOOT))
|| SUFFIX (is_text_section) (s, image_target))
{
if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS)
@@ -1639,23 +2022,3 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size,
return out_img;
}
-
-
-#undef SUFFIX
-#undef ELFCLASSXX
-#undef Elf_Ehdr
-#undef Elf_Phdr
-#undef Elf_Nhdr
-#undef Elf_Shdr
-#undef Elf_Addr
-#undef Elf_Sym
-#undef Elf_Off
-#undef Elf_Rela
-#undef Elf_Rel
-#undef ELF_R_TYPE
-#undef ELF_R_SYM
-#undef Elf_Word
-#undef Elf_Half
-#undef Elf_Section
-#undef ELF_ST_TYPE
-#undef XEN_NOTE_SIZE
diff --git a/util/grub-mklayout.c b/util/grub-mklayout.c
index b90546e12..d171c2700 100644
--- a/util/grub-mklayout.c
+++ b/util/grub-mklayout.c
@@ -28,10 +28,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <argp.h>
+
#include <unistd.h>
#include <errno.h>
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
+
+#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
+
#include "progname.h"
struct arguments
@@ -322,7 +329,7 @@ write_file (FILE *out, const char *fname, struct grub_keyboard_layout *layout)
grub_uint32_t version;
unsigned i;
- version = grub_cpu_to_le32 (GRUB_KEYBOARD_LAYOUTS_VERSION);
+ version = grub_cpu_to_le32_compile_time (GRUB_KEYBOARD_LAYOUTS_VERSION);
for (i = 0; i < ARRAY_SIZE (layout->keyboard_map); i++)
layout->keyboard_map[i] = grub_cpu_to_le32(layout->keyboard_map[i]);
@@ -377,6 +384,13 @@ write_keymaps (FILE *in, FILE *out, const char *out_filename)
sscanf (line, "keycode %u = %60s %60s %60s %60s", &keycode_linux,
normal, shift, normalalt, shiftalt);
+ if (keycode_linux >= ARRAY_SIZE (linux_to_usb_map))
+ {
+ /* TRANSLATORS: scan code is keyboard key numeric identifier. */
+ fprintf (stderr, _("Unknown keyboard scan code 0x%02x\n"), keycode_linux);
+ continue;
+ }
+
/* Not used. */
if (keycode_linux == 0x77 /* Pause */
/* Some obscure keys */
diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c
index 1112b87de..3813e8bc0 100644
--- a/util/grub-mknetdir.c
+++ b/util/grub-mknetdir.c
@@ -21,10 +21,15 @@
#include <grub/emu/config.h>
#include <grub/util/misc.h>
-#include <argp.h>
#include <string.h>
#include <errno.h>
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
+#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
+
static char *rootdir = NULL, *subdir = NULL;
static char *debug_image = NULL;
@@ -80,7 +85,8 @@ argp_parser (int key, char *arg, struct argp_state *state)
struct argp argp = {
options, argp_parser, NULL,
- "\v"N_("copies GRUB images into net_directory/subdir/target_cpu-platform."),
+ "\v"N_("Prepares GRUB network boot images at net_directory/subdir "
+ "assuming net_directory being TFTP root."),
NULL, grub_install_help_filter, NULL
};
@@ -134,7 +140,7 @@ process_input_dir (const char *input_dir, enum grub_install_plat platform)
prefix = xasprintf ("/%s", subdir);
if (!targets[platform].mkimage_target)
- grub_util_error (_("unsupported platform %s\n"), platsub);
+ grub_util_error (_("unsupported platform %s"), platsub);
grub_cfg = grub_util_path_concat (2, grubdir, "grub.cfg");
cfg = grub_util_fopen (grub_cfg, "wb");
diff --git a/util/grub-mkpasswd-pbkdf2.c b/util/grub-mkpasswd-pbkdf2.c
index 5f30c587e..5805f3c10 100644
--- a/util/grub-mkpasswd-pbkdf2.c
+++ b/util/grub-mkpasswd-pbkdf2.c
@@ -33,7 +33,12 @@
#define _GNU_SOURCE 1
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
+
#include "progname.h"
diff --git a/util/grub-mkrelpath.c b/util/grub-mkrelpath.c
index 6e64accd0..47a241a39 100644
--- a/util/grub-mkrelpath.c
+++ b/util/grub-mkrelpath.c
@@ -26,7 +26,11 @@
#include <grub/i18n.h>
#define _GNU_SOURCE 1
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
#include "progname.h"
diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c
index cfe538bd4..238d4840e 100644
--- a/util/grub-mkrescue.c
+++ b/util/grub-mkrescue.c
@@ -25,7 +25,11 @@
#include <grub/emu/exec.h>
#include <grub/emu/config.h>
#include <grub/emu/hostdisk.h>
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
#include <sys/types.h>
#include <sys/wait.h>
@@ -40,9 +44,6 @@ static char *label_color;
static char *label_bgcolor;
static char *product_name;
static char *product_version;
-static int xorriso_tail_argc;
-static int xorriso_tail_arg_alloc;
-static char **xorriso_tail_argv;
static char *output_image;
static char *xorriso;
static char *boot_grub;
@@ -112,18 +113,36 @@ static struct argp_option options[] = {
{0, 0, 0, 0, 0, 0}
};
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static char *
help_filter (int key, const char *text, void *input __attribute__ ((unused)))
{
switch (key)
{
+ case ARGP_KEY_HELP_PRE_DOC:
+ /* TRANSLATORS: it generates one single image which is bootable through any method. */
+ return strdup (_("Make GRUB CD-ROM, disk, pendrive and floppy bootable image."));
case ARGP_KEY_HELP_POST_DOC:
- return xasprintf (text, "xorriso -as mkisofs -help");
+ {
+ char *p1, *out;
+
+ p1 = xasprintf (_("Generates a bootable CD/USB/floppy image. Arguments other than options to this program"
+ " are passed to xorriso, and indicate source files, source directories, or any of the "
+ "mkisofs options listed by the output of `%s'."), "xorriso -as mkisofs -help");
+ out = xasprintf ("%s\n\n%s\n\n%s", p1,
+ _("Option -- switches to native xorriso command mode."),
+ _("Mail xorriso support requests to <bug-xorriso@gnu.org>."));
+ free (p1);
+ return out;
+ }
default:
return grub_install_help_filter (key, text, input);
}
}
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
enum {
SYS_AREA_AUTO,
SYS_AREA_COMMON,
@@ -193,16 +212,6 @@ argp_parser (int key, char *arg, struct argp_state *state)
xorriso = xstrdup (arg);
return 0;
- case ARGP_KEY_ARG:
- if (xorriso_tail_arg_alloc <= xorriso_tail_argc)
- {
- xorriso_tail_arg_alloc = 2 * (4 + xorriso_tail_argc);
- xorriso_tail_argv = xrealloc (xorriso_tail_argv,
- sizeof (xorriso_tail_argv[0])
- * xorriso_tail_arg_alloc);
- }
- xorriso_tail_argv[xorriso_tail_argc++] = xstrdup (arg);
- return 0;
default:
return ARGP_ERR_UNKNOWN;
}
@@ -210,12 +219,7 @@ argp_parser (int key, char *arg, struct argp_state *state)
struct argp argp = {
options, argp_parser, N_("[OPTION] SOURCE..."),
- /* TRANSLATORS: it generates one single image which is bootable through any method. */
- N_("Make GRUB CD-ROM, disk, pendrive and floppy bootable image.")"\v"
- N_("Generates a bootable rescue image with specified source files, source directories, or mkisofs options listed by the output of `%s'.\n\n"
- "Option -- switches to native xorriso command mode.\n\n"
- "Mail xorriso support requests to <bug-xorriso@gnu.org>."),
- NULL, help_filter, NULL
+ NULL, NULL, help_filter, NULL
};
static void
@@ -306,6 +310,7 @@ make_image_fwdisk_abs (enum grub_install_plat plat,
grub_install_make_image_wrap (source_dirs[plat], "()/boot/grub", output,
0, load_cfg, mkimage_target, 0);
grub_install_pop_module ();
+ grub_util_unlink (load_cfg);
}
static int
@@ -357,12 +362,70 @@ make_image_fwdisk (enum grub_install_plat plat,
free (out);
}
+static int
+option_is_end (const struct argp_option *opt)
+{
+ return !opt->key && !opt->name && !opt->doc && !opt->group;
+}
+
+
+static int
+args_to_eat (const char *arg)
+{
+ int j;
+
+ if (arg[0] != '-')
+ return 0;
+
+ if (arg[1] == '-')
+ {
+ for (j = 0; !option_is_end(&options[j]); j++)
+ {
+ size_t len = strlen (options[j].name);
+ if (strncmp (arg + 2, options[j].name, len) == 0)
+ {
+ if (arg[2 + len] == '=')
+ return 1;
+ if (arg[2 + len] == '\0' && options[j].arg)
+ return 2;
+ if (arg[2 + len] == '\0')
+ return 1;
+ }
+ }
+ if (strcmp (arg, "--help") == 0)
+ return 1;
+ if (strcmp (arg, "--usage") == 0)
+ return 1;
+ if (strcmp (arg, "--version") == 0)
+ return 1;
+ return 0;
+ }
+ if (arg[2] && arg[3])
+ return 0;
+ for (j = 0; !option_is_end(&options[j]); j++)
+ {
+ if (options[j].key > 0 && options[j].key < 128 && arg[1] == options[j].key)
+ {
+ if (options[j].arg)
+ return 2;
+ return 1;
+ }
+ if (arg[1] == '?')
+ return 1;
+ }
+ return 0;
+}
+
int
main (int argc, char *argv[])
{
char *romdir;
char *sysarea_img = NULL;
const char *pkgdatadir;
+ int argp_argc;
+ char **argp_argv;
+ int xorriso_tail_argc;
+ char **xorriso_tail_argv;
grub_util_host_init (&argc, &argv);
grub_util_disable_fd_syncs ();
@@ -374,7 +437,43 @@ main (int argc, char *argv[])
xorriso = xstrdup ("xorriso");
label_font = grub_util_path_concat (2, pkgdatadir, "unicode.pf2");
- argp_parse (&argp, argc, argv, 0, 0, 0);
+ argp_argv = xmalloc (sizeof (argp_argv[0]) * argc);
+ xorriso_tail_argv = xmalloc (sizeof (argp_argv[0]) * argc);
+
+ xorriso_tail_argc = 0;
+ /* Program name */
+ argp_argv[0] = argv[0];
+ argp_argc = 1;
+
+ /* argp doesn't allow us to catch unknwon arguments,
+ so catch them before passing to argp
+ */
+ {
+ int i;
+ for (i = 1; i < argc; i++)
+ {
+ if (strcmp (argv[i], "-output") == 0) {
+ argp_argv[argp_argc++] = (char *) "--output";
+ i++;
+ argp_argv[argp_argc++] = argv[i];
+ continue;
+ }
+ switch (args_to_eat (argv[i]))
+ {
+ case 2:
+ argp_argv[argp_argc++] = argv[i++];
+ /* Fallthrough */
+ case 1:
+ argp_argv[argp_argc++] = argv[i];
+ break;
+ case 0:
+ xorriso_tail_argv[xorriso_tail_argc++] = argv[i];
+ break;
+ }
+ }
+ }
+
+ argp_parse (&argp, argp_argc, argp_argv, 0, 0, 0);
if (!output_image)
grub_util_error ("%s", _("output file must be specified"));
@@ -428,6 +527,9 @@ main (int argc, char *argv[])
if (source_dirs[GRUB_INSTALL_PLATFORM_I386_PC]
|| source_dirs[GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275]
|| source_dirs[GRUB_INSTALL_PLATFORM_I386_EFI]
+ || source_dirs[GRUB_INSTALL_PLATFORM_IA64_EFI]
+ || source_dirs[GRUB_INSTALL_PLATFORM_ARM_EFI]
+ || source_dirs[GRUB_INSTALL_PLATFORM_ARM64_EFI]
|| source_dirs[GRUB_INSTALL_PLATFORM_X86_64_EFI])
system_area = SYS_AREA_COMMON;
else if (source_dirs[GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275])
@@ -546,6 +648,7 @@ main (int argc, char *argv[])
}
grub_install_pop_module ();
grub_install_pop_module ();
+ grub_util_unlink (load_cfg);
}
/** build multiboot core.img */
@@ -623,7 +726,8 @@ main (int argc, char *argv[])
if (source_dirs[GRUB_INSTALL_PLATFORM_I386_EFI]
|| source_dirs[GRUB_INSTALL_PLATFORM_X86_64_EFI]
|| source_dirs[GRUB_INSTALL_PLATFORM_IA64_EFI]
- || source_dirs[GRUB_INSTALL_PLATFORM_ARM_EFI])
+ || source_dirs[GRUB_INSTALL_PLATFORM_ARM_EFI]
+ || source_dirs[GRUB_INSTALL_PLATFORM_ARM64_EFI])
{
char *efidir = grub_util_make_temporary_dir ();
char *efidir_efi = grub_util_path_concat (2, efidir, "efi");
@@ -632,20 +736,32 @@ main (int argc, char *argv[])
char *efiimgfat;
grub_install_mkdir_p (efidir_efi_boot);
+ grub_install_push_module ("part_gpt");
+ grub_install_push_module ("part_msdos");
+
imgname = grub_util_path_concat (2, efidir_efi_boot, "bootia64.efi");
make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_IA64_EFI, "ia64-efi", imgname);
free (imgname);
+ grub_install_push_module ("part_apple");
img64 = grub_util_path_concat (2, efidir_efi_boot, "bootx64.efi");
make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_X86_64_EFI, "x86_64-efi", img64);
+ grub_install_pop_module ();
+ grub_install_push_module ("part_apple");
img32 = grub_util_path_concat (2, efidir_efi_boot, "bootia32.efi");
make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_I386_EFI, "i386-efi", img32);
+ grub_install_pop_module ();
imgname = grub_util_path_concat (2, efidir_efi_boot, "bootarm.efi");
make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_ARM_EFI, "arm-efi", imgname);
free (imgname);
+ imgname = grub_util_path_concat (2, efidir_efi_boot, "bootaa64.efi");
+ make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_ARM64_EFI, "arm64-efi",
+ imgname);
+ free (imgname);
+
if (source_dirs[GRUB_INSTALL_PLATFORM_I386_EFI])
{
imgname = grub_util_path_concat (2, efidir_efi_boot, "boot.efi");
@@ -671,9 +787,14 @@ main (int argc, char *argv[])
free (efidir_efi_boot);
efiimgfat = grub_util_path_concat (2, iso9660_dir, "efi.img");
- grub_util_exec ((const char * []) { "mformat", "-C", "-f", "2880", "-L", "16", "-i",
+ int rv;
+ rv = grub_util_exec ((const char * []) { "mformat", "-C", "-f", "2880", "-L", "16", "-i",
efiimgfat, "::", NULL });
- grub_util_exec ((const char * []) { "mcopy", "-s", "-i", efiimgfat, efidir_efi, "::/", NULL });
+ if (rv != 0)
+ grub_util_error ("`%s` invocation failed\n", "mformat");
+ rv = grub_util_exec ((const char * []) { "mcopy", "-s", "-i", efiimgfat, efidir_efi, "::/", NULL });
+ if (rv != 0)
+ grub_util_error ("`%s` invocation failed\n", "mformat");
xorriso_push ("--efi-boot");
xorriso_push ("efi.img");
xorriso_push ("-efi-boot-part");
@@ -683,9 +804,13 @@ main (int argc, char *argv[])
free (efiimgfat);
free (efidir_efi);
free (efidir);
+ grub_install_pop_module ();
+ grub_install_pop_module ();
}
+ grub_install_push_module ("part_apple");
make_image_fwdisk (GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275, "powerpc-ieee1275", "powerpc-ieee1275/core.elf");
+ grub_install_pop_module ();
if (source_dirs[GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275])
{
diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c
index 576ab400d..4907d44c0 100644
--- a/util/grub-mkstandalone.c
+++ b/util/grub-mkstandalone.c
@@ -22,9 +22,14 @@
#include <grub/util/misc.h>
#include <grub/emu/config.h>
-#include <argp.h>
#include <string.h>
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
+#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
+
static char *output_image;
static char **files;
static int nfiles;
@@ -231,7 +236,7 @@ add_tar_file (const char *from,
set_tar_value (hd.size, optr - tcn, 12);
set_tar_value (hd.mtime, mtime, 12);
hd.typeflag = 'L';
- memcpy (hd.magic, "ustar ", 7);
+ memcpy (hd.magic, MAGIC, sizeof (hd.magic));
memcpy (hd.uname, "grub", 4);
memcpy (hd.gname, "grub", 4);
@@ -261,7 +266,7 @@ add_tar_file (const char *from,
set_tar_value (hd.size, size, 12);
set_tar_value (hd.mtime, mtime, 12);
hd.typeflag = '0';
- memcpy (hd.magic, "ustar ", 7);
+ memcpy (hd.magic, MAGIC, sizeof (hd.magic));
memcpy (hd.uname, "grub", 4);
memcpy (hd.gname, "grub", 4);
@@ -279,6 +284,7 @@ add_tar_file (const char *from,
grub_util_fd_close (in);
write_pad (size);
+ free (tcn);
}
int
diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c
new file mode 100644
index 000000000..405c91170
--- /dev/null
+++ b/util/grub-module-verifier.c
@@ -0,0 +1,144 @@
+#include <stdio.h>
+#include <string.h>
+
+#include <grub/elf.h>
+#include <grub/module_verifier.h>
+#include <grub/misc.h>
+#include <grub/util/misc.h>
+
+struct grub_module_verifier_arch archs[] = {
+ { "i386", 4, 0, EM_386, GRUB_MODULE_VERIFY_SUPPORTS_REL, (int[]){
+ R_386_32,
+ R_386_PC32,
+ -1
+ } },
+ { "x86_64", 8, 0, EM_X86_64, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){
+ R_X86_64_64,
+ R_X86_64_PC64,
+ /* R_X86_64_32, R_X86_64_32S are supported but shouldn't be used because of their limited range. */
+ -1
+ }, (int[]){
+ R_X86_64_PC32,
+ -1
+ }
+ },
+ { "powerpc", 4, 1, EM_PPC, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){
+ GRUB_ELF_R_PPC_ADDR16_LO,
+ GRUB_ELF_R_PPC_REL24, /* It has limited range but GRUB adds trampolines when necessarry. */
+ GRUB_ELF_R_PPC_ADDR16_HA,
+ GRUB_ELF_R_PPC_ADDR32,
+ GRUB_ELF_R_PPC_REL32,
+ -1
+ } },
+ { "sparc64", 8, 1, EM_SPARCV9, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){
+ R_SPARC_WDISP30, /* It has limited range but GRUB adds trampolines when necessarry. */
+ R_SPARC_HH22,
+ R_SPARC_HM10,
+ R_SPARC_LM22,
+ R_SPARC_LO10,
+ R_SPARC_64,
+ R_SPARC_OLO10,
+ /* Following 2 relocations have limited range but unfortunately
+ clang generates them, as it doesn't implement mcmodel=large properly.
+ At least our heap and core are under 4G, so it's not a problem
+ usually. */
+ R_SPARC_HI22,
+ R_SPARC_32,
+ -1
+ } },
+ { "ia64", 8, 0, EM_IA_64, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){
+ R_IA64_PCREL21B, /* We should verify that it's pointing either
+ to a function or to a section in the same module.
+ Checking that external symbol is a function is
+ non-trivial and I have never seen this relocation used
+ for anything else, so assume that it always points to a
+ function.
+ */
+ R_IA64_SEGREL64LSB,
+ R_IA64_FPTR64LSB,
+ R_IA64_DIR64LSB,
+ R_IA64_PCREL64LSB,
+ R_IA64_LTOFF22X,
+ R_IA64_LTOFF22,
+ R_IA64_LTOFF_FPTR22,
+ R_IA64_LDXMOV,
+ -1
+ }, (int[]){
+ R_IA64_GPREL22,
+ -1
+ } },
+ { "mipsel", 4, 0, EM_MIPS, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){
+ R_MIPS_HI16,
+ R_MIPS_LO16,
+ R_MIPS_32,
+ R_MIPS_GPREL32,
+ R_MIPS_26,
+ R_MIPS_GOT16,
+ R_MIPS_CALL16,
+ R_MIPS_JALR,
+ -1
+ } },
+ { "mips", 4, 1, EM_MIPS, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){
+ R_MIPS_HI16,
+ R_MIPS_LO16,
+ R_MIPS_32,
+ R_MIPS_GPREL32,
+ R_MIPS_26,
+ R_MIPS_GOT16,
+ R_MIPS_CALL16,
+ R_MIPS_JALR,
+ -1
+ } },
+ { "arm", 4, 0, EM_ARM, GRUB_MODULE_VERIFY_SUPPORTS_REL, (int[]){
+ /* Some relocations are range-limited but trampolines are added when necessarry. */
+ R_ARM_ABS32,
+ R_ARM_CALL,
+ R_ARM_JUMP24,
+ R_ARM_THM_CALL,
+ R_ARM_THM_JUMP24,
+ R_ARM_V4BX,
+ R_ARM_THM_MOVW_ABS_NC,
+ R_ARM_THM_MOVT_ABS,
+ R_ARM_THM_JUMP19,
+ -1
+ } },
+ { "arm64", 8, 0, EM_AARCH64, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){
+ R_AARCH64_ABS64,
+ R_AARCH64_CALL26,
+ R_AARCH64_JUMP26,
+ -1
+ }, (int[]){
+ R_AARCH64_ADR_PREL_PG_HI21,
+ R_AARCH64_ADD_ABS_LO12_NC,
+ R_AARCH64_LDST64_ABS_LO12_NC,
+ -1
+ }
+ },
+};
+
+
+int
+main (int argc, char **argv)
+{
+ size_t module_size;
+ unsigned arch;
+ char *module_img;
+ if (argc != 3) {
+ fprintf (stderr, "usage: %s FILE ARCH\n", argv[0]);
+ return 1;
+ }
+
+ for (arch = 0; arch < ARRAY_SIZE(archs); arch++)
+ if (strcmp(archs[arch].name, argv[2]) == 0)
+ break;
+ if (arch == ARRAY_SIZE(archs))
+ grub_util_error("unknown arch: %s", argv[2]);
+
+ module_size = grub_util_get_image_size (argv[1]);
+ module_img = grub_util_read_image (argv[1]);
+ if (archs[arch].voidp_sizeof == 8)
+ grub_module_verify64(module_img, module_size, &archs[arch]);
+ else
+ grub_module_verify32(module_img, module_size, &archs[arch]);
+ return 0;
+}
diff --git a/util/grub-module-verifier32.c b/util/grub-module-verifier32.c
new file mode 100644
index 000000000..257229f8f
--- /dev/null
+++ b/util/grub-module-verifier32.c
@@ -0,0 +1,2 @@
+#define MODULEVERIFIER_ELF32 1
+#include "grub-module-verifierXX.c"
diff --git a/util/grub-module-verifier64.c b/util/grub-module-verifier64.c
new file mode 100644
index 000000000..4db6b4bed
--- /dev/null
+++ b/util/grub-module-verifier64.c
@@ -0,0 +1,2 @@
+#define MODULEVERIFIER_ELF64 1
+#include "grub-module-verifierXX.c"
diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c
new file mode 100644
index 000000000..9c04caa63
--- /dev/null
+++ b/util/grub-module-verifierXX.c
@@ -0,0 +1,371 @@
+#include <string.h>
+
+#include <grub/elf.h>
+#include <grub/module_verifier.h>
+#include <grub/util/misc.h>
+
+#if defined(MODULEVERIFIER_ELF32)
+# define SUFFIX(x) x ## 32
+# define ELFCLASSXX ELFCLASS32
+# define Elf_Ehdr Elf32_Ehdr
+# define Elf_Phdr Elf32_Phdr
+# define Elf_Nhdr Elf32_Nhdr
+# define Elf_Addr Elf32_Addr
+# define Elf_Sym Elf32_Sym
+# define Elf_Off Elf32_Off
+# define Elf_Shdr Elf32_Shdr
+# define Elf_Rela Elf32_Rela
+# define Elf_Rel Elf32_Rel
+# define Elf_Word Elf32_Word
+# define Elf_Half Elf32_Half
+# define Elf_Section Elf32_Section
+# define ELF_R_SYM(val) ELF32_R_SYM(val)
+# define ELF_R_TYPE(val) ELF32_R_TYPE(val)
+# define ELF_ST_TYPE(val) ELF32_ST_TYPE(val)
+#elif defined(MODULEVERIFIER_ELF64)
+# define SUFFIX(x) x ## 64
+# define ELFCLASSXX ELFCLASS64
+# define Elf_Ehdr Elf64_Ehdr
+# define Elf_Phdr Elf64_Phdr
+# define Elf_Nhdr Elf64_Nhdr
+# define Elf_Addr Elf64_Addr
+# define Elf_Sym Elf64_Sym
+# define Elf_Off Elf64_Off
+# define Elf_Shdr Elf64_Shdr
+# define Elf_Rela Elf64_Rela
+# define Elf_Rel Elf64_Rel
+# define Elf_Word Elf64_Word
+# define Elf_Half Elf64_Half
+# define Elf_Section Elf64_Section
+# define ELF_R_SYM(val) ELF64_R_SYM(val)
+# define ELF_R_TYPE(val) ELF64_R_TYPE(val)
+# define ELF_ST_TYPE(val) ELF64_ST_TYPE(val)
+#else
+#error "I'm confused"
+#endif
+
+#define grub_target_to_host32(x) (grub_target_to_host32_real (arch, (x)))
+#define grub_host_to_target32(x) (grub_host_to_target32_real (arch, (x)))
+#define grub_target_to_host64(x) (grub_target_to_host64_real (arch, (x)))
+#define grub_host_to_target64(x) (grub_host_to_target64_real (arch, (x)))
+#define grub_host_to_target_addr(x) (grub_host_to_target_addr_real (arch, (x)))
+#define grub_target_to_host16(x) (grub_target_to_host16_real (arch, (x)))
+#define grub_host_to_target16(x) (grub_host_to_target16_real (arch, (x)))
+#define grub_target_to_host(val) grub_target_to_host_real(arch, (val))
+
+static inline grub_uint32_t
+grub_target_to_host32_real (const struct grub_module_verifier_arch *arch,
+ grub_uint32_t in)
+{
+ if (arch->bigendian)
+ return grub_be_to_cpu32 (in);
+ else
+ return grub_le_to_cpu32 (in);
+}
+
+static inline grub_uint64_t
+grub_target_to_host64_real (const struct grub_module_verifier_arch *arch,
+ grub_uint64_t in)
+{
+ if (arch->bigendian)
+ return grub_be_to_cpu64 (in);
+ else
+ return grub_le_to_cpu64 (in);
+}
+
+static inline grub_uint64_t
+grub_host_to_target64_real (const struct grub_module_verifier_arch *arch,
+ grub_uint64_t in)
+{
+ if (arch->bigendian)
+ return grub_cpu_to_be64 (in);
+ else
+ return grub_cpu_to_le64 (in);
+}
+
+static inline grub_uint32_t
+grub_host_to_target32_real (const struct grub_module_verifier_arch *arch,
+ grub_uint32_t in)
+{
+ if (arch->bigendian)
+ return grub_cpu_to_be32 (in);
+ else
+ return grub_cpu_to_le32 (in);
+}
+
+static inline grub_uint16_t
+grub_target_to_host16_real (const struct grub_module_verifier_arch *arch,
+ grub_uint16_t in)
+{
+ if (arch->bigendian)
+ return grub_be_to_cpu16 (in);
+ else
+ return grub_le_to_cpu16 (in);
+}
+
+static inline grub_uint16_t
+grub_host_to_target16_real (const struct grub_module_verifier_arch *arch,
+ grub_uint16_t in)
+{
+ if (arch->bigendian)
+ return grub_cpu_to_be16 (in);
+ else
+ return grub_cpu_to_le16 (in);
+}
+
+static inline grub_uint64_t
+grub_host_to_target_addr_real (const struct grub_module_verifier_arch *arch, grub_uint64_t in)
+{
+ if (arch->voidp_sizeof == 8)
+ return grub_host_to_target64_real (arch, in);
+ else
+ return grub_host_to_target32_real (arch, in);
+}
+
+static inline grub_uint64_t
+grub_target_to_host_real (const struct grub_module_verifier_arch *arch, grub_uint64_t in)
+{
+ if (arch->voidp_sizeof == 8)
+ return grub_target_to_host64_real (arch, in);
+ else
+ return grub_target_to_host32_real (arch, in);
+}
+
+
+static Elf_Shdr *
+find_section (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, const char *name)
+{
+ Elf_Shdr *s;
+ const char *str;
+ unsigned i;
+
+ s = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff) + grub_target_to_host16 (e->e_shstrndx) * grub_target_to_host16 (e->e_shentsize));
+ str = (char *) e + grub_target_to_host (s->sh_offset);
+
+ for (i = 0, s = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff));
+ i < grub_target_to_host16 (e->e_shnum);
+ i++, s = (Elf_Shdr *) ((char *) s + grub_target_to_host16 (e->e_shentsize)))
+ if (strcmp (str + grub_target_to_host32 (s->sh_name), name) == 0)
+ return s;
+ return NULL;
+}
+
+static void
+check_license (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e)
+{
+ Elf_Shdr *s = find_section (arch, e, ".module_license");
+ if (s && (strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv3") == 0
+ || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv3+") == 0
+ || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv2+") == 0))
+ return;
+ grub_util_error ("incompatible license");
+}
+
+static Elf_Sym *
+get_symtab (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, Elf_Word *size, Elf_Word *entsize)
+{
+ unsigned i;
+ Elf_Shdr *s, *sections;
+ Elf_Sym *sym;
+
+ sections = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff));
+ for (i = 0, s = sections;
+ i < grub_target_to_host16 (e->e_shnum);
+ i++, s = (Elf_Shdr *) ((char *) s + grub_target_to_host16 (e->e_shentsize)))
+ if (grub_target_to_host32 (s->sh_type) == SHT_SYMTAB)
+ break;
+
+ if (i == grub_target_to_host16 (e->e_shnum))
+ return NULL;
+
+ sym = (Elf_Sym *) ((char *) e + grub_target_to_host (s->sh_offset));
+ *size = grub_target_to_host (s->sh_size);
+ *entsize = grub_target_to_host (s->sh_entsize);
+ return sym;
+}
+
+static void
+check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e)
+{
+ Elf_Sym *sym;
+ Elf_Word size, entsize;
+ unsigned i;
+
+ /* Module without symbol table and without .moddeps section is useless
+ at boot time, so catch it early to prevent build errors */
+ sym = get_symtab (arch, e, &size, &entsize);
+ if (!sym)
+ {
+ Elf_Shdr *s = find_section (arch, e, ".moddeps");
+
+ if (!s)
+ grub_util_error ("no symbol table and no .moddeps section");
+
+ if (!s->sh_size)
+ grub_util_error ("no symbol table and empty .moddeps section");
+
+ return;
+ }
+
+ for (i = 0;
+ i < size / entsize;
+ i++, sym = (Elf_Sym *) ((char *) sym + entsize))
+ {
+ unsigned char type = ELF_ST_TYPE (sym->st_info);
+
+ switch (type)
+ {
+ case STT_NOTYPE:
+ case STT_OBJECT:
+ case STT_FUNC:
+ case STT_SECTION:
+ case STT_FILE:
+ break;
+
+ default:
+ return grub_util_error ("unknown symbol type `%d'", (int) type);
+ }
+ }
+}
+
+static int
+is_symbol_local(Elf_Sym *sym)
+{
+ switch (ELF_ST_TYPE (sym->st_info))
+ {
+ case STT_NOTYPE:
+ case STT_OBJECT:
+ if (sym->st_name != 0 && sym->st_shndx == 0)
+ return 0;
+ return 1;
+
+ case STT_FUNC:
+ case STT_SECTION:
+ return 1;
+
+ default:
+ return 0;
+ }
+}
+
+static void
+section_check_relocations (const struct grub_module_verifier_arch *arch, void *ehdr,
+ Elf_Shdr *s, size_t target_seg_size)
+{
+ Elf_Rel *rel, *max;
+ Elf_Sym *symtab;
+ Elf_Word symtabsize, symtabentsize;
+
+ symtab = get_symtab (arch, ehdr, &symtabsize, &symtabentsize);
+ if (!symtab)
+ grub_util_error ("relocation without symbol table");
+
+ for (rel = (Elf_Rel *) ((char *) ehdr + grub_target_to_host (s->sh_offset)),
+ max = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_size));
+ rel < max;
+ rel = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_entsize)))
+ {
+ Elf_Sym *sym;
+ unsigned i;
+
+ if (target_seg_size < grub_target_to_host (rel->r_offset))
+ grub_util_error ("reloc offset is out of the segment");
+
+ grub_uint32_t type = ELF_R_TYPE (grub_target_to_host (rel->r_info));
+
+ if (arch->machine == EM_SPARCV9)
+ type &= 0xff;
+
+ for (i = 0; arch->supported_relocations[i] != -1; i++)
+ if (type == arch->supported_relocations[i])
+ break;
+ if (arch->supported_relocations[i] != -1)
+ continue;
+ if (!arch->short_relocations)
+ grub_util_error ("unsupported relocation 0x%x", type);
+ for (i = 0; arch->short_relocations[i] != -1; i++)
+ if (type == arch->short_relocations[i])
+ break;
+ if (arch->short_relocations[i] == -1)
+ grub_util_error ("unsupported relocation 0x%x", type);
+ sym = (Elf_Sym *) ((char *) symtab + symtabentsize * ELF_R_SYM (grub_target_to_host (rel->r_info)));
+
+ if (is_symbol_local (sym))
+ continue;
+ grub_util_error ("relocation 0x%x is not module-local", type);
+ }
+}
+
+static void
+check_relocations (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e)
+{
+ Elf_Shdr *s;
+ unsigned i;
+
+ for (i = 0, s = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff));
+ i < grub_target_to_host16 (e->e_shnum);
+ i++, s = (Elf_Shdr *) ((char *) s + grub_target_to_host16 (e->e_shentsize)))
+ if (grub_target_to_host32 (s->sh_type) == SHT_REL || grub_target_to_host32 (s->sh_type) == SHT_RELA)
+ {
+ Elf_Shdr *ts;
+
+ if (grub_target_to_host32 (s->sh_type) == SHT_REL && !(arch->flags & GRUB_MODULE_VERIFY_SUPPORTS_REL))
+ grub_util_error ("unsupported SHT_REL");
+ if (grub_target_to_host32 (s->sh_type) == SHT_RELA && !(arch->flags & GRUB_MODULE_VERIFY_SUPPORTS_RELA))
+ grub_util_error ("unsupported SHT_RELA");
+
+ /* Find the target segment. */
+ if (grub_target_to_host32 (s->sh_info) >= grub_target_to_host16 (e->e_shnum))
+ grub_util_error ("orphaned reloc section");
+ ts = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff) + grub_target_to_host32 (s->sh_info) * grub_target_to_host16 (e->e_shentsize));
+
+ section_check_relocations (arch, e, s, grub_target_to_host (ts->sh_size));
+ }
+}
+
+void
+SUFFIX(grub_module_verify) (void *module_img, size_t size, const struct grub_module_verifier_arch *arch)
+{
+ Elf_Ehdr *e = module_img;
+
+ /* Check the header size. */
+ if (size < sizeof (Elf_Ehdr))
+ grub_util_error ("ELF header smaller than expected");
+
+ /* Check the magic numbers. */
+ if (e->e_ident[EI_MAG0] != ELFMAG0
+ || e->e_ident[EI_MAG1] != ELFMAG1
+ || e->e_ident[EI_MAG2] != ELFMAG2
+ || e->e_ident[EI_MAG3] != ELFMAG3
+ || e->e_ident[EI_VERSION] != EV_CURRENT
+ || grub_target_to_host32 (e->e_version) != EV_CURRENT)
+ grub_util_error ("invalid arch-independent ELF magic");
+
+ if (e->e_ident[EI_CLASS] != ELFCLASSXX
+ || e->e_ident[EI_DATA] != (arch->bigendian ? ELFDATA2MSB : ELFDATA2LSB)
+ || grub_target_to_host16 (e->e_machine) != arch->machine)
+ grub_util_error ("invalid arch-dependent ELF magic");
+
+ if (grub_target_to_host16 (e->e_type) != ET_REL)
+ {
+ grub_util_error ("this ELF file is not of the right type");
+ }
+
+ /* Make sure that every section is within the core. */
+ if (size < grub_target_to_host (e->e_shoff)
+ + (grub_uint32_t) grub_target_to_host16 (e->e_shentsize) * grub_target_to_host16(e->e_shnum))
+ {
+ grub_util_error ("ELF sections outside core");
+ }
+
+ check_license (arch, e);
+
+ Elf_Shdr *s;
+
+ s = find_section (arch, e, ".modname");
+ if (!s)
+ grub_util_error ("no module name found");
+
+ check_symbols(arch, e);
+ check_relocations(arch, e);
+}
diff --git a/util/grub-mount.c b/util/grub-mount.c
index 118881e0d..aca5f82e3 100644
--- a/util/grub-mount.c
+++ b/util/grub-mount.c
@@ -41,8 +41,13 @@
#include <string.h>
#include <stdlib.h>
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
+#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
+
#include "progname.h"
-#include "argp.h"
static const char *root = NULL;
grub_device_t dev = NULL;
@@ -146,7 +151,6 @@ fuse_getattr (const char *path, struct stat *st)
{
struct fuse_getattr_ctx ctx;
char *pathname, *path2;
- const char *pathname_t;
if (path[0] == '/' && path[1] == 0)
{
@@ -165,12 +169,7 @@ fuse_getattr (const char *path, struct stat *st)
ctx.file_exists = 0;
- pathname_t = grub_strchr (path, ')');
- if (! pathname_t)
- pathname_t = path;
- else
- pathname_t++;
- pathname = xstrdup (pathname_t);
+ pathname = xstrdup (path);
/* Remove trailing '/'. */
while (*pathname && pathname[grub_strlen (pathname) - 1] == '/')
@@ -511,6 +510,7 @@ argp_parser (int key, char *arg, struct argp_state *state)
return 0;
}
grub_zfs_add_key (buf, real_size, 0);
+ fclose (f);
}
return 0;
@@ -541,7 +541,7 @@ argp_parser (int key, char *arg, struct argp_state *state)
}
images = xrealloc (images, (num_disks + 1) * sizeof (images[0]));
- images[num_disks] = canonicalize_file_name (arg);
+ images[num_disks] = grub_canonicalize_file_name (arg);
num_disks++;
return 0;
diff --git a/util/grub-pe2elf.c b/util/grub-pe2elf.c
index f4abf70a3..0d4084a10 100644
--- a/util/grub-pe2elf.c
+++ b/util/grub-pe2elf.c
@@ -279,7 +279,7 @@ write_reloc_section (FILE* fp, const char *name, char *image,
break;
#endif
default:
- grub_util_error ("unknown pe relocation type %d\n", pe_rel->type);
+ grub_util_error ("unknown pe relocation type %d", pe_rel->type);
}
if (type ==
diff --git a/util/grub-probe.c b/util/grub-probe.c
index db68d61f6..8ac527d2f 100644
--- a/util/grub-probe.c
+++ b/util/grub-probe.c
@@ -46,7 +46,12 @@
#include <assert.h>
#define _GNU_SOURCE 1
+
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
#include "progname.h"
@@ -72,17 +77,67 @@ enum {
PRINT_DISK
};
+static const char *targets[] =
+ {
+ [PRINT_FS] = "fs",
+ [PRINT_FS_UUID] = "fs_uuid",
+ [PRINT_FS_LABEL] = "fs_label",
+ [PRINT_DRIVE] = "drive",
+ [PRINT_DEVICE] = "device",
+ [PRINT_PARTMAP] = "partmap",
+ [PRINT_ABSTRACTION] = "abstraction",
+ [PRINT_CRYPTODISK_UUID] = "cryptodisk_uuid",
+ [PRINT_HINT_STR] = "hints_string",
+ [PRINT_BIOS_HINT] = "bios_hints",
+ [PRINT_IEEE1275_HINT] = "ieee1275_hints",
+ [PRINT_BAREMETAL_HINT] = "baremetal_hints",
+ [PRINT_EFI_HINT] = "efi_hints",
+ [PRINT_ARC_HINT] = "arc_hints",
+ [PRINT_COMPATIBILITY_HINT] = "compatibility_hint",
+ [PRINT_MSDOS_PARTTYPE] = "msdos_parttype",
+ [PRINT_GPT_PARTTYPE] = "gpt_parttype",
+ [PRINT_ZERO_CHECK] = "zero_check",
+ [PRINT_DISK] = "disk",
+ };
+
static int print = PRINT_FS;
static unsigned int argument_is_device = 0;
+static char *
+get_targets_string (void)
+{
+ char **arr = xmalloc (sizeof (targets));
+ int len = 0;
+ char *str;
+ char *ptr;
+ unsigned i;
+
+ memcpy (arr, targets, sizeof (targets));
+ qsort (arr, ARRAY_SIZE (targets), sizeof (char *), grub_qsort_strcmp);
+ for (i = 0; i < ARRAY_SIZE (targets); i++)
+ len += grub_strlen (targets[i]) + 2;
+ ptr = str = xmalloc (len);
+ for (i = 0; i < ARRAY_SIZE (targets); i++)
+ {
+ ptr = grub_stpcpy (ptr, arr[i]);
+ *ptr++ = ',';
+ *ptr++ = ' ';
+ }
+ ptr[-2] = '\0';
+ free (arr);
+
+ return str;
+}
+
static void
-do_print (const char *x)
+do_print (const char *x, void *data)
{
- grub_printf ("%s ", x);
+ char delim = *(const char *) data;
+ grub_printf ("%s%c", x, delim);
}
static void
-probe_partmap (grub_disk_t disk)
+probe_partmap (grub_disk_t disk, char delim)
{
grub_partition_t part;
grub_disk_memberlist_t list = NULL, tmp;
@@ -93,10 +148,10 @@ probe_partmap (grub_disk_t disk)
}
for (part = disk->partition; part; part = part->parent)
- printf ("%s ", part->partmap->name);
+ printf ("%s%c", part->partmap->name, delim);
if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID)
- grub_diskfilter_get_partmap (disk, do_print);
+ grub_diskfilter_get_partmap (disk, do_print, &delim);
/* In case of LVM/RAID, check the member devices as well. */
if (disk->dev->memberlist)
@@ -105,7 +160,7 @@ probe_partmap (grub_disk_t disk)
}
while (list)
{
- probe_partmap (list->disk);
+ probe_partmap (list->disk, delim);
tmp = list->next;
free (list);
list = tmp;
@@ -113,7 +168,7 @@ probe_partmap (grub_disk_t disk)
}
static void
-probe_cryptodisk_uuid (grub_disk_t disk)
+probe_cryptodisk_uuid (grub_disk_t disk, char delim)
{
grub_disk_memberlist_t list = NULL, tmp;
@@ -124,7 +179,7 @@ probe_cryptodisk_uuid (grub_disk_t disk)
}
while (list)
{
- probe_cryptodisk_uuid (list->disk);
+ probe_cryptodisk_uuid (list->disk, delim);
tmp = list->next;
free (list);
list = tmp;
@@ -132,7 +187,7 @@ probe_cryptodisk_uuid (grub_disk_t disk)
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
{
const char *uu = grub_util_cryptodisk_get_uuid (disk);
- grub_printf ("%s ", uu);
+ grub_printf ("%s%c", uu, delim);
}
}
@@ -156,7 +211,7 @@ probe_raid_level (grub_disk_t disk)
}
static void
-probe_abstraction (grub_disk_t disk)
+probe_abstraction (grub_disk_t disk, char delim)
{
grub_disk_memberlist_t list = NULL, tmp;
int raid_level;
@@ -165,7 +220,7 @@ probe_abstraction (grub_disk_t disk)
list = disk->dev->memberlist (disk);
while (list)
{
- probe_abstraction (list->disk);
+ probe_abstraction (list->disk, delim);
tmp = list->next;
free (list);
@@ -175,26 +230,26 @@ probe_abstraction (grub_disk_t disk)
if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID
&& (grub_memcmp (disk->name, "lvm/", sizeof ("lvm/") - 1) == 0 ||
grub_memcmp (disk->name, "lvmid/", sizeof ("lvmid/") - 1) == 0))
- printf ("lvm ");
+ printf ("lvm%c", delim);
if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID
&& grub_memcmp (disk->name, "ldm/", sizeof ("ldm/") - 1) == 0)
- printf ("ldm ");
+ printf ("ldm%c", delim);
if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)
- grub_util_cryptodisk_get_abstraction (disk, do_print);
+ grub_util_cryptodisk_get_abstraction (disk, do_print, &delim);
raid_level = probe_raid_level (disk);
if (raid_level >= 0)
{
- printf ("diskfilter ");
+ printf ("diskfilter%c", delim);
if (disk->dev->raidname)
- printf ("%s ", disk->dev->raidname (disk));
+ printf ("%s%c", disk->dev->raidname (disk), delim);
}
if (raid_level == 5)
- printf ("raid5rec ");
+ printf ("raid5rec%c", delim);
if (raid_level == 6)
- printf ("raid6rec ");
+ printf ("raid6rec%c", delim);
}
static void
@@ -207,7 +262,7 @@ probe (const char *path, char **device_names, char delim)
if (path != NULL)
{
- grub_path = canonicalize_file_name (path);
+ grub_path = grub_canonicalize_file_name (path);
if (! grub_path)
grub_util_error (_("failed to get canonical path of `%s'"), path);
device_names = grub_guess_root_devices (grub_path);
@@ -224,7 +279,7 @@ probe (const char *path, char **device_names, char delim)
printf ("%s", *curdev);
putchar (delim);
}
- return;
+ goto free_device_names;
}
if (print == PRINT_DISK)
@@ -240,8 +295,9 @@ probe (const char *path, char **device_names, char delim)
}
printf ("%s", disk);
putchar (delim);
+ free (disk);
}
- return;
+ goto free_device_names;
}
for (curdev = device_names; *curdev; curdev++)
@@ -373,7 +429,7 @@ probe (const char *path, char **device_names, char delim)
if (print == PRINT_HINT_STR)
{
const char *osdev = grub_util_biosdisk_get_osdev (dev->disk);
- const char *ofpath = osdev ? grub_util_devname_to_ofpath (osdev) : 0;
+ char *ofpath = osdev ? grub_util_devname_to_ofpath (osdev) : 0;
char *biosname, *bare, *efi;
const char *map;
@@ -387,6 +443,7 @@ probe (const char *path, char **device_names, char delim)
grub_util_fprint_full_disk_name (stdout, tmp, dev);
printf ("' ");
free (tmp);
+ free (ofpath);
}
biosname = grub_util_guess_bios_drive (*curdev);
@@ -429,22 +486,18 @@ probe (const char *path, char **device_names, char delim)
printf (" ");
else
printf ("\n");
-
- grub_device_close (dev);
- continue;
}
- if ((print == PRINT_COMPATIBILITY_HINT || print == PRINT_BIOS_HINT
+ else if ((print == PRINT_COMPATIBILITY_HINT || print == PRINT_BIOS_HINT
|| print == PRINT_IEEE1275_HINT || print == PRINT_BAREMETAL_HINT
|| print == PRINT_EFI_HINT || print == PRINT_ARC_HINT)
&& dev->disk->dev->id != GRUB_DISK_DEVICE_HOSTDISK_ID)
{
grub_util_fprint_full_disk_name (stdout, dev->disk->name, dev);
putchar (delim);
- continue;
}
- if (print == PRINT_COMPATIBILITY_HINT)
+ else if (print == PRINT_COMPATIBILITY_HINT)
{
const char *map;
char *biosname;
@@ -462,16 +515,14 @@ probe (const char *path, char **device_names, char delim)
{
grub_util_fprint_full_disk_name (stdout, biosname, dev);
putchar (delim);
+ free (biosname);
+ /* Compatibility hint is one device only. */
+ grub_device_close (dev);
+ break;
}
- free (biosname);
- grub_device_close (dev);
- /* Compatibility hint is one device only. */
- if (biosname)
- break;
- continue;
}
- if (print == PRINT_BIOS_HINT)
+ else if (print == PRINT_BIOS_HINT)
{
char *biosname;
biosname = grub_util_guess_bios_drive (*curdev);
@@ -479,15 +530,13 @@ probe (const char *path, char **device_names, char delim)
{
grub_util_fprint_full_disk_name (stdout, biosname, dev);
putchar (delim);
+ free (biosname);
}
- free (biosname);
- grub_device_close (dev);
- continue;
}
- if (print == PRINT_IEEE1275_HINT)
+ else if (print == PRINT_IEEE1275_HINT)
{
const char *osdev = grub_util_biosdisk_get_osdev (dev->disk);
- const char *ofpath = grub_util_devname_to_ofpath (osdev);
+ char *ofpath = grub_util_devname_to_ofpath (osdev);
const char *map;
map = grub_util_biosdisk_get_compatibility_hint (dev->disk);
@@ -505,13 +554,11 @@ probe (const char *path, char **device_names, char delim)
strcpy (p, ofpath);
grub_util_fprint_full_disk_name (stdout, tmp, dev);
free (tmp);
+ free (ofpath);
putchar (delim);
}
-
- grub_device_close (dev);
- continue;
}
- if (print == PRINT_EFI_HINT)
+ else if (print == PRINT_EFI_HINT)
{
char *biosname;
const char *map;
@@ -527,14 +574,11 @@ probe (const char *path, char **device_names, char delim)
{
grub_util_fprint_full_disk_name (stdout, biosname, dev);
putchar (delim);
+ free (biosname);
}
-
- free (biosname);
- grub_device_close (dev);
- continue;
}
- if (print == PRINT_BAREMETAL_HINT)
+ else if (print == PRINT_BAREMETAL_HINT)
{
char *biosname;
const char *map;
@@ -551,14 +595,11 @@ probe (const char *path, char **device_names, char delim)
{
grub_util_fprint_full_disk_name (stdout, biosname, dev);
putchar (delim);
+ free (biosname);
}
-
- free (biosname);
- grub_device_close (dev);
- continue;
}
- if (print == PRINT_ARC_HINT)
+ else if (print == PRINT_ARC_HINT)
{
const char *map;
@@ -568,49 +609,28 @@ probe (const char *path, char **device_names, char delim)
grub_util_fprint_full_disk_name (stdout, map, dev);
putchar (delim);
}
-
- /* FIXME */
- grub_device_close (dev);
- continue;
}
- if (print == PRINT_ABSTRACTION)
- {
- probe_abstraction (dev->disk);
- putchar (delim);
- grub_device_close (dev);
- continue;
- }
+ else if (print == PRINT_ABSTRACTION)
+ probe_abstraction (dev->disk, delim);
- if (print == PRINT_CRYPTODISK_UUID)
- {
- probe_cryptodisk_uuid (dev->disk);
- putchar (delim);
- grub_device_close (dev);
- continue;
- }
+ else if (print == PRINT_CRYPTODISK_UUID)
+ probe_cryptodisk_uuid (dev->disk, delim);
- if (print == PRINT_PARTMAP)
- {
- /* Check if dev->disk itself is contained in a partmap. */
- probe_partmap (dev->disk);
- putchar (delim);
- grub_device_close (dev);
- continue;
- }
+ else if (print == PRINT_PARTMAP)
+ /* Check if dev->disk itself is contained in a partmap. */
+ probe_partmap (dev->disk, delim);
- if (print == PRINT_MSDOS_PARTTYPE)
+ else if (print == PRINT_MSDOS_PARTTYPE)
{
if (dev->disk->partition
&& strcmp(dev->disk->partition->partmap->name, "msdos") == 0)
printf ("%02x", dev->disk->partition->msdostype);
putchar (delim);
- grub_device_close (dev);
- continue;
}
- if (print == PRINT_GPT_PARTTYPE)
+ else if (print == PRINT_GPT_PARTTYPE)
{
if (dev->disk->partition
&& strcmp (dev->disk->partition->partmap->name, "gpt") == 0)
@@ -639,15 +659,23 @@ probe (const char *path, char **device_names, char delim)
dev->disk->partition = p;
}
putchar (delim);
- grub_device_close (dev);
- continue;
}
+
+ grub_device_close (dev);
}
end:
for (curdrive = drives_names; *curdrive; curdrive++)
free (*curdrive);
free (drives_names);
+
+free_device_names:
+ if (path != NULL)
+ {
+ for (curdev = device_names; *curdev; curdev++)
+ free (*curdev);
+ free (device_names);
+ }
}
static struct argp_option options[] = {
@@ -655,12 +683,14 @@ static struct argp_option options[] = {
N_("given argument is a system device, not a path"), 0},
{"device-map", 'm', N_("FILE"), 0,
N_("use FILE as the device map [default=%s]"), 0},
- {"target", 't', "(fs|fs_uuid|fs_label|drive|device|partmap|abstraction|cryptodisk_uuid|msdos_parttype)", 0,
- N_("print filesystem module, GRUB drive, system device, partition map module, abstraction module or cryptographic container UUID [default=fs]"), 0},
+ {"target", 't', N_("TARGET"), 0, 0, 0},
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
+ {0, '0', 0, 0, N_("separate items in output using ASCII NUL characters"), 0},
{ 0, 0, 0, 0, 0, 0 }
};
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static char *
help_filter (int key, const char *text, void *input __attribute__ ((unused)))
{
@@ -669,11 +699,26 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
case 'm':
return xasprintf (text, DEFAULT_DEVICE_MAP);
+ case 't':
+ {
+ char *ret, *t = get_targets_string (), *def;
+
+ def = xasprintf (_("[default=%s]"), targets[print]);
+
+ ret = xasprintf ("%s\n%s %s %s", _("print TARGET"),
+ _("available targets:"), t, def);
+ free (t);
+ free (def);
+ return ret;
+ }
+
default:
return (char *) text;
}
}
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
struct arguments
{
char **devices;
@@ -704,46 +749,18 @@ argp_parser (int key, char *arg, struct argp_state *state)
break;
case 't':
- if (!strcmp (arg, "fs"))
- print = PRINT_FS;
- else if (!strcmp (arg, "fs_uuid"))
- print = PRINT_FS_UUID;
- else if (!strcmp (arg, "fs_label"))
- print = PRINT_FS_LABEL;
- else if (!strcmp (arg, "drive"))
- print = PRINT_DRIVE;
- else if (!strcmp (arg, "device"))
- print = PRINT_DEVICE;
- else if (!strcmp (arg, "partmap"))
- print = PRINT_PARTMAP;
- else if (!strcmp (arg, "abstraction"))
- print = PRINT_ABSTRACTION;
- else if (!strcmp (arg, "cryptodisk_uuid"))
- print = PRINT_CRYPTODISK_UUID;
- else if (!strcmp (arg, "msdos_parttype"))
- print = PRINT_MSDOS_PARTTYPE;
- else if (!strcmp (arg, "gpt_parttype"))
- print = PRINT_GPT_PARTTYPE;
- else if (!strcmp (arg, "hints_string"))
- print = PRINT_HINT_STR;
- else if (!strcmp (arg, "bios_hints"))
- print = PRINT_BIOS_HINT;
- else if (!strcmp (arg, "ieee1275_hints"))
- print = PRINT_IEEE1275_HINT;
- else if (!strcmp (arg, "baremetal_hints"))
- print = PRINT_BAREMETAL_HINT;
- else if (!strcmp (arg, "efi_hints"))
- print = PRINT_EFI_HINT;
- else if (!strcmp (arg, "arc_hints"))
- print = PRINT_ARC_HINT;
- else if (!strcmp (arg, "compatibility_hint"))
- print = PRINT_COMPATIBILITY_HINT;
- else if (strcmp (arg, "zero_check") == 0)
- print = PRINT_ZERO_CHECK;
- else if (!strcmp (arg, "disk"))
- print = PRINT_DISK;
- else
- argp_usage (state);
+ {
+ int i;
+
+ for (i = PRINT_FS; i < ARRAY_SIZE (targets); i++)
+ if (strcmp (arg, targets[i]) == 0)
+ {
+ print = i;
+ break;
+ }
+ if (i == ARRAY_SIZE (targets))
+ argp_usage (state);
+ }
break;
case '0':
@@ -845,11 +862,7 @@ main (int argc, char *argv[])
else
probe (arguments.devices[0], NULL, delim);
- if (!arguments.zero_delim && (print == PRINT_BIOS_HINT
- || print == PRINT_IEEE1275_HINT
- || print == PRINT_BAREMETAL_HINT
- || print == PRINT_EFI_HINT
- || print == PRINT_ARC_HINT))
+ if (delim == ' ')
putchar ('\n');
/* Free resources. */
diff --git a/util/grub-reboot.in b/util/grub-reboot.in
index 225fe5f21..4d4f75704 100644
--- a/util/grub-reboot.in
+++ b/util/grub-reboot.in
@@ -47,7 +47,7 @@ usage () {
gettext_printf "Usage: %s [OPTION] MENU_ENTRY\n" "$self"
gettext "Set the default boot menu entry for GRUB, for the next boot only."; echo
print_option_help "-h, --help" "$(gettext "print this message and exit")"
- print_option_help "-v, --version" "$(gettext "print the version information and exit")"
+ print_option_help "-V, --version" "$(gettext "print the version information and exit")"
dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg"
echo
@@ -81,7 +81,7 @@ do
-h | --help)
usage
exit 0 ;;
- -v | --version)
+ -V | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
diff --git a/util/grub-render-label.c b/util/grub-render-label.c
index 9a8eedbc1..ec0923b2e 100644
--- a/util/grub-render-label.c
+++ b/util/grub-render-label.c
@@ -33,10 +33,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <argp.h>
#include <unistd.h>
#include <errno.h>
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
+#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
+
#include "progname.h"
struct arguments
@@ -58,7 +63,10 @@ static struct argp_option options[] = {
{"bgcolor", 'b', N_("COLOR"), 0,
N_("use COLOR for background"), 0},
{"text", 't', N_("STRING"), 0,
- N_("set the label to render."), 0},
+ /* TRANSLATORS: The result is always stored to file and
+ never shown directly, so don't use "show" as synonym for render. Use "create" if
+ "render" doesn't translate directly. */
+ N_("set the label to render"), 0},
{"output", 'o', N_("FILE"), 0,
N_("set output filename. Default is STDOUT"), 0},
{"font", 'f', N_("FILE"), 0,
@@ -121,6 +129,10 @@ argp_parser (int key, char *arg, struct argp_state *state)
static struct argp argp = {
options, argp_parser, N_("[OPTIONS]"),
+ /* TRANSLATORS: This file takes a text and creates a graphical representation of it,
+ putting the result into .disk_label file. The result is always stored to file and
+ never shown directly, so don't use "show" as synonym for render. Use "create" if
+ "render" doesn't translate directly. */
N_("Render Apple .disk_label."),
NULL, NULL, NULL
};
diff --git a/util/grub-script-check.c b/util/grub-script-check.c
index 2111efa5a..801b3df4a 100644
--- a/util/grub-script-check.c
+++ b/util/grub-script-check.c
@@ -34,7 +34,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
#include "progname.h"
diff --git a/util/grub-set-default.in b/util/grub-set-default.in
index 83a7be12f..6036f81e5 100644
--- a/util/grub-set-default.in
+++ b/util/grub-set-default.in
@@ -49,7 +49,7 @@ usage () {
gettext_printf "This requires setting GRUB_DEFAULT=saved in %s/default/grub.\n" "$sysconfdir"
echo
print_option_help "-h, --help" "$(gettext "print this message and exit")"
- print_option_help "-v, --version" "$(gettext "print the version information and exit")"
+ print_option_help "-V, --version" "$(gettext "print the version information and exit")"
dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg"
echo
@@ -79,7 +79,7 @@ do
-h | --help)
usage
exit 0 ;;
- -v | --version)
+ -V | --version)
echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
exit 0 ;;
diff --git a/util/grub-setup.c b/util/grub-setup.c
index 7a6ca78b2..993b02068 100644
--- a/util/grub-setup.c
+++ b/util/grub-setup.c
@@ -39,7 +39,11 @@
#include <grub/emu/getroot.h>
#include <grub/util/install.h>
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
/* On SPARC this program fills in various fields inside of the 'boot' and 'core'
* image files.
@@ -94,6 +98,8 @@ static struct argp_option options[] = {
{ 0, 0, 0, 0, 0, 0 }
};
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static char *
help_filter (int key, const char *text, void *input __attribute__ ((unused)))
{
@@ -116,6 +122,8 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
}
}
+#pragma GCC diagnostic error "-Wformat-nonliteral"
+
struct arguments
{
char *boot_file;
diff --git a/util/grub-syslinux2cfg.c b/util/grub-syslinux2cfg.c
index aee938759..85fa0da14 100644
--- a/util/grub-syslinux2cfg.c
+++ b/util/grub-syslinux2cfg.c
@@ -30,7 +30,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <argp.h>
#include <unistd.h>
#include <errno.h>
#include <grub/err.h>
@@ -40,6 +39,12 @@
#include <grub/mm.h>
#include <grub/syslinux_parse.h>
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wmissing-declarations"
+#include <argp.h>
+#pragma GCC diagnostic error "-Wmissing-prototypes"
+#pragma GCC diagnostic error "-Wmissing-declarations"
+
#include "progname.h"
struct arguments
@@ -60,14 +65,16 @@ static struct argp_option options[] = {
{"root", 'r', N_("DIR"), 0,
N_("root directory of the syslinux disk [default=/]."), 0},
{"target-cwd", 'T', N_("DIR"), 0,
- N_("current directory as it will be seen on runtime [default=$pwd]."), 0},
+ N_(
+ "current directory of syslinux as it will be seen on runtime [default is parent directory of input file]."
+), 0},
{"cwd", 'c', N_("DIR"), 0,
- N_("current directory of the syslinux disk [default=$pwd]."), 0},
+ N_("current directory of syslinux [default is parent directory of input file]."), 0},
{"output", 'o', N_("FILE"), 0, N_("write output to FILE [default=stdout]."), 0},
- {"isolinux", 'i', 0, 0, N_("assume isolinux."), 0},
- {"pxelinux", 'p', 0, 0, N_("assume pxelinux."), 0},
- {"syslinux", 's', 0, 0, N_("assume syslinux."), 0},
+ {"isolinux", 'i', 0, 0, N_("assume input is an isolinux configuration file."), 0},
+ {"pxelinux", 'p', 0, 0, N_("assume input is a pxelinux configuration file."), 0},
+ {"syslinux", 's', 0, 0, N_("assume input is a syslinux configuration file."), 0},
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
{ 0, 0, 0, 0, 0, 0 }
};
@@ -168,7 +175,7 @@ main (int argc, char *argv[])
grub_host_init ();
char *t, *inpfull, *rootfull, *res;
- t = canonicalize_file_name (arguments.input);
+ t = grub_canonicalize_file_name (arguments.input);
if (!t)
{
grub_util_error (_("cannot open `%s': %s"), arguments.input,
@@ -178,7 +185,7 @@ main (int argc, char *argv[])
inpfull = xasprintf ("(host)/%s", t);
free (t);
- t = canonicalize_file_name (arguments.root ? : "/");
+ t = grub_canonicalize_file_name (arguments.root ? : "/");
if (!t)
{
grub_util_error (_("cannot open `%s': %s"), arguments.root,
@@ -199,7 +206,7 @@ main (int argc, char *argv[])
cwd = xstrdup (".");
}
- t = canonicalize_file_name (arguments.cwd ? : cwd);
+ t = grub_canonicalize_file_name (arguments.cwd ? : cwd);
if (!t)
{
grub_util_error (_("cannot open `%s': %s"), arguments.root,
diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
index 88ce5ac94..93a90233e 100644
--- a/util/grub.d/00_header.in
+++ b/util/grub.d/00_header.in
@@ -25,7 +25,7 @@ grub_lang=`echo $LANG | cut -d . -f 1`
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
-. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
+. "$pkgdatadir/grub-mkconfig_lib"
# Do this as early as possible, since other commands might depend on it.
# (e.g. the `loadfont' command might need lvm or raid modules)
@@ -152,7 +152,7 @@ if [ "x$gfxterm" = x1 ]; then
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT}"` ; then
EOF
else
- for dir in "${pkgdatadir}" "`echo "$GRUB_ROOT"'/@bootdirname@/@grubdirname@' | sed "s,//*,/,g"`" "`echo "$GRUB_ROOT"'/usr/share/grub' | sed "s,//*,/,g"`" ; do
+ for dir in "${pkgdatadir}" "`echo '/@bootdirname@/@grubdirname@' | sed "s,//*,/,g"`" /usr/share/grub ; do
for basename in unicode unifont ascii; do
path="${dir}/${basename}.pf2"
if is_path_readable_by_grub "${path}" > /dev/null ; then
@@ -282,48 +282,50 @@ fi
make_timeout ()
{
- if [ "x${1}${3}" != "x" ] ; then
- if [ "x${3}" != "x" ] ; then
- timeout="${2}"
- style="${3}"
- else
- # Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
- timeout="${1}"
- if [ "x${2}" != "x0" ] ; then
- grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
- fi
- if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
- style="hidden"
- else
- style="countdown"
- fi
+ if [ "x${3}" != "x" ] ; then
+ timeout="${2}"
+ style="${3}"
+ elif [ "x${1}" != "x" ] && [ "x${1}" != "x0" ] ; then
+ # Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
+ timeout="${1}"
+ if [ "x${2}" != "x0" ] ; then
+ grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
fi
- if [ "x${style}" = "xcountdown" ] ; then
- verbose=" --verbose"
- else
+ if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
+ style="hidden"
verbose=
+ else
+ style="countdown"
+ verbose=" --verbose"
fi
- cat << EOF
+ else
+ # No hidden timeout, so treat as GRUB_TIMEOUT_STYLE=menu
+ timeout="${2}"
+ style="menu"
+ fi
+ cat << EOF
if [ x\$feature_timeout_style = xy ] ; then
set timeout_style=${style}
set timeout=${timeout}
EOF
- if [ "x${style}" != "xmenu" ] ; then
- cat << EOF
+ if [ "x${style}" = "xmenu" ] ; then
+ cat << EOF
+# Fallback normal timeout code in case the timeout_style feature is
+# unavailable.
+else
+ set timeout=${timeout}
+EOF
+ else
+ cat << EOF
# Fallback hidden-timeout code in case the timeout_style feature is
# unavailable.
elif sleep${verbose} --interruptible ${timeout} ; then
set timeout=0
EOF
- fi
- cat << EOF
+ fi
+ cat << EOF
fi
EOF
- else
- cat << EOF
-set timeout=${2}
-EOF
- fi
}
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in
index da8069bd3..59a9a48a2 100644
--- a/util/grub.d/10_hurd.in
+++ b/util/grub.d/10_hurd.in
@@ -21,20 +21,10 @@ prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
-if [ x$GRUB_PLATFORM = xx86 ]; then
- check=--is-x86-multiboot
-elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
- check=--is-i386-xen-pae-domu
-elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
- check=--is-x86_64-xen-domu
-else
- exit 0
-fi
-
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
-. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
+. "$pkgdatadir/grub-mkconfig_lib"
CLASS="--class gnu --class os"
@@ -50,11 +40,11 @@ all_of_them=true
# FIXME: add l4 here?
kernel=
-for i in "$GRUB_ROOT"/boot/gnumach* ; do
- if test -f "$i" && "${grub_file}" $check "$i" ; then
- basename=`basename "$i"`
- dirname=`dirname "$i"`
- rel_dirname=`make_system_path_relative_to_its_root "$dirname"`
+for i in /boot/gnumach* ; do
+ if test -e $i ; then
+ basename=`basename $i`
+ dirname=`dirname $i`
+ rel_dirname=`make_system_path_relative_to_its_root $dirname`
gettext_printf "Found GNU Mach: %s" "$i" >&2
echo >&2
kernels="${kernels} ${rel_dirname}/${basename}"
@@ -68,8 +58,8 @@ case "${GRUB_FS}" in
*) hurd_fs="${GRUB_FS}fs" ;;
esac
-for i in "$GRUB_ROOT"/hurd/${hurd_fs}.static "$GRUB_ROOT"/hurd/exec ; do
- if test -f "$i" ; then
+for i in /hurd/${hurd_fs}.static /hurd/exec ; do
+ if test -e "$i" ; then
gettext_printf "Found Hurd module: %s" "$i" >&2
echo >&2
at_least_one=true
@@ -83,7 +73,7 @@ if ${at_least_one} ; then : ; else
exit 0
fi
-if ${all_of_them} && test -f "$GRUB_ROOT"/lib/ld.so.1 ; then : ; else
+if ${all_of_them} && test -e /lib/ld.so.1 ; then : ; else
gettext "Some Hurd stuff found, but not enough to boot." >&2
echo >&2
exit 1
@@ -178,7 +168,7 @@ while [ "x$kernels" != "x" ] ; do
hurd_entry "$kernel" advanced
hurd_entry "$kernel" recovery
- kernels=`echo $kernels | tr ' ' '\n' | grep -vx $kernel | tr '\n' ' '`
+ kernels=`echo $kernels | tr ' ' '\n' | fgrep -vx "$kernel" | tr '\n' ' '`
done
# If at least one kernel was found, then we need to
diff --git a/util/grub.d/10_illumos.in b/util/grub.d/10_illumos.in
index 00f1d6816..a133e1b3f 100644
--- a/util/grub.d/10_illumos.in
+++ b/util/grub.d/10_illumos.in
@@ -20,28 +20,13 @@ set -e
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
-. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
+. "$pkgdatadir/grub-mkconfig_lib"
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
CLASS="--class os"
-if [ x$GRUB_PLATFORM = xx86 ]; then
- check=--is-x86-multiboot
-elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
- check=--is-i386-xen-pae-domu
-elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
- check=--is-x86_64-xen-domu
-else
- exit 0
-fi
-
-if ! test -f "$GRUB_ROOT"/platform/i86pc/kernel || ! "${grub_file}" $check "$GRUB_ROOT"/platform/i86pc/kernel; then
- exit 0
-fi
-
-
case "${GRUB_DISTRIBUTOR}" in
*)
OS="Illumos"
@@ -60,7 +45,7 @@ message="$(gettext_printf "Loading kernel of Illumos ...")"
else
ISADIR=
fi
- zfs-bootfs $($grub_mkrelpath "$GRUB_ROOT"/) ZFS_BOOTFS
+ zfs-bootfs $($grub_mkrelpath /) ZFS_BOOTFS
echo '$(echo "$message" | grub_quote)'
multiboot $($grub_mkrelpath /platform/i86pc/kernel)/\$ISADIR/unix /platform/i86pc/kernel/\$ISADIR/unix -B \$ZFS_BOOTFS,console=text
module $($grub_mkrelpath /platform/i86pc)/\$ISADIR/boot_archive /platform/i86pc/\$ISADIR/boot_archive
diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in
index f4aa450bb..9d8e8fd85 100644
--- a/util/grub.d/10_kfreebsd.in
+++ b/util/grub.d/10_kfreebsd.in
@@ -20,23 +20,13 @@ set -e
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
-. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
+. "$pkgdatadir/grub-mkconfig_lib"
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
CLASS="--class os"
-if [ x$GRUB_PLATFORM = xx86 ]; then
- check=--is-x86-kfreebsd
-elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
- check=--is-i386-xen-pae-domu
-elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
- check=--is-x86_64-xen-domu
-else
- exit 0
-fi
-
case "${GRUB_DISTRIBUTOR}" in
Debian)
OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD"
@@ -132,10 +122,10 @@ EOF
zfs)
load_kfreebsd_module opensolaris false
- ls "$GRUB_ROOT/boot/zfs/zpool.cache" > /dev/null
+ ls "/boot/zfs/zpool.cache" > /dev/null
printf '%s\n' "${prepare_boot_cache}"
sed "s/^/$submenu_indentation/" << EOF
- kfreebsd_module $(make_system_path_relative_to_its_root $GRUB_ROOT/boot)/zfs/zpool.cache type=/boot/zfs/zpool.cache
+ kfreebsd_module $(make_system_path_relative_to_its_root /boot)/zfs/zpool.cache type=/boot/zfs/zpool.cache
EOF
;;
esac
@@ -153,9 +143,12 @@ EOF
EOF
}
-list=`for i in $GRUB_ROOT/boot/kfreebsd-* $GRUB_ROOT/boot/kernel/kernel ; do
- if grub_file_is_not_garbage "$i" && ${grub_file} $check "$i"; then echo -n "$i " ; fi
- done`
+list=
+for i in /boot/kfreebsd-* /boot/kernel/kernel ; do
+ if grub_file_is_not_garbage "$i" ; then
+ list="$list $i"
+ fi
+done
prepare_boot_cache=
boot_device_id=
title_correction_code=
@@ -173,8 +166,8 @@ while [ "x$list" != "x" ] ; do
dirname=`dirname $kfreebsd`
rel_dirname=`make_system_path_relative_to_its_root $dirname`
- if [ -f "$GRUB_ROOT"/boot/device.hints ] ; then
- devices="$GRUB_ROOT"/boot/device.hints
+ if [ -f /boot/device.hints ] ; then
+ devices=/boot/device.hints
devices_basename=`basename $devices`
devices_dirname=`dirname $devices`
devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname`
@@ -191,14 +184,14 @@ while [ "x$list" != "x" ] ; do
# zpool name
kfreebsd_device=$(${grub_probe} -t fs_label --device ${GRUB_DEVICE})
# filesystem name (empty string for the main filesystem)
- kfreebsd_device="${kfreebsd_device}$(${grub_mkrelpath} "$GRUB_ROOT"/ | sed -e "s,/*@$,,")"
+ kfreebsd_device="${kfreebsd_device}$(${grub_mkrelpath} / | sed -e "s,/*@$,,")"
;;
*)
kfreebsd_device=${kfreebsd_fs}id/${GRUB_DEVICE_UUID}
# Debian GNU/kFreeBSD can't remount root if it's supplied as UUID but
# as an UUID
if [ "x${GRUB_DISTRIBUTOR}" = "xDebian" ] \
- && ! (cat "$GRUB_ROOT"/etc/fstab | awk '!/^[[:space:]]*#/ && $2=="/" { print $1; }' \
+ && ! (cat /etc/fstab | awk '!/^[[:space:]]*#/ && $2=="/" { print $1; }' \
| grep "${kfreebsd_fs}id/${GRUB_DEVICE_UUID}" > /dev/null); then
kfreebsd_device=${GRUB_DEVICE}
fi
@@ -209,8 +202,8 @@ while [ "x$list" != "x" ] ; do
alt_version=`echo $version | sed -e "s,\.old$,,g"`
module_dir=
- for i in "$GRUB_ROOT/lib/modules/${version}" "$GRUB_ROOT/lib/modules/${alt_version}" \
- "$GRUB_ROOT/boot/kernel"; do
+ for i in "/lib/modules/${version}" "/lib/modules/${alt_version}" \
+ "/boot/kernel"; do
if test -e "$i" ; then
module_dir="$i"
break
@@ -238,7 +231,7 @@ while [ "x$list" != "x" ] ; do
kfreebsd_entry "${OS}" "${version}" recovery "-s"
fi
- list=`echo $list | tr ' ' '\n' | grep -vx $kfreebsd | tr '\n' ' '`
+ list=`echo $list | tr ' ' '\n' | fgrep -vx "$kfreebsd" | tr '\n' ' '`
done
# If at least one kernel was found, then we need to
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index e904d1edf..de9044c7f 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -21,36 +21,11 @@ prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
-. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
+. "$pkgdatadir/grub-mkconfig_lib"
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
-if [ x$GRUB_PLATFORM = xx86 ]; then
- check=--is-x86-linux32
-elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
- check=--is-i386-xen-pae-domu
-elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
- check=--is-x86_64-xen-domu
-else
- check=--is-${GRUB_PLATFORM}-linux
-fi
-
-case "x$GRUB_PLATFORM" in
- xx86)
- list=`for i in "$GRUB_ROOT"/boot/vmlinuz-* "$GRUB_ROOT"/vmlinuz-* "$GRUB_ROOT"/boot/kernel-* ; do
- if grub_file_is_not_garbage "$i" && "${grub_file}" $check "$i" ; then echo -n "$i " ; fi
- done` ;;
- *)
- list=`for i in "$GRUB_ROOT"/boot/vmlinuz-* "$GRUB_ROOT"/boot/vmlinux-* "$GRUB_ROOT"/vmlinuz-* "$GRUB_ROOT"/vmlinux-* "$GRUB_ROOT"/boot/kernel-* ; do
- if grub_file_is_not_garbage "$i" && "${grub_file}" $check "$i" ; then echo -n "$i " ; fi
- done` ;;
-esac
-
-if [ x"$list" = x ]; then
- exit 0
-fi
-
CLASS="--class gnu-linux --class gnu --class os"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
@@ -68,9 +43,11 @@ case ${GRUB_DEVICE} in
;;
esac
+# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter
+# and mounting btrfs requires user space scanning, so force UUID in this case.
if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
- || uses_abstraction "${GRUB_DEVICE}" lvm; then
+ || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
@@ -78,14 +55,14 @@ fi
case x"$GRUB_FS" in
xbtrfs)
- rootsubvol="`make_system_path_relative_to_its_root "$GRUB_ROOT"/`"
+ rootsubvol="`make_system_path_relative_to_its_root /`"
rootsubvol="${rootsubvol#/}"
if [ "x${rootsubvol}" != x ]; then
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi;;
xzfs)
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
- bootfs="`make_system_path_relative_to_its_root "$GRUB_ROOT"/ | sed -e "s,@$,,"`"
+ bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
;;
esac
@@ -140,7 +117,7 @@ linux_entry ()
echo " insmod gzio" | sed "s/^/$submenu_indentation/"
- if [ x$dirname = x"$GRUB_ROOT"/ ]; then
+ if [ x$dirname = x/ ]; then
if [ -z "${prepare_root_cache}" ]; then
prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)"
fi
@@ -169,12 +146,26 @@ EOF
EOF
}
-case "$GRUB_PLATFORM" in
- x86 | i386-xen-pae | x86_64-xen) GENKERNEL_ARCH="x86" ;;
+machine=`uname -m`
+case "x$machine" in
+ xi?86 | xx86_64)
+ list=
+ for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
+ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
+ done ;;
+ *)
+ list=
+ for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
+ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
+ done ;;
+esac
+
+case "$machine" in
+ i?86) GENKERNEL_ARCH="x86" ;;
mips|mips64) GENKERNEL_ARCH="mips" ;;
mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;;
arm*) GENKERNEL_ARCH="arm" ;;
- *) GENKERNEL_ARCH="$GRUB_PLATFORM" ;;
+ *) GENKERNEL_ARCH="$machine" ;;
esac
prepare_boot_cache=
@@ -213,7 +204,7 @@ while [ "x$list" != "x" ] ; do
done
config=
- for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "$GRUB_ROOT/etc/kernels/kernel-config-${version}" ; do
+ for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
if test -e "${i}" ; then
config="${i}"
break
@@ -254,7 +245,7 @@ while [ "x$list" != "x" ] ; do
"single ${GRUB_CMDLINE_LINUX}"
fi
- list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
+ list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
done
# If at least one kernel was found, then we need to
diff --git a/util/grub.d/10_netbsd.in b/util/grub.d/10_netbsd.in
index b1aba65c1..874f59969 100644
--- a/util/grub.d/10_netbsd.in
+++ b/util/grub.d/10_netbsd.in
@@ -20,17 +20,7 @@ set -e
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
-. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
-
-if [ x$GRUB_PLATFORM = xx86 ]; then
- check=--is-x86-kfreebsd
-elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
- check=--is-i386-xen-pae-domu
-elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
- check=--is-x86_64-xen-domu
-else
- exit 0
-fi
+. "$pkgdatadir/grub-mkconfig_lib"
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
@@ -46,13 +36,19 @@ netbsd_load_fs_module ()
loader="$1" # "knetbsd" or "multiboot"
kernel="$2" # absolute path to the kernel file
- if "${grub_file}" --is-x86_64-kfreebsd "${kernel}"; then
- karch="amd64"
- else
+ case $(zcat -f "${kernel}" | file -bL - | cut -d , -f 2 | tr -d ' ') in
+ Intel80386)
karch="i386"
- fi
+ ;;
+ x86-64)
+ karch="amd64"
+ ;;
+ *)
+ return
+ ;;
+ esac
- case $GRUB_FS in
+ case $(${grub_probe} --target=fs -d ${GRUB_DEVICE}) in
ext2)
kmod="ext2fs"
;;
@@ -71,9 +67,9 @@ netbsd_load_fs_module ()
esac
kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }')
- kmodule="$GRUB_ROOT/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod"
+ kmodule="/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod"
- if test -z "$karch" -o -z "$kversion" -o ! -f "${kmodule}"; then
+ if test -z "$karch" || test -z "$kversion" || test ! -f "${kmodule}"; then
return
fi
@@ -98,10 +94,6 @@ netbsd_entry ()
type="$3"
args="$4" # extra arguments appended to loader command
- if [ "x${loader}" = xmultiboot ] && [ x$GRUB_PLATFORM = xx86 ] && ! "$grub_file" --is-x86-multiboot "$kernel"; then
- return
- fi
-
kroot_device="$(echo ${GRUB_DEVICE} | sed -e 's,^/dev/r,,')"
if [ -z "$boot_device_id" ]; then
@@ -155,13 +147,10 @@ pattern="^ELF[^,]*executable.*statically linked"
submenu_indentation=""
is_top_level=true
-for k in "$GRUB_ROOT"/netbsd $(ls -t "$GRUB_ROOT"/netbsd?* 2>/dev/null) ; do
+for k in /netbsd $(ls -t /netbsd?* 2>/dev/null) ; do
if ! grub_file_is_not_garbage "$k" ; then
continue
fi
- if ! "$grub_file" $check "$k"; then
- continue
- fi
if ! (zcat -f "$k" | file -bL - | grep -q "${pattern}") 2>/dev/null ; then
continue
fi
diff --git a/util/grub.d/10_windows.in b/util/grub.d/10_windows.in
index 9025914f6..554c5614b 100644
--- a/util/grub.d/10_windows.in
+++ b/util/grub.d/10_windows.in
@@ -24,7 +24,7 @@ datarootdir="@datarootdir@"
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
-. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
+. "$pkgdatadir/grub-mkconfig_lib"
case "`uname 2>/dev/null`" in
CYGWIN*) ;;
@@ -66,11 +66,11 @@ for drv in $drives ; do
osid=
# Check for Vista bootmgr.
- if [ -f "$dir"/bootmgr -a -f "$dir"/boot/bcd ] ; then
+ if [ -f "$dir"/bootmgr ] && [ -f "$dir"/boot/bcd ] ; then
OS="$(gettext "Windows Vista/7 (loader)")"
osid=bootmgr
# Check for NTLDR.
- elif [ -f "$dir"/ntldr -a -f "$dir"/ntdetect.com -a -f "$dir"/boot.ini ] ; then
+ elif [ -f "$dir"/ntldr ] && [ -f "$dir"/ntdetect.com ] && [ -f "$dir"/boot.ini ] ; then
OS=`get_os_name_from_boot_ini "$dir"/boot.ini` || OS="$(gettext "Windows NT/2000/XP (loader)")"
osid=ntldr
needmap=t
diff --git a/util/grub.d/10_xnu.in b/util/grub.d/10_xnu.in
index 54c06135c..9c40b4536 100644
--- a/util/grub.d/10_xnu.in
+++ b/util/grub.d/10_xnu.in
@@ -24,30 +24,20 @@ datarootdir="@datarootdir@"
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
-. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
-
-if [ x$GRUB_PLATFORM != xx86 ]; then
- exit 0
-fi
+. "$pkgdatadir/grub-mkconfig_lib"
osx_entry() {
if [ x$2 = x32 ]; then
# TRANSLATORS: it refers to kernel architecture (32-bit)
bitstr="$(gettext "(32-bit)")"
- if ! [ -f "$GRUB_ROOT"/mach_kernel ] || ! "${grub_file}" --is-i386-xnu "$GRUB_ROOT"/mach_kernel; then
- return;
- fi
else
# TRANSLATORS: it refers to kernel architecture (64-bit)
bitstr="$(gettext "(64-bit)")"
- if ! [ -f "$GRUB_ROOT"/mach_kernel ] || ! "${grub_file}" --is-x86_64-xnu "$GRUB_ROOT"/mach_kernel; then
- return;
- fi
fi
# TRANSLATORS: it refers on the OS residing on device %s
onstr="$(gettext_printf "(on %s)" "${GRUB_DEVICE}")"
cat << EOF
-menuentry '$(echo "Darwin/Mac OS X $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'xnu-$2-$(grub_get_device_id "${GRUB_DEVICE}")' {
+menuentry '$(echo "Darwin/Mac OS X $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${GRUB_DEVICE}")' {
EOF
save_default_entry | grub_add_tab
prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab
@@ -60,12 +50,15 @@ EOF
fi
fi
if [ \$do_resume = 0 ]; then
- xnu_uuid ${GRUB_DEVICE_UUID} uuid
+ xnu_uuid ${OSXUUID} uuid
if [ -f /Extra/DSDT.aml ]; then
acpi -e /Extra/DSDT.aml
fi
if [ /kernelcache -nt /System/Library/Extensions ]; then
$1 /kernelcache boot-uuid=\${uuid} rd=*uuid
+ elif [ -f /System/Library/Kernels/kernel ]; then
+ $1 /System/Library/Kernels/kernel boot-uuid=\${uuid} rd=*uuid
+ xnu_kextdir /System/Library/Extensions
else
$1 /mach_kernel boot-uuid=\${uuid} rd=*uuid
if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
@@ -100,5 +93,6 @@ EOF
EOF
}
+OSXUUID="`${grub_probe} --target=fs_uuid --device ${GRUB_DEVICE} 2> /dev/null`"
osx_entry xnu_kernel 32
osx_entry xnu_kernel64 64
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index fbc1ce004..c48af948d 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -21,15 +21,11 @@ prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
-. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
+. "$pkgdatadir/grub-mkconfig_lib"
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
-if [ x$GRUB_PLATFORM != xx86 ]; then
- exit 0
-fi
-
CLASS="--class gnu-linux --class gnu --class os --class xen"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
@@ -47,9 +43,11 @@ case ${GRUB_DEVICE} in
;;
esac
+# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter
+# and mounting btrfs requires user space scanning, so force UUID in this case.
if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
|| ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
- || uses_abstraction "${GRUB_DEVICE}" lvm; then
+ || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then
LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else
LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
@@ -65,14 +63,14 @@ fi
case x"$GRUB_FS" in
xbtrfs)
- rootsubvol="`make_system_path_relative_to_its_root "$GRUB_ROOT"/`"
+ rootsubvol="`make_system_path_relative_to_its_root /`"
rootsubvol="${rootsubvol#/}"
if [ "x${rootsubvol}" != x ]; then
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi;;
xzfs)
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
- bootfs="`make_system_path_relative_to_its_root "$GRUB_ROOT"/ | sed -e "s,@$,,"`"
+ bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
;;
esac
@@ -141,11 +139,22 @@ EOF
EOF
}
-linux_list=`for i in "$GRUB_ROOT"/boot/vmlinu[xz]-* "$GRUB_ROOT"/vmlinu[xz]-* "$GRUB_ROOT"/boot/kernel-*; do
- if grub_file_is_not_garbage "$i" && "${grub_file}" --is-x86-xen-dom0 "$i"; then
- echo -n "$i " ;
+linux_list=
+for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do
+ if grub_file_is_not_garbage "$i"; then
+ basename=$(basename $i)
+ version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
+ dirname=$(dirname $i)
+ config=
+ for j in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
+ if test -e "${j}" ; then
+ config="${j}"
+ break
+ fi
+ done
+ if (grep -qx "CONFIG_XEN_DOM0=y" "${config}" 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" "${config}" 2> /dev/null); then linux_list="$linux_list $i" ; fi
fi
- done`
+done
if [ "x${linux_list}" = "x" ] ; then
exit 0
fi
@@ -159,9 +168,10 @@ file_is_not_sym () {
esac
}
-xen_list=`for i in "$GRUB_ROOT"/boot/xen*; do
- if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" && ${grub_file} --is-x86-multiboot "$i"; then echo -n "$i " ; fi
- done`
+xen_list=
+for i in /boot/xen*; do
+ if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then xen_list="$xen_list $i" ; fi
+done
prepare_boot_cache=
boot_device_id=
@@ -249,12 +259,12 @@ while [ "x${xen_list}" != "x" ] ; do
"single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
fi
- list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
+ list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
done
if [ x"$is_top_level" != xtrue ]; then
echo ' }'
fi
- xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $current_xen | tr '\n' ' '`
+ xen_list=`echo $xen_list | tr ' ' '\n' | fgrep -vx "$current_xen" | tr '\n' ' '`
done
# If at least one kernel was found, then we need to
diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
index 0470e6685..515a68c7a 100644
--- a/util/grub.d/30_os-prober.in
+++ b/util/grub.d/30_os-prober.in
@@ -24,13 +24,13 @@ datarootdir="@datarootdir@"
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@"
-. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
+. "$pkgdatadir/grub-mkconfig_lib"
if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
exit 0
fi
-if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then
+if [ -z "`which os-prober 2> /dev/null`" ] || [ -z "`which linux-boot-prober 2> /dev/null`" ] ; then
# missing os-prober and/or linux-boot-prober
exit 0
fi
@@ -71,6 +71,9 @@ EOF
fi
if [ /kernelcache -nt /System/Library/Extensions ]; then
$1 /kernelcache boot-uuid=\${uuid} rd=*uuid
+ elif [ -f /System/Library/Kernels/kernel ]; then
+ $1 /System/Library/Kernels/kernel boot-uuid=\${uuid} rd=*uuid
+ xnu_kextdir /System/Library/Extensions
else
$1 /mach_kernel boot-uuid=\${uuid} rd=*uuid
if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
@@ -112,16 +115,17 @@ for OS in ${OSPROBED} ; do
LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
BOOT="`echo ${OS} | cut -d ':' -f 4`"
- UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"
- EXPUUID="$UUID"
+ if UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"; then
+ EXPUUID="$UUID"
- if [ x"${DEVICE#*@}" != x ] ; then
+ if [ x"${DEVICE#*@}" != x ] ; then
EXPUUID="${EXPUUID}@${DEVICE#*@}"
- fi
+ fi
- if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" -a "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then
- echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2
- continue
+ if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" ] && [ "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then
+ echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2
+ continue
+ fi
fi
BTRFS="`echo ${OS} | cut -d ':' -f 5`"
@@ -134,6 +138,9 @@ for OS in ${OSPROBED} ; do
LONGNAME="${LABEL}"
fi
+ # os-prober returns text string followed by optional counter
+ CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')"
+
gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2
case ${BOOT} in
@@ -141,7 +148,7 @@ for OS in ${OSPROBED} ; do
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
cat << EOF
-menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
+menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
EOF
save_default_entry | grub_add_tab
prepare_grub_to_access_device ${DEVICE} | grub_add_tab
@@ -173,7 +180,7 @@ EOF
DEVICE=${DEVICE%@*}
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
cat << EOF
-menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
+menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
EOF
save_default_entry | sed -e "s/^/\t/"
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
@@ -229,7 +236,7 @@ EOF
if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
cat << EOF
-menuentry '$(echo "$OS $onstr" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
+menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
EOF
save_default_entry | grub_add_tab
printf '%s\n' "${prepare_boot_cache}"
@@ -277,9 +284,11 @@ EOF
echo "$title_correction_code"
;;
macosx)
- OSXUUID="${UUID}"
- osx_entry xnu_kernel 32
- osx_entry xnu_kernel64 64
+ if [ "${UUID}" ]; then
+ OSXUUID="${UUID}"
+ osx_entry xnu_kernel 32
+ osx_entry xnu_kernel64 64
+ fi
;;
hurd)
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
@@ -319,9 +328,8 @@ EOF
EOF
;;
*)
- echo -n " "
# TRANSLATORS: %s is replaced by OS name.
- gettext_printf "%s is not yet supported by grub-mkconfig.\n" "${LONGNAME}" >&2
+ gettext_printf "%s is not yet supported by grub-mkconfig.\n" " ${LONGNAME}" >&2
;;
esac
done
diff --git a/util/import_gcry.py b/util/import_gcry.py
index 1319a8ca8..2b3322d3a 100644
--- a/util/import_gcry.py
+++ b/util/import_gcry.py
@@ -369,6 +369,14 @@ for cipher_file in cipher_files:
if not m is None:
skip_statement = True
continue
+ m = re.match ("static const char sample_secret_key", line)
+ if not m is None:
+ skip_statement = True
+ continue
+ m = re.match ("static const char sample_public_key", line)
+ if not m is None:
+ skip_statement = True
+ continue
m = re.match ("static void sign|static gpg_err_code_t sign|static gpg_err_code_t generate",
line)
if not m is None:
@@ -526,6 +534,12 @@ for src in sorted (os.listdir (os.path.join (indir, "src"))):
fw.close ()
continue
+ if src == "g10lib.h":
+ fw.write (f.read ().replace ("(printf,f,a)", "(__printf__,f,a)"))
+ f.close ()
+ fw.close ()
+ continue
+
fw.write (f.read ())
f.close ()
fw.close ()
diff --git a/util/misc.c b/util/misc.c
index 386d8472f..d545212d9 100644
--- a/util/misc.c
+++ b/util/misc.c
@@ -74,26 +74,6 @@ grub_util_get_path (const char *dir, const char *file)
return path;
}
-size_t
-grub_util_get_image_size (const char *path)
-{
- FILE *f;
- size_t ret;
-
- f = grub_util_fopen (path, "rb");
-
- if (!f)
- grub_util_error (_("cannot open `%s': %s"), path, strerror (errno));
-
- fseeko (f, 0, SEEK_END);
-
- ret = ftello (f);
-
- fclose (f);
-
- return ret;
-}
-
char *
grub_util_read_image (const char *path)
{
@@ -121,28 +101,6 @@ grub_util_read_image (const char *path)
}
void
-grub_util_load_image (const char *path, char *buf)
-{
- FILE *fp;
- size_t size;
-
- grub_util_info ("reading %s", path);
-
- size = grub_util_get_image_size (path);
-
- fp = grub_util_fopen (path, "rb");
- if (! fp)
- grub_util_error (_("cannot open `%s': %s"), path,
- strerror (errno));
-
- if (fread (buf, 1, size, fp) != size)
- grub_util_error (_("cannot read `%s': %s"), path,
- strerror (errno));
-
- fclose (fp);
-}
-
-void
grub_util_write_image_at (const void *img, size_t size, off_t offset, FILE *out,
const char *name)
{
@@ -262,6 +220,6 @@ grub_register_exported_symbols (void)
int
grub_qsort_strcmp (const void *p1, const void *p2)
{
- return strcmp(*(char **)p1, *(char **)p2);
+ return strcmp(*(char *const *)p1, *(char *const *)p2);
}
diff --git a/util/mkimage.c b/util/mkimage.c
index 26d9816e0..9ad4cfe42 100644
--- a/util/mkimage.c
+++ b/util/mkimage.c
@@ -46,6 +46,7 @@
#include <grub/ia64/reloc.h>
#include <grub/osdep/hostfile.h>
#include <grub/util/install.h>
+#include <grub/util/mkimage.h>
#define ALIGN_ADDR(x) (ALIGN_UP((x), image_target->voidp_sizeof))
@@ -53,41 +54,12 @@
#include <lzma.h>
#endif
+#pragma GCC diagnostic ignored "-Wcast-align"
+
#define TARGET_NO_FIELD 0xffffffff
-struct grub_install_image_target_desc
-{
- const char *dirname;
- const char *names[6];
- grub_size_t voidp_sizeof;
- int bigendian;
- enum {
- IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT,
- IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_SPARC64_CDCORE,
- IMAGE_I386_IEEE1275,
- IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH,
- IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC,
- IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT, IMAGE_XEN, IMAGE_I386_PC_ELTORITO
- } id;
- enum
- {
- PLATFORM_FLAGS_NONE = 0,
- PLATFORM_FLAGS_DECOMPRESSORS = 2,
- PLATFORM_FLAGS_MODULES_BEFORE_KERNEL = 4,
- } flags;
- unsigned total_module_size;
- unsigned decompressor_compressed_size;
- unsigned decompressor_uncompressed_size;
- unsigned decompressor_uncompressed_addr;
- unsigned link_align;
- grub_uint16_t elf_target;
- unsigned section_align;
- signed vaddr_offset;
- grub_uint64_t link_addr;
- unsigned mod_gap, mod_align;
- grub_compression_t default_compression;
- grub_uint16_t pe_target;
-};
+/* use 2015-01-01T00:00:00+0000 as a stock timestamp */
+#define STABLE_EMBEDDING_TIMESTAMP 1420070400
#define EFI32_HEADER_SIZE ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE \
+ GRUB_PE32_SIGNATURE_SIZE \
@@ -116,6 +88,7 @@ static const struct grub_install_image_target_desc image_targets[] =
.decompressor_compressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_size = TARGET_NO_FIELD,
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
+ .reloc_table_offset = TARGET_NO_FIELD,
.section_align = 1,
.vaddr_offset = 0,
.link_addr = GRUB_KERNEL_I386_COREBOOT_LINK_ADDR,
@@ -555,7 +528,6 @@ static const struct grub_install_image_target_desc image_targets[] =
.decompressor_uncompressed_addr = TARGET_NO_FIELD,
.section_align = GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN,
.vaddr_offset = 0,
- .link_addr = GRUB_KERNEL_ARM_UBOOT_LINK_ADDR,
.elf_target = EM_ARM,
.mod_gap = GRUB_KERNEL_ARM_UBOOT_MOD_GAP,
.mod_align = GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN,
@@ -600,119 +572,6 @@ static const struct grub_install_image_target_desc image_targets[] =
},
};
-#define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x)))
-#define grub_host_to_target32(x) (grub_host_to_target32_real (image_target, (x)))
-#define grub_target_to_host64(x) (grub_target_to_host64_real (image_target, (x)))
-#define grub_host_to_target64(x) (grub_host_to_target64_real (image_target, (x)))
-#define grub_host_to_target_addr(x) (grub_host_to_target_addr_real (image_target, (x)))
-#define grub_target_to_host16(x) (grub_target_to_host16_real (image_target, (x)))
-#define grub_host_to_target16(x) (grub_host_to_target16_real (image_target, (x)))
-
-static inline grub_uint32_t
-grub_target_to_host32_real (const struct grub_install_image_target_desc *image_target,
- grub_uint32_t in)
-{
- if (image_target->bigendian)
- return grub_be_to_cpu32 (in);
- else
- return grub_le_to_cpu32 (in);
-}
-
-static inline grub_uint64_t
-grub_target_to_host64_real (const struct grub_install_image_target_desc *image_target,
- grub_uint64_t in)
-{
- if (image_target->bigendian)
- return grub_be_to_cpu64 (in);
- else
- return grub_le_to_cpu64 (in);
-}
-
-static inline grub_uint64_t
-grub_host_to_target64_real (const struct grub_install_image_target_desc *image_target,
- grub_uint64_t in)
-{
- if (image_target->bigendian)
- return grub_cpu_to_be64 (in);
- else
- return grub_cpu_to_le64 (in);
-}
-
-static inline grub_uint32_t
-grub_host_to_target32_real (const struct grub_install_image_target_desc *image_target,
- grub_uint32_t in)
-{
- if (image_target->bigendian)
- return grub_cpu_to_be32 (in);
- else
- return grub_cpu_to_le32 (in);
-}
-
-static inline grub_uint16_t
-grub_target_to_host16_real (const struct grub_install_image_target_desc *image_target,
- grub_uint16_t in)
-{
- if (image_target->bigendian)
- return grub_be_to_cpu16 (in);
- else
- return grub_le_to_cpu16 (in);
-}
-
-static inline grub_uint16_t
-grub_host_to_target16_real (const struct grub_install_image_target_desc *image_target,
- grub_uint16_t in)
-{
- if (image_target->bigendian)
- return grub_cpu_to_be16 (in);
- else
- return grub_cpu_to_le16 (in);
-}
-
-static inline grub_uint64_t
-grub_host_to_target_addr_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in)
-{
- if (image_target->voidp_sizeof == 8)
- return grub_host_to_target64_real (image_target, in);
- else
- return grub_host_to_target32_real (image_target, in);
-}
-
-static inline grub_uint64_t
-grub_target_to_host_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in)
-{
- if (image_target->voidp_sizeof == 8)
- return grub_target_to_host64_real (image_target, in);
- else
- return grub_target_to_host32_real (image_target, in);
-}
-
-#define GRUB_IEEE1275_NOTE_NAME "PowerPC"
-#define GRUB_IEEE1275_NOTE_TYPE 0x1275
-
-/* These structures are defined according to the CHRP binding to IEEE1275,
- "Client Program Format" section. */
-
-struct grub_ieee1275_note_desc
-{
- grub_uint32_t real_mode;
- grub_uint32_t real_base;
- grub_uint32_t real_size;
- grub_uint32_t virt_base;
- grub_uint32_t virt_size;
- grub_uint32_t load_base;
-};
-
-struct grub_ieee1275_note
-{
- Elf32_Nhdr header;
- char name[ALIGN_UP(sizeof (GRUB_IEEE1275_NOTE_NAME), 4)];
- struct grub_ieee1275_note_desc descriptor;
-};
-
-#define GRUB_XEN_NOTE_NAME "Xen"
-
-#define grub_target_to_host(val) grub_target_to_host_real(image_target, (val))
-
#include <grub/lib/LzmaEnc.h>
static void *SzAlloc(void *p __attribute__ ((unused)), size_t size) { return xmalloc(size); }
@@ -820,125 +679,20 @@ compress_kernel (const struct grub_install_image_target_desc *image_target, char
if (image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS
&& (comp != GRUB_COMPRESSION_NONE))
- grub_util_error (_("unknown compression %d\n"), comp);
+ grub_util_error (_("unknown compression %d"), comp);
*core_img = xmalloc (kernel_size);
memcpy (*core_img, kernel_img, kernel_size);
*core_size = kernel_size;
}
-struct fixup_block_list
-{
- struct fixup_block_list *next;
- int state;
- struct grub_pe32_fixup_block b;
-};
-
-/*
- * R_ARM_THM_CALL/THM_JUMP24
- *
- * Relocate Thumb (T32) instruction set relative branches:
- * B.W, BL and BLX
- */
-static grub_err_t
-grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr)
-{
- grub_int32_t offset;
-
- offset = grub_arm_thm_call_get_offset (target);
-
- grub_dprintf ("dl", " sym_addr = 0x%08x", sym_addr);
-
- offset += sym_addr;
-
- grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n",
- target, sym_addr, offset);
-
- /* Keep traditional (pre-Thumb2) limits on blx. In any case if the kernel
- is bigger than 2M (currently under 150K) then we probably have a problem
- somewhere else. */
- if (offset < -0x200000 || offset >= 0x200000)
- return grub_error (GRUB_ERR_BAD_MODULE,
- "THM_CALL Relocation out of range.");
-
- grub_dprintf ("dl", " relative destination = %p",
- (char *) target + offset);
-
- return grub_arm_thm_call_set_offset (target, offset);
-}
-
-/*
- * R_ARM_THM_JUMP19
- *
- * Relocate conditional Thumb (T32) B<c>.W
- */
-static grub_err_t
-grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr)
-{
- grub_int32_t offset;
-
- if (!(sym_addr & 1))
- return grub_error (GRUB_ERR_BAD_MODULE,
- "Relocation targeting wrong execution state");
-
- offset = grub_arm_thm_jump19_get_offset (target);
-
- /* Adjust and re-truncate offset */
- offset += sym_addr;
-
- if (!grub_arm_thm_jump19_check_offset (offset))
- return grub_error (GRUB_ERR_BAD_MODULE,
- "THM_JUMP19 Relocation out of range.");
-
- grub_arm_thm_jump19_set_offset (target, offset);
-
- return GRUB_ERR_NONE;
-}
-
-/*
- * R_ARM_JUMP24
- *
- * Relocate ARM (A32) B
- */
-static grub_err_t
-grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr)
-{
- grub_int32_t offset;
-
- if (sym_addr & 1)
- return grub_error (GRUB_ERR_BAD_MODULE,
- "Relocation targeting wrong execution state");
-
- offset = grub_arm_jump24_get_offset (target);
- offset += sym_addr;
-
- if (!grub_arm_jump24_check_offset (offset))
- return grub_error (GRUB_ERR_BAD_MODULE,
- "JUMP24 Relocation out of range.");
-
-
- grub_arm_jump24_set_offset (target, offset);
-
- return GRUB_ERR_NONE;
-}
-
-#pragma GCC diagnostic ignored "-Wcast-align"
-
-#define MKIMAGE_ELF32 1
-#include "grub-mkimagexx.c"
-#undef MKIMAGE_ELF32
-
-#define MKIMAGE_ELF64 1
-#include "grub-mkimagexx.c"
-#undef MKIMAGE_ELF64
-
const struct grub_install_image_target_desc *
grub_install_get_image_target (const char *arg)
{
unsigned i, j;
for (i = 0; i < ARRAY_SIZE (image_targets); i++)
- for (j = 0; image_targets[i].names[j]
- && j < ARRAY_SIZE (image_targets[i].names); j++)
+ for (j = 0; j < ARRAY_SIZE (image_targets[i].names) &&
+ image_targets[i].names[j]; j++)
if (strcmp (arg, image_targets[i].names[j]) == 0)
return &image_targets[i];
return NULL;
@@ -988,17 +742,14 @@ grub_install_generate_image (const char *dir, const char *prefix,
grub_compression_t comp)
{
char *kernel_img, *core_img;
- size_t kernel_size, total_module_size, core_size, exec_size;
- size_t memdisk_size = 0, config_size = 0, config_size_pure = 0;
+ size_t total_module_size, core_size;
+ size_t memdisk_size = 0, config_size = 0;
size_t prefix_size = 0;
char *kernel_path;
size_t offset;
- struct grub_util_path_list *path_list, *p, *next;
- size_t bss_size;
- grub_uint64_t start_address;
- void *rel_section = 0;
- size_t reloc_size = 0, align;
+ struct grub_util_path_list *path_list, *p;
size_t decompress_size = 0;
+ struct grub_mkimage_layout layout;
if (comp == GRUB_COMPRESSION_AUTO)
comp = image_target->default_compression;
@@ -1040,8 +791,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
if (config_path)
{
- config_size_pure = grub_util_get_image_size (config_path) + 1;
- config_size = ALIGN_ADDR (config_size_pure);
+ config_size = ALIGN_ADDR (grub_util_get_image_size (config_path) + 1);
grub_util_info ("the size of config file is 0x%" GRUB_HOST_PRIxLONG_LONG,
(unsigned long long) config_size);
total_module_size += config_size + sizeof (struct grub_module_header);
@@ -1061,15 +811,13 @@ grub_install_generate_image (const char *dir, const char *prefix,
(unsigned long long) total_module_size);
if (image_target->voidp_sizeof == 4)
- kernel_img = load_image32 (kernel_path, &exec_size, &kernel_size, &bss_size,
- total_module_size, &start_address, &rel_section,
- &reloc_size, &align, image_target);
+ kernel_img = grub_mkimage_load_image32 (kernel_path, total_module_size,
+ &layout, image_target);
else
- kernel_img = load_image64 (kernel_path, &exec_size, &kernel_size, &bss_size,
- total_module_size, &start_address, &rel_section,
- &reloc_size, &align, image_target);
- if (image_target->id == IMAGE_XEN && align < 4096)
- align = 4096;
+ kernel_img = grub_mkimage_load_image64 (kernel_path, total_module_size,
+ &layout, image_target);
+ if (image_target->id == IMAGE_XEN && layout.align < 4096)
+ layout.align = 4096;
if ((image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS)
&& (image_target->total_module_size != TARGET_NO_FIELD))
@@ -1077,7 +825,10 @@ grub_install_generate_image (const char *dir, const char *prefix,
= grub_host_to_target32 (total_module_size);
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
- memmove (kernel_img + total_module_size, kernel_img, kernel_size);
+ {
+ memmove (kernel_img + total_module_size, kernel_img, layout.kernel_size);
+ memset (kernel_img, 0, total_module_size);
+ }
if (image_target->voidp_sizeof == 8)
{
@@ -1086,15 +837,14 @@ grub_install_generate_image (const char *dir, const char *prefix,
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
modinfo = (struct grub_module_info64 *) kernel_img;
else
- modinfo = (struct grub_module_info64 *) (kernel_img + kernel_size);
- memset (modinfo, 0, sizeof (struct grub_module_info64));
+ modinfo = (struct grub_module_info64 *) (kernel_img + layout.kernel_size);
modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC);
modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info64));
modinfo->size = grub_host_to_target_addr (total_module_size);
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
offset = sizeof (struct grub_module_info64);
else
- offset = kernel_size + sizeof (struct grub_module_info64);
+ offset = layout.kernel_size + sizeof (struct grub_module_info64);
}
else
{
@@ -1103,31 +853,27 @@ grub_install_generate_image (const char *dir, const char *prefix,
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
modinfo = (struct grub_module_info32 *) kernel_img;
else
- modinfo = (struct grub_module_info32 *) (kernel_img + kernel_size);
- memset (modinfo, 0, sizeof (struct grub_module_info32));
+ modinfo = (struct grub_module_info32 *) (kernel_img + layout.kernel_size);
modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC);
modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info32));
modinfo->size = grub_host_to_target_addr (total_module_size);
if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL)
offset = sizeof (struct grub_module_info32);
else
- offset = kernel_size + sizeof (struct grub_module_info32);
+ offset = layout.kernel_size + sizeof (struct grub_module_info32);
}
for (p = path_list; p; p = p->next)
{
struct grub_module_header *header;
- size_t mod_size, orig_size;
+ size_t mod_size;
- orig_size = grub_util_get_image_size (p->name);
- mod_size = ALIGN_ADDR (orig_size);
+ mod_size = ALIGN_ADDR (grub_util_get_image_size (p->name));
header = (struct grub_module_header *) (kernel_img + offset);
- memset (header, 0, sizeof (struct grub_module_header));
header->type = grub_host_to_target32 (OBJ_TYPE_ELF);
header->size = grub_host_to_target32 (mod_size + sizeof (*header));
offset += sizeof (*header);
- memset (kernel_img + offset + orig_size, 0, mod_size - orig_size);
grub_util_load_image (p->name, kernel_img + offset);
offset += mod_size;
@@ -1143,7 +889,6 @@ grub_install_generate_image (const char *dir, const char *prefix,
curs = grub_util_get_image_size (pubkey_paths[i]);
header = (struct grub_module_header *) (kernel_img + offset);
- memset (header, 0, sizeof (struct grub_module_header));
header->type = grub_host_to_target32 (OBJ_TYPE_PUBKEY);
header->size = grub_host_to_target32 (curs + sizeof (*header));
offset += sizeof (*header);
@@ -1158,7 +903,6 @@ grub_install_generate_image (const char *dir, const char *prefix,
struct grub_module_header *header;
header = (struct grub_module_header *) (kernel_img + offset);
- memset (header, 0, sizeof (struct grub_module_header));
header->type = grub_host_to_target32 (OBJ_TYPE_MEMDISK);
header->size = grub_host_to_target32 (memdisk_size + sizeof (*header));
offset += sizeof (*header);
@@ -1172,13 +916,11 @@ grub_install_generate_image (const char *dir, const char *prefix,
struct grub_module_header *header;
header = (struct grub_module_header *) (kernel_img + offset);
- memset (header, 0, sizeof (struct grub_module_header));
header->type = grub_host_to_target32 (OBJ_TYPE_CONFIG);
header->size = grub_host_to_target32 (config_size + sizeof (*header));
offset += sizeof (*header);
grub_util_load_image (config_path, kernel_img + offset);
- *(kernel_img + offset + config_size_pure - 1) = 0;
offset += config_size;
}
@@ -1187,20 +929,18 @@ grub_install_generate_image (const char *dir, const char *prefix,
struct grub_module_header *header;
header = (struct grub_module_header *) (kernel_img + offset);
- memset (header, 0, sizeof (struct grub_module_header));
header->type = grub_host_to_target32 (OBJ_TYPE_PREFIX);
header->size = grub_host_to_target32 (prefix_size + sizeof (*header));
offset += sizeof (*header);
- grub_memset (kernel_img + offset, 0, prefix_size);
grub_strcpy (kernel_img + offset, prefix);
offset += prefix_size;
}
grub_util_info ("kernel_img=%p, kernel_size=0x%" GRUB_HOST_PRIxLONG_LONG,
kernel_img,
- (unsigned long long) kernel_size);
- compress_kernel (image_target, kernel_img, kernel_size + total_module_size,
+ (unsigned long long) layout.kernel_size);
+ compress_kernel (image_target, kernel_img, layout.kernel_size + total_module_size,
&core_img, &core_size, comp);
free (kernel_img);
@@ -1231,7 +971,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
name = "none_decompress.img";
break;
default:
- grub_util_error (_("unknown compression %d\n"), comp);
+ grub_util_error (_("unknown compression %d"), comp);
}
decompress_path = grub_util_get_path (dir, name);
@@ -1252,7 +992,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
if (image_target->decompressor_uncompressed_size != TARGET_NO_FIELD)
*((grub_uint32_t *) (decompress_img
+ image_target->decompressor_uncompressed_size))
- = grub_host_to_target32 (kernel_size + total_module_size);
+ = grub_host_to_target32 (layout.kernel_size + total_module_size);
if (image_target->decompressor_uncompressed_addr != TARGET_NO_FIELD)
{
@@ -1266,18 +1006,16 @@ grub_install_generate_image (const char *dir, const char *prefix,
full_size = core_size + decompress_size;
full_img = xmalloc (full_size);
- memset (full_img, 0, full_size);
memcpy (full_img, decompress_img, decompress_size);
memcpy (full_img + decompress_size, core_img, core_size);
- memset (full_img + decompress_size + core_size, 0,
- full_size - (decompress_size + core_size));
-
free (core_img);
core_img = full_img;
core_size = full_size;
+ free (decompress_img);
+ free (decompress_path);
}
switch (image_target->id)
@@ -1287,16 +1025,17 @@ grub_install_generate_image (const char *dir, const char *prefix,
case IMAGE_I386_PC_ELTORITO:
if (GRUB_KERNEL_I386_PC_LINK_ADDR + core_size > 0x78000
|| (core_size > (0xffff << GRUB_DISK_SECTOR_BITS))
- || (kernel_size + bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000))
+ || (layout.kernel_size + layout.bss_size
+ + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000))
grub_util_error (_("core image is too big (0x%x > 0x%x)"),
GRUB_KERNEL_I386_PC_LINK_ADDR + (unsigned) core_size,
0x78000);
/* fallthrough */
case IMAGE_COREBOOT:
case IMAGE_QEMU:
- if (kernel_size + bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000)
+ if (layout.kernel_size + layout.bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000)
grub_util_error (_("kernel image is too big (0x%x > 0x%x)"),
- (unsigned) kernel_size + (unsigned) bss_size
+ (unsigned) layout.kernel_size + (unsigned) layout.bss_size
+ GRUB_KERNEL_I386_PC_LINK_ADDR,
0x68000);
break;
@@ -1418,12 +1157,13 @@ grub_install_generate_image (const char *dir, const char *prefix,
reloc_addr = ALIGN_UP (header_size + core_size,
image_target->section_align);
- pe_size = ALIGN_UP (reloc_addr + reloc_size,
+ pe_size = ALIGN_UP (reloc_addr + layout.reloc_size,
image_target->section_align);
- pe_img = xmalloc (reloc_addr + reloc_size);
+ pe_img = xmalloc (reloc_addr + layout.reloc_size);
memset (pe_img, 0, header_size);
memcpy ((char *) pe_img + header_size, core_img, core_size);
- memcpy ((char *) pe_img + reloc_addr, rel_section, reloc_size);
+ memset ((char *) pe_img + header_size + core_size, 0, reloc_addr - (header_size + core_size));
+ memcpy ((char *) pe_img + reloc_addr, layout.reloc_section, layout.reloc_size);
header = pe_img;
/* The magic. */
@@ -1437,7 +1177,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
c->machine = grub_host_to_target16 (image_target->pe_target);
c->num_sections = grub_host_to_target16 (4);
- c->time = grub_host_to_target32 (time (0));
+ c->time = grub_host_to_target32 (STABLE_EMBEDDING_TIMESTAMP);
c->characteristics = grub_host_to_target16 (GRUB_PE32_EXECUTABLE_IMAGE
| GRUB_PE32_LINE_NUMS_STRIPPED
| ((image_target->voidp_sizeof == 4)
@@ -1457,14 +1197,14 @@ grub_install_generate_image (const char *dir, const char *prefix,
(header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE
+ sizeof (struct grub_pe32_coff_header));
o->magic = grub_host_to_target16 (GRUB_PE32_PE32_MAGIC);
- o->code_size = grub_host_to_target32 (exec_size);
- o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size
+ o->code_size = grub_host_to_target32 (layout.exec_size);
+ o->data_size = grub_cpu_to_le32 (reloc_addr - layout.exec_size
- header_size);
- o->bss_size = grub_cpu_to_le32 (bss_size);
- o->entry_addr = grub_cpu_to_le32 (start_address);
+ o->bss_size = grub_cpu_to_le32 (layout.bss_size);
+ o->entry_addr = grub_cpu_to_le32 (layout.start_address);
o->code_base = grub_cpu_to_le32 (header_size);
- o->data_base = grub_host_to_target32 (header_size + exec_size);
+ o->data_base = grub_host_to_target32 (header_size + layout.exec_size);
o->image_base = 0;
o->section_alignment = grub_host_to_target32 (image_target->section_align);
@@ -1482,7 +1222,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
o->num_data_directories = grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES);
o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr);
- o->base_relocation_table.size = grub_host_to_target32 (reloc_size);
+ o->base_relocation_table.size = grub_host_to_target32 (layout.reloc_size);
sections = o + 1;
}
else
@@ -1495,11 +1235,11 @@ grub_install_generate_image (const char *dir, const char *prefix,
(header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE
+ sizeof (struct grub_pe32_coff_header));
o->magic = grub_host_to_target16 (GRUB_PE32_PE64_MAGIC);
- o->code_size = grub_host_to_target32 (exec_size);
- o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size
+ o->code_size = grub_host_to_target32 (layout.exec_size);
+ o->data_size = grub_cpu_to_le32 (reloc_addr - layout.exec_size
- header_size);
- o->bss_size = grub_cpu_to_le32 (bss_size);
- o->entry_addr = grub_cpu_to_le32 (start_address);
+ o->bss_size = grub_cpu_to_le32 (layout.bss_size);
+ o->entry_addr = grub_cpu_to_le32 (layout.start_address);
o->code_base = grub_cpu_to_le32 (header_size);
o->image_base = 0;
o->section_alignment = grub_host_to_target32 (image_target->section_align);
@@ -1518,40 +1258,41 @@ grub_install_generate_image (const char *dir, const char *prefix,
= grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES);
o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr);
- o->base_relocation_table.size = grub_host_to_target32 (reloc_size);
+ o->base_relocation_table.size = grub_host_to_target32 (layout.reloc_size);
sections = o + 1;
}
/* The sections. */
text_section = sections;
strcpy (text_section->name, ".text");
- text_section->virtual_size = grub_cpu_to_le32 (exec_size);
+ text_section->virtual_size = grub_cpu_to_le32 (layout.exec_size);
text_section->virtual_address = grub_cpu_to_le32 (header_size);
- text_section->raw_data_size = grub_cpu_to_le32 (exec_size);
+ text_section->raw_data_size = grub_cpu_to_le32 (layout.exec_size);
text_section->raw_data_offset = grub_cpu_to_le32 (header_size);
- text_section->characteristics = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_CODE
- | GRUB_PE32_SCN_MEM_EXECUTE
- | GRUB_PE32_SCN_MEM_READ);
+ text_section->characteristics = grub_cpu_to_le32_compile_time (
+ GRUB_PE32_SCN_CNT_CODE
+ | GRUB_PE32_SCN_MEM_EXECUTE
+ | GRUB_PE32_SCN_MEM_READ);
data_section = text_section + 1;
strcpy (data_section->name, ".data");
- data_section->virtual_size = grub_cpu_to_le32 (kernel_size - exec_size);
- data_section->virtual_address = grub_cpu_to_le32 (header_size + exec_size);
- data_section->raw_data_size = grub_cpu_to_le32 (kernel_size - exec_size);
- data_section->raw_data_offset = grub_cpu_to_le32 (header_size + exec_size);
+ data_section->virtual_size = grub_cpu_to_le32 (layout.kernel_size - layout.exec_size);
+ data_section->virtual_address = grub_cpu_to_le32 (header_size + layout.exec_size);
+ data_section->raw_data_size = grub_cpu_to_le32 (layout.kernel_size - layout.exec_size);
+ data_section->raw_data_offset = grub_cpu_to_le32 (header_size + layout.exec_size);
data_section->characteristics
- = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
+ = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
| GRUB_PE32_SCN_MEM_READ
| GRUB_PE32_SCN_MEM_WRITE);
#if 0
bss_section = data_section + 1;
strcpy (bss_section->name, ".bss");
- bss_section->virtual_size = grub_cpu_to_le32 (bss_size);
- bss_section->virtual_address = grub_cpu_to_le32 (header_size + kernel_size);
+ bss_section->virtual_size = grub_cpu_to_le32 (layout.bss_size);
+ bss_section->virtual_address = grub_cpu_to_le32 (header_size + layout.kernel_size);
bss_section->raw_data_size = 0;
bss_section->raw_data_offset = 0;
bss_section->characteristics
- = grub_cpu_to_le32 (GRUB_PE32_SCN_MEM_READ
+ = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_MEM_READ
| GRUB_PE32_SCN_MEM_WRITE
| GRUB_PE32_SCN_ALIGN_64BYTES
| GRUB_PE32_SCN_CNT_INITIALIZED_DATA
@@ -1560,23 +1301,23 @@ grub_install_generate_image (const char *dir, const char *prefix,
mods_section = data_section + 1;
strcpy (mods_section->name, "mods");
- mods_section->virtual_size = grub_cpu_to_le32 (reloc_addr - kernel_size - header_size);
- mods_section->virtual_address = grub_cpu_to_le32 (header_size + kernel_size + bss_size);
- mods_section->raw_data_size = grub_cpu_to_le32 (reloc_addr - kernel_size - header_size);
- mods_section->raw_data_offset = grub_cpu_to_le32 (header_size + kernel_size);
+ mods_section->virtual_size = grub_cpu_to_le32 (reloc_addr - layout.kernel_size - header_size);
+ mods_section->virtual_address = grub_cpu_to_le32 (header_size + layout.kernel_size + layout.bss_size);
+ mods_section->raw_data_size = grub_cpu_to_le32 (reloc_addr - layout.kernel_size - header_size);
+ mods_section->raw_data_offset = grub_cpu_to_le32 (header_size + layout.kernel_size);
mods_section->characteristics
- = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
+ = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
| GRUB_PE32_SCN_MEM_READ
| GRUB_PE32_SCN_MEM_WRITE);
reloc_section = mods_section + 1;
strcpy (reloc_section->name, ".reloc");
- reloc_section->virtual_size = grub_cpu_to_le32 (reloc_size);
- reloc_section->virtual_address = grub_cpu_to_le32 (reloc_addr + bss_size);
- reloc_section->raw_data_size = grub_cpu_to_le32 (reloc_size);
+ reloc_section->virtual_size = grub_cpu_to_le32 (layout.reloc_size);
+ reloc_section->virtual_address = grub_cpu_to_le32 (reloc_addr + layout.bss_size);
+ reloc_section->raw_data_size = grub_cpu_to_le32 (layout.reloc_size);
reloc_section->raw_data_offset = grub_cpu_to_le32 (reloc_addr);
reloc_section->characteristics
- = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
+ = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
| GRUB_PE32_SCN_MEM_DISCARDABLE
| GRUB_PE32_SCN_MEM_READ);
free (core_img);
@@ -1743,6 +1484,8 @@ grub_install_generate_image (const char *dir, const char *prefix,
free (core_img);
core_img = rom_img;
core_size = rom_size;
+ free (boot_img);
+ free (boot_path);
}
break;
case IMAGE_QEMU_MIPS_FLASH:
@@ -1777,11 +1520,11 @@ grub_install_generate_image (const char *dir, const char *prefix,
memset (hdr, 0, sizeof (*hdr));
hdr->ih_magic = grub_cpu_to_be32_compile_time (GRUB_UBOOT_IH_MAGIC);
- hdr->ih_time = grub_cpu_to_be32 (time (0));
+ hdr->ih_time = grub_cpu_to_be32 (STABLE_EMBEDDING_TIMESTAMP);
hdr->ih_size = grub_cpu_to_be32 (core_size);
- hdr->ih_load = grub_cpu_to_be32 (image_target->link_addr);
- hdr->ih_ep = grub_cpu_to_be32 (image_target->link_addr);
- hdr->ih_type = GRUB_UBOOT_IH_TYPE_KERNEL;
+ hdr->ih_load = 0;
+ hdr->ih_ep = 0;
+ hdr->ih_type = GRUB_UBOOT_IH_TYPE_KERNEL_NOLOAD;
hdr->ih_os = GRUB_UBOOT_IH_OS_LINUX;
hdr->ih_arch = GRUB_UBOOT_IH_ARCH_ARM;
hdr->ih_comp = GRUB_UBOOT_IH_COMP_NONE;
@@ -1842,7 +1585,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
target_addr = (image_target->link_addr - decompress_size);
else
target_addr = ALIGN_UP (image_target->link_addr
- + kernel_size + total_module_size, 32);
+ + layout.kernel_size + total_module_size, 32);
ecoff_img = xmalloc (program_size + sizeof (*head) + sizeof (*section));
grub_memset (ecoff_img, 0, program_size + sizeof (*head) + sizeof (*section));
@@ -1889,16 +1632,16 @@ grub_install_generate_image (const char *dir, const char *prefix,
target_addr = (image_target->link_addr - decompress_size);
else
target_addr = ALIGN_UP (image_target->link_addr
- + kernel_size + total_module_size, 32);
+ + layout.kernel_size + total_module_size, 32);
}
else
target_addr = image_target->link_addr;
if (image_target->voidp_sizeof == 4)
- generate_elf32 (image_target, note, &core_img, &core_size,
- target_addr, align, kernel_size, bss_size);
+ grub_mkimage_generate_elf32 (image_target, note, &core_img, &core_size,
+ target_addr, layout.align, layout.kernel_size, layout.bss_size);
else
- generate_elf64 (image_target, note, &core_img, &core_size,
- target_addr, align, kernel_size, bss_size);
+ grub_mkimage_generate_elf64 (image_target, note, &core_img, &core_size,
+ target_addr, layout.align, layout.kernel_size, layout.bss_size);
}
break;
}
@@ -1906,13 +1649,7 @@ grub_install_generate_image (const char *dir, const char *prefix,
grub_util_write_image (core_img, core_size, out, outname);
free (core_img);
free (kernel_path);
- free (rel_section);
+ free (layout.reloc_section);
- while (path_list)
- {
- next = path_list->next;
- free ((void *) path_list->name);
- free (path_list);
- path_list = next;
- }
+ grub_util_free_path_list (path_list);
}
diff --git a/util/probe.c b/util/probe.c
index c389f5dcf..fa7ca34d1 100644
--- a/util/probe.c
+++ b/util/probe.c
@@ -73,7 +73,7 @@ grub_util_guess_bios_drive (const char *orig_path)
{
char *canon;
char *ptr;
- canon = canonicalize_file_name (orig_path);
+ canon = grub_canonicalize_file_name (orig_path);
if (!canon)
return NULL;
ptr = strrchr (orig_path, '/');
@@ -102,7 +102,7 @@ grub_util_guess_efi_drive (const char *orig_path)
{
char *canon;
char *ptr;
- canon = canonicalize_file_name (orig_path);
+ canon = grub_canonicalize_file_name (orig_path);
if (!canon)
return NULL;
ptr = strrchr (orig_path, '/');
@@ -131,7 +131,7 @@ grub_util_guess_baremetal_drive (const char *orig_path)
{
char *canon;
char *ptr;
- canon = canonicalize_file_name (orig_path);
+ canon = grub_canonicalize_file_name (orig_path);
if (!canon)
return NULL;
ptr = strrchr (orig_path, '/');
diff --git a/util/render-label.c b/util/render-label.c
index 9702ed953..91c080c9c 100644
--- a/util/render-label.c
+++ b/util/render-label.c
@@ -20,6 +20,7 @@
#include <config.h>
#include <grub/util/misc.h>
+#include <grub/util/install.h>
#include <grub/i18n.h>
#include <grub/term.h>
#include <grub/font.h>
@@ -32,7 +33,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <argp.h>
#include <unistd.h>
#include <errno.h>
@@ -157,7 +157,7 @@ grub_util_render_label (const char *label_font,
ieee1275_palette[cptr].a = 0xff;
char * t;
- t = canonicalize_file_name (label_font);
+ t = grub_canonicalize_file_name (label_font);
if (!t)
{
grub_util_error (_("cannot open `%s': %s"), label_font,
diff --git a/util/resolve.c b/util/resolve.c
index 002bfbd72..3e887d2ff 100644
--- a/util/resolve.c
+++ b/util/resolve.c
@@ -271,3 +271,17 @@ grub_util_resolve_dependencies (const char *prefix,
return prev;
}
}
+
+void
+grub_util_free_path_list (struct grub_util_path_list *path_list)
+{
+ struct grub_util_path_list *next;
+
+ while (path_list)
+ {
+ next = path_list->next;
+ free ((void *) path_list->name);
+ free (path_list);
+ path_list = next;
+ }
+}
diff --git a/util/setup.c b/util/setup.c
index 9fb91a82f..8aa5a39a7 100644
--- a/util/setup.c
+++ b/util/setup.c
@@ -312,6 +312,9 @@ SETUP (const char *dir,
char **cur;
int found = 0;
+ if (!root_devices)
+ grub_util_error (_("cannot find a device for %s (is /dev mounted?)"), dir);
+
for (cur = root_devices; *cur; cur++)
{
char *drive;
@@ -322,7 +325,10 @@ SETUP (const char *dir,
continue;
try_dev = grub_device_open (drive);
if (! try_dev)
- continue;
+ {
+ free (drive);
+ continue;
+ }
if (!found && try_dev->disk->id == dest_dev->disk->id
&& try_dev->disk->dev->id == dest_dev->disk->dev->id)
{
@@ -350,6 +356,10 @@ SETUP (const char *dir,
}
grub_util_info ("guessed root_dev `%s' from "
"dir `%s'", root_dev->disk->name, dir);
+
+ for (cur = root_devices; *cur; cur++)
+ free (*cur);
+ free (root_devices);
}
grub_util_info ("setting the root device to `%s'", root);
@@ -526,7 +536,7 @@ SETUP (const char *dir,
bl.block = bl.first_block;
while (bl.block->len)
{
- grub_memset (bl.block, 0, sizeof (bl.block));
+ grub_memset (bl.block, 0, sizeof (*bl.block));
bl.block--;
@@ -667,15 +677,17 @@ unable_to_embed:
if (dest_dev->disk->id != root_dev->disk->id
|| dest_dev->disk->dev->id != root_dev->disk->dev->id)
{
- const char *dest_ofpath;
+ char *dest_ofpath;
dest_ofpath
= grub_util_devname_to_ofpath (grub_util_biosdisk_get_osdev (root_dev->disk));
+ /* FIXME handle NULL result */
grub_util_info ("dest_ofpath is `%s'", dest_ofpath);
strncpy (boot_devpath, dest_ofpath,
GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1);
boot_devpath[GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1] = 0;
+ free (dest_ofpath);
}
else
{
generated by cgit v1.2.3 (git 2.25.1) at 2026-06-28 23:32:23 +0000